picosoc: use preprocessor for generating target-specific linker script

This commit is contained in:
Steffen Vogel 2019-02-11 23:44:47 +01:00
parent f3b1246c86
commit eb64df6c3e
4 changed files with 24 additions and 7 deletions

3
picosoc/.gitignore vendored
View File

@ -11,6 +11,7 @@
/hx8kdemo_fw.elf /hx8kdemo_fw.elf
/hx8kdemo_fw.hex /hx8kdemo_fw.hex
/hx8kdemo_fw.bin /hx8kdemo_fw.bin
/hx8kdemo_sections.lds
/icebreaker.asc /icebreaker.asc
/icebreaker.bin /icebreaker.bin
/icebreaker.json /icebreaker.json
@ -22,5 +23,7 @@
/icebreaker_fw.elf /icebreaker_fw.elf
/icebreaker_fw.hex /icebreaker_fw.hex
/icebreaker_fw.bin /icebreaker_fw.bin
/icebreaker_sections.lds
/testbench.vcd /testbench.vcd
/cmos.log /cmos.log

View File

@ -33,8 +33,11 @@ hx8kprog: hx8kdemo.bin hx8kdemo_fw.bin
hx8kprog_fw: hx8kdemo_fw.bin hx8kprog_fw: hx8kdemo_fw.bin
iceprog -o 1M hx8kdemo_fw.bin iceprog -o 1M hx8kdemo_fw.bin
hx8kdemo_fw.elf: sections.lds start.s firmware.c hx8kprog_sections.lds: sections.lds
riscv32-unknown-elf-gcc -DHX8KDEMO -march=rv32imc -Wl,-Bstatic,-T,sections.lds,--strip-debug -ffreestanding -nostdlib -o hx8kdemo_fw.elf start.s firmware.c riscv32-unknown-elf-cpp -P -DHX8KDEMO -o $@ $^
hx8kdemo_fw.elf: hx8kdemo_sections.lds start.s firmware.c
riscv32-unknown-elf-gcc -DHX8KDEMO -march=rv32imc -Wl,-Bstatic,-T,hx8kdemo_sections.lds,--strip-debug -ffreestanding -nostdlib -o hx8kdemo_fw.elf start.s firmware.c
hx8kdemo_fw.hex: hx8kdemo_fw.elf hx8kdemo_fw.hex: hx8kdemo_fw.elf
riscv32-unknown-elf-objcopy -O verilog hx8kdemo_fw.elf hx8kdemo_fw.hex riscv32-unknown-elf-objcopy -O verilog hx8kdemo_fw.elf hx8kdemo_fw.hex
@ -76,8 +79,11 @@ icebprog: icebreaker.bin icebreaker_fw.bin
icebprog_fw: icebreaker_fw.bin icebprog_fw: icebreaker_fw.bin
iceprog -o 1M icebreaker_fw.bin iceprog -o 1M icebreaker_fw.bin
icebreaker_fw.elf: sections.lds start.s firmware.c icebreaker_sections.lds: sections.lds
riscv32-unknown-elf-gcc -DICEBREAKER -march=rv32ic -Wl,-Bstatic,-T,sections.lds,--strip-debug -ffreestanding -nostdlib -o icebreaker_fw.elf start.s firmware.c riscv32-unknown-elf-cpp -P -DICEBREAKER -o $@ $^
icebreaker_fw.elf: icebreaker_sections.lds start.s firmware.c
riscv32-unknown-elf-gcc -DICEBREAKER -march=rv32ic -Wl,-Bstatic,-T,icebreaker_sections.lds,--strip-debug -ffreestanding -nostdlib -o icebreaker_fw.elf start.s firmware.c
icebreaker_fw.hex: icebreaker_fw.elf icebreaker_fw.hex: icebreaker_fw.elf
riscv32-unknown-elf-objcopy -O verilog icebreaker_fw.elf icebreaker_fw.hex riscv32-unknown-elf-objcopy -O verilog icebreaker_fw.elf icebreaker_fw.hex

View File

@ -21,9 +21,9 @@
#include <stdbool.h> #include <stdbool.h>
#ifdef ICEBREAKER #ifdef ICEBREAKER
#define MEM_TOTAL 0x20000 # define MEM_TOTAL 0x20000 /* 128 KB */
#elif HX8KDEMO #elif HX8KDEMO
#define MEM_TOTAL 0x200 # define MEM_TOTAL 0x200 /* 2 KB */
#else #else
# error "Set -DICEBREAKER or -DHX8KDEMO when compiling firmware.c" # error "Set -DICEBREAKER or -DHX8KDEMO when compiling firmware.c"
#endif #endif

View File

@ -1,7 +1,15 @@
#ifdef ICEBREAKER
# define MEM_TOTAL 0x20000 /* 128 KB */
#elif HX8KDEMO
# define MEM_TOTAL 0x200 /* 2 KB */
#else
# error "Set -DICEBREAKER or -DHX8KDEMO when compiling firmware.c"
#endif
MEMORY MEMORY
{ {
FLASH (rx) : ORIGIN = 0x00100000, LENGTH = 0x400000 /* entire flash, 4 MiB */ FLASH (rx) : ORIGIN = 0x00100000, LENGTH = 0x400000 /* entire flash, 4 MiB */
RAM (xrw) : ORIGIN = 0x00000000, LENGTH = 0x000400 /* 1 KB */ RAM (xrw) : ORIGIN = 0x00000000, LENGTH = MEM_TOTAL
} }
SECTIONS { SECTIONS {