Ok, so this might be a slightly weird one...
I have a very large program that uses a whole lot of RAM. If I don't move some things to RAM2 then RAM1 overflows and the program dies. But, it seems when I use the below lines:
Then any CAN reception causes a hard crash that reboots the Teensy. Removing the DMAMEM portion of these lines fixes the problem.
Here is the output of the crash dump:
What is difficult about this output is that the code execution address is 0x13C22000 which is within FLASH space. Yes, I did in fact also move some code to execute from FLASH if I didn't think it was particularly speed critical. That brings up another question of "how in the heck do I use addr2line when code is executing from flash?!" I tried to remove the leading 1 (0x10000000) so that the data was not within the FLASH address but that of course doesn't exactly work. Are there any tricks to figuring out what code was executing when it was doing so from FLASH memory and not RAM1?
Second part of the question: is it a bad idea to simultaneously use both RAM2 and code execution from FLASH?
And, can I somehow dump the processor registers in the crash dump? IACCVIOL doesn't entirely tell me what happened, it would require that I could query the state of the processor registers at the point of the crash.
I guess the bottom line is that you can run into some really interesting crashes when your program gets large enough that you have to spread things around and somewhat counter to "the way it usually is done" (tm) I'm in uncharted territory (for me) with the Teensy and obviously I can't just attach a J-Link to this and get better info. So, any tips about how to better handle this in the future would be appreciated. For now I can just remove DMAMEM from those lines and be OK but I want to better understand how I messed up and do better.
I have a very large program that uses a whole lot of RAM. If I don't move some things to RAM2 then RAM1 overflows and the program dies. But, it seems when I use the below lines:
Code:
DMAMEM FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> Can0; //Reg CAN or SWCAN depending on mode
DMAMEM FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> Can1; //Isolated CAN
DMAMEM FlexCAN_T4FD<CAN3, RX_SIZE_256, TX_SIZE_16> Can2; //Only CAN-FD capable output
Then any CAN reception causes a hard crash that reboots the Teensy. Removing the DMAMEM portion of these lines fixes the problem.
Here is the output of the crash dump:
Code:
E(0.676038) SYSTEM CRASHED! Analyzing the crash data.
CrashReport:
A problem occurred at (system time) 20:3:38
Code was executing from address 0x13C22000
CFSR: 1
(IACCVIOL) Instruction Access Violation
Temperature inside the chip was 46.36 °C
Startup CPU clock speed is 600MHz
Reboot was caused by auto reboot after fault or bad interrupt detected
What is difficult about this output is that the code execution address is 0x13C22000 which is within FLASH space. Yes, I did in fact also move some code to execute from FLASH if I didn't think it was particularly speed critical. That brings up another question of "how in the heck do I use addr2line when code is executing from flash?!" I tried to remove the leading 1 (0x10000000) so that the data was not within the FLASH address but that of course doesn't exactly work. Are there any tricks to figuring out what code was executing when it was doing so from FLASH memory and not RAM1?
Second part of the question: is it a bad idea to simultaneously use both RAM2 and code execution from FLASH?
And, can I somehow dump the processor registers in the crash dump? IACCVIOL doesn't entirely tell me what happened, it would require that I could query the state of the processor registers at the point of the crash.
I guess the bottom line is that you can run into some really interesting crashes when your program gets large enough that you have to spread things around and somewhat counter to "the way it usually is done" (tm) I'm in uncharted territory (for me) with the Teensy and obviously I can't just attach a J-Link to this and get better info. So, any tips about how to better handle this in the future would be appreciated. For now I can just remove DMAMEM from those lines and be OK but I want to better understand how I messed up and do better.