Categories
IoT Zephyr

Zephyr Weekly Update – C11 threads, Enhanced logging, and more

This has been a very busy week for the community, with an above average amount of new drivers and boards getting merged. Speaking of recently added boards, I am very excited to include one, the super tiny M5Stack AtomS3, in my Zephyr Tech Talk presentation next Wednesday! 🙂

I hope many of you will join, as I will be covering how I ended up migrating my now pretty old, and frankly quite hackish, Artificial Nose project to Zephyr in a matter of hours. I used this opportunity to deep more into some Zephyr features that I hadn’t add a chance to touch before, like Zbus, and I can’t wait to share my experience with y’all.

You should register to make sure you don’t miss the live stream, and of course feel free to also share the event with your network!

Support for C11 threads

The C11 standard introduced a native multi-threading API that aims at establishing a portable API for all things threads.

POSIX is of course a very popular programming model for manipulating threads, but being part of the language itself, the API introduced in the 2011 version of the C standard is effectively (or should be at least!) supported on *any* platform that supports the C11 standard.

#include <stdio.h>
#include <threads.h>

// Thread function
int printHelloWorld(void *arg) {
    printf("Hello, World!\n");
    return 0;
}

int main() {
    thrd_t thread;

    // Create a new thread
    if (thrd_create(&thread, printHelloWorld, NULL) != thrd_success) {
        fprintf(stderr, "Error creating thread\n");
        return 1;
    }

    // Wait for the created thread to terminate
    thrd_join(thread, NULL);

    return 0;
}

Chris Friedt has been working on bringing C11 threads support to Zephyr and this materialized this week with PR #60759 being merged. Quite interestingly, since Zephyr already exposes a POSIX API, most of the threads.h APIs end up mapping mostly 1-to-1 to POSIX functions.

Logging to multiple UARTs

A new zephyr,log-uart chosen node can be used to indicate that log outputs may be sent to multiple UARTs.

Until now, the UART log backend would have been only logging to the zephyr,console chosen node, but with PR #64917 it’s now possible to have the following kind of node in your Devicetree to indicate the various UARTs where you’d like logs to show up:

/ {
	chosen {
		zephyr,log-uart = &log_uarts;
	};

	log_uarts: log_uarts {
		compatible = "zephyr,log-uart";
		uarts = <&uart0 &uart1>;
	};

    ...
};

New keyboard matrix GPIO driver

A new type of driver has been introduced to allow modeling a keyboard matrix out of any set of GPIOs. The gpio-kbd-matrix binding allows you to define your keyboard matrix configuration such as:

  kbd-matrix {
          compatible = "gpio-kbd-matrix";
          row-gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
                      <&gpio0 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
          col-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>,
                      <&gpio0 3 GPIO_ACTIVE_LOW>,
                      <&gpio0 4 GPIO_ACTIVE_LOW>;
          no-ghostkey-check;
  };

More details in PR #65117.

Boards & SoCs

  • The nRF9131 Evaluation Kit from Nordic is a single-board evaluation kit for the nRF9131 SiP for LTE-M and NB-IoT.
nRF9131 EK (Credit: Nordic Semiconductor)
  • The M5Stack AtomS3 is a *very* tiny ESP32-S3 based developer kit that manages to fit a small 0.85″ LCD display on what is effectively a 1×1″ (24×24mm) piece of electronics!
    Since it also has an on-board accelerometer, it can run the LVGL Accelerometer Chart code sample out-of-the-box!
LVGL Accelerometer Chart code sample running on the M5Stack AtomS3 board.
  • The Renesas Starter Kit+ for RZ/T2M is an evaluation and development kit for the RZ/T2M MPU. (PR #64566)
  • Support has been added for the Verdin iMX8M Plus Computer on Module (CoM) from Toradex. (PR #61713)
  • UP Squared Pro 7000 is now supported. It is the 3rd generation of palm-sized developer board of UP Boards series and it is powered by an Intel Alder Lake N (Intel N-series Platform) SoC. (PR #65019)
  • Support has been added for the STM32H7B0 SoC series. (PR #65092)

Drivers

  • New driver for the Linear Technologies LTC2451 ADC, an ultra-tiny 16-bit ADC. (PR #64390)
  • New driver for Renesas HS3001 and HS3003 temperature/humidity sensors (PR #63016)
  • A charger driver has been added to the already existing regulator driver for the MAX20335 multi-function device. (PR #64971)
  • The LPS22DF altimeter / pressure sensor is now supported. It is an ultracompact, piezoresistive, absolute pressure sensor that can be used as a digital output barometer, with an output data rate up to 200 Hz (PR #62028)
  • The NXP LPC DMA driver now supports hardware triggering. (PR #64573)
  • New driver for NXP FlexRAM memory controller. FlexRAM is a highly configurable and flexible RAM memory array, found on e.g. RT10XX and RT11XX series. (PR #62788)
  • New modem driver for Quectel EG25-G. (PR #64746)
  • New driver for ExplorIR-M CO2 sensor. A new co2_polling code samples was also introduced to make it easy to try things out with this driver (or any other CO2 driver really!). (PR #64621)
  • A new CAN shell command (can timing) adds support for setting raw timing values. (PR #65054)

Miscellaneous

  • The inter-core messaging (ICMsg) backend now supports the transfer of dynamically allocated buffers. (PR #58741)
  • Added API to BLE Audio CAP to set codec capabilities. (PR #63223)
  • Zephyr native simulator is now the recommended target for running Zephyr in your desktop/POSIX environment, and the documentation has been updated to reflect that.
  • The UART Shell backend has been reworked to support the asynchronous UART API. (PR #63967)
  • A new set of shell commands (cred ...) allow to interactively set TLS network credentials. See the list of commands here. (PR #64343)
  • MCUmgr OS management group now has functions for getting/setting the current time to/from the rtc alias device. (PR #64934)
  • The Bluetooth “broadcast audio source” code sample now supports using e.g. your host computer as the audio source.
    Granted that you are running the sample on a device that has a USB Device stack and Audio support, enabling CONFIG_USE_USB_AUDIO_INPUT will make your device show up as a sound device when plugged to your computer, and any audio that you will send to this “virtual speaker”, will be broadcast over LE Audio! 🔊

A big thank you to the 11 individuals who had their first pull request accepted this week, 💙 🙌: @TimTTP, @GabrielHAFs, @LipinskiPNordicSemi, @michael-whg, @josuah, @CkovMk, @CharlesDias, @ndaneil, @xvigo, @KamilxPaszkiet, and @mpenate-ellenbytech.

As always, I very much welcome your thoughts and feedback in the comments below!

If you enjoyed this article, don’t forget to subscribe to this blog to be notified of upcoming publications! And of course, you can also always find me on Twitter and Mastodon.

Catch up on all previous issues of the Zephyr Weekly Update:

By Benjamin Cabé

Benjamin Cabé is a technology enthusiast with a passion for empowering developers to build innovative solutions. He has invented an award-winning open source and open hardware artificial nose that he likes to use as an educational platform for people interested in diving into the world of embedded development.
He is currently a Developer Advocate for the Zephyr Project at the Linux Foundation and lives near Toulouse, France, where he enjoys baking sourdough bread with the help of his artificial nose.

One reply on “Zephyr Weekly Update – C11 threads, Enhanced logging, and more”

Leave a Reply

Your email address will not be published. Required fields are marked *