Changes

Jump to: navigation, search

MISC-TN-004: Running Debian (armbian) on SBCSPG

6,229 bytes added, 09:55, 14 February 2020
no edit summary
{{InfoBoxTop}}
{{AppliesToSBCSPG}}
{{AppliesToIoT}}
{{InfoBoxBottom}}
{{WarningMessage|text=This application technical note was validated against specific versions of hardware and software. It may not work with other versions.}}[[Category:MISC-AN-TN]][[Category:MISC-TN]][[Category:IoT]]
__FORCETOC__
== History ==
{| class="wikitable" border="1"
|July 2019
|First public release
|-
|1.0.1
|October 2019
|Detailed armbian version
|-
|}
==Introduction==
In the last years, Debian-based distributions have distributions⁠—which are very widespread in desktop/server environments—have grown in popularity in the embedded world as well. Nowadays, there are several approaches to create such a Distribution distribution for embedded targets, however. [https://elbe-rfs.org/ ELBE], [https://github.com/zuka0828/meta-eid meta-eid], and [https://www.armbian.com/ armbian] are just three examples of different tools available today [1]. This Technical Note shows how to run such a distribution on SBCSPG, a product designed and manufactured by DAVE Embedded Systems to build compact IoT gateways for industrial applications. Specifically, this example makes use of '''Armbian Stretch''', which is based on Debian 9.
This Technical Note shows how to run such a distribution on SBCSPG, a product designed and manufactured by DAVE Embedded Systems to build compact IoT gateways for industrial applications.
-----
[1] For more details, please see for instance these presentations:
* [https://events.linuxfoundation.org/wp-content/uploads/2017/12/ELCE2018_Debian-Yocto-State-of-the-Art_r6_Kazuhiro-Hayashi.pdf Debian & Yocto: State of the Art (Oct 23rd, 2018)]
* [https://elinux.org/images/4/42/ELBE-Isar-Deby_jamboree63_r2.pdf Debian + YoctoProject Based Projects: Collaboration Status (Dec 1st, 2017)]
 
==The hardware platform==
As stated previously, the SBCSPG gateway is suited to implement low-cost edge computing devices.  [[File:Edge-v-cloud-computing-graphic.png|thumb|center|600px|Cloud and Edge computing in a typical IIoT scenario (image source: [https://www.openautomationsoftware.com/wp-content/uploads/2017/04/edge-v-cloud-computing-graphic.png])]]  From an architectural standpoint, SBCSPG is similar to the [[:Category:SBC_Lynx|SBC Lynx]]. As such, it is powered by NXP i.MX6UL system-on-chip (SoC).  [[File:SBCSPG-1.jpg|center|thumb|600px|SBCSPG Industrial IoT gateway]]  It is equipped with three network interfaces⁠—two Ethernet ports and a WiFi⁠—and provides several combinations of serial ports like RS232, RS485, and RS422. It also has two USB ports (host and OTG) and a microSD slot.
==Creating the root file system==
To create the root file system, the procedure described [https://github.com/armbian/build here] was followed. Before starting the actual build process, the following patch was applied in order to add the support for the SBCSPG target.
 
<pre>
diff --git a/config/boards/sbcspg.conf b/config/boards/sbcspg.conf
new file mode 100644
index 00000000..1d1411eb
--- /dev/null
+++ b/config/boards/sbcspg.conf
@@ -0,0 +1,11 @@
+# i.MX6UL-powered industrial gateway by DAVE Embedded Systems
+BOARD_NAME="sbcspg"
+BOARDFAMILY="rialto"
+BOOTCONFIG="mx6_cubox-i_config"
+#
+MODULES=""
+MODULES_NEXT=""
+#
+KERNEL_TARGET="default,next,dev"
+CLI_TARGET="buster,bionic:default,next"
+DESKTOP_TARGET=""
diff --git a/config/sources/rialto.conf b/config/sources/rialto.conf
new file mode 100644
index 00000000..0d8b97a8
--- /dev/null
+++ b/config/sources/rialto.conf
@@ -0,0 +1,84 @@
+BOOTSOURCE='https://github.com/SolidRun/u-boot.git'
+BOOTDIR='u-boot-cubox'
+BOOTBRANCH='branch:v2018.01-solidrun-imx6'
+BOOTCONFIG="mx6cuboxi_defconfig"
+BOOTSCRIPT='boot-cubox.cmd:boot.cmd'
+BOOTENV_FILE='cubox-default.txt'
+
+UBOOT_TARGET_MAP=';emmc;SPL:SPL.emmc u-boot.img:u-boot.img.emmc
+ ;sdhc;SPL:SPL.sdhc u-boot.img:u-boot.img.sdhc
+ ;sdhc;SPL:SPL.sata u-boot.img:u-boot.img.sata
+ ;sdhc;SPL:SPL.spi-flash u-boot.img:u-boot.img.spi-flash'
+
+UBOOT_USE_GCC='> 7.0'
+KERNEL_USE_GCC='> 7.0'
+KERNELSOURCE=$MAINLINE_KERNEL_SOURCE
+KERNELDIR=$MAINLINE_KERNEL_DIR
+
+case $BRANCH in
+
+ default)
+
+ KERNELBRANCH='branch:linux-4.14.y'
+
+ ;;
+
+ next)
+
+ KERNELBRANCH='branch:linux-5.1.y'
+
+ ;;
+
+ dev)
+
+ KERNELBRANCH='branch:linux-5.1.y'
+ LINUXCONFIG='linux-cubox-next'
+
+ ;;
+
+esac
+
+CPUMIN=396000
+CPUMAX=996000
+GOVERNOR=interactive
+
+SERIALCON=ttymxc0
+
+
+write_uboot_platform()
+{
+ dd if=$1/SPL.sdhc of=$2 bs=1K seek=1 status=noxfer > /dev/null 2>&1
+ dd if=$1/u-boot.img.sdhc of=$2 bs=1K seek=69 status=noxfer > /dev/null 2>&1
+}
+
+if [[ $BOARD == wandboard-quad ]]; then
+ UBOOT_USE_GCC='> 6.3'
+ KERNEL_USE_GCC='> 6.3'
+ CPUMAX=1008000
+ GOVERNOR=ondemand
+ BOOTSOURCE=$MAINLINE_UBOOT_SOURCE
+ BOOTDIR=$MAINLINE_UBOOT_DIR
+ BOOTBRANCH="branch:v2017.03"
+ write_uboot_platform()
+ {
+ dd if=$1/SPL of=$2 bs=512 seek=2 status=noxfer > /dev/null 2>&1
+ dd if=$1/u-boot.img of=$2 seek=69 bs=1k status=noxfer > /dev/null 2>&1
+ }
+fi
+
+family_tweaks()
+{
+ # TODO: Fix the workaround in firstrun?
+ #chroot $SDCARD /bin/bash -c "LC_ALL=C LANG=C update-rc.d brcm4330-patch defaults > /dev/null"
+ echo ""
+}
+
+family_tweaks_bsp()
+{
+ install -m 644 $SRC/packages/bsp/cubox/99-hdmi_fb0.conf $destination/etc/X11/xorg.conf.d/99-hdmi_fb0.conf
+ install -m 755 $SRC/packages/bsp/cubox/brcm_patchram_plus $destination/usr/bin/brcm_patchram_plus
+ cp $SRC/packages/bsp/cubox/brcm4330 $destination/etc/default/
+ # TODO: replace by a systemd service
+ mkdir $destination/etc/init.d/
+ install -m 755 $SRC/packages/bsp/cubox/brcm4330-patch $destination/etc/init.d/brcm4330-patch
+}
</pre>
 
When the process is completed, the <code>output/images</code> directory is populated with the following files:
<pre>
Armbian_5.91_Sbcspg_Debian_stretch_default_.img
Armbian_5.91_Sbcspg_Debian_stretch_default_.txt
</pre>
The <code>.img</code> is the one we need to deploy the root file system onto the target platform.
 
Even though it is not recommended, the build process was run natively on a PC equipped with Ubuntu 18.04.
==Deploying the root file system onto the target==
This procedure consists of the following steps:
*Mount the <code>.img</code> file
*Copy the root file system to a microSD card
*Move the microSD card to the target
*Configure the target in order to mount the ''armbian'' root file system from the microSD card.
 
It is assumed that there is an ext4 partition on the microSD card large enough to cointain the ''armbian'' root file system, which is about 900MB.
 
To mount the <code>.img</code> file, issue the following commands.
<pre class="board-terminal">
sudo kpartx -v -a Armbian_5.91_Sbcspg_Debian_stretch_default_.img
</pre>
If this operation is completed succesfully, you'll see something like this:
<pre class="board-terminal">
# ll /dev/mapper/
total 0
drwxr-xr-x 2 root root 80 lug 29 11:52 ./
drwxr-xr-x 21 root root 4440 lug 29 15:50 ../
crw------- 1 root root 10, 236 lug 29 11:41 control
lrwxrwxrwx 1 root root 7 lug 29 11:52 loop18p1 -> ../dm-0
</pre>
And then:
<pre class="board-terminal">
sudo mkdir /mnt/tmp
sudo mount /dev/mapper/loop18p1 /mnt/tmp/ -o ro
</pre>
As <code>root</code>, copy the files from <code>/mnt/tmp/</code> to the desired partition into the microSD card.
 
After the copy operation is finished, unmount the microSD card and move it to the target.
 
To configure the SBCSPG to mount the root file system from this partition, several options are available. The following example shows how the U-Boot environment variables were set to retrieve the Linux kernel image and the device tree blob (DTB) via Ethernet, while the file system is mounted from the microSD card. In practice, an ad hoc variable⁠—named <code>net_mmc</code>⁠—was added:
<pre class="board-terminal">
=> print net_mmc
net_mmc=run loadk loadfdt mmcargs addip addcons addmisc; if run configid_fixupfdt; then bootm ${loadaddr} - ${fdtaddr}; fi
=> edit mmcroot
edit: /dev/mmcblk0p4 rootwait rw
</pre>
 
The following section shows the full boot process.
===Full bootstrap process===
To expand the box, please click on the ''Expand'' link on the right.
<pre class="board-terminal mw-collapsible mw-collapsed">
U-Boot 2016.03-rialto-1.1.2 (Jan 17 2019 - 15:10:28 +0100), Build: jenkins-Rialto_U-Boot-10
Normal Boot
Hit any key to stop autoboot: 0
=> print net_mmc
net_mmc=run loadk loadfdt mmcargs addip addcons addmisc; if run configid_fixupfdt; then bootm ${loadaddr} - ${fdtaddr}; fi
=> edit mmcroot
edit: /dev/mmcblk0p4 rootwait rw
=> run net_mmc
FEC0 Waiting for PHY auto negotiation to complete...... done
dave_user, Administrators
5,138
edits

Navigation menu