bholland

Document about compiling a kernel, and rootfs for the firefly boards

Recommended Posts

Hello all,

 

I wrote up this documentation mostly as notes to myself about how I successfully built a kernel and ubuntu core rootfs.  If you could let me know how to improve it, please let me know. I don't generally write documentation. I focused on the roc-rk3328-cc but it should work okay for a variety of the Firefly chips. 

 

Thanks,

~Ben

barebone_to_ubunutu.md

Share this post


Link to post
Share on other sites

Thanks for the docs.  But have run into some issues trying to use it. 

  1. mk_kernel.sh got an error because of missing "mmd" command.  Installed it using "sudo apt install mtools".
  2. mk_uboot.sh got error for because of missing u-boot folder.  Created it manually using "mkdir u-boot".
  3. Finally got stuck with another error in mk_uboot.sh.  It complains of missing rule for target "roc-rk3328-cc_defconfig"  I am unable to locate this file anywhere on my system.

Below is what I attempted, step by step.  Thanks for any help you can provide.

 

Guy

 

######################################
# Created VirtualBox VM with:
#   4 processosors, 2 GB Memory, 20 GB Storage
#   Installed Kubuntu 16.04
######################################

 

sudo apt update
sudo apt upgrade

 

##############
# Rebooted VM
##############

 

sudo apt install git gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu device-tree-compiler lzop libncurses5-dev libssl1.0.0 libssl-dev qemu qemu-user-static binfmt-support debootstrap

mkdir ~/temp/firefly_build
cd ~/temp/firefly_build
git clone https://github.com/FireflyTeam/kernel.git
git clone https://github.com/FireflyTeam/build.git
git clone https://github.com/FireflyTeam/rkbin.git

cd kernel
make menuconfig

 

########################################################
# Added settings for built-in TUN/TAP:
### Device Drivers --> Network Device Support ---> Universal TUN/TAP device driver support

 

# Added settings for built-in Xtables
### Networking Support ---> Networking Options ---> Network packet filtering framework (Netfilter) ---> Core Netfilter Configuration ---> Netfilter Xtables support

 

# Added settings for built-in IP Tables
### Networking Support ---> Networking Options ---> Network packet filtering framework (Netfilter) ---> Network packet filtering framework
########################################################

 

cd ..
./build/mk-kernel.sh roc-rk3328-cc

 

#####################################################################
# This caused an ERROR to be generated:

 

### Generate Boot image start
###mkfs.fat 3.0.28 (2015-05-16)
###mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
###./build/mk-image.sh: line 59: mmd: command not found
### MAKE KERNEL IMAGE FAILED.

 

# Found the "mmd" command in the mtools package:
#####################################################################

 

sudo apt install mtools
./build/mk-kernel.sh roc-rk3328-cc

 

#####################################################################
# Now I get success messages:

 

### Generate Boot image start
###mkfs.fat 3.0.28 (2015-05-16)
###mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
### Generate Boot image : /home/gspillman/temp/firefly_build/out/boot.img success!
### Kernel build success!
#####################################################################

 

./build/mk-uboot.sh roc-rk3328-cc

 

##################################################################################
# This caused another ERROR:

 

### Building U-boot for roc-rk3328-cc board!
### Using roc-rk3328-cc_defconfig
###./build/mk-uboot.sh: line 35: cd: /home/gspillman/temp/firefly_build/u-boot: No such file or directory
### MAKE UBOOT IMAGE FAILED.

 

# OK, lets manually create the u-boot directory
##################################################################################

 

mkdir u-boot
./build/mk-uboot.sh roc-rk3328-cc

 

#######################################################
# Now get different ERROR:

 

### Building U-boot for roc-rk3328-cc board!
### Using roc-rk3328-cc_defconfig
###make: *** No rule to make target 'roc-rk3328-cc_defconfig'.  Stop.
### MAKE UBOOT IMAGE FAILED.

 

# Using the following returns no results:
### find -iname roc-rk3328-cc_defconfig
#######################################################

 

 

Share this post


Link to post
Share on other sites

Finally got a bootable image file, and have OpenVPN running on the FireFly Renegade (ROC-3328-CC).  I'm now getting around 90 megabit per second throughput, as opposed to 30 megabit with the Raspberry Pi 3.  I think the Renegade could probably do more, as I am hitting the limits of my ISP.

 

