Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Mar 7, 2016
2 parents 7ab2eed + 619f088 commit 01bbe8f
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 19 deletions.
6 changes: 5 additions & 1 deletion debootstrap-ng.sh
Expand Up @@ -142,6 +142,8 @@ debootstrap_ng()
umount $DEST/cache/sdcard
fi

rm -rf $DEST/cache/sdcard

# remove exit trap
trap - INT TERM EXIT

Expand All @@ -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"
Expand Down Expand Up @@ -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"

} #############################################################################
59 changes: 59 additions & 0 deletions 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 permanently, 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 <b> to boot again, <q> 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
24 changes: 6 additions & 18 deletions fel-load.sh
Expand Up @@ -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()
{
Expand All @@ -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
Expand Down

0 comments on commit 01bbe8f

Please sign in to comment.