cancel
Showing results for 
Search instead for 
Did you mean: 

LRWAN3 - Hard Fault on AT+DR command

PDevo.1
Associate II

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.

0693W00000GXBx4QAH.png 

0693W00000GXBxEQAX.png 

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 :

0693W00000GXBszQAH.png 

Keil :

0693W00000GXBy2QAH.png 

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 !

1 ACCEPTED SOLUTION

Accepted Solutions
PDevo.1
Associate II

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 :

0693W00000GXVMNQA5.png

View solution in original post

5 REPLIES 5
PDevo.1
Associate II

For those interested, full project for Nucleo L073RZ can be found here : https://github.com/PCov3r/Nucleo-LRWAN3

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
PDevo.1
Associate II

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 :

0693W00000GXVMNQA5.png

>>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()

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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