The one major change I made was to use Ubuntu 16.04.4, which only needed about a dozen packages upgraded.  When you did an "apt upgrade" with 16.04.1, it effectively brought you up to 16.04.4 by upgrading 300+ packages.

 

Thank you to bholland, who's instructions got me most of the way, and Cameron Ross, who provided the last missing piece to the puzzle.

 

Below is what I did to create my bootable image file.  You should still read bholland's instructions as it has more in-depth descriptions for each step.  Make sure to replace <new user> and <hostname> with meaningful values.

 

Guy

 

#-------
# Created VirtualBox VM with:
#   4 processosors
#   2 GB Memory
#   30 GB Storage
#   Installed Kubuntu 16.04.4
#-------

 

sudo apt update
sudo apt upgrade

 

#-------
# Reboot VM
#-------

 

sudo apt install git gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu device-tree-compiler lzop libncurses5-dev libssl1.0.0 libssl-dev qemu qemu-user-static binfmt-support debootstrap swig libpython-dev mtools pv

 

mkdir ~/temp
mkdir ~/temp/firefly_build

git clone https://github.com/FireflyTeam/kernel.git
git clone https://github.com/FireflyTeam/build.git
git clone https://github.com/FireflyTeam/rkbin.git
git clone https://github.com/FireflyTeam/u-boot.git

 

cd kernel
make menuconfig

 

#-------
# Load Config from "arch/arm64/configs/fireflyrk3328_linux_defconfig"
#
# Device Drivers -->
#   Network Device Support --->
#     Universal TUN/TAP device driver support <Mark with an asterisk(*)>
#
# Networking Support --->
#   Networking Options --->
#     Network packet filtering framework (Netfilter) --->
#       Core Netfilter Configuration --->
#         <Mark all options with an asterisk (*)>
#
# Networking Support --->
#   Networking Options --->
#     Network packet filtering framework (Netfilter) --->
#      IP: Net Filter configurations -->
#        <Mark all options with an asterisk (*)>
#
# Save Config to "arch/arm64/configs/fireflyrk3328_linux_defconfig"
#-------

 

cd ..
./build/mk-kernel.sh roc-rk3328-cc
./build/mk-uboot.sh roc-rk3328-cc

mkdir ubuntu_core
install -d ./ubuntu_core/{linux,rootfs,archives/{ubuntu-base,debs,hwpacks},images,scripts}
cd ubuntu_core
wget -P archives/ubuntu-base -c http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.4/release/ubuntu-base-16.04.4-base-arm64.tar.gz

 

dd if=/dev/zero of=images/rootfs.img bs=1M count=0 seek=1000
sudo mkfs.ext4 -F -L ROOTFS images/rootfs.img
# <enter user password>
rm -rf rootfs && install -d rootfs
sudo mount -o loop images/rootfs.img rootfs
sudo rm -rf rootfs/lost+found
sudo tar -xzf archives/ubuntu-base/ubuntu-base-16.04.4-base-arm64.tar.gz -C rootfs/
sudo cp -a /usr/bin/qemu-aarch64-static rootfs/usr/bin/

 

sudo chroot rootfs/
passwd root
# <enter new root password>
# <re-enter new root password>

useradd -G sudo -m -s /bin/bash <new user>
passwd <new user>
# <enter new user password>
# <re-enter new user password>

echo "<hostname>" > /etc/hostname
echo "127.0.0.1    localhost.localdomain localhost" > /etc/hosts
echo "127.0.0.1    <hostname>" >> /etc/hosts
mkdir /etc/network
mkdir /etc/network/interfaces.d
echo "auto eth0" > /etc/network/interfaces.d/eth0
echo "iface eth0 inet dhcp" >> /etc/network/interfaces.d/eth0
echo "nameserver 127.0.1.1" > /etc/resolv.conf

apt update
apt upgrade
apt install ifupdown net-tools sudo ssh iptables openvpn nano unzip

 

exit
sudo sync
# <enter user password>
sudo umount rootfs/

cd ..

 

build/mk-image.sh -c rk3328 -t system -r ubuntu_core/images/rootfs.img
build/flash_tool.sh -c rk3328 -d ubuntu_16.04.4_roc-rk3328-cc_arch64_$(date +%Y%m%d).img -p system -i out/system.img

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now