MISC-AN-002: Creating a root file system using Buildroot for AURA SOM

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box


History
Date Version
2024/09/04 buildroot 2024.08


Introduction[edit | edit source]

By default, AURA comes with a DESK-MX9-L Yocto distribution. Nevertheless, other distributions can be used as well. This application note shows how to run one of them, Buildroot.

Buildroot is known to be very simple to configure and build. An exhaustive discussion of Buildroot is beyond the scope of this application note. The interested reader can refer for example to this presentation which compares in detail Yocto and Buildroot.

The test bed used for this application note is composed of the same hardware/software platform delivered along with the DESK-MX9-L. About Buildroot, the version buildroot-2024.08 was used.

Virtual Machine requirements[edit | edit source]

The building process may require higher resources than the original DESK-MX9-L MVM settings: this depends on the package selected in the .config file and their build resources.

MVM with 4 CPU cores and 16GB of RAM

Downloading, configuring and building[edit | edit source]

This process is straightforward. Once the file buildroot-2024.08.tar.gz is downloaded and decompressed on your Linux host machine, get into the Buildroot directory, and run make menuconfig.

Buildroot make menuconfig

Then enter the Target options menu and select:

  • AArch64 (little endian) for Target Architecture
  • cortex-A55 for Target Architecture Variant

as shown in the following picture.

Buildroot make menuconfig


Another important configuration is the Freescale i.MX Libraries settings (Target packages → Hardware handling → Freescale i.MX libraries) for i.MX93 processor and its imx-tools (imx-codec, imx-kobs, firmware)

i.MX libraries


That's it: after saving your configuration, and exiting menuconfig, you can start the build process by simply issuing the make command.

For your sake of convenience, the created .config file can be downloaded from here (rename it as .config).

Linux kernel[edit | edit source]

The latest Linux kernel version provided in the DAVE' git repositories can be used for building the kernel image too.

The kernel tarball can be copied into the proper Buildroot directory:

Linux kernel tarball

Also the related device tree will be built and both artifacts installed into /boot root file system directory

Package list[edit | edit source]

The root file system package composition has been created for a list of packages commonly used for creating a root file system good for all seasons.

Here below a list of most important selected packages:

  • Qt6.7 libraries including: DBus, core5compat, serialport, mqtt, opcua, websockets
  • framebuffer utilities like: fbset, fbgrab and the fb-test application
  • python3 interpreter including python3-ssl, python-flask, python-fastapi, python-jinja2, python-pip, python-canopen, python-pymodbus, python-serial, python-schedule, python-scapy, python-setuptools
  • web server: thttpd
  • database: sqlite3
  • network applications: avahi, iw, ntp, openssh, wget
  • Javascript: angularjs, bootstrap
  • package managers: opkg, rpm

Moreover, the weston desktop has been integrated into the build.

Build the targets[edit | edit source]

It is enough to run the make command and buildroot will start building the toolchain and then cross-compiling the overall selected packages.

Once the build process has been completed, the output/images directory will contain the binary artifact:

dvdk@vagrant:~/buildroot/buildroot-2024.08$ ls -la output/images/
total 452276
drwxr-xr-x 2 dvdk dvdk      4096 Sep  3 14:20 .
drwxrwxr-x 6 dvdk dvdk      4096 Sep  3 14:20 ..
lrwxrwxrwx 1 dvdk dvdk        70 Sep  3 13:27 ddr_fw.bin -> /home/dvdk/buildroot/buildroot-2024.08/output/images/lpddr4_fw.bin                                                           
-rw-r--r-- 1 dvdk dvdk  33266176 Sep  3 14:19 Image                                                                                                                                          
-rwxr-xr-x 1 dvdk dvdk     45551 Sep  3 14:19 imx93-aura-som0002-cb2001.dtb                                                                                                                  
-rw-r--r-- 1 dvdk dvdk     49152 Sep  3 13:27 lpddr4_1d_fw.bin                                                                                                                               
-rw-r--r-- 1 dvdk dvdk     49152 Sep  3 13:27 lpddr4_2d_fw.bin                                                                                                                               
-rw-r--r-- 1 dvdk dvdk      1660 Sep  3 13:27 lpddr4_dmem_1d_v202201.bin
-rw-r--r-- 1 dvdk dvdk     16384 Sep  3 13:27 lpddr4_dmem_1d_v202201_pad.bin
-rw-r--r-- 1 dvdk dvdk      1408 Sep  3 13:27 lpddr4_dmem_2d_v202201.bin
-rw-r--r-- 1 dvdk dvdk     16384 Sep  3 13:27 lpddr4_dmem_2d_v202201_pad.bin
-rw-r--r-- 1 dvdk dvdk      1112 Sep  3 13:27 lpddr4_dmem_qb_v202201.bin
-rw-r--r-- 1 dvdk dvdk     98304 Sep  3 13:27 lpddr4_fw.bin
-rw-r--r-- 1 dvdk dvdk     32428 Sep  3 13:27 lpddr4_imem_1d_v202201.bin
-rw-r--r-- 1 dvdk dvdk     32768 Sep  3 13:27 lpddr4_imem_1d_v202201_pad.bin
-rw-r--r-- 1 dvdk dvdk     25668 Sep  3 13:27 lpddr4_imem_2d_v202201.bin
-rw-r--r-- 1 dvdk dvdk     32768 Sep  3 13:27 lpddr4_imem_2d_v202201_pad.bin
-rw-r--r-- 1 dvdk dvdk      9616 Sep  3 13:27 lpddr4_imem_qb_v202201.bin
-rw-r--r-- 1 dvdk dvdk      1668 Sep  3 13:27 lpddr4_pmu_train_1d_dmem_201904.bin
-rw-r--r-- 1 dvdk dvdk      1660 Sep  3 13:27 lpddr4_pmu_train_1d_dmem_202006.bin
-rw-r--r-- 1 dvdk dvdk      1668 Sep  3 13:27 lpddr4_pmu_train_1d_dmem.bin
-rw-r--r-- 1 dvdk dvdk     32632 Sep  3 13:27 lpddr4_pmu_train_1d_imem_201904.bin
-rw-r--r-- 1 dvdk dvdk     32364 Sep  3 13:27 lpddr4_pmu_train_1d_imem_202006.bin
-rw-r--r-- 1 dvdk dvdk     32244 Sep  3 13:27 lpddr4_pmu_train_1d_imem.bin
-rw-r--r-- 1 dvdk dvdk      1400 Sep  3 13:27 lpddr4_pmu_train_2d_dmem_201904.bin
-rw-r--r-- 1 dvdk dvdk      1404 Sep  3 13:27 lpddr4_pmu_train_2d_dmem_202006.bin
-rw-r--r-- 1 dvdk dvdk      1380 Sep  3 13:27 lpddr4_pmu_train_2d_dmem.bin
-rw-r--r-- 1 dvdk dvdk     24308 Sep  3 13:27 lpddr4_pmu_train_2d_imem_201904.bin
-rw-r--r-- 1 dvdk dvdk     25456 Sep  3 13:27 lpddr4_pmu_train_2d_imem_202006.bin
-rw-r--r-- 1 dvdk dvdk     23232 Sep  3 13:27 lpddr4_pmu_train_2d_imem.bin
-rw-r--r-- 1 dvdk dvdk     65536 Sep  3 13:27 lpddr4x_dmem_qb_v202306.bin
-rwxr-xr-x 1 dvdk dvdk     65536 Sep  3 13:27 lpddr4x_dmem_qb_v202311.bin
-rw-r--r-- 1 dvdk dvdk     65536 Sep  3 13:27 lpddr4x_dmem_v202306.bin
-rwxr-xr-x 1 dvdk dvdk     65536 Sep  3 13:27 lpddr4x_dmem_v202311.bin
-rw-r--r-- 1 dvdk dvdk     24980 Sep  3 13:27 lpddr4x_imem_qb_v202306.bin
-rwxr-xr-x 1 dvdk dvdk     25140 Sep  3 13:27 lpddr4x_imem_qb_v202311.bin
-rw-r--r-- 1 dvdk dvdk     51436 Sep  3 13:27 lpddr4x_imem_v202306.bin
-rwxr-xr-x 1 dvdk dvdk     51672 Sep  3 13:27 lpddr4x_imem_v202311.bin
-rw-r--r-- 1 dvdk dvdk 327987200 Sep  3 14:20 rootfs.tar
-rw-r--r-- 1 dvdk dvdk 101016261 Sep  3 14:20 rootfs.tar.bz2

dvdk@vagrant:~/buildroot/buildroot-2024.08$ 

If the SDK is required for building the application in the building environment, it is possible to generate the SDK using:

make sdk

and this will produce:

dvdk@vagrant:~/buildroot/buildroot-2024.08$ ls -la output/images/aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz 
-rw-r--r-- 1 dvdk dvdk 585587841 Sep  4 12:50 output/images/aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz
dvdk@vagrant:~/buildroot/buildroot-2024.08$ 

Adding further packages[edit | edit source]

In real world applications, additional packages are usually added by selecting them under the Target packages item of the configuration menu. Just look at the packages directory to see which ones are available out of the box. To add further packages, please refer to this link.

Buildroot file system on the target[edit | edit source]

The created root file system can be extracted in a Virtual Machine local directory that can be used for starting the rfs via nfs:

dvdk@vagrant:~/buildroot$ mkdir rfs && cd rfs
dvdk@vagrant:~/buildroot/rfs$ sudo tar jxpf ../buildroot-2024.08/output/images/rootfs.tar.bz2
dvdk@vagrant:~/buildroot/rfs$ 

Starting the root file system in the target will welcome you with the classic prompt:

...
...
[    6.499668] Freeing unused kernel memory: 3392K
[    6.518948] Run /sbin/init as init process
[    6.944560] systemd[1]: System time before build time, advancing clock.
[    7.115132] systemd[1]: systemd 256.4 running in system mode (-PAM -AUDIT -SELINUX -APPARMOR -IMA -SMACK -SECCOMP -GCRYPT -GNUTLS +OPENSSL -ACL +BLKID -CURL -ELFUTILS -FIDO2 -IDN2 -IDN -IPTC +KMOD -LIBCRYPTSETUP -LIBCRYPTSETUP_PLUGINS -LIBFDISK +PCRE2 -PWQUALITY -P11KIT -QRENCODE -TPM2 +BZIP2 -LZ4 -XZ +ZLIB -ZSTD -BPF_FRAMEWORK +XKBCOMMON -UTMP -SYSVINIT +LIBARCHIVE)
[    7.147712] systemd[1]: Detected architecture arm64.

Welcome to Buildroot 2024.08!

[    7.197355] systemd[1]: Hostname set to <buildroot>.
[    7.227691] systemd[1]: Initializing machine ID from random generator.
[    8.668382] systemd[1]: Queued start job for default target Multi-User System.
[    8.702499] systemd[1]: Created slice Slice /system/modprobe.
[  OK  ] Created slice Slice /system/modprobe.
[    8.724354] systemd[1]: Created slice Slice /system/serial-getty.
[  OK  ] Created slice Slice /system/serial-getty.
[    8.747320] systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Started Dispatch Password Requests to Console Directory Watch.
[    8.775299] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Started Forward Password Requests to Wall Directory Watch.
[    8.799107] systemd[1]: Expecting device /dev/ttyLP0...
         Expecting device /dev/ttyLP0...
