[rendering] Add batch mode to the simple code
[wikipediardware.git] / bootloader / Makefile
blob0fd112c442240a781c73b3ca0d9f3000dbdab4ca
1 LIBDIR=../toolchain/mini-libc
2 FATFSDIR=../fatfs
3 FATFS_MODE = read-only
4 COMMON=../common
5 LIBS = $(FATFSDIR)/lib/${FATFS_MODE}/libtinyfat.a $(LIBDIR)/lib/libc.a `$(CC) -print-libgcc-file-name`
6 LDFLAGS=-static --strip-all -s --no-gc-sections -N -L$(LIBDIR)
7 INCLUDES = -I$(FATFSDIR)/src -I$(LIBDIR)/include/ -I$(FATFSDIR)/config/c33/${FATFS_MODE}/ -I$(COMMON)
8 OBJCOPY_FLAGS=-I elf32-c33 -O binary
10 TARGETS=rs232 eeprom-1st eeprom-2nd eeprom-2nd.bin e07load/e07load gfxtool/gfxtool
11 VPATH=$(COMMON)
13 BOOTLOADER_TTY ?= /dev/ttyUSB0
14 FLASH_ROM_MAP_FILE ?= wikireader.map
16 ifeq ($(MAKECMDGOALS),bootloader232)
17 EXTRA_CFLAGS = -DEEPROM1ST_LOAD_FROM_RS232=1
18 else
19 EXTRA_CFLAGS = -DEEPROM1ST_LOAD_FROM_EEPROM=1
20 endif
22 ifneq ($(MAKECMDGOALS),flash-bootloader)
23 $(shell [ -f last_bootfrom ] && [ -z "`grep '\$(EXTRA_CFLAGS)' last_bootfrom`" ] && rm last_bootfrom)
24 endif
27 bootloader:$(TARGETS)
29 bootloader232:bootloader
32 #### e07load
33 e07load/e07load::
34 make -C e07load
36 #### gfxtool
37 gfxtool/gfxtool::
38 make -C gfxtool
40 #### first boot loader
41 rs232.elf: rs232.o
42 $(GCC) -o $@ $(LDFLAGS) $< -Wl,'-Ttext=0'
44 rs232: rs232.elf
45 $(OBJCOPY) $(OBJCOPY_FLAGS) --only-section=.text --set-start=0 $< $@
47 #### second boot loader
48 last_bootfrom:
49 $(shell echo $(EXTRA_CFLAGS) > last_bootfrom)
51 eeprom-1st.o: eeprom-1st.c eeprom-2nd last_bootfrom
52 $(GCC) -c $(CFLAGS) $(EXTRA_CFLAGS) -DEEPROM_PAYLOAD_SIZE=`wc -c eeprom-2nd | cut -f1 -d' '` $<
54 eeprom-1st.elf: eeprom-1st.o eeprom.o
55 $(GCC) -o $@ $(LDFLAGS) $^ -Wl,'-Ttext=0'
57 eeprom-1st: eeprom-1st.elf
58 $(OBJCOPY) $(OBJCOPY_FLAGS) --only-section=.text --set-start=0 $< $@
60 #### third boot loader
61 eeprom-2nd.elf: eeprom-2nd.o misc.o eeprom.o elf32.o lcd.o eeprom-2nd.lds ../fatfs/lib/${FATFS_MODE}/libtinyfat.a
62 $(LD) -o $@ $(LDFLAGS) $^ $(LIBS) -T $(<:.o=.lds) -Map $(<:.o=.map)
64 eeprom-2nd: eeprom-2nd.elf
65 $(OBJCOPY) $(OBJCOPY_FLAGS) --only-section=.text \
66 --only-section=.rodata \
67 $< $@
69 eeprom-2nd.bin: eeprom-2nd.elf
70 $(OBJCOPY) $(OBJCOPY_FLAGS) --only-section=.text \
71 --only-section=.rodata \
72 --pad-to=8192 \
73 $< $@
76 # flash target
77 flash-bootloader: $(TARGETS)
78 time e07load/e07load --tty="${BOOTLOADER_TTY}" "${FLASH_ROM_MAP_FILE}"
80 clean:
81 make -C e07load clean
82 make -C gfxtool clean
83 rm -fr $(TARGETS) *.o *.elf *.bin *.d eeprom-2nd.map last_bootfrom *.asm33 *.header
85 include ../common/Makefile
87 # application headers
88 %.header: %.c
89 awk -f ../scripts/GenerateApplicationHeader.awk "$<" >"$@"