Skip to content

Commit 9c19ea4

Browse files
committed
Replaced direct all to __sinit() with call to __libc_init_array() in startup_*.S , for all projects. Use t0,t1 regs instead of a0,a1. Updated binaries.
1 parent dfb7295 commit 9c19ea4

31 files changed

+71
-79
lines changed

advanced/circuitpython/riscv-emu.py/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ $(BUILD)/%.o: %.S
8585

8686
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) $(SRC_CIRCUITPY_COMMON)
8787

88-
all: $(BUILD)/firmware.elf $(BUILD)/circuitpy.img
88+
all: $(BUILD)/firmware.elf $(BUILD)/firmware.bin $(BUILD)/circuitpy.img
8989

9090
BOARD_LD := $(wildcard boards/$(BOARD)/link.ld)
9191

advanced/circuitpython/riscv-emu.py/link.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ MEMORY
77

88
SECTIONS
99
{
10+
. = 0x00000000;
11+
1012
.text : ALIGN(4)
1113
{
1214
KEEP(*(.init))

advanced/circuitpython/riscv-emu.py/start.S

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.section .text
1+
.section .init
22
.globl _start
33

44
_start:
@@ -13,25 +13,23 @@ _start:
1313
mv s1, a1
1414

1515
# initialize .bss
16-
la a0, __bss_start
17-
la a1, __bss_end
16+
la t0, __bss_start
17+
la t1, __bss_end
1818
z_bss:
19-
sw zero, 0(a0)
20-
addi a0, a0, 4
21-
blt a0, a1, z_bss
19+
sw zero, 0(t0)
20+
addi t0, t0, 4
21+
blt t0, t1, z_bss
2222

2323
# initialize .sbss
24-
la a0, __sbss_start
25-
la a1, __sbss_end
24+
la t0, __sbss_start
25+
la t1, __sbss_end
2626
z_sbss:
27-
sw zero, 0(a0)
28-
addi a0, a0, 4
29-
blt a0, a1, z_sbss
27+
sw zero, 0(t0)
28+
addi t0, t0, 4
29+
blt t0, t1, z_sbss
3030

3131
# initialize Newlib
32-
la a0, _impure_ptr
33-
lw a0, 0(a0)
34-
call __sinit
32+
call __libc_init_array
3533

3634
# restore a0 and a1
3735
mv a0, s0

advanced/coremark/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ Inspect the results in `run1.log` and `run2.log`:
1616
```
1717
2K performance run parameters for coremark.
1818
CoreMark Size : 666
19-
Total ticks : 14828555
20-
Total time (secs): 14
21-
Iterations/Sec : 1
22-
Iterations : 20
19+
Total ticks : 12326926
20+
Total time (secs): 12
21+
Iterations/Sec : 3
22+
Iterations : 40
2323
Compiler version : GCC12.2.0
24-
Compiler flags : -march=rv32i_zicsr -mabi=ilp32 -O2 -D_REENT_SMALL -DPERFORMANCE_RUN=1
24+
Compiler flags : -march=rv32im_zicsr -mabi=ilp32 -O2 -D_REENT_SMALL -DPERFORMANCE_RUN=1
2525
Memory location : heap
2626
seedcrc : 0xe9f5
2727
[0]crclist : 0xe714
2828
[0]crcmatrix : 0x1fd7
2929
[0]crcstate : 0x8e3a
30-
[0]crcfinal : 0x4983
30+
[0]crcfinal : 0x65c5
3131
Correct operation validated. See README.md for run and reporting rules.
3232
```

advanced/coremark/riscv-emu.py/start_newlib.S

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.section .text
1+
.section .init
22
.globl _start
33

44
_start:
@@ -13,25 +13,23 @@ _start:
1313
mv s1, a1
1414

1515
# initialize .bss
16-
la a0, __bss_start
17-
la a1, __bss_end
16+
la t0, __bss_start
17+
la t1, __bss_end
1818
z_bss:
19-
sw zero, 0(a0)
20-
addi a0, a0, 4
21-
blt a0, a1, z_bss
19+
sw zero, 0(t0)
20+
addi t0, t0, 4
21+
blt t0, t1, z_bss
2222

2323
# initialize .sbss
24-
la a0, __sbss_start
25-
la a1, __sbss_end
24+
la t0, __sbss_start
25+
la t1, __sbss_end
2626
z_sbss:
27-
sw zero, 0(a0)
28-
addi a0, a0, 4
29-
blt a0, a1, z_sbss
27+
sw zero, 0(t0)
28+
addi t0, t0, 4
29+
blt t0, t1, z_sbss
3030

3131
# initialize Newlib
32-
la a0, _impure_ptr
33-
lw a0, 0(a0)
34-
call __sinit
32+
call __libc_init_array
3533

3634
# restore a0 and a1
3735
mv a0, s0

advanced/freertos/port/start.S

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.section .text
1+
.section .init
22
.globl _start
33

44
_start:
@@ -13,33 +13,31 @@ _start:
1313
mv s1, a1
1414

1515
# initialize .bss
16-
la a0, __bss_start
17-
la a1, __bss_end
16+
la t0, __bss_start
17+
la t1, __bss_end
1818
z_bss:
19-
sw zero, 0(a0)
20-
addi a0, a0, 4
21-
blt a0, a1, z_bss
19+
sw zero, 0(t0)
20+
addi t0, t0, 4
21+
blt t0, t1, z_bss
2222

2323
# initialize .sbss
24-
la a0, __sbss_start
25-
la a1, __sbss_end
24+
la t0, __sbss_start
25+
la t1, __sbss_end
2626
z_sbss:
27-
sw zero, 0(a0)
28-
addi a0, a0, 4
29-
blt a0, a1, z_sbss
27+
sw zero, 0(t0)
28+
addi t0, t0, 4
29+
blt t0, t1, z_sbss
3030

31-
# initialize Newlib -- uncomment these if your FreeRTOS application needs Newlib-nano
32-
# la a0, _impure_ptr
33-
# lw a0, 0(a0)
34-
# call __sinit
31+
# initialize Newlib -- uncomment this if your FreeRTOS application needs Newlib-nano
32+
# call __libc_init_array
3533

3634
# install trap handler for FreeRTOS
3735
#if defined(MTIMER_MMIO) && MTIMER_MMIO == 1
38-
la a0, freertos_risc_v_trap_handler
36+
la t0, freertos_risc_v_trap_handler
3937
#else
40-
la a0, freertos_risc_v_trap_handler_riscvpy
38+
la t0, freertos_risc_v_trap_handler_riscvpy
4139
#endif
42-
csrw mtvec, a0
40+
csrw mtvec, t0
4341

4442
# restore a0 and a1
4543
mv a0, s0

advanced/micropython/port-riscv-emu.py/start.S

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,24 @@ _start:
1313
mv s1, a1
1414

1515
# initialize .bss
16-
la a0, __bss_start
17-
la a1, __bss_end
16+
la t0, __bss_start
17+
la t1, __bss_end
1818
z_bss:
19-
sw zero, 0(a0)
20-
addi a0, a0, 4
21-
blt a0, a1, z_bss
19+
sw zero, 0(t0)
20+
addi t0, t0, 4
21+
blt t0, t1, z_bss
2222

2323
# initialize .sbss
24-
la a0, __sbss_start
25-
la a1, __sbss_end
24+
la t0, __sbss_start
25+
la t1, __sbss_end
2626
z_sbss:
27-
sw zero, 0(a0)
28-
addi a0, a0, 4
29-
blt a0, a1, z_sbss
27+
sw zero, 0(t0)
28+
addi t0, t0, 4
29+
blt t0, t1, z_sbss
3030

3131
#if (MICROPY_PORT_MODE == MODE_REPL_NEWLIB)
3232
# initialize Newlib
33-
la a0, _impure_ptr
34-
lw a0, 0(a0)
35-
call __sinit
33+
call __libc_init_array
3634
#endif
3735

3836
# restore a0 and a1

prebuilt/circuitpython.bin

322 KB
Binary file not shown.

prebuilt/circuitpython.elf

216 Bytes
Binary file not shown.

prebuilt/freertos_app1.elf

256 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)