Rpi3 64bit kernel and U-boot booting up

Cross-build prerequisite:

gcc-arch64-linux-gnu          g++-5               ncurses-dev
make       git           bc          u-boot-tools          device-tree-compiler

Assuming there is already a Cross-build environment: Built on Ubuntu Server 16.04.02

Prerequisites:

Ubuntu Base Rootfs (install additional package using apt-get)
Raspberry pi kernel (Have not tried using Upstream kernel)
Raspberry pi firmware (bootcode.bin, start.elf, fixup.dat and the rest of start_ and fixup_)
U-boot


µSD card:(assuming you already know how)

Your µSD card(boot partition) should contain the following:

bootcode.bin
start.elf (and the rest of the start_ file)
fixup.dat (and the rest of the fixup_ file)
config.txt
cmdline.txt

For the config.txt and cmdline.txt, we have to create them and include this lines.

config.txt:

arm_control=0x200
force_turboo=1
enable_uart=1
device_tree_address=0x100
device_tree_end=0x8000
#kernel=u-boot.bin
dtparam=i2c_arm=on
dtparam=spi=on

cmdline.txt:

net.ifnames=0 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait


U-Boot:

Get the source code by cloning the U-Boot git repository or download the tar file.

git clone –depth 1 –branch v2017.03 –single-branch git://git.denx.de/u-boot.git
ftp://ftp.denx.de/pub/u-boot/u-boot-2017.03.tar.bz2

Then configure and build u-boot. For 64-bit use rpi_3_defconfig

cd u-boot/
sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- rpi_3_defconfig

Then compile it.

sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

To change output directory use O=directory path/

sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=directory path/

After it has been built. Locate u-boot.bin as this is the file we need. Copy it to your µSD card and rename it to kernel8.img or keep its name as it is and uncomment the line kernel=u-boot.bin in config.txt. Boot it up to confirm that it’s working.


Kernel:

Get the kernel source code at the official Raspberry pi git repository.

git clone –depth 1 –branch v2017.03 –single-branch https://github.com/raspberrypi/linux.git

Use bcmrpi3_defconfig for kernel config. You can further configure it according to your needs. But for now, its fine to leave it be.

cd linux
sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcmrpi3_defconfig
sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j 3
after the above compiled run for device-tree-blob:
sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j 3 dtbs

Locate Image (no need to convert for U-Boot use it as it is for 64bit) file at arch/arm64/boot/ and the bcm2710-rpi-3-b.dtb at arch/arm/boot/dts/. I’m having trouble using bcm2837-rpi-3-b.dtb. So for now use bcm2710-rpi-3-b.dtb instead. Copy the Image and bcm2710-rpi-3-b.dtb files to your µSD card boot partition. At this point, you can test it if it will boot the kernel but we need to have a boot script that U-Boot needs. We’re using the boot.script from this file: 20160517-raspi3-arm64-firmware-kernel.tar.xz. Modify and create the boot.scr from it.

boot.script should look like this:

fdt addr 0x100
fdt get value bootargs /chosen bootargs
setenv kernel_addr_r 0x01000000
setenv ramdisk_addr_r 0x02100000
fatload mmc 0:1 ${kernel_addr_r} Image
fatload mmc 0:1 ${ramdisk_addr_r} initrd.img
setenv initrdsize $filesize
fatload mmc 0:1 ${fdt_addr_r} bcm2710-rpi-3-b.dtb
booti ${kernel_addr_r} ${ramdisk_addr_r}:${initrdsize} ${fdt_addr_r}

Since we don’t have a Ramdisk yet, comment that line and replace ${ramdisk_addr_r}:${initrdsize} with ‘-‘. removing the apostrope
Or copy the initrd.img to use it temporarily. You can now then verify at this point that our kernel boot as well and will stop at some point since we still do not have a filesystem.

next post will be about on how to make a filesystem base on Ubuntu Base.

rpi3-64

Reference:

https://wiki.ubuntu.com/ARM/RaspberryPi/RaspberryPi3

https://wiki.ubuntu.com/Base

https://www.raspberrypi.org/documentation/linux/kernel/building.md

https://kernelnomicon.org/?p=682

Donate

Advertisements
About

From Philippines. a new comer in using raspberry pi 3

Tagged with:
Posted in Raspberry pi 3
2 comments on “Rpi3 64bit kernel and U-boot booting up
  1. That is a really good tip especially to those fresh to the blogosphere. Brief but very accurate information… Appreciate your sharing this one. A must read post!

    Like

  2. If you are going for finest contents like myself, only go to see this web site everyday since it offers feature contents, thanks

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: