candle-usb / candleLight_fw

gs_usb compatible firmware for candleLight, cantact and canable
Other
642 stars 283 forks source link

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

Closed fenugrec closed 1 year ago

fenugrec commented 1 year ago

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

fenugrec commented 1 year 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 1 year 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 1 year 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 1 year ago

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

fenugrec commented 1 year ago

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

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

marckleinebudde commented 1 year 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 1 year ago

So everything should be fine?

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

marckleinebudde commented 1 year ago

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