cancel
Showing results for 
Search instead for 
Did you mean: 

Simple question about board specific example codes

1ntelligentmoron
Associate

Background

I have developed firmware for a LoRaWAN device by modifying the LoRaWAN_End_Node example for the B-WL5M-SUBG1 development board, which was extracted from the STM32Cube MCU Package for STM32WL series (v.1.3.0) from ST's website (not through CubeIDE). Based on this, I have further developed a custom PCB containing the STM32WL5MOC and other peripherals (antennae, RTC, LEDs, buzzers, etc.).

 

Situation

To test the custom board, I have flashed the STM32 chip with a simple firmware which toggles the GPIO pins based on button presses - this works as intended. However, when I flash the LoRaWAN_End_Node example for B-WL5M-SUBG1 (downloaded from STM32CubeIDE v.1.18.1) onto the STM32 chip, the device was able to join the LoRaWAN network once, but failed subsequent joins due to a repeated nonce. After numerous failed attempts at fixing this, I went back to the example code downloaded from CubeIDE, and now my LoRaWAN server cannot even receive a join request.

When looking at the current instruction pointer in debug mode, I have noticed that the programme has entered the error handler from somewhere before the main loop is run.

 

Questions

1. Is there a function in CubeIDE to trace the instruction pointer?
2. Are example codes board specific, i.e. they will not run if I do not use the board it is written for?
3. If the answer to Q2 is yes, then why did the code work once at the very beginning?

I am still new to STM32 development, please keep the answers simple. Thank you!

2 REPLIES 2
asjadkhan
Visitor

Yes, CubeIDE lets you trace via the debugger + call stack. Example codes are often board-specific, so mismatched pin/clock configs can cause crashes on custom PCBs. It worked once likely due to memory/reset state, but you’ll need to adapt the BSP code for your own hardware.

Ozone
Principal

> 1. Is there a function in CubeIDE to trace the instruction pointer?

While I don't use CubeIDE, it is still an Eclipse-based IDE, and you should be able to follow Eclipse debugging tutorials. The functionality you want goes under the name of "instruction stepping" there. In other words, step through machine instructions rather than source code lines.

2. Are example codes board specific, i.e. they will not run if I do not use the board it is written for?

More or less.
Many examples depend on specific peripherals on specific pins, and need a specific peripheral components on those pins.

> However, when I flash the LoRaWAN_End_Node example for B-WL5M-SUBG1 ... onto the STM32 chip, the device was able to join the LoRaWAN network once, but failed subsequent joins due to a repeated nonce

This is, I think, adifferent issue.
Many ST examples are sketchy, and not well tested - to put it mildly.
I use to call it "Kung-Fu software".

> When looking at the current instruction pointer in debug mode, I have noticed that the programme has entered the error handler from somewhere before the main loop is run.

Which seems a good starting point.
You should be able to identify the error handler in the debugger.
Or, if it is the hardfault handler, the actual cause. Just inspect the fault registers in the SCB peripheral.