1 LIBDIR
=..
/toolchain
/mini-libc
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
13 BOOTLOADER_TTY ?
= /dev
/ttyUSB0
14 FLASH_ROM_MAP_FILE ?
= wikireader.map
16 ifeq ($(MAKECMDGOALS
),bootloader232
)
17 EXTRA_CFLAGS
= -DEEPROM1ST_LOAD_FROM_RS232
=1
19 EXTRA_CFLAGS
= -DEEPROM1ST_LOAD_FROM_EEPROM
=1
22 ifneq ($(MAKECMDGOALS
),flash-bootloader
)
23 $(shell [ -f last_bootfrom
] && [ -z
"`grep '\$(EXTRA_CFLAGS)' last_bootfrom`" ] && rm last_bootfrom
)
29 bootloader232
:bootloader
40 #### first boot loader
42 $(GCC
) -o
$@
$(LDFLAGS
) $< -Wl
,'-Ttext=0'
45 $(OBJCOPY
) $(OBJCOPY_FLAGS
) --only-section
=.text
--set-start
=0 $< $@
47 #### second boot loader
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 \
69 eeprom-2nd.bin
: eeprom-2nd.elf
70 $(OBJCOPY
) $(OBJCOPY_FLAGS
) --only-section
=.text \
71 --only-section
=.rodata \
77 flash-bootloader
: $(TARGETS
)
78 time e07load
/e07load
--tty
="${BOOTLOADER_TTY}" "${FLASH_ROM_MAP_FILE}"
83 rm -fr
$(TARGETS
) *.o
*.elf
*.bin
*.d eeprom-2nd.map last_bootfrom
*.asm33
*.header
85 include ..
/common
/Makefile
89 awk
-f ..
/scripts
/GenerateApplicationHeader.awk
"$<" >"$@"