LRWAN3 - Hard Fault on AT+DR command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-10 11:21 AM
Hi everyone,
I have a pnucleo lrwan3 kit and I'm trying to setup the end node using the LRWAN NS1 AT Master example from I-NUCLEO-LRWAN package.
Everything is working fine until the program gets to the AT+DR command. There a Hard Fault occurs and it gets stuck in a forever loop (default handler).
I tried to isolate the problem using the debugger. When the program reaches the switch(DEVICE_STATE) statement, the hard fault occurs. The problem is that I can't get the debugger to enter this switch statement, but it does enter, as various AT commands are being printed after the switch, and before the hard fault.
I tried to get infos on this hard fault, but the analyzer does not provide me any clue. I can only get the SP register value and I have not enough knowledge to get any useful info out of it.
I suspect a problem with the AT+DR command. In fact, the program load and works like a charm using Keil uVision. The hard fault only occurs with STM32CubeIDE. You may think that I played with the configuration of the board, but it is not the case... And that's why I'm desperate.
STM32Cube :
Keil :
I checked and double checked the program on both Keil and STM32Cube, but I can't see a single difference...
Could anyone please give me some help ? Or at least advice ?
Thanks !
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-14 6:28 AM
Found a solution !
Apparently for no reason, it can crashes on the AT+DR command. To solve the issue, you just have to change the Lora_SetDataRate() function as follow :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-11 10:18 AM
For those interested, full project for Nucleo L073RZ can be found here : https://github.com/PCov3r/Nucleo-LRWAN3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-11 11:35 AM
I tend to use a HardFault Handler that outputs actionable data. https://github.com/cturvey/RandomNinjaChef/blob/main/KeilHardFault.c
You look at a disassembly of the specific instruction faulting, and those immediately prior, and you do so in the context of the CPU registers. You can then back-fit that into your C code, and the structures, and variables it's working with. Identify the potential culprits, and then add sanity checking code around them so you know pointers etc have valid/expected values, and if they are wrong due to initialization or corruption.
Make sure to explicitly clear local/auto variables.
Try with different optimization.
Watch for appropriate use of volatile variables.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-14 6:28 AM
Found a solution !
Apparently for no reason, it can crashes on the AT+DR command. To solve the issue, you just have to change the Lora_SetDataRate() function as follow :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-14 3:23 PM
>>Apparently for no reason...
No, for a reason you haven't established.
Looks to be alignment, or access via the pointer modifies something out of scope.
Might see similar errors for sscanf()
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-14 3:42 PM
Yes my mistake. I should have said that as a beginner this is a pretty awkward issue haha.
​
The fact that it worked on keil but not on CubeIDE made it even harder to find. But glad I got it working now
