Categories
IoT Zephyr

Zephyr Weekly Update – Aug. 23, 2024

As there were quite a few large and significant features that landed since the last time I posted, I will use a slightly different approach this week and won’t be going in details through all the new boards, drivers, or SoCs, but will rather spend time on presenting what these new features are and how they can be useful to you.

Manage your Zephyr SDK using West

I can’t believe we’ve lived all this years without such a command, but I am really glad it’s now available! While you typically don’t (re-)install the Zephyr SDK everyday, this is a task which can require quite a bit of work and be error-prone. And this is even more true for Zephyr newcomers, of course.

With the new west sdk command, one can now easily manage the download and installation of the Zephyr SDK. In most cases, it will just work™ and will, for example, automatically look for the latest version of the SDK.

The Zephyr Getting Started Guide should be updated shortly to take advantage of this new cool tool, but in the meantime I really encourage you to basically have a look at the various options documented via west sdk --help so that you keep the tool in mind for next time you need to tinker with your Zephyr SDK!

New performance profiling subsytem

We had two Zephyr Tech Talks in the recent past where we discussed tracing and profiling (check them out!) and the question that was asked first on both occasions was: what’s the performance impact on my application going to be if I enable tracing/profiling?

It is an important question since in most cases you don’t want the performance overhead to be such that it will completely change how your application behaves, for example due to tasks taking longer to do their job and causing changes in the scheduling.

A new profiling subsystem has recently been introduced with a first implementation of a very lightweight profiling mechanism that samples the stack trace at regular intervals.

Once a given configurable period has elapsed, you are able to retrieve the captured raw information, run it through a Python script, and then directly feed it into FlameGraph to get a visual representation of what your application has been busy doing during that time.

This provides you with a quick overview of what’s going on, and allows you to potentially spot unexpected bottlenecks, or a stack getting dangerously close to overflowing.

HTTP Server sample gets some nice improvements