...
...
...
[  OK  ] Started Serial Getty on ttyLP0.
[  OK  ] Reached target Login Prompts.
[  OK  ] Started Tiny HTTP Daemon.
[  OK  ] Finished Save/Restore Sound Card State.
[  OK  ] Started D-Bus System Message Bus.
         Starting WPA supplicant...
[  OK  ] Started Avahi mDNS/DNS-SD Stack.
[  OK  ] Started WPA supplicant.
[  OK  ] Reached target Network.
         Starting Dropbear SSH daemon...
         Starting Network Time Service...
         Starting OpenSSH server daemon...
[  OK  ] Started Dropbear SSH daemon.
[  OK  ] Started Network Time Service.
[   16.515911] remoteproc remoteproc0: releasing imx-rproc
[   16.521303] platform imx93-cm33: deferred probe pending
[  OK  ] Started OpenSSH server daemon.
[  OK  ] Reached target Multi-User System.

Welcome to Buildroot
buildroot login:

Packages application version[edit | edit source]

Then, the main applications will show their version:

# python3 --version
Python 3.12.4
# pip3 --version
pip 23.3.2 from /usr/lib/python3.12/site-packages/pip (python 3.12)
# sqlite3 --version
3.46.0 2024-05-23 13:25:27 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e (64-bit)
# thttpd -V
thttpd/2.29 23May2018
# gst-launch-1.0 --version
gst-launch-1.0 version 1.22.9
GStreamer 1.22.9
Unknown package origin
#

Use cases[edit | edit source]

weston[edit | edit source]

The Wayland compositor can be added to the root file system image. In this way it is possible to start the weston desktop:

# export XDG_RUNTIME_DIR=/run/user
# weston
Date: 2024-09-04 UTC
[13:37:29.596] weston 13.0.3
               https://wayland.freedesktop.org
               Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
               Build: 13.0.3
[13:37:29.623] Command line: weston
[13:37:29.623] OS: Linux, 6.1.55-desk-mx9-l-5.1.0+geededa2c10f6, #1 SMP PREEMPT Fri Apr  5 14:03:11 UTC 2024, aarch64
[13:37:29.623] Flight recorder: enabled
[13:37:29.623] warning: XDG_RUNTIME_DIR "/run/user" is not configured
correctly.  Unix access mode must be 0700 (current mode is 0755),
and must be owned by the user UID 0 (current owner is UID 0).
Refer to your distribution on how to get it, or
http://www.freedesktop.org/wiki/Specifications/basedir-spec
on how to implement it.
[13:37:29.629] Starting with no config file.
[13:37:29.648] Output repaint window is 7 ms maximum.
[13:37:29.659] Loading module '/usr/lib/libweston-13/drm-backend.so'
[13:37:29.717] initializing drm backend
[13:37:29.717] Trying libseat launcher...
[13:37:29.719] [seatd/seat.c:39] Created VT-bound seat seat0
[13:37:29.719] [seatd/server.c:145] New client connected (pid: 361, uid: 0, gid: 0)
[13:37:29.719] [libseat/backend/seatd.c:633] Started embedded seatd
[13:37:29.719] [seatd/seat.c:170] Added client 1 to seat0
[13:37:29.720] [libseat/libseat.c:73] Seat opened with backend 'builtin'
[13:37:29.720] [libseat/backend/seatd.c:212] Enabling seat
[13:37:29.721] libseat: session control granted
[13:37:29.725] [seatd/seat.c:480] Opened client 1 on seat0
[13:37:29.728] using /dev/dri/card0
[13:37:29.728] DRM: supports atomic modesetting
[13:37:29.728] DRM: does not support GBM modifiers
[13:37:29.728] DRM: does not support async page flipping
[13:37:29.728] DRM: supports picture aspect ratio
[13:37:29.728] Using Pixman renderer
[13:37:30.273] event0  - 44440000.bbnsm:pwrkey: is tagged by udev as: Keyboard
[13:37:30.273] event0  - 44440000.bbnsm:pwrkey: device is a keyboard
[13:37:30.641] libinput: configuring device "44440000.bbnsm:pwrkey".
[13:37:30.642] DRM: head 'LVDS-1' found, connector 35 is connected, EDID make 'unknown', model 'unknown', serial ''
               Supported EOTF modes: SDR
