Skip to main content
Associate
Question

How do you test STM32 firmware logic on your PC before flashing the board?

Most of my STM32 work so far has been tested by flashing the board and debugging on the hardware, which works but feels slow when the bug is really in the application logic rather than in the peripheral setup.

 

I am curious how other people approach this. Do you structure your code so the core logic can be built and run on a PC, and if so, how do you handle the HAL calls and peripheral access? Do you use a unit test framework, simple test programs, or something else entirely?

 

I would also like to know what you do not bother testing this way, and where you draw the line between logic that is worth testing on the PC and code that only makes sense to test on the board. Any practical examples of how you organise the project in CubeIDE would be helpful.

1 reply

Andrew Neil
Super User

Nothing specifically to do with STM32 here - just standard test-harness stuff, mocking, etc.

 

Also take a look at:

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.