The HTTP server sample has some new interesting features worth checking out, as it now serves new resources that demonstrates something closer to what you may be interested in doing for a real-life scenario.

    More specifically the sample now serves a “home page” that’s much more useful as before, as it exercises HTTP resource handlers that are doing more than the simple “echo” service from before. Namely, there is now:

    • a /led resource that can be POSTed to and will take JSON commands allowing to toggle an LED on or off. This is also a great way to get some concrete example of how JSON can be used in combination with the HTTP server library, as it’s definitely a common serialization format 🙂
    • an improved WebSocket showcase since the web page can now show network traffic statistics in real-time, directly streamed from the Zephyr device to the browser.
    • a new /uptime endpoint that serves the device uptime dynamically.

    Give the code sample a try, I am pretty confident this will give you some inspiration 🙂


    A big thank you to the 23 individuals who had their first pull request accepted since the last post 💙 🙌: @maxdog988, @lucien-nxp, @thenguyenyf, @Stan-Corellium, @Yagoor, @tot0rokr, @Terezvent, @johankraft, @epc-ake, @deGerard, @marek14, @cyberjupiter, @wearyzen, @xiaolusu, @bianik, @zin-HXQ, @haduongquang, @krzysztofgawrys, @KushnerovMikhail, @tunguyen4585, @GrygiriiS, @esoutham-lvt, and @morihisa-momona.

    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:

    Categories
    IoT Zephyr

    Zephyr Weekly Update – Feeling a disturbance in the Force

    We are just a few days away from hitting 100,000 (!) commits on the main Zephyr repository, and things are not really slowing down despite the summer holidays 🙂 Let’s dive right in!

    New Haptics driver class

    It is common for interactive devices to provide haptic feedback to the user. For example, pressing widgets on a touch screen may trigger gentle vibrations while a stronger vibration may indicate that the action was not successful. Well, as of this week, Zephyr supports haptic feedback devices through a new haptics driver class!

    An IC providing haptic feedback functionality is typically hooked up to a tiny motor that will vibrate when a signal is sent to it. The actual vibration pattern can be controlled in several ways: directly feeding the IC with a PWM or analogue signal, using built-in “melodies” available from the chip’s ROM (ex. “strong click”, “short double click”, etc.), etc.

    The new haptics driver class provides a common API for starting/stopping vibrations, and for now most of the actual configuration is done through hardware-specific API. (PR #76343)

    Texas Instruments DRV2605 is the only driver implementing this API for now, but let’s hope we’ll get more in the near future.

    I’ll try to prepare a short demo of this new feature for the next blog post, but you may check out this code sample in the meantime.

    A practical State Machine Framework example

    I have mentioned Zephyr’s State Machine Framework quite a bit in the past, and I am happy to see that more and more subsystems are either transitioning to it, or considering doing so. State machines are something you definitely don’t want to get wrong, and using a proven framework can really help with making your code easier to read, test, and maintain over time.

    We have a new very cool code sample that implements a calculator with a fancy LVGL GUI and whose logic is implemented using the State Machine Framework.

    It is really nice to see how to turn a pretty complex state machine into something that can actually be executed and hooked up to a UI. I hope this will inspire folks to look at SMF whenever they’re just about to get lost in switch/case madness 🙂

    (PR #76465)

    SoCs, Boards & Shields

    Support has been added for the following SoCs:

    • Several SoCs from Analog Devices’ DARWIN MAX326xx Series (MAX32662 , MAX32666, MAX32675). (PR #73578, #73560, #73576)
    • FLPR (Fast Lightweight Processor) RISC-V core on nRF54H20 is now supported. (PR #75451)
    • Wi-Fi driver for the NXP RW612 has been added. (PR #76289)

    New boards and shields:

    • The nRF7002 EK is a versatile evaluation kit in the form of an Arduino shield that can be used in Nordic and non-Nordic host boards. (PR #75714)
    • 01space ESP32C3-0.42-OLED. (PR #74964)
    • STM32F405 Core. (PR #74378)

    Drivers

    • New MBOX driver for ESP32. (PR #76301)
    • New DMA driver for MAX32xxx. (PR #76627)

    Miscellaneous

    • Added support for Wi-Fi Device Provisioning Protocol (DPP) via hostap. DPP is a secure, simplified method for connecting devices to a Wi-Fi network without needing to share the network password directly. (PR #73707)
    • A new reset_stats() API has been introduced to allow resetting Wi-Fi usage statistics. (PR #75768)
    • New sample application demonstrating how to use the CoAP client. (PR #76069)
    • LittleFS module has been updated to 2.9.3. (PR #74001)
    • POSIX
      • Added support for _POSIX_THREAD_PRIO_PROTECT. (PR #74386)
      • Implemented readdir_r. (PR#74394)

    A big thank you to the 16 individuals who had their first pull request accepted this week, 💙 🙌: @alexstanoev-nordic, @nngt88, @pyadvichuk, @duynguyenxa, @juliaazziz, @LeoBRIANDSmile, @aa889788, @yiding, @konrad1s, @unsanded, @thales-nascimento, @pblxptr, @LiLongNXP, @Robibobo1, @asingh-GiN, and @00thirdeye00.

    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:

    Categories
    IoT Zephyr

    Zephyr Weekly Update – Rust coming to Zephyr?

    It has been way too long since I posted a Zephyr Weekly Update, so let’s try to get back to a more regular schedule, shall we? The past few weeks have been very busy for the Zephyr community as the new Long-Term Support version of the project, Zephyr 3.7 was just released.

    It is a big milestone for the project and it brings a lot of new features and improvements which I’ve been covering in details in last week’s announcement blog post. I also had a lot of fun diving into some of the most significant changes and putting together this video that’s packed with in-depth demos of the new HTTP Server, Precision Time Protocol integration, and more.

    As for this week’s news, just keep reading!

    Rust coming to Zephyr?

    The first few weeks after a major release are the perfect time for new significant features to be proposed, and this is exactly what is happening right now with the proposal to add Rust support to Zephyr.

    RFC #65837 describes the bulk of the proposal and there’s now a number of pull requests with actual code and documentation that I highly encourage everyone to give a try.

    #![no_std]
    
    use zephyr::printkln;
    
    extern crate zephyr;
    
    #[no_mangle]
    extern "C" fn rust_main() {
        printkln!("Hello world from Rust on {}",
                  zephyr::kconfig::CONFIG_BOARD);
    }

    I am really excited to see all the work and discussions happening around the topic as this will be my excuse to finally learn Rust!

    Interesting, and related: as of this week, probe-rs is a new supported runner which you can use to flash/debug a supported board. (PR #71627)

    probe-rs is an embedded debugging and target interaction toolkit. It enables its user to program and debug microcontrollers via a debug probe.

    Upcoming Zephyr Tech Talk

    Join me on Wednesday, August 7 (3.oo pm CEST / 9.00 am EDT) for a new Zephyr Tech Talk live stream! Katarzyna Zalewska will be back on the show and we will be discussing some of the best practices for monitoring the health of IoT devices in realtime.

    You may join us from YouTube or LinkedIn, whichever you prefer 🙂

    Boards & SoCs

    Not an exhaustive list, but some of the new boards and shields recently added are:

    • Added support for the Nucleo-H503RB board (PR #75590)
    • Added support for Mikroe BLE TINY Click shield. (PR #76246)
    • Added support for Adafruit Feather nrf52840 Sense. (PR #76135)

    Drivers

    • New driver for ST LSM9DS1 9-DOF IMU. (PR #73141)
    • New RTC driver for Micro Crystal RV-8263-C8 . (PR #73385)
    • New driver for Infineon CAT1 QSPI flash controller. (PR #73976)
    • New True-RNG driver for Analog Device MAX32xxx SoC series. (PR #74943)

    Miscellaneous

    • HTTP server now allows to serve static resources directly from the file system. The content type of the resource is auto-guessed based on the file extension, and .gz files are also automatically treated as compressed content and HTTP headers set accordingly. Neat! (PR #76106)
    • Emulated UART devices can now be added to a zephyr,uart-emul UART controller. (PR #75827)
    • New LwM2M shell command (obs) to dig into active observations. (PR #74293)

    A big thank you to the 23 individuals who had their first pull request accepted since Zephyr 3.7 was released, 💙 🙌: @jacobw, @bas-archembedded, @dberlin, @alexstanoev-nordic, @maarten1C96, @SandraArrow, @Finwood, @juliaazziz, @LeoBRIANDSmile, @Finomnis, @anobli, @gschwaer, @WalkingTalkingPotato, @florolf, @thales-nascimento, @mrodgers-witekio, @VineetaNarkhede-eaton, @GaofengZhangNXP, @munir-zin, @olivier-le-sage, @00thirdeye00, @nordic-pikr, and @jsarha.

    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: