home Sonstiges Linux OpenBSD Links

For other releases please see here. This is the current release.

Linux from Scratch r11.0-93 on Wandboard i.MX6

I created a minimal LFS system. It might be interesting for people who are searching a minimal system for their own Wandboard projects.

My SD card image can be downloaded here.

Please use the upper SD card slot at the Wandboard:

Installed/used software
from LFS:
Linux kernel headers 5.4.162, Man-pages-5.13, Iana-Etc-20211124, Glibc-2.34, Zlib-1.2.11, Bzip2-1.0.8, Xz-5.2.5, Zstd-1.5.0, File-5.41, Readline-8.1, M4-1.4.19, Bc-5.2.1, Flex-2.6.4, Tcl-8.6.11, Expect-5.45.4, DejaGNU-1.6.3, Binutils-2.37, GMP-6.2.1, MPFR 4.1.0, MPC 1.21, Attr-2.5.1, Acl-2.3.1, Libcap-2.61, Shadow-4.9, Pkg-config-0.29.2, Ncurses-6.3, Sed-4.8, Psmisc-23.4, Gettext-0.21, Bison-3.8.2, Grep-3.7, Bash-5.1.8, Libtool-2.4.6, GDBM-1.22, Gperf-3.1, Expat-2.4.1, Inetutils-2.2, Less-590, Perl-5.34.0, XML::Parser-2.46, Intltool-0.51.0, Autoconf-2.71, Automake-1.16.5, Kmod-29, Libelf from Elfutils-0.186, Libffi-3.4.2, OpenSSL-1.1.1l, Python-3.10.0, Ninja-1.10.2, Meson-0.60.2, Coreutils-9.0, Check-0.15.2, Diffutils-3.8, Gawk-5.1.1, Findutils-4.8.0, Groff-1.22.4, Gzip-1.11, IPRoute2-5.15.0, Kbd-2.4.0, Libpipeline-1.5.4, Make-4.3, Patch-2.7.6, Tar-1.34, Texinfo-6.8, Vim-8.2.3704, Eudev-3.2.10, Man-DB-2.9.4, Procps-ng-3.3.17, Util-linux-2.37.2, E2fsprogs-1.46.4, Sysklogd-1.5.1, Sysvinit-3.00

additional software:
isl 0.24, which 2.21, GCC 11.2.0 (with enabled languages c,c++,d,fortran,go,objc,obj-c++), libtasn1 4.18.0, p11-kit 0.24.0, make-ca 1.9, libunistring 0.9.10, libidn2 2.3.2, libpsl-0.21.1, pcre2 10.39, wget 1.21.2, cpio 2.13, joe 4.6, nano 5.9, net-tools 2.10 (and from there additional ifconfig because this knows IPv6), traceroute 2.1.0, tree 1.8.0, libtirpc 1.3.2, lsof 4.94.0, iptables 1.8.7, lynx 2.8.9rel.1, LZO 2.10, lzop 1.04, time 1.9, libnl 3.5.0, curl 7.80.0, rpcbind 1.2.6, git 2.34.1, dhcpcd 9.4.1, libxml 2.9.12, wireless tools 29, wpa_supplicant 2.9, openssh 8.8p1, htop 3.1.1, iotop 1.20, screen 4.8.0, Net::SSLeay-1.90, URI-5.10, IO::Socket::SSL-2.072 , sntp and ntpdate from ntp 4.2.8p15, uboot (via git checkout, see below), linux kernel 5.4.154 with Wandboard patches (see below)


Network connectivity

The image is configured to request an IP address via DHCP via ethernet connection. Dhcpcd will send out the hostname wandboard. If you have a Fritzbox, the system should be SSH able via wandboard.fritz.box
Sadly I did an error in the configuration of dhcpcd.conf. Please check out the IP in the menu of your Fritzbox etc. To get wandboard.fritz.box you need to edit /etc/dhcpcd.conf and remove the leading # from #hostname
WLAN is not configured, you need to configure the WPA passphrase. See file HowToGetWLANrunning in the home directory of root.

Resizing the partition

Use cfdisk /dev/mmcblk2. There is a menu point Resize.
Use resize2fs /dev/mmcblk2p1 to expand the filesystem.

Hints if you want to create your own LFS

As LFS target please use armv7l-lfs-linux-gnueabihf - Chapter 4.4 Setting Up the Environment:
cat > ~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=armv7l-lfs-linux-gnueabihf
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL LFS_TGT PATH
EOF
Chapter 5.5.1 Installation of Glibc:
case $(uname -m) in
    i?86)   ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3
    ;;
    x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
            ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
    ;;
    armv7l) ln -sfv ld-linux.so.3 $LFS/lib/ld-lsb.so.3
    ;;
esac
Chapter 7.7.1 Installation of Target Libstdc++
../libstdc++-v3/configure            \
    CXXFLAGS="-g -O2 -D_GNU_SOURCE"  \
    --prefix=/usr                    \
    --disable-multilib               \
    --disable-nls                    \
    --host=armv7l-lfs-linux-gnueabihf \
    --disable-libstdcxx-pch
Chapter 9.6.2 Configuring Sysvinit
I added an agetty entry in /etc/inittab for the serial console:
#Serial
c0:12345:respawn:/sbin/agetty 115200 ttymxc0 vt100
Hint: on the Wandboard, ttymxc0 is the serial line, not ttyS0

Chapter 9.6.5 Configuring the Linux Console
After trying a boot with the new LFS, it stopped with this error message:

*****Setting up Linux console...                                       [ FAIL ]
*****                                                                  [ FAIL ]
     FAILURE:

You should not be reading this error message.

It means that an unforeseen error took place in
/etc/rc.d/rcS.d/S70console,
which exited with a return value of 1.
If you're able to track this error down to a bug in one of
the files provided by the LFS book,
please be so kind to inform us at lfs-dev@linuxfromscratch.org (Registration required).
*****                                                                  [ FAIL ]
     Press Enter to continue...
After pressing Enter to system continues to boot. But usually you have not a serial console connected and you will never see this message.
I figured out that there is a line in cat /etc/sysconfig/console which caused the error. Comment the line starting with LEGACY_CHARSET with a #
# Begin /etc/sysconfig/console

UNICODE="1"
KEYMAP="de-latin1"
KEYMAP_CORRECTIONS="euro2"
#LEGACY_CHARSET="iso-8859-15" # Removed, with this enabled the console init script stops
FONT="LatArCyrHeb-16 -m 8859-15"

# End /etc/sysconfig/console

Compiling and installing U-Boot

The information are taken from https://forum.digikey.com/t/debian-getting-started-with-the-wandboard/12707

git clone -b v2019.04 https://github.com/u-boot/u-boot --depth=1
cd u-boot/
wget -c https://github.com/eewiki/u-boot-patches/raw/master/v2019.04/0001-wandboard-uEnv.txt-bootz-n-fixes.patch
patch -p1 < 0001-wandboard-uEnv.txt-bootz-n-fixes.patch
make distclean
make wandboard_defconfig 
make
You should find now two files: SPL and u-boot.img. Assume your SD card is /dev/sdb, install U-Boot with this commands (as root):
dd if=/dev/zero of=/dev/sdb bs=1M count=10
dd if=SPL of=/dev/sdb seek=1 bs=1k
dd if=u-boot.img of=/dev/sdb seek=69 bs=1k
Hint: if you are already on a Wandboard, the SD card might be /dev/mmcblk0 or /dev/mmcklb2

To create a partition, use the program sfdisk (as root). You should use a newer version of sfdisk (=> 2.26):

sfdisk /dev/sdb <<-__EOF__
1M,4G,L,*
__EOF__

Compiling and installing a Linux kernel

The information are taken from https://forum.digikey.com/t/debian-getting-started-with-the-wandboard/12707. You might need to change path names depending is you are inside a LFS chroot or not. Take care that you do not destroy your host system /boot directory!

If you are building on the Wandboard, you might add to create some swap space before:

fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
mkswap: /swapfile: warning: wiping old swap signature.
Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
no label, UUID=67a07d2f-350e-4ca3-b388-1324bcf4a62c
swapon /swapfile
Now get the kernel with patches:
git clone https://github.com/RobertCNelson/armv7-multiplatform
cd armv7-multiplatform/
git checkout origin/v5.4.x -b tmp
./build_kernel.sh
You don't need to change anything in the configuration dialog.

At the end the kernel, modules and dtbs archive has been build. You get an overview. Example:

