# HG changeset patch # User Paul Boddie # Date 1434065880 -7200 # Node ID 82e00671c53d5f1c21fbcdd254a9122f2330e395 # Parent 3b8486cade380bbefab1970d3c797381e562f624 Made the stage 2 payload work as a uImage file with U-Boot (2012.10-rc2). diff -r 3b8486cade38 -r 82e00671c53d stage2/Makefile --- a/stage2/Makefile Fri Jun 12 01:33:55 2015 +0200 +++ b/stage2/Makefile Fri Jun 12 01:38:00 2015 +0200 @@ -35,8 +35,8 @@ -I../include LDFLAGS = -nostdlib -EL -pie +UIMAGE = uImage PAYLOAD = stage2.bin -UIMAGE = uImage TARGET = $(PAYLOAD:.bin=.elf) DUMP = $(PAYLOAD:.bin=.dump) MAP = $(PAYLOAD:.bin=.map) @@ -70,13 +70,13 @@ all: $(PAYLOAD) $(UIMAGE) clean: - rm -f $(OBJ) $(TARGET) $(PAYLOAD) $(DUMP) *.map + rm -f $(OBJ) $(TARGET) $(PAYLOAD) $(UIMAGE) $(DUMP) *.map distclean: clean echo "Nothing else to clean." $(UIMAGE): $(PAYLOAD) - $(MKIMAGE) -A mips -O linux -T standalone -C none -a 0x80000000 -e 0x80000000 -n NanoPayload -d $(PAYLOAD) $(UIMAGE) + $(MKIMAGE) -A mips -O u-boot -T standalone -C none -a 0x80000000 -e 0x80000000 -n NanoPayload -d $(PAYLOAD) $(UIMAGE) $(PAYLOAD): $(TARGET) $(OBJCOPY) -O binary $(@:.bin=.elf) $@+ diff -r 3b8486cade38 -r 82e00671c53d stage2/board-nanonote.c --- a/stage2/board-nanonote.c Fri Jun 12 01:33:55 2015 +0200 +++ b/stage2/board-nanonote.c Fri Jun 12 01:38:00 2015 +0200 @@ -131,3 +131,8 @@ lastdec = 0; timestamp = 0; } + +int is_started(void) +{ + return REG_CPM_CLKGR != 0; +} diff -r 3b8486cade38 -r 82e00671c53d stage2/board-nanonote.h --- a/stage2/board-nanonote.h Fri Jun 12 01:33:55 2015 +0200 +++ b/stage2/board-nanonote.h Fri Jun 12 01:38:00 2015 +0200 @@ -7,5 +7,6 @@ void cpm_init(void); void rtc_init(void); void timer_init(void); +int is_started(void); #endif /* __BOARD_NANONOTE_H__ */ diff -r 3b8486cade38 -r 82e00671c53d stage2/stage2.c --- a/stage2/stage2.c Fri Jun 12 01:33:55 2015 +0200 +++ b/stage2/stage2.c Fri Jun 12 01:38:00 2015 +0200 @@ -31,6 +31,7 @@ /* Relocate object locations. */ volatile unsigned int start_addr, got_start, got_end, addr, offset; + volatile int started; /* get absolute start address */ __asm__ __volatile__( @@ -59,10 +60,13 @@ /* The actual work. */ - gpio_init2(); - cpm_init(); - rtc_init(); - timer_init(); + started = is_started(); + if (!started) { + gpio_init2(); + cpm_init(); + rtc_init(); + timer_init(); + } lcd_init(); while (1); }