-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiling cdc_msc example for SAMD21G18 works fine using -O0 but hangs using -O1 #303
Comments
Ok, it's a hardfault. But it seems like it is to do with the JLink programming itself; if I power cycle the microcontroller after programming it works fine... |
you should check your vector ISR table, probably put atttribute((used)) in the proper place of isr vector to prevent it is optimized out. |
I can't tell whether this applies, but last time I had a problem like this, it was because I forgot to manually mark some I/O addresses as volatile: #97 (comment) |
This is a bug in the J-Link tools, not in tinyusb. |
Turns out this is not a bug in the segger tools, but rather a dud linker script provided by Atmel/Microchip. The script does not set the entry point of the code correctly, so it defaults to zero in the elf header. It is should be set to the address of
This problem appears to be present in at least the feather_m0_express linker file. The hardfault was because the PC was being set to 0 after reset, which meant that the CPU was trying to decode the vector table as instructions. |
Thanks for the findout, I will check and fix the feather m0 and/or other m0 boards as well. |
I checked, but with and without
The address of Reset_Handler doesn't change at all. Adding this is right thing to do, though I am curious which version gcc/toolchain you are using, and your OS as well. |
using
And with the entry point line it correctly points to the
|
@jeremyherbert ah yeash, you are right, I wasn't doing the correct checking readelf is more precise. Reset_Handler is at 00002fb9
readelf without
readelf WITH addition of
|
thank you for reporting the issue, I have updated the linker for all samd board to include |
I'm trying to port tinyusb to the seeeduino xiao which uses the SAMD21G18A. Since this is the same chip as the feather_m0_express I used it as a template to begin. I've made the following changes:
feather_m0_express.c
toseeeduino_xiao.c
seeeduino_xiao.c
, changing the button and LED pin, as well as deleting the code which configures the clock outputsamd21g18a_flash.ld
to set the ROM base address to 0x00000000, length 0x00040000 (this is because I am debugging with a J-Link and don't care about the bootloader for the time being).If I build the
cdc_msc
example with any optimisation level other than-O0
, the code just hangs. According to my JLink, it's just spinning in theDummy_Handler
function. With-O0
everything works fine.Will try to work out which interrupt is firing.
The text was updated successfully, but these errors were encountered: