Improve picosoc demo firmware, picosoc firmware build fixes

Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
Clifford Wolf 2018-08-14 13:49:08 +02:00
parent ce9d92939a
commit b3f292a988
3 changed files with 59 additions and 19 deletions

View File

@ -39,10 +39,10 @@ firmware.elf: sections.lds start.s firmware.c
riscv32-unknown-elf-gcc -march=rv32imc -Wl,-Bstatic,-T,sections.lds,--strip-debug -ffreestanding -nostdlib -o firmware.elf start.s firmware.c
firmware.hex: firmware.elf
riscv32-unknown-elf-objcopy -O verilog firmware.elf > firmware.hex
riscv32-unknown-elf-objcopy -O verilog firmware.elf firmware.hex
firmware.bin: firmware.elf
riscv32-unknown-elf-objcopy -O binary firmware.elf > firmware.bin
riscv32-unknown-elf-objcopy -O binary firmware.elf firmware.bin
# ---- Testbench for SPI Flash Model ----

View File

@ -108,10 +108,11 @@ char getchar_prompt(char *prompt)
uint32_t cycles_begin, cycles_now, cycles;
__asm__ volatile ("rdcycle %0" : "=r"(cycles_begin));
reg_leds = ~0;
if (prompt)
print(prompt);
reg_leds = ~0;
while (c == -1) {
__asm__ volatile ("rdcycle %0" : "=r"(cycles_now));
cycles = cycles_now - cycles_begin;
@ -123,6 +124,7 @@ char getchar_prompt(char *prompt)
}
c = reg_uart_data;
}
reg_leds = 0;
return c;
}
@ -340,22 +342,16 @@ void cmd_benchmark_all()
// --------------------------------------------------------
extern uint32_t _sidata, _sdata, _edata, _sbss, _ebss;
void main()
{
// copy data section
for (uint32_t *src = &_sidata, *dest = &_sdata; dest < &_edata;) {
*dest++ = *src++;
}
// zero out .bss section
for (uint32_t *dest = &_sbss; dest < &_ebss;) {
*dest++ = 0;
}
{
reg_leds = 31;
reg_uart_clkdiv = 104;
print("Booting..\n");
reg_leds = 63;
set_flash_qspi_flag();
reg_leds = 127;
while (getchar_prompt("Press ENTER to continue..\n") != '\r') { /* wait */ }
print("\n");

View File

@ -35,11 +35,55 @@ addi x29, zero, 0
addi x30, zero, 0
addi x31, zero, 0
# zero initialize scratchpad memory
# Update LEDs
li a0, 0x03000000
li a1, 1
sw a1, 0(a0)
# zero initialize entire scratchpad memory
li a0, 0x00000000
setmemloop:
sw zero, 0(x1)
addi x1, x1, 4
blt x1, sp, setmemloop
sw a0, 0(a0)
addi a0, a0, 4
blt a0, sp, setmemloop
# Update LEDs
li a0, 0x03000000
li a1, 3
sw a1, 0(a0)
# copy data section
la a0, _sidata
la a1, _sdata
la a2, _edata
bge a1, a2, end_init_data
loop_init_data:
lw a3, 0(a0)
sw a3, 0(a1)
addi a0, a0, 4
addi a1, a1, 4
blt a1, a2, loop_init_data
end_init_data:
# Update LEDs
li a0, 0x03000000
li a1, 7
sw a1, 0(a0)
# zero-init bss section
la a0, _sbss
la a1, _ebss
bge a0, a1, end_init_bss
loop_init_bss:
sw zero, 0(a0)
addi a0, a0, 4
blt a0, a1, loop_init_bss
end_init_bss:
# Update LEDs
li a0, 0x03000000
li a1, 15
sw a1, 0(a0)
# call main
call main