-----------------------------
'arch/arm/boot/zImage' -> '/sources/l/armv7-multiplatform/deploy/5.4.154-armv7-x62.zImage'
'.config' -> '/sources/l/armv7-multiplatform/deploy/config-5.4.154-armv7-x62'
-rwxr-xr-x 1 root root 9.8M Nov 28 20:09 /sources/l/armv7-multiplatform/deploy/5.4.154-armv7-x62.zImage
-----------------------------
Building modules archive...
Compressing 5.4.154-armv7-x62-modules.tar.gz...
-rw-r--r-- 1 root root 23M Nov 28 20:16 /sources/l/armv7-multiplatform/deploy/5.4.154-armv7-x62-modules.tar.gz
-----------------------------
Building dtbs archive...
Compressing 5.4.154-armv7-x62-dtbs.tar.gz...
-rw-r--r-- 1 root root 4.7M Nov 28 20:17 /sources/l/armv7-multiplatform/deploy/5.4.154-armv7-x62-dtbs.tar.gz
-----------------------------
Script Complete
eewiki.net: [user@localhost:~$ export kernel_version=5.4.154-armv7-x62]
-----------------------------
In this example the kernel version is 5.4.154-armv7-x62 Create /boot/uEnv.txt with this content:
uname_r=5.4.154-armv7-x62
console=tty0
#console=ttymxc0
#cmdline=video=HDMI-A-1:1024x768@60e
cmdline=video=HDMI-A-1:1920x1080@60e
uname_r is the kernel that U-Boot should load. The filename must start with vmlinuz, so copy and rename the kernel:
cp -v ./deploy/5.4.154-armv7-x62.zImage /boot/vmlinuz-5.4.154-armv7-x62
Install the dtbs files:
mkdir -p /boot/dtbs/5.4.154-armv7-x62/
tar -xvf ./deploy/5.4.154-armv7-x62-dtbs.tar.gz -C /boot/dtbs/5.4.154-armv7-x62/
Install kernel modules (Again: you might need to modify the path, take care that you don't destroy your host system /lib! Using the -h switch for tar is recommended especially if /lib is only a symbolic link to /usr/lib like we have in newer LFS versions):
tar -hxvf ./deploy/5.4.154-armv7-x62-modules.tar.gz -C /

Booting from SATA drive

Only the Quad Wandboard has a SATA connector.
The Wandboard will always boot the kernel from the SD card, so you must simply add a root=/dev/sda1 to /boot/uEnv.txt (again on the SD card).
The best ways is: install the image /on the SD card, prepare the SATA drive and change the value in /uEnv.txt. So should it look:
uname_r=5.4.154-armv7-x62
console=tty0
#console=ttymxc0
#cmdline=root=/dev/sda1 rw video=HDMI-A-1:1024x768@60e
cmdline=root=/dev/sda1 rw video=HDMI-A-1:1920x1080@60e

WLAN firmware files

mkdir -p /lib/firmware/brcm/
cd /lib/firmware/brcm/
wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4329-sdio.bin
wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4330-sdio.bin
wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4329-sdio.txt
wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4330-sdio.txt

Adding a Dallas DS1307 RTC (real time clock)

This has been untested, but should work.

The Wandboard onboard RTC will always loose the time if powered off. Simplest way is to set the time via NTP. But if don't want this or your configuration has no access to a NTP server, you can add a Dallas DS1307 RTC chip via I2C connection.
I bought a small Adafruit DS1307 board. It has five pin, but you only have to connect four wires: +5V, GND, SDA, SCL. The board needs a CR1220 battery to keep the time. On my first tries I inserted the battery in the wrong direction - the DS1307 has not kept the time ;)
The I2C pins SDA and SCL are at JP2 expansion pin header, +5V and GND are at JP4. See Wandboard User Guide page 7 for information which pin is which signal. My wiring looks bad, but it works:
Click here to enlarge

Finally you must the tell the system that there is a DS1307 RTC. With my minimal LFS system from above, edit /etc/rc.d/init.d/settimeviantp and add the red lines:

case "$1" in
    start)
        echo "try to set time via DS1307"
        echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
        sleep 3
        /sbin/hwclock --rtc /dev/rtc1 --hctosys
        echo "Setting time via NTP from ptbtime1.ptb.de..."
        sleep 10
        /usr/sbin/ntpdate -s ptbtime1.ptb.de
        sleep 1
        ;;
The echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device command is important. This tells the kernel that there is a DS1307 device. The kernel needs to be compiled with I2C and DS1307 RTC support.

Run now /etc/rc.d/init.d/settimeviantp start

At dmesg you should see that the DS1307 recognized:

root@wandboard:~ # dmesg | grep ds1307
[   12.591586] rtc-ds1307 0-0068: registered as rtc1
[   12.597197] i2c i2c-0: new_device: Instantiated device ds1307 at 0x68
The DS1307 is registered as rtc1, so we have to tell the hwclock command via parameter --rtc /dev/rtc1 that this should be used.

To set the time to the DS1307 RTC from the current kernel time which has been hopefully set via NTP, use:

root@wandboard:~ # hwclock --rtc /dev/rtc1 -w
You may want to create a crontab script that updates at least one time per day the time via NTP and sync to the DS1307.

If something doesn't work it is always good to check with I2C Tools. Does it see the DS1307?

root@wandboard:~ # i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
If you see instead of 68 only UU: you have set already the device via settimeviantp script (echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device)

Keep in mind: the Wandboard has two I2C busses, my wiring from above is on the first I2C bus, which is checked via the parameter -y 0

Nullmodem cable

I'm able to watch the boot process via a serial null modem cable. But it seems so that my keystrokes are not transmitted. Currently no idea why. I have a second Wandboard (DUAL version) where the null modem cable works as expected. Once agetty started a login dialog, it worked. Set speed to 115200 in your terminal program. If you are searching for a terminal program for Windows - try PuTTY (yes it can handle serial connections too).

zurück zur Linuxübersicht
Letzte Aktualisierung dieser Seite: 23. Januar 2022