Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


sprintf stops execution

Hi all

I have a problem with the sprintf function in a stm32f4 discovery board.
i use win 10 32bit and the ac6 version is 1.14.1.201707031232

The code has
char s200;
int i;

i=0;
sprint((s,”some text : %d”, i);

In debug and normal execution the program stops in sprintf for ever.
If the sprintf function dont has any of the % parameters the function is executed normally.

Thank all in advance.

Are you using the 200 bytes char inside a function!? The local variables of the functions are being allocated on the stack, so maybe your stack size isn’t big enough to hold that much data. You can increase your stack size by editing the linker script, but anyway it isn’t a great idea to use 200 bytes buffer on the stack. Just use a global variable.

Thank you bugmenot

To test it I made a new project with only these lines

  1. include “stm32f4xx.h”
  2. include “stm32f4_discovery.h”


char s200;
int i;

int main(void)
{

i=0;
sprintf(s,”Text :”);

sprintf(s,”Text :%d”,i);

sprintf(s,”Text :”);

for(;;);
}

the first sprintf is executed but the second stops forever.
In the bigger project in which i face the problem the s and i was into the function body and i have change the linker script with heap and stack in 0x2000 but nothing.

Well, that is strange. What do you mean “stops forever”? The execution just never comes back from the function? I would try to use the debugger and pause the execution when it’s stuck, so I could find out where (which code line / instruction) and why and it got stuck.

I check it with the debugger
Pressing F6 the program pass the first sprintf but never goes out from the second sprintf


1 - You have to Include the stdio.h , gcc will provide fake function read about “warning: implicit declaration of function”.
2 - Make sure the optimzation is turned off and max for debugging
3 - The code you write does not compile, so please provide the code as in IDE

best reagds,
Mazen

Thank you mazensaad

the code in ide is as below

  1. include
  2. include “stm32f4xx.h”
  3. include “stm32f4_discovery.h”


char s 200 ;
int i;

int main(void)
{
i=0;
sprintf(s,”Text :”);
sprintf(s,”Text :%d”,i);
sprintf(s,”Text :”);
for(;;);
}

but when i press the post button i the char s loses his brackets,
anyway this section was a part of a bigger project and the printout was in a LCD display.
So when i put the sprintf function the program stops only when the sprintf has parameters.
I make a new project only with this code and i have the same results.
Going step by step with the debugger the execution stop in the second sprintf.
Do i must change the _write routine in syscalls.c ? But this is not a printf to make a redirection.

Thank you for your time and best regards
Akis


 

Newest Forum Posts

  1. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  2. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  10. Build a project in "release" mode by tang, 2025-02-20 10:36

Last-Modified Blogs