cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting system from application

mjroeq
Associate

Hello,

I have made a custom STM32F412 board, intended for safety applications within various types of machinery.

I have completed the hardware and I am now working on the software, which I need some help to organize correctly.

Since all applications running on the board are safety related, most of the software is not related to the actual application (type of machinery) being operated.
Rather, the majority of the code is running various monitoring and diagnostics routines to ensure that both hardware and software functions as intended; e.g. timing constraints on code execution, monitoring of RAM and Flash memory, etc.

All of this "system monitoring" is maintained by me, and must be certified independently. It must not be modified, accidentally or intentionally, by the programmers that subsequently write the code for the specific applications running on top of the system monitoring.

For that matter, I would like to statically compile everything, including peripheral configuration, interrupt routines, clock setup, main function, etc. and then subsequently have the application be provided externally as a single function .

My initial thought was to create a "system" project in cubeIDE that contains the entire system setup, main function, startup script, etc., along with the application defined as an empty __weak function, and then compile this project as a static library.

I would then create a secondary "application" project, to include the static system library, while overriding the _weak application method, with the business logic of the actual application being implemented. The "application" project would not be supposed to include any setup, main function, startup script, or anything, since this should all be available from the "system" library.

mjroeq_0-1758112501387.png

 

I have however not been able to get this to work:
- I can compile the static "system" library as wall as the "application" program, seemingly without issues
- I can flash the board, also without issues
- I can get the board to run, and enter the main function, while single stepping through the application
- When I let the program run without single stepping, I get an exception that sends me to the Default_Handler in the startup script

I am not sure if what I am trying to do is a viable approach for getting the separation I need.

Any inputs on getting this to work, or for an alternative approach, would be greatly appreciated.

1 REPLY 1
Saket_Om
ST Employee

Hello @mjroeq 

Could you please inspect the call stack at the moment the default handler is triggered. By examining the call stack, you can identify the last function or instruction executed before the default handler was invoked, which often points directly to the source of the issue. Additionally, it is important to check the interrupt vector table to determine if any handler is missing or misconfigured.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om