- added packhex

- flasjgen bugfix data types

git-svn-id: http://moon:8086/svn/mips@4 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2014-07-20 18:53:17 +00:00
parent 6f3d6c1b0c
commit 0d15861c80
4 changed files with 633 additions and 71 deletions
+48 -47
View File
@@ -25,6 +25,7 @@ ifeq ($(TLB),yes)
else
FLASHGEN=../tools/flashgen
endif
PACKHEX=../tools/packhex
LIBS=-lm -lsys
@@ -54,7 +55,7 @@ test_fft.elf: test_fft.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
hello.elf: hello.c libsys.a
$(CC) $(CFLAGS) -o $@ -Os hello.c $(LIBS) >$@.map
@@ -62,7 +63,7 @@ hello.elf: hello.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
blittertest.elf: blittertest.c libsys.a
$(CC) $(CFLAGS) -o $@ -Os blittertest.c $(LIBS) >$@.map
@@ -70,7 +71,7 @@ blittertest.elf: blittertest.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
blittertest_tb.elf: blittertest_tb.c libsys.a
$(CC) $(CFLAGS) -o $@ -Os blittertest_tb.c $(LIBS) >$@.map
@@ -78,7 +79,7 @@ blittertest_tb.elf: blittertest_tb.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
testbench.elf: testbench.c libsys.a
$(CC) $(CFLAGS) -O3 -o $@ -DHZ=1000 -DNOSIGNAL -DBATCHMODE -DNOMAIN -Os -g testbench.c paranoia.c delay_mips.c bogomips.c $(LIBS) >$@.map
@@ -86,7 +87,7 @@ testbench.elf: testbench.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_irq.elf: test_irq.c libsys.a
$(CC) $(CFLAGS) -o $@ test_irq.c $(LIBS) >$@.map
@@ -94,7 +95,7 @@ test_irq.elf: test_irq.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
dhry.elf: dhry_1.c dhry_2.c dhry.h libsys.a
$(CC) $(CFLAGS) -o $@ -DHZ=1000 dhry_1.c dhry_2.c $(LIBS) >$@.map
@@ -102,7 +103,7 @@ dhry.elf: dhry_1.c dhry_2.c dhry.h libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
queens.elf: queens.c libsys.a
$(CC) $(CFLAGS) -o $@ -DUNIX_Old -DHZ=1000 queens.c $(LIBS) >$@.map
@@ -110,7 +111,7 @@ queens.elf: queens.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
stanford.elf: stanford.c libsys.a
$(CC) $(CFLAGS) -O3 -o $@ -DHZ=1000 stanford.c $(LIBS) >$@.map
@@ -118,7 +119,7 @@ stanford.elf: stanford.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
paranoia.elf: paranoia.c libsys.a
$(CC) $(CFLAGS) -O3 -o $@ -DNOSIGNAL -DBATCHMODE paranoia.c $(LIBS) >$@.map
@@ -126,7 +127,7 @@ paranoia.elf: paranoia.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
rmd160_test.elf: rmd160_test.c rmd160.c rmd160.h libsys.a
$(CC) $(CFLAGS) -O3 -o $@ rmd160_test.c rmd160.c $(LIBS) >$@.map
@@ -134,7 +135,7 @@ rmd160_test.elf: rmd160_test.c rmd160.c rmd160.h libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
hashtest.elf: hashtest.c rmd160.c rmd160.h libsys.a
$(CC) $(CFLAGS) -O3 -o $@ hashtest.c rmd160.c $(LIBS) >$@.map
@@ -142,7 +143,7 @@ hashtest.elf: hashtest.c rmd160.c rmd160.h libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
Bessel.elf: Bessel.c libsys.a
$(CC) $(CFLAGS) -o $@ Bessel.c $(LIBS) >$@.map
@@ -150,7 +151,7 @@ Bessel.elf: Bessel.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
whet.elf: whet.c libsys.a
$(CC) $(CFLAGS) -o $@ whet.c $(LIBS) >$@.map
@@ -158,7 +159,7 @@ whet.elf: whet.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
phrasen.elf: phrasen.c libsys.a
$(CC) $(CFLAGS) -o $@ phrasen.c $(LIBS) >$@.map
@@ -166,7 +167,7 @@ phrasen.elf: phrasen.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
dttl.elf: dttl.c random.c libsys.a
$(CC) $(CFLAGS) -o $@ dttl.c random.c $(LIBS) >$@.map
@@ -174,7 +175,7 @@ dttl.elf: dttl.c random.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
richards_benchmark.elf: richards_benchmark.c libsys.a
$(CC) $(CFLAGS) -o $@ richards_benchmark.c $(LIBS) >$@.map
@@ -182,7 +183,7 @@ richards_benchmark.elf: richards_benchmark.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_exception.elf: test_exception.c libsys.a
$(CC) $(CFLAGS) -o $@ -O1 test_exception.c $(LIBS) >$@.map
@@ -190,7 +191,7 @@ test_exception.elf: test_exception.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
life.elf: life.c libsys.a
$(CC) $(CFLAGS) -o $@ -g life.c $(LIBS) >$@.map
@@ -198,7 +199,7 @@ life.elf: life.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
r3.elf: r3.c libsys.a
$(CC) $(CFLAGS) -O3 -o $@ -DJMIPS_VGA -O2 r3.c $(LIBS) >$@.map
@@ -206,7 +207,7 @@ r3.elf: r3.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
gunzip.elf: gunzip.c inflate.c crc32.c libsys.a
$(CC) $(CFLAGS) -o $@ -o $@ gunzip.c inflate.c crc32.c $(LIBS) >$@.map
@@ -214,7 +215,7 @@ gunzip.elf: gunzip.c inflate.c crc32.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
basic_math.elf: basicmath_small.c rad2deg.c cubic.c isqrt.c libsys.a
$(CC) $(CFLAGS) -o $@ -o $@ basicmath_small.c rad2deg.c cubic.c isqrt.c $(LIBS) >$@.map
@@ -222,7 +223,7 @@ basic_math.elf: basicmath_small.c rad2deg.c cubic.c isqrt.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
JMAN_SRC= \
jman/bintree.c \
@@ -246,7 +247,7 @@ jman_patches.elf: $(JMAN_SRC) jman/main_patches.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
jman_patchmeshes.elf: $(JMAN_SRC) jman/main_patchmeshes.c jman/patches2.c libsys.a
$(CC) $(CFLAGS) -I../ -o $@ -o $@ jman/main_patchmeshes.c jman/patches2.c $(JMAN_SRC) $(LIBS) >$@.map
@@ -254,7 +255,7 @@ jman_patchmeshes.elf: $(JMAN_SRC) jman/main_patchmeshes.c jman/patches2.c libsys
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
jman_polys.elf: $(JMAN_SRC) jman/main_polypin.c jman/polys.c libsys.a
$(CC) $(CFLAGS) -I../ -o $@ -o $@ jman/main_polypin.c jman/polys.c $(JMAN_SRC) $(LIBS) >$@.map
@@ -262,7 +263,7 @@ jman_polys.elf: $(JMAN_SRC) jman/main_polypin.c jman/polys.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
serdump.elf: serdump.c libsys.a
$(CC) $(CFLAGS) -O3 -o $@ -O2 serdump.c $(LIBS) >$@.map
@@ -270,7 +271,7 @@ serdump.elf: serdump.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
pppi.elf: pppissue/test1.c pppissue/utils.c pppissue/pppd.h libsys.a
$(CC) $(CFLAGS) -O2 -o $@ -O2 pppissue/test1.c pppissue/utils.c $(LIBS) >$@.map
@@ -278,7 +279,7 @@ pppi.elf: pppissue/test1.c pppissue/utils.c pppissue/pppd.h libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
lwl.elf: lwl.c libsys.a
$(CC) $(CFLAGS) -O2 -o $@ lwl.c $(LIBS) >$@.map
@@ -286,7 +287,7 @@ lwl.elf: lwl.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
ucb.elf: ucb.c libsys_sim.a
$(CC) $(CFLAGS) -O2 -o $@ ucb.c -lsys_sim >$@.map
@@ -294,7 +295,7 @@ ucb.elf: ucb.c libsys_sim.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_timer.elf: test_timer.c libsys_sim.a
$(CC) $(CFLAGS) -O2 -o $@ test_timer.c -lsys_sim >$@.map
@@ -302,7 +303,7 @@ test_timer.elf: test_timer.c libsys_sim.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_exception_sim.elf: test_exception_sim.c libsys_sim.a
$(CC) $(CFLAGS) -O2 -o $@ test_exception_sim.c -lsys_sim >$@.map
@@ -310,7 +311,7 @@ test_exception_sim.elf: test_exception_sim.c libsys_sim.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_tlb_sim.elf: test_tlb_sim.c libsys_sim.a
$(CC) $(CFLAGS) -O2 -o $@ test_tlb_sim.c -lsys_sim >$@.map
@@ -318,7 +319,7 @@ test_tlb_sim.elf: test_tlb_sim.c libsys_sim.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_dcache_sim.elf: test_dcache.c libsys_sim.a
$(CC) $(CFLAGS) -O0 -o $@ test_dcache.c -lsys_sim >$@.map
@@ -326,7 +327,7 @@ test_dcache_sim.elf: test_dcache.c libsys_sim.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_hpi.elf: hpi.c test_hpi.c cfiflash.c libsys.a
$(CC) $(CFLAGS) -o $@ -g hpi.c test_hpi.c cfiflash.c $(LIBS) >$@.map
@@ -334,7 +335,7 @@ test_hpi.elf: hpi.c test_hpi.c cfiflash.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_vga.elf: test_vga.c libsys.a
$(CC) $(CFLAGS) -o $@ test_vga.c $(LIBS) >$@.map
@@ -342,7 +343,7 @@ test_vga.elf: test_vga.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
barcode.elf: barcode.c libsys.a
$(CC) $(CFLAGS) -o $@ barcode.c $(LIBS) >$@.map
@@ -350,7 +351,7 @@ barcode.elf: barcode.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
lua.elf: lua_init.c libsys.a
$(CC) $(CFLAGS) -I./lua-5.1.4/etc -I./lua-5.1.4/src -o $@ lua_init.c $(LIBS) >$@.map
@@ -358,7 +359,7 @@ lua.elf: lua_init.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
mandelbrot.elf: mandelbrot.c libsys.a
$(CC) $(CFLAGS) -o $@ mandelbrot.c $(LIBS) >$@.map
@@ -366,7 +367,7 @@ mandelbrot.elf: mandelbrot.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
bogomips.elf: bogomips.c delay_mips.c libsys.a
$(CC) $(CFLAGS) -DHZ=1000 -o $@ bogomips.c delay_mips.c $(LIBS) >$@.map
@@ -374,7 +375,7 @@ bogomips.elf: bogomips.c delay_mips.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_asm.elf: test_asm.S libsys.a
$(CC) $(CFLAGS) -DHZ=1000 -o $@ test_asm.S $(LIBS) >$@.map
@@ -382,7 +383,7 @@ test_asm.elf: test_asm.S libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_ac97.elf: test_ac97.c libsys.a
$(CC) $(CFLAGS) -o $@ test_ac97.c $(LIBS) >$@.map
@@ -390,7 +391,7 @@ test_ac97.elf: test_ac97.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
aes256_1.elf: aes256_1.c aes256.c aes256.h libsys.a
$(CC) $(CFLAGS) -O3 -o $@ aes256_1.c aes256.c $(LIBS) >$@.map
@@ -398,7 +399,7 @@ aes256_1.elf: aes256_1.c aes256.c aes256.h libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_gpio.elf: test_gpio.c marvell_88e1111.c mii-bitbang.c emac.c emac.h ethernet.c ethernet.h arp.c arp.h icmp.c icmp.h ipv4.c ipv4.h udp.c udp.h dhcp.c dhcp.h fifo.c fifo.h libsys.a
$(CC) $(CFLAGS) -o $@ -O2 test_gpio.c marvell_88e1111.c mii-bitbang.c emac.c ethernet.c arp.c icmp.c ipv4.c udp.c dhcp.c fifo.c $(LIBS) >$@.map
@@ -406,7 +407,7 @@ test_gpio.elf: test_gpio.c marvell_88e1111.c mii-bitbang.c emac.c emac.h etherne
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_emac_sim.elf: test_emac_sim.c emac.c emac.h libsys.a
$(CC) $(CFLAGS) -o $@ -Os test_emac_sim.c emac.c $(LIBS) >$@.map
@@ -414,7 +415,7 @@ test_emac_sim.elf: test_emac_sim.c emac.c emac.h libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
mips_io.elf: mips_io.c libsys.a
$(CC) $(CFLAGS) -o $@ mips_io.c $(LIBS) >$@.map
@@ -422,7 +423,7 @@ mips_io.elf: mips_io.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
mips_instr.elf: mips_instr.c libsys.a
$(CC) $(CFLAGS) -o $@ mips_instr.c $(LIBS) >$@.map
@@ -430,7 +431,7 @@ mips_instr.elf: mips_instr.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
test_endianess.elf: test_endianess.c libsys.a
$(CC) $(CFLAGS) -O0 -o $@ test_endianess.c $(LIBS) >$@.map
@@ -438,7 +439,7 @@ test_endianess.elf: test_endianess.c libsys.a
$(OBJCOPY) $@ -O binary $@.bin
$(OBJCOPY) -O srec $@ $@.srec
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
cat $@.srec | packhex > $@.pack
cat $@.srec | $(PACKHEX) > $@.pack
clean:
rm -rf *.a *.o *.bin *.map *.dis *.srec *.pack *.elf $(PROG) > /dev/null
+4 -1
View File
@@ -1,7 +1,7 @@
CFLAGS=-O2
CC=gcc
PREFIX=/usr/local
all: romgen ramgen flashgen flashgen_tlb
all: romgen ramgen flashgen flashgen_tlb packhex
romgen: ./src/romgen.c
$(CC) $(CFLAGS) ./src/romgen.c -lm -o ./romgen
@@ -15,6 +15,9 @@ flashgen: ./src/flashgen.c
flashgen_tlb: ./src/flashgen.c
$(CC) $(CFLAGS) -DSDRAM_BASE=0x80000000 -DFLASH_BASE_MEM=0x88000000 ./src/flashgen.c -lm -o ./flashgen_tlb
packhex: ./src/packhex.c
$(CC) $(CFLAGS) ./src/packhex.c -lm -o ./packhex
install:
cp romgen $(PREFIX)/bin
cp ramgen $(PREFIX)/bin
+13 -23
View File
@@ -2,17 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define INT8 char
#define INT16 short
#define INT32 long
#define UINT8 unsigned char
#define UINT16 unsigned short
#define UINT32 unsigned long
#define INT int
#define UINT unsigned int
#define FLOAT32 float
#define FLOAT64 double
#include <stdint.h>
#ifndef SDRAM_BASE
#define SDRAM_BASE 0x40000000
@@ -24,9 +14,9 @@
#define MAGIC_EB 0x4A464931 // "JFI1" in big-endian;
#define MAGIC_EL 0x3149464A // "JFI1" in little-endian;
UINT32 conv_endian32(UINT32 src)
uint32_t conv_endian32(uint32_t src)
{
UINT32 dst;
uint32_t dst;
dst = (0xFF000000 & (src << 24))
| (0x00FF0000 & (src << 8))
@@ -39,13 +29,13 @@ UINT32 conv_endian32(UINT32 src)
// --------------------------------------------------------------
typedef struct _sflash_img_hdr_t
{
UINT32 magic;
UINT32 target_addr;
UINT32 img_offset;
UINT32 img_size;
UINT32 hdr_next;
UINT8 img_name[128];
UINT8 res[108];
uint32_t magic;
uint32_t target_addr;
uint32_t img_offset;
uint32_t img_size;
uint32_t hdr_next;
uint8_t img_name[128];
uint8_t res[108];
} flash_img_hdr_t;
@@ -73,7 +63,7 @@ int main(int argc, char *argv[])
char name_flash[1024];
char name_prj[1024];
char *pBuf;
UINT32 *pBuf32;
uint32_t *pBuf32;
flash_img_hdr_t img_hdr = {0};
FILE *pFile;
@@ -107,7 +97,7 @@ int main(int argc, char *argv[])
filesize = (end-start);
pBuf = (char*)malloc(filesize);
fread(pBuf, 1, filesize, pFile);
filesize = fread(pBuf, 1, filesize, pFile);
fclose(pFile);
@@ -129,7 +119,7 @@ int main(int argc, char *argv[])
if ((argv[2][0] == '-') && (toupper(argv[2][1]) == 'E') && (toupper(argv[2][2]) == 'B'))
{
img_hdr.magic = MAGIC_EB;
pBuf32 = (UINT32*)pBuf;
pBuf32 = (uint32_t*)pBuf;
for (i=0; i < filesize/4; i ++)
pBuf32[i] = conv_endian32(pBuf32[i]);
}
+568
View File
@@ -0,0 +1,568 @@
/***** P A C K H E X . C ************************************************
*
* Packhex is a hex-file compaction utility. It attempts to concatenate
* hex records to produce more size-efficient packaging.
*
* Limitations: Input files must be correctly formatted. This utility
* is not robust enough to detect hex-record formatting
* errors.
*
* Published: May 1993 Embedded Systems Programming magazine
* "Creating Faster Hex Files"
*
* URL: ESP magazine: http://www.embedded.com
* Source Code: ftp://ftp.mfi.com/pub/espmag/1993/pakhex.zip
*
* Author: Mark Gringrich
*
* Compiler: Microsoft C 6.0
* cl /F 1000 packhex.c
*
*
* $Id: packhex.c,v 1.9 2004/04/20 07:07:08 ralf Exp $
*
**************************************************************************/
/* #define SMALLER_RECORDS */
#ifdef SMALLER_RECORDS
#define MAX_LEN_S1_RECS 128
#define MAX_LEN_S2_RECS 128
#define MAX_LEN_S3_RECS 128
#else
#define MAX_LEN_S1_RECS 252
#define MAX_LEN_S2_RECS 251
#define MAX_LEN_S3_RECS 250
#endif
/*--------------------------------- includes ---------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if 0
#include "config.h"
#ifndef VMS
#ifndef HAVE_STRERROR
extern int sys_nerr;
extern char *sys_errlist[];
#define strerror( _err ) \
((_err) < sys_nerr) ? sys_errlist [(_err)] : "unknown error"
#else /* HAVE_STRERROR */
char *strerror ();
#endif
#else /* VMS */
char *strerror (int,...);
#endif
#endif
#if defined(__unix__) && !defined(EXIT_FAILURE)
#define EXIT_FAILURE -1
#define EXIT_SUCCESS 0
#endif
/*--------------------------------- defines ----------------------------------*/
#define YES 1
#define MAX_LINE_SIZE 600
#define EOS '\0'
/*---------------------------------- macros ----------------------------------*/
/* Convert ASCII hexadecimal digit to value. */
#define HEX_DIGIT( C ) ( ( ( ( C ) > '9' ) ? ( C ) + 25 : ( C ) ) & 0xF )
/*--------------------------------- typedefs ---------------------------------*/
typedef unsigned char Boolean;
typedef unsigned char Uchar;
typedef unsigned int Uint;
typedef unsigned long Ulong;
typedef struct /* Functions and constant returning Hex-record vital stats. */
{
Boolean ( *is_data_record )( char * );
Ulong ( *get_address )( char * );
Uint ( *get_data_count )( char * );
const Uint max_data_count;
char *( *get_data_start )( char * );
void ( *put_data_record )( Uint, Ulong, char * );
} Rec_vitals;
/*--------------------------- function prototypes ----------------------------*/
Rec_vitals * identify_first_data_record( char *, int );
Ulong get_ndigit_hex( char *, int );
/*----------------------------- Intel Hex format -----------------------------*/
/*
* Intel Hex data-record layout
*
* :aabbbbccd...dee
*
* : - header character
* aa - record data byte count, a 2-digit hex value
* bbbb - record address, a 4-digit hex value
* cc - record type, a 2-digit hex value:
* "00" is a data record
* "01" is an end-of-data record
* "02" is an extended-address record
* "03" is a start record
* d...d - data (always an even number of chars)
* ee - record checksum, a 2-digit hex value
* checksum = 2's complement
* [ (sum of bytes: aabbbbccd...d) modulo 256 ]
*/
Boolean is_intel_data_rec( char * rec_str )
{
return( ( rec_str[ 0 ] == ':' ) && ( rec_str[ 8 ] == '0' ) );
}
Uint get_intel_rec_data_count( char * rec_str )
{
return( ( Uint ) get_ndigit_hex( rec_str + 1, 2 ) );
}
Ulong get_intel_rec_address( char * rec_str )
{
return( get_ndigit_hex( rec_str + 3, 4 ) );
}
char * get_intel_rec_data_start( char * rec_str )
{
return( rec_str + 9 );
}
void put_intel_data_rec( Uint count, Ulong address, char * data_str )
{
char *ptr;
Uint sum = count + ( address >> 8 & 0xff ) + ( address & 0xff );
for ( ptr = data_str ; *ptr != EOS ; ptr += 2 )
sum += ( Uint ) get_ndigit_hex( ptr, 2 );
printf(
":%02X%04lX00%s%02X\n", count, address, data_str, (~sum + 1) & 0xff
);
}
Rec_vitals intel_hex =
{
is_intel_data_rec,
get_intel_rec_address,
get_intel_rec_data_count,
255, /* Maximum data bytes in a record. */
get_intel_rec_data_start,
put_intel_data_rec
};
/*------------------------- Motorola S1-record format ------------------------*/
/*
* Motorola S-record data-record layout
*
* Sabbc...cd...dee
*
* S - header character
* a - record type, a 1-digit value:
* "0" is a header record
* "1" is a 2-byte-address data record
* "2" is a 3-byte-address data record
* "3" is a 4-byte-address data record
* "7" is a 4-byte-address end-of-data record
* "8" is a 3-byte-address end-of-data record
* "9" is a 2-byte-address end-of-data record
* bb - record length in bytes, a 2-digit hex value
* (record length doesn't count the header/type
* chars and checksum byte)
* c...c - record address, a 4-, 6-, or 8-digit value,
* depending on record type
* d...d - data (always an even number of chars)
* ee - record checksum, a 2-digit hex value
* checksum = 1's complement
* [ (sum of all bytes: bbc..cd...d) modulo 256 ]
*/
#define S1_COUNT_OFFSET 3
Boolean is_moto_s1_data_rec( char * rec_str )
{
return ( ( rec_str[ 0 ] == 'S' ) && ( rec_str[ 1 ] == '1' ) );
}
Uint get_moto_s1_rec_data_count( char * rec_str )
{
return( ( Uint ) get_ndigit_hex( rec_str + 2, 2 ) - S1_COUNT_OFFSET );
}
Ulong get_moto_s1_rec_address( char * rec_str )
{
return( get_ndigit_hex( rec_str + 4, 4 ) );
}
char * get_moto_s1_rec_data_start( char * rec_str )
{
return( rec_str + 8 );
}
void put_moto_s1_data_rec( Uint count, Ulong address, char * data_str )
{
char *ptr;
Uint sum = S1_COUNT_OFFSET + count +
( address >> 8 & 0xff ) + ( address & 0xff );
for ( ptr = data_str ; *ptr != EOS ; ptr += 2 )
sum += ( Uint ) get_ndigit_hex( ptr, 2 );
printf(
"S1%02X%04lX%s%02X\n",
count + S1_COUNT_OFFSET, address, data_str, ~sum & 0xff
);
}
Rec_vitals motorola_s1_rec =
{
is_moto_s1_data_rec,
get_moto_s1_rec_address,
get_moto_s1_rec_data_count,
MAX_LEN_S1_RECS, /* Maximum data bytes in a record. */
get_moto_s1_rec_data_start,
put_moto_s1_data_rec
};
/*------------------------- Motorola S2-record format ------------------------*/
#define S2_COUNT_OFFSET 4
Boolean is_moto_s2_data_rec( char * rec_str )
{
return ( ( rec_str[ 0 ] == 'S' ) && ( rec_str[ 1 ] == '2' ) );
}
Uint get_moto_s2_rec_data_count( char * rec_str )
{
return( ( Uint ) get_ndigit_hex( rec_str + 2, 2 ) - S2_COUNT_OFFSET );
}
Ulong get_moto_s2_rec_address( char * rec_str )
{
return( get_ndigit_hex( rec_str + 4, 6 ) );
}
char * get_moto_s2_rec_data_start( char * rec_str )
{
return( rec_str + 10 );
}
void put_moto_s2_data_rec( Uint count, Ulong address, char * data_str )
{
char *ptr;
Uint sum = S2_COUNT_OFFSET + count + ( address >> 16 & 0xff ) +
( address >> 8 & 0xff ) +
( address & 0xff );
for ( ptr = data_str ; *ptr != EOS ; ptr += 2 )
sum += ( Uint ) get_ndigit_hex( ptr, 2 );
printf(
"S2%02X%06lX%s%02X\n",
count + S2_COUNT_OFFSET, address, data_str, ~sum & 0xff
);
}
Rec_vitals motorola_s2_rec =
{
is_moto_s2_data_rec,
get_moto_s2_rec_address,
get_moto_s2_rec_data_count,
MAX_LEN_S2_RECS, /* Maximum data bytes in a record. */
get_moto_s2_rec_data_start,
put_moto_s2_data_rec
};
/*------------------------- Motorola S3-record format ------------------------*/
#define S3_COUNT_OFFSET 5
Boolean is_moto_s3_data_rec( char * rec_str )
{
return ( ( rec_str[ 0 ] == 'S' ) && ( rec_str[ 1 ] == '3' ) );
}
Uint get_moto_s3_rec_data_count( char * rec_str )
{
return( ( Uint ) get_ndigit_hex( rec_str + 2, 2 ) - S3_COUNT_OFFSET );
}
Ulong get_moto_s3_rec_address( char * rec_str )
{
return( get_ndigit_hex( rec_str + 4, 8 ) );
}
char * get_moto_s3_rec_data_start( char * rec_str )
{
return( rec_str + 12 );
}
void put_moto_s3_data_rec( Uint count, Ulong address, char * data_str )
{
char *ptr;
Uint sum = S3_COUNT_OFFSET + count + ( address >> 24 & 0xff ) +
( address >> 16 & 0xff ) +
( address >> 8 & 0xff ) +
( address & 0xff );
for ( ptr = data_str ; *ptr != EOS ; ptr += 2 )
sum += ( Uint ) get_ndigit_hex( ptr, 2 );
printf(
"S3%02X%08lX%s%02X\n",
count + S3_COUNT_OFFSET, address, data_str, ~sum & 0xff
);
}
Rec_vitals motorola_s3_rec =
{
is_moto_s3_data_rec,
get_moto_s3_rec_address,
get_moto_s3_rec_data_count,
MAX_LEN_S3_RECS, /* Maximum data bytes in a record. */
get_moto_s3_rec_data_start,
put_moto_s3_data_rec
};
/*-------------------- Put your favorite hex format here ---------------------*/
/*
* * * * The following is a template for an additional hex format: * * *
*
*
* Boolean is_X_data_rec( char * rec_str ) {}
*
* Uint get_X_rec_data_count( char * rec_str ) {}
*
* Ulong get_X_rec_address( char * rec_str ) {}
*
* char * get_X_rec_data_start( char * rec_str ) {}
*
* void put_X_data_rec( Uint count, Ulong address, char * data_str ) {}
*
* Rec_vitals X_rec =
* {
* is_X_data_rec,
* get_X_rec_address,
* get_X_rec_data_count,
* MAXIMUM DATA BYTES IN A RECORD,
* get_X_rec_data_start,
* put_X_data_rec
* };
*
*/
/*----------------------------------------------------------------------------*/
/*
* Put address of additional Rec_vitals structures
* in this array, before the NULL entry.
*/
Rec_vitals *formats[] =
{
&intel_hex,
&motorola_s1_rec,
&motorola_s2_rec,
&motorola_s3_rec,
( Rec_vitals * ) NULL
};
/**** main *****************************************************************
*
*
* Expects: Nothing (no command-line parameters).
*
* Returns: Exit status (EXIT_SUCCESS or EXIT_FAILURE).
*
* Reads hex records on the standard input and attempts to
* splice adjacent data fields together. Results appear on
* the standard output.
*
*******************************************************************************/
int main(
int argc,
char **argv
)
{
char inbuff[ MAX_LINE_SIZE ], outbuff[ MAX_LINE_SIZE ];
char *in_dptr, *out_dptr;
int d_total, d_count, d_excess, n;
int length;
Ulong in_rec_addr, out_rec_addr = 0;
Rec_vitals *rptr;
/* Sift through file until first hex record is identified. */
rptr = identify_first_data_record( inbuff, MAX_LINE_SIZE );
if ( rptr == NULL )
{
fputs( "No hex records found.\n", stderr );
exit( EXIT_FAILURE );
}
/* Attempt data-record splicing until end-of-file is reached. */
d_total = 0;
for (;;) {
if ( rptr->is_data_record( inbuff ) == YES )
{ /* Input record is a data record. */
d_count = rptr->get_data_count( inbuff );
in_rec_addr = rptr->get_address( inbuff );
in_dptr = rptr->get_data_start( inbuff );
if ( d_total == 0 || in_rec_addr != out_rec_addr + d_total )
{ /* Begin a new output record. */
if ( d_total != 0 )
rptr->put_data_record( d_total, out_rec_addr, outbuff );
out_dptr = outbuff;
n = d_total = d_count;
out_rec_addr = in_rec_addr;
}
else if
( ( d_excess = d_total + d_count - rptr->max_data_count ) > 0 )
{ /* Output a maximum-length record, then start a new record. */
strncat( outbuff, in_dptr, 2 * ( d_count - d_excess ) );
rptr->put_data_record(
rptr->max_data_count, out_rec_addr, outbuff
);
in_dptr += 2 * ( d_count - d_excess );
out_dptr = outbuff;
n = d_total = d_excess;
out_rec_addr += rptr->max_data_count;
}
else
{ /* Append input record's data field with accumulated data. */
out_dptr = outbuff + ( 2 * d_total );
d_total += n = d_count;
}
strncpy( out_dptr, in_dptr, 2 * n );
out_dptr[ 2 * n ] = EOS;
}
else
{ /* Not a data record;
* flush accumulated data then echo non-data record.
*/
if ( d_total != 0 )
{
rptr->put_data_record( d_total, out_rec_addr, outbuff );
d_total = 0;
}
puts( inbuff );
}
inbuff[ MAX_LINE_SIZE - 1 ] = '\0';
if ( !fgets( inbuff, MAX_LINE_SIZE, stdin ) )
break;
if ( inbuff[ MAX_LINE_SIZE - 1 ] ) {
fprintf( stderr, "Input line too long" );
exit( 1 );
}
length = strlen(inbuff);
inbuff[length - 1] = '\0';
}
return ( EXIT_SUCCESS );
}
/**** identify_first_data_record *******************************************
*
* Expects: Pointer to hex-record line buffer.
*
* Returns: Pointer to hex-record structure (NULL if no match found).
*
* Reads the standard input, line by line, searching for a valid
* record header character. If a valid header is found, a pointer
* to the hex-record's type structure is returned, otherwise NULL.
*
* The input-stream pointer is left pointing to the first valid hex record.
*
*******************************************************************************/
Rec_vitals * identify_first_data_record( char * buff_ptr, int max_length )
{
Rec_vitals ** ptr;
int length;
for ( ;; ) {
buff_ptr[ max_length - 1 ] = '\0';
if ( !fgets( buff_ptr, max_length, stdin ) )
break;
if ( buff_ptr[ max_length - 1 ] ) {
fprintf( stderr, "Input line too long" );
exit( 1 );
}
length = strlen(buff_ptr);
buff_ptr[length - 1] = '\0';
for ( ptr = formats ; *ptr != ( Rec_vitals * ) NULL ; ptr++ )
if ( ( *ptr )->is_data_record( buff_ptr ) == YES )
return( *ptr ); /* Successful return. */
puts( buff_ptr ); /* Echo non-hex-record line. */
}
return( ( Rec_vitals * ) NULL ); /* Unsuccessful return. */
}
/**** get_ndigit_hex *******************************************************
*
* Expects: Pointer to first ASCII hexadecimal digit, number of digits.
*
* Returns: Value of hexadecimal string as an unsigned long.
*
*******************************************************************************/
Ulong get_ndigit_hex( char * cptr, int digits )
{
Ulong value;
for ( value = 0 ; --digits >= 0 ; cptr++ )
value = ( value * 16L ) + HEX_DIGIT( *cptr );
return( value );
}