XUELK-AN-004: Running OpenWrt distribution

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
SBC Lynx-top.png Applies to SBC Lynx
Warning-icon.png This application note was validated against specific versions of the kit only. It may not work with other versions. Supported versions are listed in the History section. Warning-icon.png

History[edit | edit source]

Version Date Notes
1.0.0 February 2017 First public release

Introduction[edit | edit source]

By default, AXEL ULite and SBC Lynx Embedded Linux Kit (XUELK) comes with a Yocto distribution. Nevertheless, other distributions can be used as well. This application note shows how to run one of them, OpenWrt.

Generally speaking, OpenWrt is particularly suited for networking devices such as routers and access points. As such, it can be very useful when used in combination with SBC Lynx, to address networking-related use cases.

An exhaustive discussion of OpenWrt is beyond the scope of this application note. For more information, please refer to the project's home page.

The test bed used for this application note is composed of the same hardware/software platform delivered along with the XUELK. The only relevant difference is related to the root file system. The default one will be replaced with the one generated by the OpenWrt build process, as described in the follwing sections.

Donwloading, configuring and building[edit | edit source]

The following commands can be used to generate a root file system for ARM Cortex-A7 target, such as SBC Lynx.

First of all, download the required files:

git clone https://github.com/openwrt/openwrt.git
cd openwrt/
./scripts/feeds update -a
./scripts/feeds install -a

Enter the configuration menu in order to select the proper Target System and Subtarget

make menuconfig

as shown in the following pictures.

Target System selection
Subtarget selection

Start the build process:

make defconfig
make V=s

Once the build process is completed, the root file system is available in the openwrt/build_dir/target-arm_cortex-a7+neon-vfpv4_musl-1.1.16_eabi/root-brcm2708 subdirectory.

Mounting the OpenWrt file system on the target[edit | edit source]

It seems that the OpenWrt file system does not work if mounted over NFS. To overcome this hurdle, we can copy the file system to the ext3 partition of the microSD card.

On host side, make the OpenWrt file system available for the NFS mount. In the following example, the /opt/nfsroot directory - and its subdirectories - is exported.

mkdir /opt/nfsroot/openwrt/root-brcm2708
sudo cp -aRv build_dir/target-arm_cortex-a7+neon-vfpv4_musl-1.1.16_eabi/root-brcm2708/* /opt/nfsroot/openwrt/root-brcm2708/

Boot the target using Yocto root file system as root file system, mounted over NFS (192.168.0.80 is the IP address of the NFS server). Once they target has completed the boot process, mount the directory including OpenWrt root file system.

...
Freescale i.MX Release Distro 3.14.52-1.1.1 sbc-lynx /dev/ttymxc0

sbc-lynx login: root
Password:
root@sbc-lynx:~# mkdir /mnt/tmp
root@sbc-lynx:~# mkdir /mnt/tmp2
root@sbc-lynx:~# mount 192.168.0.80:/opt/nfsroot/openwrt/root-brcm2708 /mnt/tmp2

Then mount the ext3 partition of the microSD card.

root@sbc-lynx:~# mount -t auto /dev/mmcblk0p2 /mnt/tmp/

Erase all of the files it cointains.

root@sbc-lynx:~# rm -rf /mnt/tmp/*

Copy the files of the OpenWrt file systems into the ext4 partition of the microSD card.

root@sbc-lynx:~# cp -aRv /mnt/tmp2/* /mnt/tmp
'/mnt/tmp2/bin/uclient-fetch' -> '/mnt/tmp/bin/uclient-fetch'
'/mnt/tmp2/bin/busybox' -> '/mnt/tmp/bin/busybox'
...
'/mnt/tmp2/usr' -> '/mnt/tmp/usr'
'/mnt/tmp2/www' -> '/mnt/tmp/www'
root@sbc-lynx:~# sync

Booting with OpenWrt root file system[edit | edit source]

That target can be rebooted with the default configuration, in order to mount the root file system from the ext3 partition of the microSD card:

...
[    4.679170] ALSA device list:
[    4.682184]   No soundcards found.
[    4.702526] kjournald starting.  Commit interval 5 seconds
[    5.893894] EXT3-fs (mmcblk0p2): using internal journal
[    5.900130] EXT3-fs (mmcblk0p2): mounted filesystem with ordered data mode
[    5.907149] VFS: Mounted root (ext3 filesystem) on device 179:2.
[    5.915814] devtmpfs: mounted
[    5.919610] Freeing unused kernel memory: 408K (80b15000 - 80b7b000)
[    6.008321] init: Console is alive
[    6.012064] init: - watchdog -
[    6.026440] init: - preinit -
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[    9.316163] mount_root: mounting /dev/root
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
[   10.933664] FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[   10.953636] procd: - early -
[   10.957603] procd: - watchdog -
[   11.733672] procd: - ubus -
[   11.792741] procd: - init -
Please press Enter to activate this console.



BusyBox v1.24.2 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 DESIGNATED DRIVER (Bleeding Edge, 50104)
 -----------------------------------------------------
  * 2 oz. Orange Juice         Combine all juices in a
  * 2 oz. Pineapple Juice      tall glass filled with
  * 2 oz. Grapefruit Juice     ice, stir well.
  * 2 oz. Cranberry Juice
 -----------------------------------------------------
root@OpenWrt:/# free
             total       used       free     shared    buffers     cached
Mem:        507148      14344     492804          0        396       2432
-/+ buffers/cache:      11516     495632
Swap:            0          0          0
root@OpenWrt:/# du -csh
5.1M    .
5.1M    total