Fix RAM initialisation
The reset handler is responsible for loading the variables default values. This includes variables initialized to 0, although they are handed through bss and not data
This commit is contained in:
parent
4464156981
commit
086f9155f7
@ -64,7 +64,10 @@ SECTIONS
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sbss = .;
|
||||
*(.bss)
|
||||
. = ALIGN(4);
|
||||
_ebss = .;
|
||||
} > RAM
|
||||
|
||||
/* memory space allocated to stack. The stack is situated at the very end of
|
||||
|
||||
24
startup.s
24
startup.s
@ -34,19 +34,35 @@ hdr_reset:
|
||||
ldr r1, = _sdata
|
||||
ldr r2, = _edata
|
||||
subs r2, r2, r1
|
||||
bcc startup_init_end
|
||||
bcc data_init_end
|
||||
ldr r3, = _sromdata
|
||||
|
||||
movs r0, #0
|
||||
|
||||
startup_init_loop:
|
||||
data_init_loop:
|
||||
ldr r4, [r3, r0]
|
||||
str r4, [r1, r0]
|
||||
adds r0, r0, #4
|
||||
cmp r0, r2
|
||||
bcc startup_init_loop
|
||||
bcc data_init_loop
|
||||
|
||||
startup_init_end:
|
||||
data_init_end:
|
||||
//initialize RAM to zero
|
||||
ldr r1, = _sbss
|
||||
ldr r2, = _ebss
|
||||
subs r2, r2, r1
|
||||
bcc bss_init_end
|
||||
movs r3, #0
|
||||
|
||||
movs r0, #0
|
||||
|
||||
bss_init_loop:
|
||||
str r3, [r1, r0]
|
||||
adds r0, r0, #4
|
||||
cmp r0, r2
|
||||
bcc bss_init_loop
|
||||
|
||||
bss_init_end:
|
||||
b main
|
||||
b hdr_reset
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user