Zephyr Blinky sample on Arduino UNO R4 WIFI

· msj's blog


Arduino has announced plans to migrate from Arm Mbed to Zephyr RTOS, with a beta release expected by the end of 2024. This shift signifies a move towards a more powerful and flexible real-time operating system (RTOS) for your Arduino projects. Zephyr, known for its broad hardware support, already offers compatibility with several Arduino boards, including the UNO R4 WIFI (check the full list here). This opens up exciting possibilities for developers familiar with the Arduino ecosystem. Speaking of getting started, I recently dove into the world of Zephyr development and successfully set up the SDK and toolchain for local development. The official Zephyr getting started guide was incredibly helpful in navigating the process. Now, the next step is to leverage this new knowledge and explore the possibilities of Zephyr with an Arduino board like the UNO R4 WIFI.

Let's build the classic "blinky" example on this platform using Zephyr RTOS!

1(.venv)  zephyrproject % west update
2(.venv)  zephyrproject % cd zephyr
3(.venv)  zephyr % west sdk install
4(.venv)  zephyr % pyocd pack install r7fa4m1ab 
50000999 I No pack index present, downloading now... [pack_cmd]
6Downloading packs (press Control-C to cancel):
7    Renesas.RA_DFP.5.6.0
8Downloading descriptors (001/001)

After updating we can build and flash Blinky sample:

 1(.venv)  zephyr % west build -p always -b arduino_uno_r4_wifi samples/basic/blinky
 2-- west build: making build dir ~/zephyrproject/zephyr/build pristine
 3-- west build: generating a build system
 4Loading Zephyr default modules (Zephyr base).
 5-- Application: ~/zephyrproject/zephyr/samples/basic/blinky
 6-- CMake version: 3.30.5
 7-- Found Python3: ~/zephyrproject/.venv/bin/python3.13 (found suitable version "3.13.0", minimum required is "3.10") found components: Interpreter
 8-- Cache files will be written to: ~/Library/Caches/zephyr
 9-- Zephyr version: 3.7.99 (~/zephyrproject/zephyr)
10-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
11-- Board: arduino_uno_r4_wifi, qualifiers: r7fa4m1ab3cfm
12-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
13-- Found host-tools: zephyr 0.17.0 (~/zephyr-sdk-0.17.0)
14-- Found toolchain: zephyr 0.17.0 (~/zephyr-sdk-0.17.0)
15-- Found Dtc: /usr/local/bin/dtc (found suitable version "1.7.1", minimum required is "1.4.6")
16-- Found BOARD.dts: ~/zephyrproject/zephyr/boards/arduino/uno_r4/arduino_uno_r4_wifi.dts
17-- Generated zephyr.dts: ~/zephyrproject/zephyr/build/zephyr/zephyr.dts
18-- Generated pickled edt: ~/zephyrproject/zephyr/build/zephyr/edt.pickle
19-- Generated zephyr.dts: ~/zephyrproject/zephyr/build/zephyr/zephyr.dts
20-- Generated devicetree_generated.h: ~/zephyrproject/zephyr/build/zephyr/include/generated/zephyr/devicetree_generated.h
21-- Including generated dts.cmake file: ~/zephyrproject/zephyr/build/zephyr/dts.cmake
22Parsing ~/zephyrproject/zephyr/Kconfig
23Loaded configuration '~/zephyrproject/zephyr/boards/arduino/uno_r4/arduino_uno_r4_wifi_defconfig'
24Merged configuration '~/zephyrproject/zephyr/samples/basic/blinky/prj.conf'
25Configuration saved to '~/zephyrproject/zephyr/build/zephyr/.config'
26Kconfig header saved to '~/zephyrproject/zephyr/build/zephyr/include/generated/zephyr/autoconf.h'
27-- Found GnuLd: ~/zephyr-sdk-0.17.0/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
28-- The C compiler identification is GNU 12.2.0
29-- The CXX compiler identification is GNU 12.2.0
30-- The ASM compiler identification is GNU
31-- Found assembler: ~/zephyr-sdk-0.17.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
32-- Using ccache: /usr/local/bin/ccache
33-- Configuring done (31.1s)
34-- Generating done (19.5s)
35-- Build files have been written to: ~/zephyrproject/zephyr/build
36-- west build: building application
37[1/116] Preparing syscall dependency handling
38
39[3/116] Generating include/generated/zephyr/version.h
40-- Zephyr version: 3.7.99 (~/zephyrproject/zephyr), build: v3.7.0-5484-g4a8a035bd7b9
41[116/116] Linking C executable zephyr/zephyr.elf
42Memory region         Used Size  Region Size  %age Used
43           FLASH:       13620 B       240 KB      5.54%
44             RAM:        4416 B        32 KB     13.48%
45        IDT_LIST:          0 GB        32 KB      0.00%
46Generating files from ~/zephyrproject/zephyr/build/zephyr/zephyr.elf for board: arduino_uno_r4_wifi
47
48(.venv)  zephyr % west flash                                                      
49-- west flash: rebuilding
50ninja: no work to do.
51-- west flash: using runner pyocd
52-- runners.pyocd: Flashing file: ~/zephyrproject/zephyr/build/zephyr/zephyr.hex
530003876 I Loading ~/zephyrproject/zephyr/build/zephyr/zephyr.hex at 0x00004000 [load_cmd]
54[==================================================] 100%
550008091 I Erased 14336 bytes (7 sectors), programmed 14336 bytes (7 pages), skipped 0 bytes (0 pages) at 3.35 kB/s [loader]

It's alive!

Blinky