Build Raspberry Pi 3+ RDKB dunfell image

Note. The flow is based on: https://wiki.rdkcentral.com/pages/viewpage.action?pageId=130090892

Run build container

The build process is to be done within a docker container Ubuntu18_04_rdkb_dunfell.

Note. The container can’t be run from root! 

docker run -ti --user $UID:$GID --workdir="/home/$USER" --volume="/etc/group:/etc/group:ro" --volume="/etc/passwd:/etc/passwd:ro" --volume="/etc/shadow:/etc/shadow:ro" -v ${PWD}:/home/$USER javrv/ubuntu18_04_rdkb_dunfell:v1 /bin/bash

Repo Setup

In order to use Yocto build system, the repo tool must be properly installed on the machine.

To install Repo make sure you have a /bin directory in your home directory of the build container and that it is included in your path

userX@bf34301d1247:~$ mkdir ~/bin
userX@bf34301d1247:~$ PATH=~/bin:$PATH
userX@bf34301d1247:~$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
#sometimes http doesn’t work and https should help
userX@bf34301d1247:~$ chmod a+x ~/bin/repo

Note. It is also recommended to put credentials in ~/.netrc when interacting with repo.

userX@bf34301d1247:~$ echo ~/.netrc
/home/userX/.netrc
userX@bf34301d1247:~$ vim ~/.netrc

Example of .netrc

machine code.rdkcentral.com
login <userX , not an email>
password <userX password on rdkb>

Prepare build environment

Create a build folder (will be created on host machine!)

userX@bf34301d1247:~$ mkdir rdkb_rpi
userX@bf34301d1247:~$ cd ./rdkb_rpi/

Set encoding.

userX@bf34301d1247:~/rdkb_rpi$ export LANG=en_US.UTF-8

Tell git who you are

user@bf34301d1247:~/rdkb_rpi$ git config --global user.email <email used on rdkb forum>
user@bf34301d1247:~/rdkb_rpi$ git config --global user.name <Name of User>


Build RPI image:

  • for RPi3
userX@bf34301d1247:~/rdkb_rpi$ repo init -u https://code.rdkcentral.com/r/manifests -b rdkb-2021q3-dunfell -m rdkb-extsrc.xml
userX@bf34301d1247:~/rdkb_rpi$ repo sync -j`nproc` --no-clone-bundle
userX@bf34301d1247:~/rdkb_rpi$ MACHINE=raspberrypi-rdk-broadband source meta-cmf-raspberrypi/setup-environment
userX@bf34301d1247:~/rdkb_rpi/build-raspberrypi-rdk-broadband$ bitbake rdk-generic-broadband-image
  • for RPi4
userX@bf34301d1247:~/rdkb_rpi$ repo init -u https://code.rdkcentral.com/r/manifests -m rdkb.xml -b rdkb-2024q1-dunfell
userX@bf34301d1247:~/rdkb_rpi$ repo sync --no-clone-bundle --no-tags -j`nproc`
userX@bf34301d1247:~/rdkb_rpi$ MACHINE=raspberrypi4-rdk-broadband source meta-cmf-raspberrypi/setup-environment
userX@bf34301d1247:~/rdkb_rpi/build-raspberrypi-rdk-broadband$ bitbake rdk-generic-broadband-image

Built artefacts you can find in:

build-raspberrypi-rdk-broadband/tmp/deploy/images/raspberrypi-rdk-broadband

Example:

rdkb-generic-broadband-image_rdkb-2021q3-dunfell_20240524105104.rootfs.wic.bz2

Flashing Procedure

SD card flashing flow from https://wiki.rdkcentral.com/pages/viewpage.action?pageId=130090892 could be used.

Example:

$ bzip2 -d rdk-generic-broadband-image-raspberrypi-rdk-broadband.wic.bz2
$ sudo -E bmaptool copy --nobmap rdk-generic-broadband-image-raspberrypi-rdk-broadband.wic /dev/sdb

