Compiling for the NanoNote
From Qi-Hardware
This is about compiling C on your workstation so that it runs on the NanoNote.
- Follow the instructions on the Building_Software_Image page from git clone to make. It's a lot easier than it looks, doesn't require root and you don't need to install anything other than essential build tools on your workstation. You can minimize your build time if you minimize your .config by unticking anything in make menuconfig that you don't need to rebuild
- Use the toolchain produced by the previous step to compile your own software
[edit] Example
Makefile. STAGING_DIR will need to reflect where you put OpenWRT
PROJECT = hello-sdl STAGING_DIR = $(HOME)/nanonote/openwrt-xburst/staging_dir ROOT_DIR = $(STAGING_DIR)/target-mipsel_uClibc-0.9.30.1 CC = $(STAGING_DIR)/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mipsel-openwrt-linux-uclibc-gcc CFLAGS = -Wall INCLUDES = -I. -I$(ROOT_DIR)/usr/include LIBS = -lSDL -L$(ROOT_DIR)/usr/lib PARTS = main.o .c.o: $(RM) $@ $(CC) -c $(CFLAGS) $(INCLUDES) $*.c all: $(PROJECT) $(PROJECT): $(PARTS) $(CC) -Wl,-rpath-link=$(ROOT_DIR)/usr/lib $(LIBS) -o $(PROJECT) $(PARTS) clean: rm -f *.o $(PROJECT)
main.c. You'll need to supply your own image.bmp to run this example.
#include <SDL/SDL.h>
int main( int argc, char **argv)
{
if ( SDL_Init( SDL_INIT_VIDEO) != 0) {
printf("Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit( SDL_Quit);
SDL_Surface *screen = SDL_SetVideoMode( 320, 240, 24, SDL_DOUBLEBUF);
if ( NULL == screen) {
printf("Unable to set video mode: %s\n", SDL_GetError());
return 1;
}
SDL_Surface *original_image = SDL_LoadBMP("image.bmp");
if ( NULL == original_image) {
printf("Unable to load bitmap: %s\n", SDL_GetError());
return 1;
}
SDL_Surface *image = SDL_DisplayFormat( original_image);
SDL_FreeSurface( original_image);
SDL_Rect blit_from = { 0, 0, image->w, image->h};
SDL_Rect blit_to = { 90, 90, image->w, image->h};
SDL_BlitSurface( image, &blit_from, screen, &blit_to);
SDL_Flip( screen);
SDL_Delay( 2500);
return 0;
}