2017-07-14 04:35 AM
With mbed-os `printf('Hello world');` would print 'Hello world' on ttyACM0
How can I achieve the same this using STMCube32 HAL API's?
Initially printf() was giving me some undefined reference errors in sbrk() system call errors.
I added `-specs=nosys.specs` to linker flags. the compilation was successful.
But cat /dev/ttyACM0 does not show any prints.
How can I get printf working on ttyACM0?
2017-07-28 01:30 AM
I am waiting for a reply.
Can some one please share your thoughts??
Without debug logs, I am finding it difficult to debug my application..
:(
2017-07-28 03:47 AM
With mbed-os `printf('Hello world');` would print 'Hello world' on ttyACM0
How can I achieve the same this using STMCube32 HAL API's?
...
I am waiting for a reply.
Perhaps because hardly anybody using this combination ?
Or is able/willing to share ?
You could try a different approach, like implementing UART output directly.
Or implementing the missing clib stuff to redirect the printf() output.
I don't use an OS on the MCU, so I have no example. But try a search here on this forum or elsewhere.
2017-07-31 06:11 AM
Please, have a look at section 7.2 of
it covers this subject.2017-07-31 01:44 PM
I have a few STM32CubeMX projects that implement a CDC-ACM on the USB_OTG_FS interface on STM32F7xx and STM32F4xx using the HAL driver and USB device stack's CDC virtual serial port. In order to make 'print()' send output to the port, you must write a few functions to direct the output from that function to the USB CDC-ACM.
With 'newlib' or 'newlib nano', there are a few ways to do this. My favorite is to write a function with the name '_write_r()' that, in turn, calls the USB stack. In my experience, you can instead implement your own 'write()' function, and if you're not using an rtos, you should end up with the same result (maybe even with an RTOS). See
https://stackoverflow.com/questions/32031929/implementing-write-write-or-write-r-with-newlib
for more information on what implementing '_write_r()' and friends involves.I don't currently have access to my project, or I'd give more details. It will be a few days before I'm back at my desk and can pull an example up.
2018-01-26 06:05 PM
Hi,
look this examples:
http://www.emcu.eu/how-to-implement-printf-for-send-message-via-usb-on-stm32-nucleo-boards/
2018-01-29 01:30 AM
There's an example on how to do printf over UART in STM32F4 Cube firmware package under 'Projects/STM32446E-Nucleo/Examples/UART/UART_Printf'. Should be simple to adapt it to your board as there's nothing specific to the MCU family.
2018-01-29 03:15 AM
I believe answering to this (old) thread is akin to flogging a dead horse ...
2018-01-29 04:33 AM
Not helped by the forum itself promoting a selection of Dead Horses under 'Related Content' and 'Recommended Content'.
>:(