From b5f7a4453a2fa7f96059456589bded18bc753aa0 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Mon, 7 Mar 2016 19:34:56 +0300 Subject: [PATCH 1/2] Initial documentation for fel-load Small fixes in fel-load and debootstrap-ng --- debootstrap-ng.sh | 6 +++- documentation/fel-boot.md | 59 +++++++++++++++++++++++++++++++++++++++ fel-load.sh | 24 ++++------------ 3 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 documentation/fel-boot.md diff --git a/debootstrap-ng.sh b/debootstrap-ng.sh index 0350f9227746..33f5609e9edc 100644 --- a/debootstrap-ng.sh +++ b/debootstrap-ng.sh @@ -142,6 +142,8 @@ debootstrap_ng() umount $DEST/cache/sdcard fi + rm -rf $DEST/cache/sdcard + # remove exit trap trap - INT TERM EXIT @@ -168,7 +170,7 @@ create_rootfs_cache() # stage: debootstrap base system # apt-cacher-ng mirror configurarion - if [[ $RELEASE = trusty ]]; then + if [[ $RELEASE == trusty || $RELEASE == xenial ]]; then local apt_mirror="http://localhost:3142/ports.ubuntu.com/" else local apt_mirror="http://localhost:3142/httpredir.debian.org/debian" @@ -526,6 +528,8 @@ unmount_on_exit() losetup -d $LOOP >/dev/null 2>&1 + rm -rf $DEST/cache/sdcard + exit_with_error "debootstrap-ng was interrupted" } ############################################################################# diff --git a/documentation/fel-boot.md b/documentation/fel-boot.md new file mode 100644 index 000000000000..ca1ecd42a572 --- /dev/null +++ b/documentation/fel-boot.md @@ -0,0 +1,59 @@ +# FEL/NFS boot explanation + +### What is FEL/NFS boot? + +FEL/NFS boot mode is a possibility to test freshly created Armbian distribution without using SD card. It is implemented by loading u-boot, kernel, boot script and .bin/.dtb file via [USB FEL mode](https://linux-sunxi.org/FEL/USBBoot) and providing root filesystem via NFS share. + +Note, this mode is designed only for testing. To use root on NFS, use `ROOTFS_TYPE=nfs` option. + +### Requirements + +- Allwinner device that supports FEL mode. Check [wiki](https://linux-sunxi.org/FEL) to find out how to enter FEL mode with your device +- USB connection between build host and board OTG port (VM USB passthrough or USB over IP may work too) +- Network connection between build host and board. For target board **wired** Ethernet connection is required (either via onboard Ethernet or via USB ethernet adapter that has required kernel modules built-in) +- NFS ports on build host should be reachable from board perspective (you may need to open ports in firewall or change network configuration of your VM) +- Selected kernel should have built-in support for DHCP and NFS root filesystem + +#### Additional requirements (recommended) + +- DHCP server in local network +- UART console connected to target board + +### Build script options + +- KERNEL_ONLY=no +- EXTENDED_DEBOOTSTRAP=yes +- ROOTFS_TYPE=fel + +Example: +``` +./compile.sh KERNEL_ONLY=no BOARD=cubietruck BRANCH=next PROGRESS_DISPLAY=plain USE_MAINLINE_GOOGLE_MIRROR=yes RELEASE=jessie BUILD_DESKTOP=no EXTENDED_DEBOOTSTRAP=yes ROOTFS_TYPE=fel +``` + +### Shutdown and reboot + +Once you start FEL boot, you will see this prompt: + +``` +[ o.k. ] Press to boot again, to finish [ FEL ] +``` + +Pressing `q` (or any key other than `b`) deletes current rootfs and finishes build process, so you need to shut down or reboot your board to avoid possible problems. All changes to root filesystem will persist until you exit FEL mode. + +To reboot again into testing system, switch your board into FEL mode and press `b`. + +Because kernel and .bin/.dtb file are loaded from rootfs each time, it's possible to update kernel or its configuration (via `apt-get`, `dtc`, `fex2bin`/`bin2fex`) from within running system. + +### Advanced configuration + +If you don't have DHCP server in your local network or if you need to alter kernel command line, use `lib/scripts/fel-boot.cmd.template` as a template and save modified script as `userpatches/fel-boot.cmd`. Check [this](https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/Documentation/filesystems/nfs/nfsroot.txt) for configuring static IP for NFS root + +Set `FEL_DTB_FILE` to relative path to .dtb or .bin file if it can't be obtained from u-boot config (mainline kernel) or boot/script.bin (legacy kernel) + +You may need to set these additional options (it's a good idea to put them in `userpatches/lib.config`: + +Set `FEL_NET_IFNAME` to name of your network interface if you have more than one non-loopback interface with assigned IPv4 address on your build host + +Set `FEL_LOCAL_IP` to IP address that can be used to reach NFS server on your build host if it can't be obtained from ifconfig (i.e. port forwarding to VM guest) + +Set `FEL_AUTO=yes` to skip prompt before trying FEL load diff --git a/fel-load.sh b/fel-load.sh index 93045d1f434e..63a9b8332fbb 100644 --- a/fel-load.sh +++ b/fel-load.sh @@ -9,26 +9,9 @@ # This file is a part of tool chain https://github.com/igorpecovnik/lib # -## NOTES -# -# Set FEL_NET_IFNAME to name of your network interface if you have -# more than one non-loopback interface with assigned IPv4 address -# -# Set FEL_LOCAL_IP to IP address that can be used to reach NFS on your build host -# if it can't be obtained from ifconfig (i.e. port forwarding to VM guest) -# -# It's a good idea to set these settings in userpatches/lib.config if needed - - -# Set FEL_DTB_FILE to relative path to .dtb or .bin file if it can't be obtained -# from u-boot config (mainline) or boot/script.bin (legacy) -# # FEL_ROOTFS should be set to path to debootstrapped root filesystem # unless you want to kill your /etc/fstab and share your rootfs on NFS # without any access control -# -# Set FEL_AUTO to "yes" to skip prompt before trying FEL load -# fel_prepare_host() { @@ -41,7 +24,12 @@ fel_prepare_host() fel_prepare_target() { - cp $SRC/lib/scripts/fel-boot.cmd.template $FEL_ROOTFS/boot/boot.cmd + if [[ -f $SRC/userpatches/fel-boot.cmd ]]; then + display_alert "Using custom boot script" "userpatches/fel-boot.cmd" "info" + cp $SRC/userpatches/fel-boot.cmd $FEL_ROOTFS/boot/boot.cmd + else + cp $SRC/lib/scripts/fel-boot.cmd.template $FEL_ROOTFS/boot/boot.cmd + fi if [[ -z $FEL_LOCAL_IP ]]; then FEL_LOCAL_IP=$(ifconfig $FEL_NET_IFNAME | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') fi From 619f0880dfcebfcf5f4b750d2c9e95496f5ae521 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Mon, 7 Mar 2016 20:46:57 +0300 Subject: [PATCH 2/2] Small correction --- documentation/fel-boot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/fel-boot.md b/documentation/fel-boot.md index ca1ecd42a572..7eead7b71a35 100644 --- a/documentation/fel-boot.md +++ b/documentation/fel-boot.md @@ -4,7 +4,7 @@ FEL/NFS boot mode is a possibility to test freshly created Armbian distribution without using SD card. It is implemented by loading u-boot, kernel, boot script and .bin/.dtb file via [USB FEL mode](https://linux-sunxi.org/FEL/USBBoot) and providing root filesystem via NFS share. -Note, this mode is designed only for testing. To use root on NFS, use `ROOTFS_TYPE=nfs` option. +Note, this mode is designed only for testing. To use root on NFS permanently, use `ROOTFS_TYPE=nfs` option. ### Requirements