candle-usb / candleLight_fw

gs_usb compatible firmware for candleLight, cantact and canable
Other
662 stars 292 forks source link

startup.c is broken - hardfault with large BSS #140

Closed fenugrec closed 2 years ago

fenugrec commented 2 years ago

see description in https://github.com/candle-usb/candleLight_fw/pull/135#issuecomment-1317912852

fenugrec commented 2 years ago

incidentally, looking at disasm for good build, there's already a _start function that initializes BSS (bss_start to bss_end) with memset. Still looking into what part of newlib-nano would handle initialized data - I think we have redundancy in startup.c that we could get rid of.

marckleinebudde commented 2 years ago

I think the problem is the too large data section. See https://github.com/candle-usb/candleLight_fw/pull/141 for a fix.

fenugrec commented 2 years ago

Fixed in 59896b65fdd588fed40cc4d9efec00d21f04ad31 via #141 . We still need to initialized .rodata because newlib will not do that for us (it does clear BSS though)

marckleinebudde commented 2 years ago

.rodata is read only data, right? Does it live in the ROM?

fenugrec commented 2 years ago

.rodata is read only data, right? Does it live in the ROM?

my bad, I meant the initialized RAM stuff, .data

marckleinebudde commented 2 years ago

My patch replaced the 32-bit manual copy loop by a memcpy(), which takes length in bytes. So everything should be fine?

fenugrec commented 2 years ago

So everything should be fine?

Yes. We can't get rid of startup.c , but it should work now.

marckleinebudde commented 2 years ago

FYI: https://github.com/ARM-software/CMSIS_5/issues/632