Also, balenaEtcher (https://etcher.balena.io/ ) GUI tool could be recommended.

Possible issues

During the build procedure, some compilation issues might appear.

1) heaptrack-1.0.0-r0 do_fetch: Fetcher failure: Fetch command export - heaptrack-1.0.0-r0 do_fetch: Fetcher failure: Fetch command export

Fix based on: https://code.rdkcentral.com/r/c/rdk/components/generic/rdk-oe/meta-cmf/+/69360/1/recipes-common/heaptrack/heaptrack_1.0.0.bbappend

--- ./meta-rdk-ext/recipes-common/heaptrack/heaptrack_back.inc  2024-05-25 01:14:23.907493272 +0300
+++ meta-rdk-ext/recipes-common/heaptrack/heaptrack.inc 2024-05-24 13:50:33.733624971 +0300
@@ -6,7 +6,7 @@


DEPENDS = "zlib boost libunwind elfutils"

-SRC_URI = "git://github.com/KDE/heaptrack \
+SRC_URI = "git://github.com/KDE/heaptrack;protocol=https \
           file://rdk_heaptrack.patch \
          "
S = "${WORKDIR}/git"

Build Sample C application for Raspberry Pi 3+ 

Note. The flow is based on:

https://wiki.rdkcentral.com/display/RDK/Integration+Guide+for+third-party+applications+into+RDK-B+stack

Add new meta folder

Download meta-rdk-sampleapp.tar.gz and extract to rdkb_rpi folder.

Add the application meta-layer to the machine configuration

Modify meta-cmf-raspberrypi layer:

diff --git a/conf/layer.conf b/conf/layer.conf
index 0e9a369..aa6c1e4 100644
--- a/conf/layer.conf
+++ b/conf/layer.conf
@@ -20,10 +20,12 @@ LAYERDEPENDS_cmf-raspberrypi_append = "${@' camera cmf-camera' if ("camera" in d
 

LAYERDEPENDS_cmf-raspberrypi_append = " raspberrypi"
 

+LAYERDEPENDS_cmf-raspberrypi = "rdk-sampleapp"
+
require conf/distro/include/rdk-rpi.inc
require conf/include/rdk-external-src-platform.inc

diff --git a/recipes-core/packagegroups/packagegroup-rdk-oss-broadband.bbappend b/recipes-core/packagegroups/packagegroup-rdk-oss-broadband.bbappend
index 198bf68..74d62e4 100644
--- a/recipes-core/packagegroups/packagegroup-rdk-oss-broadband.bbappend
+++ b/recipes-core/packagegroups/packagegroup-rdk-oss-broadband.bbappend
@@ -13,6 +13,7 @@ RDEPENDS_packagegroup-rdk-oss-broadband_append = " \
   rtl8192eu \
   rtl88x2bu \
   ethtool \
+    sampleapp \
"
 

RDEPENDS_packagegroup-rdk-oss-broadband_remove_aarch64 = "alljoyn"
diff --git a/setup-environment b/setup-environment
index 170b385..1b0d561 100755
--- a/setup-environment
+++ b/setup-environment
@@ -141,3 +141,15 @@ if [ "${RDK_ENABLE_REFERENCE_IMAGE}" = "y" ]; then
       echo "export RDK_ENABLE_REFERENCE_IMAGE = \"y\"" >> conf/local.conf
   fi
fi
+
+# Add meta-rdk-sampleapp only if not already present for RDK-B
+echo "${_RDK_FLAVOR}"
+if [[ "${_RDK_FLAVOR}" = "rdkb" ]]
+then
+   if [ $(grep '^BBLAYERS' conf/bblayers.conf | grep -c 'meta-rdk-sampleapp') -eq 0 -a -d  $TOP_DIR/meta-rdk-sampleapp ]
+   then
+        cat >> conf/bblayers.conf <<EOF
+BBLAYERS =+ "\${RDKROOT}/meta-rdk-sampleapp"
+EOF
+   fi
+fi

Build a new image and flash 

userX@bf34301d1247:~/rdkb_rpi/build-raspberrypi-rdk-broadband$ bitbake rdk-generic-broadband-image

Built artefacts you can find in:

build-raspberrypi-rdk-broadband/tmp/deploy/images/raspberrypi-rdk-broadband

