Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


sprintf call causes STM32L4xx to crash

Hello,
I am trying to convert an integer number into a string. I have tried both a locally defined string and a global instance. I have increased my stack size. Interestingly this works correctly when tried on STM32CubeIDE. I am only passing 101 as an int. M am presuming it’s to do with hoc GCC being being called? Ignore RetVal as that was going to be converted into a float like 10.1.

Code excerpt:

float32_t ParamConverter(int32_t Input){

float32_t RetVal = 0;
char Holding5;

sprintf(Holding, “%i”, Input);

return 0;
}

First - use snprintf() instead of sprintf(). While THIS example with THIS specific value (101) will not overflow your 5 byte buffer, it is a good habit to get in to. For example:

sprintf( Holding, sizeof(Holding), “%i”, Input );

Second - can you be more specific about what “crash” means? Does your code end up somewhere you don’t expect, like a fault handler? Note that by default, all fault handlers are simply an empty loop, which usually ends up as a “jump to self” instruction in the startup code just after the call to main(). You may need real code in your fault handlers, or at least a breakpoint so you can inspect the fault registers to see what caused the fault.

Is that code snippet you showed us REALLY the entire function? Or is there more to it?


STM32 crashes when using the sprintf function

1. Software environment: Keil MDK 5.15
2. Hardware environment: STM32F103C8T6 minimum system
Today, when I was programming STM32, I made a strange mistake. The program was blocked in a function. After looking it up for a long time, I found that it was blocked in the sprintf function!!
Serial port printed the first sentence, the card died, the next sentence did not execute to.



The reasons are as follows

__’‘void foo(char *path)
{
...
printu(“enter dir:%s\r\n”, path);
sprintf(path + i, “/%s”, fn);
printu(“enter1 dir:%s\r\n”, path);
...

}

call foo(“0:”);’‘__



The access to the path array is out of bounds! When calling, write as follows:

__’‘char path10 =”0:”;
foo(path);’‘__