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


Strange error debugging serial output on custom board

So I have a project created in STM32CubeMX (version 5, if that’s relevant) and I can compile, flash and run the program on the board. All well and good.

If I call printf(“hi”), there’s no output on the serial lines.

So I read up, and printf() is supposed to call _write(int, char*, int) which in turn is coded to call _ _io_putchar(uint8_t). In my case that’s not happening. I can put a breakpoint in _ _io_putchar() and step into (or over) printf() and the breakpoint never gets triggered.

Just to prove the serial hardware was ok (new, custom board, remember) I tried calling __io_putchar(‘*’) a few times, and this *did* send characters down the serial line.

I can’t find any other instances of __io_putchar() being defined in the codebase (I searched recursively in the project directory for all occurrences using ack), so I’m a bit confused.

my __io_putchar (that works If called directly) is in main.c and looks like:

void __io_putchar(uint8_t ch)
{
if ((char)ch == ‘\n’)
HAL_UART_Transmit(&huart6,(uint8_t*)”\r”,1,1);

HAL_UART_Transmit(&huart6,(uint8_t*)&ch,1,1);
}

my _write is in the STM32CubeMX-generated syscalls.c and looks like:


int _write(int file, char *ptr, int len)
{
int DataIdx;

for (DataIdx = 0; DataIdx < len; DataIdx++)
{
__io_putchar(*ptr++);
}
return len;
}

Anyone got any ideas ? Is it somehow dragging the weakly-linked version of __io_putchar in, instead of mine ? Any ideas gratefully received :-)

So, talking to myself here, but just in case anyone else is as clueless about SW4STM32 as I am...

It turns out that the generated ‘syscalls.c’ file, although it appears in the file list, is not automatically compiled until you manually move it from Utilities to a Src/ folder. Once you’ve done that, _write() will be compiled, and will call your __io_putchar() code. Until you do that, _write() is implemented as a nop in libc.

So I now have printf() working fine...


Hello SpecedCowboy,
thanks for the hint. I have syscalls.c in the Src folder from the beginning of the project. Strange why you had it in the Utilities.
I am using semihosting now. According to many helpful internet pages or forums I am sending a few variable values (debug info) to the console in the IDE (using printf()).
It was recommended to click on the syscalls.c (in the tree) and do Exclude from the build. It is possible to inslude it in the Properties of the file in the IDE.
This I write only because it relates with this topic and might help to someone.

vt23