Zephyr
Overview
Release Notes
For full details about this release, refer to the Release Notes.
Zephyr
From the Introduction section of the Zephyr Project Documentation:
The Zephyr OS is based on a small-footprint kernel designed for use on resource-constrained and embedded systems: from simple embedded environmental sensors and LED wearables to sophisticated embedded controllers, smart watches, and IoT wireless applications.
Prerequisites
Install Zephyr SDK and its dependencies by following the latest version of Zephyr’s Getting Started Guide.
Inside zephyrproject/zephyr add Variscite's Zephyr repository:
$ git remote add varigit https://github.com/varigit/zephyr $ git fetch varigit v4.0-branch_var01 $ git checkout v4.0-branch_var01
Demos pins
Default pins used by the demos are:
DART-MX93 | ||||
---|---|---|---|---|
Function | SoC balls | SoM pins | DT8MCB pins | Notes |
UART7 RX/TX | M21 / M20 | J2.87 / J2.89 | J12.11 / J12.13 | Zephyr debug console |
GPIO4_IO01 | AA10 | J1.11 | J12.14 | Output of the Blinky/Button demo |
GPIO2_IO27 | W21 | J2.54 | J13.17 | Input of the Button demo |
VAR-SOM-MX93 | ||||
---|---|---|---|---|
Function | SoC balls | SoM pins | Symphony pins | Notes |
UART7 RX/TX | M21 / M20 | J1.175 / J1.124 | J18.5 / J18.3 | Zephyr debug console |
GPIO4_IO28 | U4 | J1.75 | J17.6 | Output of the Blinky/Button demo Pin referenced to 1.8V |
GPIO2_IO27 | W21 | J1.69 | J18.2 | Input of the Button demo |
Available demos
The following demos have been tested and validated for the VAR-SOM-MX93 and DART-MX93:
- samples/hello_world
- samples/basic/blinky
- samples/basic/button
Building a demo
With Zephyr SDK installed, the demos can be built by being inside the Python virtual environment and typing the following command inside the zephyr directory:
$ west build -p -b imx93_var_<dart_or_som>/MIMX9352/<m33_or_a55> <demo_path>
For example, building the hello_world demo for the Cortex-m33 TCM of the VAR-SOM-MX93:
$ west build -p -b imx93_var_dart/MIMX9352/m33 samples/hello_world
The built binaries zephyr.bin and zephyr.elf are inside build/zephyr.
Running Cortex-M demos
Running a Demo using Yocto Scripts
In Yocto Dunfell and newer, Variscite provides scripts to simplify loading firmware via U-Boot or Linux:
Script | Description |
---|---|
/etc/remoteproc/variscite-rproc-u-boot | Configure U-Boot to load firmware on boot |
/etc/remoteproc/variscite-rproc-linux | Load and run firmware using Linux remoteproc framework |
Examples
variscite-rproc-u-boot example on imx8mp-var-dart:
root@imx8mp-var-dart:~# /etc/remoteproc/variscite-rproc-u-boot -f /boot/zephyr.bin Configuring for TCM memory + fw_setenv m7_addr 0x7E0000 + fw_setenv fdt_file imx8mp-var-dart-dt8mcustomboard-m7.dtb + fw_setenv use_m7 yes + fw_setenv m7_bin zephyr.bin Finished: Please reboot, the m7 firmware will run during U-Boot
variscite-rproc-linux example on imx8mp-var-dart:
root@imx8mp-var-dart:~# /etc/remoteproc/variscite-rproc-linux -f /lib/firmware/zephyr.elf [ 212.888118] remoteproc remoteproc0: powering up imx-rproc [ 212.899215] remoteproc remoteproc0: Booting fw image zephyr.elf, size 515836 [ 212.912070] remoteproc remoteproc0: No resource table in elf [ 213.444675] remoteproc remoteproc0: remote processor imx-rproc is now up
Manually running demos
To run manually run Cortex M demos it is necessary to manually load the appropriate device tree file.
To allow the Cortex-M33 to access shared resources without experiencing Linux kernel conflicts, a dedicated device tree must be loaded, by selecting the right version with the symbolic link in the /boot folder of the booting media.
These device trees contain m33 label in their name.
The below table lists dtb blob file names for VAR-SOM-MX93 (on the Symphony Board) and DART-MX93 (on DT8MCustomBoard) with support for the M33:
File Name |
Description |
---|---|
imx93-var-som-symphony-m33.dtb | VAR-SOM-MX93 (Rev 2.x+) device tree blob for Symphony-Board 1.4a and above. |
imx93-var-dart-dt8mcustomboard-m33.dtb | DART-MX93 device tree blob for DT8MCustomBoard 2.0 and above. |
These device trees disable some of the base device tree nodes in order to avoid conflicts between the Cortex-A55 processors and Cortex-M33.
For the full list of device tree blob files, refer to the "Build Results" section in the appropriate wiki page for the specific Yocto/Debian release you are using.
Running a demo from U-Boot
To assist in loading M33 firmware from U-Boot prior to Linux boot, Variscite has created a dedicated set of U-Boot environment commands.
To enable Cortex-M U-Boot auto-loading:
=> setenv use_m33 yes; saveenv
To disable Cortex-M U-Boot auto-loading:
=> setenv use_m33 no; saveenv
Note that the Cortex A55s and M33 have a different memory addressing "view" that is documented in the reference manual. Additionally, the bootaux command for the M33 uses secure aliases from the M33's point of view. Thus, two variables must be set properly in order to set the loading address (defaults used in the example below):
=> setenv m33_addr 0x201E0000 => setenv m33_addr_auxview 0x1FFE0000 => saveenv
To set the name of the Cortex-M binary
=> setenv m33_bin cm_hello_world.bin; saveenv
After enabling as above, the U-Boot boot command will handle loading the Cortex-M firmware when the system begins the boot process. For testing, it is possible to invoke the Cortex-M33 boot process manually:
=> run loadm33bin && run runm33bin
After booting in Linux, the M33 will be listed as in the "attached" state by remoteproc:
# cat /sys/class/remoteproc/remoteproc0/state attached
Running a demo from Linux
The Linux remoteproc framework can be used to load the Cortex-M33 firmware from Linux userspace.
Increase kernel loglevel while debugging:
# sysctl kernel.printk=7;
If the state is 'running', stop the Cortex-M33
# echo stop > /sys/class/remoteproc/remoteproc0/state
Load new firmware
# echo cm_hello_world.elf > /sys/class/remoteproc/remoteproc0/firmware
Run the new firmware
# echo start > /sys/class/remoteproc/remoteproc0/state
Running Cortex-A demos
Running a demo from U-Boot
Transfer built binary zephyr.bin to the boot directory of the SD card or USB drive and plug it into the carrier board.
Power the board up and stop U-Boot execution at prompt.
Load zephyr.bin from the SD card:
=> load mmc $mmcdev:$mmcpart 0xd0000000 /boot/zephyr.bin 36926 bytes read in 5 ms (7 MiB/s) => dcache flush; icache flush; go 0xd0000000 ## Starting application at 0xd0000000 ...
Load zephyr.bin from the USB drive:
=> usb start starting USB... Bus usb@38100000: extcon_ptn5150_phy_mode: phy mode is host ... => load usb 0:1 0xd0000000 zephyr.bin 36926 bytes read in 9 ms (3.9 MiB/s) => dcache flush; icache flush; go 0xd0000000 ## Starting application at 0xd0000000 ...
Debugging a demo
JTAG Hardware
The Cortex-M firmware can be debugged using a JTAG debugger. Variscite recommends using a Segger J-Link Ultra+, J-Link Pro, or J-Link Wi-Fi debugger. You may also need a 9-pin Cortex-M adapter from Segger.
JTAG interface
The JTAG interface is not exposed directly on the VAR-SOM-MX93 / DART-MX93 but the associated signals are exposed via the J1 connector for the VAR-SOM-MX93 and via the J2 connector for the DART-MX93. They are shown in the table below:
Signal | SoC balls | VAR-SOM-MX93 Pins | Symphony Pins | DART-MX93 Pins | DT8MCB Pins | Segger Adapter Pins |
---|---|---|---|---|---|---|
TCLK_SWCLK | Y1 | J1.51 | J18.8 | J2.26 | J12.7 | 9 |
TDI | W1 | J1.53 | J18.6 | J2.24 | J12.5 | 5 |
TDO_TRACESWO | Y2 | J1.52 | J18.4 | J2.20 | J12.1 | 13 |
TMS_SWDIO | W2 | J1.50 | J18.10 | J2.22 | J12.3 | 7 |
Vtref | J3.2 | J13.3 | 1 | |||
GND | J3.20 | J13.4 | 4 |
Please refer to SoM datasheet for further details.