tools: add bootrom

Signed-off-by: liangkangnan <liangkangnan@163.com>
verilator
liangkangnan 2023-04-01 15:06:00 +08:00
parent 9aba174156
commit 6aa5f18429
5 changed files with 56 additions and 0 deletions

6
tools/bootrom/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
# Object files
*.o
*.bin
*.elf
*.mem
*.dump

19
tools/bootrom/Makefile Normal file
View File

@ -0,0 +1,19 @@
target := bootrom
BIN2MEM := ../BinToMem.py
RISCV_TOOLS_PATH := /opt/riscv32/bin
RISCV_TOOLS_PREFIX := riscv32-unknown-elf-
GCC?=$(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)gcc)
OBJCOPY?=$(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)objcopy)
OBJDUMP?=$(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)objdump)
all:
$(GCC) -Tlink.ld bootrom.S -march=rv32im -mabi=ilp32 -mcmodel=medlow -nostartfiles -nostdlib -static -Wl,--no-gc-sections -o $(target).elf
$(OBJCOPY) -O binary $(target).elf $(target).bin
$(OBJDUMP) -d $(target).elf --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data > $(target).dump
$(BIN2MEM) $(target).bin $(target).mem
clean:
rm -f *.img *.dump *.bin *.sv *.elf *.mem

10
tools/bootrom/README.md Normal file
View File

@ -0,0 +1,10 @@
Bootrom源码。
当从外部Flash启动时需要先从此Bootrom启动做一些初始化操作然后通过Bootrom跳转到Flash地址空间执行用户程序。
编译:
```
make
```

10
tools/bootrom/bootrom.S Normal file
View File

@ -0,0 +1,10 @@
.global entry
.option norvc
entry:
lui a0, 0x0200
slli a0, a0, 0x4
// jump to 0x02000000
jalr a0
loop:
j loop

11
tools/bootrom/link.ld Normal file
View File

@ -0,0 +1,11 @@
OUTPUT_ARCH( "riscv" )
ENTRY( entry )
SECTIONS
{
. = 0x01000000;
.text :
{
*(.text)
}
_end = .;
}