[13:37:30.643] Registered plugin API 'weston_drm_output_api_v1' of size 40
[13:37:30.643] Color manager: no-op
[13:37:30.643] Output 'LVDS-1' attempts EOTF mode: SDR
[13:37:30.643] Output 'LVDS-1' using color profile: stock sRGB color profile
[13:37:30.646] DRM: output LVDS-1 uses shadow framebuffer.
[13:37:30.646] Output LVDS-1 (crtc 33) video modes:
               800x480@67.9, preferred, current, 35.0 MHz
[13:37:30.646] associating input device event0 with output LVDS-1 (none by udev)
[13:37:30.646] Output 'LVDS-1' enabled with head(s) LVDS-1
[13:37:30.647] Compositor capabilities:
               arbitrary surface rotation: yes
               screen capture uses y-flip: no
               cursor planes: yes
               arbitrary resolutions: no
               view mask clipping: yes
               explicit sync: no
               color operations: no
               presentation clock: CLOCK_MONOTONIC, id 1
               presentation clock resolution: 0.000000001 s
[13:37:30.655] Loading module '/usr/lib/weston/desktop-shell.so'
[13:37:30.678] launching '/usr/libexec/weston-keyboard'
[13:37:30.680] launching '/usr/libexec/weston-desktop-shell'
could not load cursor 'dnd-move'
could not load cursor 'dnd-copy'
could not load cursor 'dnd-none'
could not load cursor 'dnd-move'
could not load cursor 'dnd-copy'
could not load cursor 'dnd-none'
...
...

gstreamer[edit | edit source]

The gstreamer framework provides many features like the videotestsrc:

# gst-launch-1.0 videotestsrc ! video/x-raw,width=800,height=480 ! fbdevsink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
0:00:03.6 / 99:99:99.

or the video decoding of a H.264 853x480 mov video file:

# gst-launch-1.0 filesrc location=/root/BigBuckBunny_853x480p_h264.mov ! decodebin ! videoconvert ! fbdevsink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
0:00:01.8 / 0:09:56.4 (0.3 %)

python[edit | edit source]

Using the built ptthon packages, it is possible to import them on python shell, for example:

# python3
Python 3.12.4 (main, Sep  3 2024, 13:00:29) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
>>> import fastapi
>>> import serial
>>> import can
>>> import pymodbus
>>> import schedule
>>>

or check the installed packages:

# pip3 list
Package           Version
----------------- -------
annotated-types   0.7.0
anyio             4.4.0
blinker           1.7.0
canopen           2.2.0
cbor              1.0.0
cbor2             5.5.1
click             8.1.7
evdev             1.6.1
fastapi           0.111.0
Flask             3.0.0
idna              3.7
itsdangerous      2.2.0
Jinja2            3.1.4
MarkupSafe        2.1.5
msgpack           1.0.7
netifaces         0.11.0
packaging         24.0
pip               23.3.2
pydantic          2.8.2
pydantic_core     2.20.1
pymodbus          3.7.0
pyserial          3.5
pyserial-asyncio  0.6
python-can        4.3.1
RPi.GPIO          0.7.1
rpm               4.18.1
scapy             2.5.0
schedule          1.2.1
setuptools        71.0.3
smbus             1.1
sniffio           1.3.1
starlette         0.37.2
typing_extensions 4.12.2
ujson             5.7.0
Werkzeug          2.3.8
wrapt             1.14.1
#

Binary artifacts[edit | edit source]

buildroot binary artifacts (root file system, kernel+dtb and SDK) can be downloaded from DAVE Embedded Systems cloud server

N.B. config file should be renamed as .config in the buildroot directory before starting the build process