3 3
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
On 4/11/2018 at 1:57 AM, gspillman said:

#

# Save Config to "arch/arm64/configs/fireflyrk3328_linux_defconfig"
#-------

 

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

Making the kernel I got:
 

CC      fs/nfs/dir.o
  CC      drivers/gpu/drm/drm_panel.o
drivers/gpu/arm/midgard/ipa/mali_kbase_ipa.c:582:22: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
error, forbidden warning:mali_kbase_ipa.c:582
  .get_static_power = &kbase_get_static_power,
                      ^
drivers/gpu/arm/midgard/ipa/mali_kbase_ipa.c:582:22: note: (near initialization for 'kbase_ipa_power_model_ops.get_static_power')
drivers/gpu/arm/midgard/ipa/mali_kbase_ipa.c:583:23: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
error, forbidden warning:mali_kbase_ipa.c:583
  .get_dynamic_power = &kbase_get_dynamic_power,
                       ^
drivers/gpu/arm/midgard/ipa/mali_kbase_ipa.c:583:23: note: (near initialization for 'kbase_ipa_power_model_ops.get_dynamic_power')
scripts/Makefile.build:277: recipe for target 'drivers/gpu/arm/midgard/ipa/mali_kbase_ipa.o' failed
make[4]: *** [drivers/gpu/arm/midgard/ipa/mali_kbase_ipa.o] Error 1
scripts/Makefile.build:484: recipe for target 'drivers/gpu/arm/midgard' failed
make[3]: *** [drivers/gpu/arm/midgard] Error 2
scripts/Makefile.build:484: recipe for target 'drivers/gpu/arm' failed
make[2]: *** [drivers/gpu/arm] Error 2
make[2]: *** Waiting for unfinished jobs....
  CC      drivers/gpu/drm/drm_of.o

......

LD      drivers/gpu/drm/built-in.o
scripts/Makefile.build:484: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1031: recipe for target 'drivers' failed
make: *** [drivers] Error 2
make: *** Waiting for unfinished jobs....
  CC      lib/fonts/font_8x8.o

....
LD      net/built-in.o
 MAKE KERNEL IMAGE FAILED.

Share this post


Link to post
Share on other sites
6 minutes ago, Igor said:


This doesn't seems to be compiling using our tools nor sources we use.

 

Ooopps!

 

Just kidding then!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
3 3