Author Topic: STM32: Logging library choices  (Read 9309 times)

0 Members and 1 Guest are viewing this topic.

Offline dkonigsTopic starter

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
STM32: Logging library choices
« on: October 12, 2020, 11:47:24 pm »
So I'm getting started figuring out STM32, and like many developers I appreciate being able to have my code generate log messages out the serial port. I'm also planning to use FreeRTOS for my project, if that helps to provide some background.

Ideally, I'd like to use some sort of well-written logging library for doing this, rather than simply hacking together HAL_UART_Transmit calls (directly or via printf redirection). I'm trying to figure out what options are out there, and I honestly haven't been able to find much.

As far as I know, two choices have come up so far...
  • Take the ESP_LOG code from the ESP32 platform's ESP-IDF, and port it to STM32 (This isn't very hard, and I actually just did a first pass at it.)
  • Take the "iot_logging" code from Amazon's FreeRTOS AWS Reference Integrations project, and hope I can free it from depending on a lot of code in that project I don't particularly care about. (and I'm not thrilled about having "Iot" prefixes all over the place either)

Are there any other good options for this that I'm not considering?

(I actually really like bits of how the ESP32 logging code works, but lifting code from the framework for a totally different MCU feels a little weird.)
 

Offline nuclearcat

  • Supporter
  • ****
  • Posts: 383
  • Country: lb
Re: STM32: Logging library choices
« Reply #1 on: October 12, 2020, 11:50:15 pm »
Consider using SWO instead of uart.
And probably avoid printf, especially %f, STM32 has few nasty bugs related to combination of it with FreeRTOS. Hint - anything that invoke dynamic memory allocation internally might not work well with Cube implementation of FreeRTOS.
« Last Edit: October 13, 2020, 12:49:09 am by nuclearcat »
 
The following users thanked this post: dkonigs

Offline dkonigsTopic starter

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
Re: STM32: Logging library choices
« Reply #2 on: October 13, 2020, 12:58:32 am »
While that doesn't actually answer my question, it did lead me down a rabbit hole on issues relating to FreeRTOS on STM32 that has caused me to add a whole bunch of bookmarks that I'll definitely be reviewing closely as I get farther along in this project :-)

My main question has more to do with finding that front-end library that manages the generation of logging messages from within your code, rather than the back-end function that actually spews the formatted log message out some I/O device (which all of these libraries do generally let you rewrite however you see fit.)
 

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1811
  • Country: us
Re: STM32: Logging library choices
« Reply #3 on: October 13, 2020, 06:33:36 pm »
If you're using a Segger J-Link, an even better option is RTT: https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/
"That's not even wrong" -- Wolfgang Pauli
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: STM32: Logging library choices
« Reply #4 on: October 13, 2020, 06:52:56 pm »
One thing you can do is to put the code that updates the serial data in the idle task of freeRToS.

You free up some software interaction by using dma. I am pretty sure you can use dma from memory to the uart, then the peripheral manages outputing the chars.
 

Offline dkonigsTopic starter

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
Re: STM32: Logging library choices
« Reply #5 on: December 05, 2020, 03:31:04 am »
I'm still surprised there aren't really any obvious answers on this one. I know everyone had helpful suggestions for the best way to emit text out a debug port, but that's not really what I was asking about.

So after seeing how much baggage I'd have to drag along to use the "iot_logging" library, I ended up just porting over the ESP_LOG framework from ESP32's ESP-IDF.  It really wasn't that difficult to do, is fairly self-contained, and gives me pretty much everything I need.  There might be a few places in the guts I'll need to tweak in the future, but this gets the job done.
 

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: STM32: Logging library choices
« Reply #6 on: December 05, 2020, 05:31:15 am »
If you're using a Segger J-Link, an even better option is RTT: https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/

Which is pretty much what I have been using with Mecrisp-Stellaris Forth for a while, but it doesn't need a Segger J-Link as any Stlink device will do.
https://mecrisp-stellaris-folkdoc.sourceforge.io/swdcom.html#swdcom

 
 

Online Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5382
  • Country: nl
Re: STM32: Logging library choices
« Reply #7 on: December 05, 2020, 11:21:03 am »
You can use any library made for logging that formats data in some kind of way useful to you. That library does not have to be STM32 specific.

The only specific part for your STM32 is a function to output that data, and that depends on where you want to log to. UART, SWO, I2C flash chip, uSD card, SPI RF dongle, etc.

If you want a completely pre-baked solution, maybe the "arduino" or the "mbed" frameworks work for you. Those may have logging functions built in.
 

Offline dkonigsTopic starter

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
Re: STM32: Logging library choices
« Reply #8 on: December 05, 2020, 03:25:51 pm »
You can use any library made for logging that formats data in some kind of way useful to you. That library does not have to be STM32 specific.
This is true, but I still don't see you (or anyone else) offering any recommendations whatsoever on libraries they've found useful for this purpose. (And sometimes there are semi-platform-specifics, such as if they hook into the APIs of some RTOS for mutexes.)

The only specific part for your STM32 is a function to output that data, and that depends on where you want to log to. UART, SWO, I2C flash chip, uSD card, SPI RF dongle, etc.
And any decent logging library does let you, as the user, hook in your own function for handling this part.

If you want a completely pre-baked solution, maybe the "arduino" or the "mbed" frameworks work for you. Those may have logging functions built in.
Unless you're actually aware of logging libraries built into, or on top of, these frameworks to point at as examples, that doesn't really help.
« Last Edit: December 05, 2020, 03:28:38 pm by dkonigs »
 

Offline zeke

  • Contributor
  • Posts: 14
Re: STM32: Logging library choices
« Reply #9 on: January 13, 2021, 09:53:36 pm »
Ideally, I'd like to use some sort of well-written logging library for doing this, rather than simply hacking together HAL_UART_Transmit calls (directly or via printf redirection). I'm trying to figure out what options are out there, and I honestly haven't been able to find much.

Are there any other good options for this that I'm not considering?

Yes, here is one more option for you:
https://github.com/armink/EasyLogger


 
The following users thanked this post: Skashkash, dkonigs

Offline dkonigsTopic starter

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
Re: STM32: Logging library choices
« Reply #10 on: January 18, 2021, 07:07:23 am »
Yes, here is one more option for you:
https://github.com/armink/EasyLogger

Thanks!  This is exactly the sort of thing I was actually looking for!

Unfortunately all of the documentation, commit history, issues, etc, are in Chinese. However, the code itself is (thankfully) commented/named in English and seems quite straightforward and easy to understand. I'm definitely going to check it out.
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: STM32: Logging library choices
« Reply #11 on: January 18, 2021, 07:37:12 pm »
Library for debug output? Seriously? How hard is it to dump stuff via UART at 2mbit or whatever?

What does this library do that UART dump + some C#/java/python app doesn't do?
I love the smell of FR4 in the morning!
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: STM32: Logging library choices
« Reply #12 on: January 18, 2021, 07:46:02 pm »
Consider using SWO instead of uart.
And probably avoid printf, especially %f, STM32 has few nasty bugs related to combination of it with FreeRTOS. Hint - anything that invoke dynamic memory allocation internally might not work well with Cube implementation of FreeRTOS.

The only thing needed is to redefine malloc and free to use the FreeRTOS functions. Works like a charm even with creating complex C++ objects with new()
I love the smell of FR4 in the morning!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->