Categories
IoT Zephyr

Zephyr Weekly Update – HTTP Server FTW! 🥳

Happy Friday, and welcome back for a new Zephyr Weekly Update! Before diving into some of the additions and notable updates from this week, I wanted to mention that the recordings of all the presentations from the Zephyr Developer Summit 2024 are now available on the YouTube channel of the Zephyr Project.

There were some truly great sessions (and speakers!) and there is a very good chance that you will want to catch up and watch all of them if you didn’t have a chance to attend in person! 😀

HTTP Server

This week’s big update is the addition of a long awaited HTTP server library. It supports HTTP/1.1 as well as HTTP/2, with or without TLS, and WebSocket support should be coming shortly! This has been a multi-month effort that started last year as a Google Summer of Code project from Emna Rekik.

Similar to the socket and CoAP services, adding new HTTP resources can easily be done, with very little overhead, not so differently from how you would do it in a higher-level language like Python or JavaScript!

struct http_resource_detail_static index_html_gz_resource_detail = {
	.common = {
			.type = HTTP_RESOURCE_TYPE_STATIC,
			.bitmask_of_supported_http_methods = BIT(HTTP_GET),
			.content_encoding = "gzip",
		},
	.static_data = index_html_gz,
	.static_data_len = sizeof(index_html_gz),
};

HTTP_RESOURCE_DEFINE(index_html_gz_resource, test_http_service, "/",
		     &index_html_gz_resource_detail);

I highly recommend you dive into the new code sample that will tell you a lot more about the various capabilities of this new service, including how to configure it, or even to profile it.

Power Management for dummies using the Zephyr shell

You’ve heard me praise the Zephyr shell many times before. It is an awesome resource to quickly troubleshoot your system and interact with all your peripherals and subsystems without having to write any code.

A new pm shell module has been introduced to let you interact with the power management subsystem using simple commands. Assuming that power management is indeed enabled in your Zephyr application, you can now do things like pm suspend mydevice to quickly suspend a device.

What’s more, device list, which might be one of the most useful commands in the Zephyr now also gives you feedback regarding the actual PM mode of all the devices in your system:

uart:~$ device list
devices:
- i2c@40003000 (active)
- buttons (active, usage=1)
- leds (READY)

In this example, leds is a device that does not support PM, i2c supports PM with manual suspend and resume actions and is currently active, and buttons supports runtime PM, is currently active and “used” by one user.

As part of introducing all these great commands, Fabio has also added a new callback that a shell module might implement to make tab-completion for device names smarter. In the context of the new pm shell command mentioned before, it means that only devices that do support power management will be suggested when you hit TAB!

Please check out PR #72037 and update your shell modules accordingly 🙂

