Skip to main content
Blog

Zephyr Weekly Update – New CoAP service

By November 10, 2023No Comments

Hi everyone! In case you missed it, the Eclipse Foundation just released the results of their 2023 IoT Developer Survey. It is always a challenge to understand the trends in adoption of open source software as there is no obligation on the adopters’ side to tell when and where they are using open source projects 🙂

This survey is very helpful in shedding some light on the technology stacks people are using in their IoT solutions, and it’s nice to see Zephyr is on their radar.

Developer Embedded OS Preferences on Constrained Devices

Linux (43%), and FreeRTOS
(25%) are the top embedded
OS choices for constrained
devices. A solid 17% of
developers prefer no OS at all,
while Zephyr enjoys a
respectable 13%, compared to
only 8% in 2022.

In other news, here are some of the things that have kept the Zephyr community busy this week!

CoAP “servlets”

When building an IoT device, one typically wants to spend time writing their actual application logic, not reinventing the wheel regarding how they should implement the “Internet” aspect of their “Thing”

A merged pull request from this week, PR #64265, is introducing a CoAP server API that allows to easily register CoAP resources against a CoAP “service”, effectively getting rid of most of the boilerplate one would have to come up with if building on lower layer APIs.

In a nutshell, and in a slightly simplified way, a minimal CoAP server + /hello resource would not require much more code than:

COAP_SERVICE_DEFINE(coap_server, 
			"0.0.0.0",
			&coap_port, 
			COAP_SERVICE_AUTOSTART);

static int my_get(struct coap_resource *resource, struct coap_packet *request,
                  struct sockaddr *addr, socklen_t addr_len)
{
    static const char *msg = "Hello, world!";
    uint8_t data[CONFIG_COAP_SERVER_MESSAGE_SIZE];
    struct coap_packet response;
    
    /** ... **/
    
    coap_packet_append_payload(&response, (uint8_t *)msg, sizeof(msg));

    return coap_resource_send(resource, &response, addr, addr_len);
}


static const char * const my_resource_path[] = { "hello", NULL };
COAP_RESOURCE_DEFINE(my_resource, coap_server, {
    .path = my_resource_path,
    .get = my_get
});

The CoAP service can then be started/stopped using coap_service_start()/coap_service_stop() (in the example above it’s set to start automatically) or using shell commands, and things like the magic ./well-known/core endpoint, retransmissions, etc. are automatically taken care of by the service.

I love it when Zephyr gets new features like this. This new service feels very much like what you would expect to find in a full-blown operating system, and yet we’re still talking about super constrained devices here.

You should definitely check out the code sample to get more familiar with this new API.

Boards & SoCs

  • Arm Cortex-A and Cortex-R now support SMP! It is worth noting that FPU_SHARING and USERSPACE are not supported yet. (PR #61206)
  • It is now possible to have a custom interrupt control interface implementation on Cortex-M, using the CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER option.
    While all Cortex-M platforms have an NVIC controller,custom SoCs may have additional IRQ controllers, or require custom handling. This option allows to indicate that these SoCs are using custom interrupt control interface implementation
  • The Firefly ROC-RK3568 mini computer is an ARM64 board with a quad-core Cortex-A55 @ 2GHz, 4GB of LPDDR, 32GB of eMMC, M.2 PCI Express slots, dual Gigabit Ethernet ports, and more. It is now supported in Zephyr! (PR #64217)
Lolin S2 Mini dev kit
  • Support has been added for the Lolin S2 Mini (also known as Wemos S2 Mini …and I am realizing as I am typing this that I have one sitting on my desk, and one connected to my electricity meter monitoring the consumption of my house! Guess I need to do some hacking and porting soon!). This small devkit features an ESP32-S2 with 4MB of Flash, 2MB of PSRAM, and can be used with a variety of shields.
  • On STM32, the ADC driver now supports power management. A code sample has been added to demonstrate the improvements (spoiler alert: consumption can be almost 20x less now). (PR #64191)
  • Clock control driver is now available for Ambiq SoCs. (PR #63097)
  • Added support for NXP Multirate Timer peripheral. (PR #64801)

Drivers

  • A new Wi-Fi driver is available for the Infineon AIROC, as found in CYW4343W, CYW4373, CYW43012, CYW43012, CYW43439. It is pretty exciting since among other things, it means we should soon see Wi-Fi support added to the Rasperry Pi Pico W. (PR #63721)
  • The aforementioned Wi-Fi module supports both SPI and SDIO interfaces, and it’s the latter that’s used by the driver for now.
    SDIO is an extension of the SD specification covering I/O functions, and it turns out support for it was also just added to Zephyr. (PR #56869)
  • The Analog AD5592 is a versatile multifunction IC that has 8 I/O pins that can be independently configured to act as DAC output, ADC inputs, or regular GPIOs.
    A new “multi-function” driver is now available to leverage all these different options easily from the Devicetree. (PR #64592)
  • New Ethernet driver for Microchip LAN8651. (PR #63614)
  • New driver for the TSL2561 light sensor. (PR #56869)

Miscellaneous

  • A new spinlock mechanism, ticket spinlocks, has been introduced. It is meant to help in situations where traditional locking would be “unfair” across multiple CPUs due to how the implementation only relies on a single atomic variable. Ticket spinlocks provide true FIFO ordering at the cost of slightly increased memory footprint. (PR #61541)
  • Some awesome work to implement the official LwM2M interoperability tests, in particular the ones related to bootstrapping, registration, device management and service enablement interface, and information reporting interface. I highly encourage you to have a look as this is also a great way to get up to speed with using Pytest for Zephyr testing 🙂 (PR #64013)

    I wonder if the Open Mobile Alliance still organizes PlugFests, but I would live to see Zephyr participate in the future.

  • CMSIS version has been updated to 5.9.0 in the Zephyr manifest. (PR #64851)
  • API for Bluetooth CAP Commander has been introduced. (PR #64645)

A big thank you to the 7 individuals who had their first pull request accepted this week, 💙 🙌: @cocoeoli, @mgolu, @topisani, @samueltardieu, @p9n, @BenjaminDeuter, and @raffi-g.

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