Example:

rdkb-generic-broadband-image_rdkb-2021q3-dunfell_20240524105104.rootfs.wic.bz2

Test C app 

root@RaspberryPi-Gateway:~# /usr/bin/sampleAppn
Hello Sample Program     1717965344.000000
root@RaspberryPi-Gateway:~#

Build Sample Rust application for Raspberry Pi 3+ 

Add pre-built rust meta layer

This guide uses meta-rust-bin layer.

This layer exists as a tradeoff against other options, e.g. the meta-rust project. Both exist to satisfy different requirements. Because this layer uses the upstream compiled versions of Rust and Cargo, it will never be able to support architectures or options not supported by the Rust team itself.

Also, because this layer uses pre-built Rust standard libraries, it is possible that the standard libraries provided with this layer will be less efficient than code produced by a custom-compiled standard library.

  • However, using pre-built tools has advantages:
  • Updating the layer to a new version of Rust is as easy as updating checksums and file names, so new versions of Rust are available quickly.
  • In almost all modern systems, it is faster to download the binaries than it is to download source and build the Rust toolchain from scratch.
  • Compatibility across multiple versions of Yocto is maximized since only basic, stable recipe features are used.
  • Trivial support for all architectures supported by upstream Rust.

The following is to be done.

Clone meta-rust-bin layer into ./meta-openembedded

cd ./meta-openembedded/
git clone https://github.com/rust-embedded/meta-rust-bin.git

Add Support for New Versions

cd ./meta-rust-bin/
./build-new-version.sh nightly

Add rust tool-chains new layer

userX@bf34301d1247:~/rdkb_rpi/build-raspberrypi-rdk-broadband$ bitbake-layers add-layer ../meta-openembedded/meta-rust-bin

Check if added:

userX@bf34301d1247:~/rdkb_rpi/build-raspberrypi-rdk-broadband$ bitbake-layers show-layers
NOTE: Starting bitbake server...
layer                 path                                      priority
==========================================================================

meta-rust-bin         /home/userX/rdkb_rpi/meta-openembedded/meta-rust-bin  7

Add Rust hello world recipe

In ./meta-cmf-raspberrypi create new folder (inspired by this)

mkdir recipes-example
cd ./recipes-example  

Download rust-hello-world.tar.gz and extract to this folder.

As meta-rust-bin is in use, please make sure to update the inherited class of rust-hello-world_git.bb recipe to cargo_bin

Modify 

inherit cargo

to

inherit cargo_bin

Add Rust hello world binary to RPI image

In ./meta-cmf-raspberrypi create new folder modify:

diff --git a/recipes-core/packagegroups/packagegroup-rdk-oss-broadband.bbappend b/recipes-core/packagegroups/packagegroup-rdk-oss-broadband.bbappend
index 198bf68..ae03620 100644
--- a/recipes-core/packagegroups/packagegroup-rdk-oss-broadband.bbappend
+++ b/recipes-core/packagegroups/packagegroup-rdk-oss-broadband.bbappend
@@ -13,6 +13,8 @@ RDEPENDS_packagegroup-rdk-oss-broadband_append = " \
   rtl8192eu \
   rtl88x2bu \
   ethtool \
+    sampleapp \
+    rust-hello-world \
"

RDEPENDS_packagegroup-rdk-oss-broadband_remove_aarch64 = "alljoyn"

Build a new image and flash 

Use approach from above

Test Rust app 

root@RaspberryPi-Gateway:~# find / -name rust-hello-world
/usr/bin/rust-hello-world
root@RaspberryPi-Gateway:~# 
root@RaspberryPi-Gateway:~# ls -la /usr/bin/rust-hello-world
-rwxr-xr-x    1 root     root        288640 Jun 14 22:00 /usr/bin/rust-hello-world
root@RaspberryPi-Gateway:~# ls -la /usr/bin/sampleAppn      
-rwxr-xr-x    1 root     root          5800 Jun  9 18:13 /usr/bin/sampleAppn
root@RaspberryPi-Gateway:~# /usr/bin/rust-hello-world 
Hello, world!
  • No labels