Boards & SoCs

  • Added MMC driver for RCAR. (PR #60285)
  • Added TPM counter support on i.MX93 Cortex-A Core. (PR #70714)
  • Added RTC driver for Nuvoton Numaker m46x. (PR #71929)
  • Added ADC driver for Nuvoton numaker m2l31x. (PR#71267)
  • Added SDHC driver for ESP32. (PR #71165)

New boards:

  • MikroElektronika Weather Click shield, which features Bosch BME280 sensor (humidity, pressure, temperature). (PR #71076)
  • STM32C0116 DK, a development board for the STM32C0 series of MCUs — Cortex-M0+ with 32K of Flash, 6K of RAM, a Grove connector, a 5-way joystick, … (PR #71722)

Drivers

  • Texas Instruments TMP114 is an ultra-thin, high accuracy, I2C temperature sensor with a 16-bit ADC and an accuracy of ±0.2°C. (PR #71964)

Miscellaneous

  • Added support for LoRaWAN Fragmented Data Block Transport Service. Being able to transmit fragmented blocks of data over an otherwise very constrained network in terms of MTU means essentially unlocking the ability to perform firmware upgrades over-the-air. (PR #68570)
  • New ability for west to run some commands (e.g. erase, recover) only once, either at the beginning or at the end of the programming of a board when using sysbuild. This allows to e.g. only erase the flash once when targeting a multi-core SoC. More documentation available here. (PR #69748)
  • Added support for EUI64 device identifiers in hwinfo. (PR#72057)
  • New code samples for the I2C Target API. (PR #72103)
  • New settings_save_subtree() API allows to only save items from a settings subtree that are different from their persisted value. (PR #72113)

A big thank you to the 9 individuals who had their first pull request accepted this week, 💙 🙌: @swift-tk, @DeHess, @dalprahcd, @0x6e, @fgihl, @bogdanm, @tychofrei02, @JefersonFernando, and @kail.

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 – Device model becoming increasingly flexible

Welcome to this new edition of your weekly…ish Zephyr update. I have been quite busy over the past few weeks, travelling to Embedded World and Zephyr Developer Summit, and it was hard to find time for this weekly blog.

Speaking of in-person events, you have only a few days left to apply to speak at the upcoming Zephyr Developer Summit Europe 2024, held as part of the Open Source Summit 2024 in Vienna, Austria, on September 16-18!

Deferred device initialization

There have been many discussions in the past few months around improving the flexibility of Zephyr device model, in particular around making it possible to defer the initialization of a device. There are many reasons why one may want to decouple the instantiation of a device from its actual initialization, and whether a device should actually be fully initialized is often a decision worth making at runtime (ex. several devices may be sharing common resources, and only one such device may be actually active at a given point in time).

Now that pull request #67335 has been merged, any device may use the zephyr,deferred-init property in Devicetree to indicate they shouldn’t be automatically initialized but, rather, leave this step to the discretion of the programmer by means of the new device_init() API.

Relocation of ARM ELF binaries

In the context of LLEXT (linkable loadable extensions), it is important for Zephyr to be able to process an ELF binary “on the fly” as it needs to relocate the various sections of the file to the proper memory sections. PR #70452 introduced support for all the relocation types for ARM ELF files (i.e. partial and shared linking are now also properlu supported) making it possible to address even more scenarios which, if you think about the new “deferred initialization” mode, may very well include dynamically loading new device drivers in the not so distant future 🙂

Boards & SoCs

As there were a lot of things happening over the past three weeks, this section really focuses on the main highlights — please don’t be mad at me if I forgot something significant (and please comment to help correct the mistake!).

  • Historically, running Zephyr application on Espressif ESP32 devices involved a second-stage bootloader as the initial bootloader was always the ESP-IDF bootloader. A new “simple boot” mode now allows to build applications that don’t require this second-stage bootloading. This makes for optimized memory and size, and is now the default option when building for ESP32, but MCUboot remains a possible alternative. (PR #70505)
  • Renesas SmartBond SoCs now have power management support, and MCU can now enter low-power mode when needed. (PR #61857)
  • Frame-pointer based stack unwinding for RISC-V architecture. (PR #69912)
  • Improved coredump for RISC-V 64 bits: it now includes all the registers. (PR #70949)

There’s quite a few new boards whose support has been added, including:

  • Raspberry Pi 5. (PR #70538)
  • Arduino UNO R4 WiFi. (PR #71041)
  • STM32L152C Discovery kit. (PR #70765)
  • Renesas R-CAR Spider S4 (ARM64). (PR #68141)
  • ESP32-S2 and ESP32-S3 Devkit-C. (PR #66462 and #66463)
  • Phytec phyBOARD-Electra AM64x. (PR #70965)
  • Waveshare ESP32-S3-Touch-LCD-1.28. (PR #67311)

Drivers

  • Added a driver for the output diagnostics of the TLE9104 low-side switch. (PR #67029)
  • New driver for CHSC6X round display controller, found e.g. on the Seeed Studio Round Display for XIAO. (PR #71073)
  • Add support for half-duplex (3-wire) to the SPI controller driver for Raspberry Pi Pico. (PR#69634)
  • New input driver for PAW32XX mouse sensors. (PR #71716)
  • New driver for Analog Devices AD569x series of low-power output DACs. (PR #71338)
  • New loopback disk driver allowing to transparently read/write from/to a file on the filesystem. (PR #69895)
  • New driver for ST7796S LCD display controller. (PR #69991)
  • Added Altera FPGA bridge support. (PR #71360)
  • New I3C driver for Nuvoton NPCX SoCs. (PR #71366)
  • Added Murata NCP15XH103 compensation table to generic thermistor driver. (PR #70912)

Miscellaneous

  • For architecture that have MMU supported (and enabled!), it is now possible to memory map thread stacks, making it possible to create guard pages that can help catching stack overflows/underflows. (PR #70810)
  • A lot of work is going into the Eclipse hawkBit client, to make it more configurable. (see e.g. PR #68806)
  • High-speed support has been improved in the new USB device stack, and it’s now USB 2.0 compliant. (PR #67749)
  • A new I3C shell module has been introduced. (PR #70773)
  • west’s built-in support for generating SPDX SBOM files has been updated to now support SPDX 2.3 (vs. 2.2 before). The main addition is the ability to indicate the PrimaryPackagePurpose for each package. (PR #70581)
  • The Wi-Fi shell module now allows to configure multiple security modes for each network. (PR #71044)
  • The code samples for Bluetooth Heartrate monitor have been updated to support extended advertising and hence be long-range compatible on SoCs that support Bluetooth Low Energy Coded PHY. (PR #70257)

A big thank you to the 31 individuals who had their first pull request accepted since my last post, 💙 🙌: @arnebdr, @ahaslam2, @achech, @Lahyllas, @ulmanyar, @lkoudelka, @franc0is, @nicogou, @lluiscampos, @jan-kubiznak, @petarsusac, @adityaganesh, @erang20, @nordic-bami, @hardeepsharma95, @ke6zfi, @alvsun, @hansbinderup, @rob-the-dude, @orangecms, @selescop, @doeni98, @jomigo96, @nxpadamm, @nlebedenco, @ABESTM, @SaintNicholas, @gkrulce, @nordic-babu, @raintamer, and @DmytroYaskov.

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 – Networking goodness

Happy Friday! Welcome back for another edition of the Zephyr Weekly Update… with two weeks worth of news this time around 🙂

In case you missed it, I highly recommend you catch up the recording of this week’s Zephyr Tech Talk. We discussed the new hardware model introduced for the upcoming Zephyr 3.7 release, the kind of use cases it allows to address, and what you need to do to migrate your existing board definitions. We had well over 200 people attending—a record!

And now, for some of the things that recently landed in the main Zephyr tree…

Use host networking stack in native simulator

The native simulator is getting a lot of love recently, and a noteworthy improvement is the fact that there is now a way to directly use the host’s networking stack, which means it’s now much easier to leverage networking in the simulator, without having to rely on TUN/TAP interfaces and error-prone configuration scripts.

Read more in the documentation of the native simulator. (PR #65116)

“Cooked mode” capture

On the topic of networking, it is now possible to perform so-called “cooked mode capture” of network traffic. In a nutshell, this means that it’s now possible to capture the packets that are being sent and received by the Zephyr networking stack without requiring a physical network interface to be present.

More details on how this works in the documentation, as well as the dedicated net-capture code sample. (PR #70926)

Boards & SoCs

  • Seeed Studio XIAO Expansion Board is a cheap yet very complete expansion shield for boards with the XIAO form factor. It includes an OLED display, a microSD card slot, an RTC, and plenty of Grove connectors. Thanks Charles for adding support for it in(PR #69999!
  • ST B-LCD40-DSI1 is a shield with a 4″ WVGA TFT LCD with MIPI DSI interface and a capacitive touchscreen. (PR #70350)
  • WeAct Studio MiniSTM32H743 Core board features a STM32H743VIT6 (Cortex-M7 @ 480 MHz), 2MB of Flash, and 2x 8MB of external Flash. (PR #69267)
  • M5Stack ATOM Lite is a tiny ESP32-PICO-D4 based devkit with an RGB LED, an infra-red LED, and a Grove connector. The really small form factor makes it one of my favorite targets for quick ESP32 tests. (PR #68190)
  • Several new drivers for some NXP peripherals:
    • ESAI (Enhanced Serial Audio Interface), used for serial communication with e.g. DSPs, S/PDIF transceivers, … (PR #68875)
    • ENET QOS (Ethernet QoS).(PR #70637)
    • hwinfo now available for RW SoCs. (PR #70456)

General drivers

  • STTS22H is an ultralow-power, high-accuracy, digital temperature sensor, with an operating range of -40 °C to +125 °C. (PR #68356)
  • Aosong DHT20 temperature and humidity sensor (sometimes found as Aosong AHT20, or Aosong AM2301B, don’t ask me why). (PR #67279)
  • Angst+Pfister oxygen sensors from the MDLx5 series. (ex. FCX-MLD25 & FCX-MLD95). (PR #68689)
  • onsemi MT9M114 is a 1/6″ 1.26 Megapixel CMOS digital image sensor and the Zephyr driver for it was significantly reworked to improve framerate and support more resolutions. (PR #70237)
  • Cellular modem drivers can now expose IMEI and ICCID info. (PR #69217)
  • New GNSS Driver for U-BLOX M10. (PR #68350)
  • New driver for Sitronix CF1133 touchscreen controller. (PR #68321)
  • New driver for Cirque Pinnacle 1CA027 trackpads. (PR #69438)
  • ST LIS2DUX12 accelerometer (ultralow-power 3-axis smart accelerometer, with anti-aliasing filter) is now supported. (PR #65259)
  • Existing MPU6050 has been reworked to now also support MPU6500. (PR #70130)

Miscellaneous

  • LVGL module has been updated to v8.4.0, and LVGL 9 support is imminent! (PR #70470)
  • A significant overhaul of the Virtual LAN (VLAN) implementation . (PR #70345)
  • CONFIG_NET_SOCKETS_POSIX_NAMES Kconfig option is being deprecated. You can read more about why in the migration guide entry that was created for this change. (PR #69950)
  • ram_report and rom_report West targets now show the address of the objects in the output reports. (PR #69542)
  • RTT Shell backend now detects the presence of a host, preventing deadlocks in situations where the shell would end up continually writing to RTT. (PR #68941)
  • Added support to configure BSSID in Wi-Fi connect command. (PR #70024)
  • mDNS responder used to make it mandatory to have all the records set at compile time. It is now possible to provide the records at runtime. (PR #60271)
  • POSIX:
    • Added support for clock_getres(). (PR #70525)
    • Added support for pthread_rwlockattr_setpshared(). (PR #70421)
    • Added support for pthread_attr_getinheritsched() and pthread_attr_setinheritsched(). (PR #68470)
    • Added support for pthread_setschedprio(). (PR #71001)
    • Added missing implementations for POSIX networking API calls. (PR #70635)

A big thank you to the 24 individuals who had their first pull request accepted in the past couple weeks, 💙 🙌: @mayankmahajan-nxp, @swkim101, @fpistm, @erian747, @zakport, @benni44, @clemdy, @ZhaoxiangJin, @zejiang0jason, @akscram, @RickBruyninckx, @kdunn926, @raffarost, @jatedev, @cliu5764, @glneo, @23131dw, @HesselM, @arikgreen, @ringlej, @bmulder-innoseis, @mdubielx, @ct-fk, and @javanlacerda.

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: