FalcoGer
Posts: 35
Joined: Mon Jul 09, 2018 6:35 am

Tutorial: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Thu Aug 09, 2018 5:39 pm

Overview
After a lot of messing around and plenty of trial and error I managed to find a way to install Ubuntu 18.04 for ARM64 on the Raspberry Pi3B.
To save you the headaches I had, I have compiled this step by step guide. Basic common sense required, please don't just copy+paste the code segments, but instead read through the instructions and have some idea what the code does and if needed adjust to your specific case.

To install Ubuntu in this fashion, you need to do the following steps:
  • Format the SD Card
  • Put the Ubuntu Net Installer onto the SD Card
  • Install Ubuntu
  • Fix the bootloader
  • Configure OS
Most of the information is from here: https://wiki.ubuntu.com/ARM/RaspberryPi ... .2FAArch64
However there are some Issues and I'd like to give a step by step manual where everything is in the correct order.

For the manual you need a working linux distribution, either native or on a VM.
I used Ubuntu 18.04 AMD64 Desktop version on Oracle VM, but anything should be okay.

Format SD Card
First you need to put the SD card into your linux desktop. If you're using a VM, then pass through the USB card reader to it before inserting the SD card. Otherwise windows might want to format it for you or create SystemVolumeInformation or other such nonsense.
Insert the card. If it was mounted automatically, then unmount it.

Get Ubuntu for your desktop/laptop or use a VM (like vmware or oracle vm) with ubuntu, 64bit
If using a vm, then pass through the usb card reader to it.
Insert the sd card into your desktop pc
if not installed, install gparted on your linux machine. Of course parted works fine too, if you prefer the console.

With GParted
  • Delete partition table on SD Card
  • Create msdos partition table on SD Card
  • Create Primary Partion 1 with FAT32 about 128MB
  • Set 'Boot' Flag
Leave the rest empty. It will be formatted during the installation.

Mount the partition to /mnt, actual drive device may vary (meaning it might not be sdb, check gparted for the name)

Code: Select all

sudo mount /dev/sdb1 /mnt
This is where the bootloader and the net installer image goes later.
Installing the net installer onto the partition
Now that the device is formatted and you can work on getting the net installer onto the SD card

Get the bootloader

Code: Select all

wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-bootloader_1.20180417-1_armhf.deb
dpkg-deb -x raspberrypi-bootloader_1.20180417-1_armhf.deb ~/Desktop/pi-bootloader
rm raspberrypi-bootloader_1.20180417-1_armhf.deb
sudo cp ~/Desktop/pi-bootloader/boot* /mnt
Get and crosscompile UBoot

Code: Select all

sudo apt-get install build-essential bison flex git make gcc gcc-aarch64-linux-gnu
git clone --progress http://git.denx.de/u-boot.git
cd u-boot
make rpi_3_defconfig
make CROSS_COMPILE=aarch64-linux-gnu-
sudo cp u-boot.bin /mnt/kernel8.img
cd ..
Copy the device tree blob (.dtb)
(although I have no idea where it is stated that it should be loaded or even what it does)

Code: Select all

wget http://ports.ubuntu.com/dists/bionic/main/installer-arm64/current/images/device-tree/bcm2837-rpi-3-b.dtb
sudo mkdir /mnt/dtb/broadcom/
sudo cp bcm2837-rpi-3-b.dtb /mnt/dtb/broadcom
Download the net installer mini-iso and copy it onto the sd card
Get the iso from here: https://www.ubuntu.com/download/server/arm
Select the net installation.

Code: Select all

mkdir /tmp/mini-iso
sudo mount -o loop mini.iso /tmp/mini-iso
sudo cp -rT /tmp/mini-iso /mnt
mkdir /tmp/efi-img
sudo mount -o loop /tmp/mini-iso/boot/grub/efi.img /tmp/efi-img
sudo cp -rT /tmp/efi-img /mnt
sudo umount /tmp/efi-img
sudo umount /tmp/mini-iso
Force write changes and unmount the card.
This is to make sure everything was written correctly to the card.

Code: Select all

sync
sudo umount /mnt
now you have a bootable sd card that can be used to install ubuntu from network

Install Ubuntu using the net installer onto SD Card
  • Stick the card into the Raspberry Pi 3B
  • Boot it up.
  • Select Install
  • Set Locale, Keyboard layout, Geographic position, etc
  • Partition disk. (I use a 16GB SD Card like this:
    • 128MB Fat32 boot partition (part1) - select this partition to not be altered! (i.e. not used)
    • 1.5GB swap partition (part2)
    • rest ext4 mounted on / (part3))
  • Additional software: Don't install desktop environment at this point, openssh if wanted
  • Grub installation (expectedly) fails -> continue without bootloader
  • set clock to utc
at this point you have ubuntu installed, but can't actually boot to it.
Bend grub.cfg to boot ubuntu automatically
After a restart you will be prompted to install Ubuntu again. Do not select an option, and instead press the C-key to drop into the shell.
There use

Code: Select all

ls
to figure out what your drives are called. Mine were (hd0,msdos1), (hd0,msdos2) and (hd0,msdos3)
Set the root file system with

Code: Select all

set root=(hd0,msdos3)
and then try to read the file system with

Code: Select all

ls /
This should list a unix file system root with all the typical directories in them. (/var, /run/, /tmp, /root, /usr, /bin, /etc, ...), if so then that's your ubuntu installation.
Try to manually boot Ubuntu with

Code: Select all

set root=(hd0,msdos3) # if not done already
linux /boot/vmlinuz root=/dev/mmcblk0p3
initrd /boot/initrd.img
boot
If this works then you're almost done.

So shut down the pi and put the SD card back into your desktop linux that you used to make your SD card and mount partition 1 where the net installer is. Then go to /boot/grub/ and edit grub.cfg (on the SD card, not your local machine.)

At the top, after some color settings, there should be a line like this:

Code: Select all

insmod gzio
so just below that add

Code: Select all

set timeout=10

menuentry 'Ubuntu' {
	set background_color=black
	set root=(hd0,msdos3)
	linux /boot/vmlinuz root=/dev/mmcblk0p3
	initrd /boot/initrd.img
}
menuentry 'UbuntuOLD' {
	set background_color=black
	set root=(hd0,msdos3)
	linux /boot/vmlinuz.old root=/dev/mmcblk0p3
	initrd /boot/initrd.img.old
}
Now you're all done!

To boot from USB you need to change out /dev/mmcblk0p3 to /dev/sda3 I think.
also you might want to call

Code: Select all

ls
From the grub shell to make sure it's (hd0)
This is of course not safe if you plug multiple usb devices and/or sd cards in as this will shift the hard drive numbers around.
EDIT: I figured out how to use UUIDs to reference the partitions in grub. See the Final Touches section below.
Your OTP memory on your pi3b (not +) needs to be set to allow USB booting first, but I suppose you could use Raspbian for that.
I havn't tried booting my Ubuntu setup from USB yet

Boot and configure your new, shiny Ubuntu for arm64
It takes some time to boot. so give it 2 or 3 minutes.
There are also 4 error messages that some grub files are not found. You can ignore those messages, it boots anyway.
EDIT: They can not be safely ignored. Sometimes (I don't know the mechanism for that) it will promt you to 'press any key to continue'. How to fix the errors is down in the Final Touches section.

After installing and correct booting you can install your desktop environment if you desire.

Code: Select all

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install xubuntu-desktop
Or whichever one you want.

For me there is an issue where the Desktop hangs due to my specific HDMI monitor. This is a faulty HDMI (VC4) kernel module. You don't actually need it, so it can be safely blacklisted.
REF: https://fedoraproject.org/wiki/Architec ... Usage_Tips

on your pi, or add it from your desktop linux.

Code: Select all

echo blacklist vc4 > /etc/modprobe.d/blacklist-vc4.conf
Hope this helps.

Final touches
To get rid of the boot errors from grub because of missing .mod files copy the files from
https://packages.debian.org/jessie/arm6 ... n/download
to (part1)/boot/grub/arm64-efi/


You can switch out the hard links to partion and hard drive numbers in grub config with your drives UUIDs
First open a shell in your ubuntu on your pi and type

Code: Select all

sudo blkid
this will list all your drives with their UUIDs.
change your grub config in this way:

Code: Select all

menuentry 'Ubuntu' {
	set background_color=black
	# set root=(hd0,msdos3)
	search --no-floppy --fs-uuid --set=root <UUID HERE>
	# linux /boot/vmlinuz root=/dev/mmcblk0p3
	linux /boot/vmlinuz root=UUID=<UUID HERE>
	initrd /boot/initrd.img
}
menuentry 'UbuntuOLD' {
	set background_color=black
	# set root=(hd0,msdos3)
	search --no-floppy --fs-uuid --set=root <UUID HERE>
	# linux /boot/vmlinuz.old root=/dev/mmcblk0p3
	linux /boot/vmlinuz.old root=UUID=<UUID HERE>
	initrd /boot/initrd.img.old
}
To set up autologin like raspbian:
create /etc/ligtdm/lightdm.conf with the following content:

Code: Select all

[Seat:*]
autologin-user=<USERNAME>
autologin-user-timeout=0
Make grub pretty (xterm):
get unicode.pf2 from (part3)/boot/grub/fonts/unicode.pf2 and copy it to (part1)/boot/grub/fonts/unicode.pf2
before the menuentry settings in grub.cfg add the following lines

Code: Select all

# menu color and gzio goes up here

# load graphics
font=unicode
if loadfont $font ; then
    set gfxmode=auto
    insmod all_video
    insmod gfxterm
    set locale_dir=$prefix/locale
    set lang=en_US # or whatever else you have
    insmod gettext
fi
terminal_output gfxterm

# menu goes down here
note: I mainly copied the lines from my VM ubuntu's grub config. I checked in the grub console on the pi all the if [ x$feature_whatever_feature = xy ]
you can check with
echo $feature_whatever_feature and check if it's 'y'
and then copied the relevant branch.
This might not work for you.

WiFi
I didn't personally try this yet, but for sure it doesn't work by default. I don't need it though.
REF: https://wiki.ubuntu.com/ARM/RaspberryPi#WiFi
Last edited by FalcoGer on Wed Aug 15, 2018 12:15 pm, edited 16 times in total.

jahboater
Posts: 2917
Joined: Wed Feb 04, 2015 6:38 pm

Re: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Thu Aug 09, 2018 5:57 pm

Many thanks for this well written tutorial.
I'll try it ASAP.

FalcoGer
Posts: 35
Joined: Mon Jul 09, 2018 6:35 am

Re: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Thu Aug 09, 2018 6:20 pm

jahboater wrote:
Thu Aug 09, 2018 5:57 pm
Many thanks for this well written tutorial.
I'll try it ASAP.
tell me how it goes for you. and be prepared, even with a good connection this will take you at least half a day. At least all the installing does. and there are a couple of times when the pi wants your prompts during installation, so you need to have a look over every few minutes.

jahboater
Posts: 2917
Joined: Wed Feb 04, 2015 6:38 pm

Re: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Fri Aug 10, 2018 9:59 am

Does this work for the new Pi3B+ ?

procount
Posts: 1258
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Fri Aug 10, 2018 10:12 am

Great tutorial - I may use it to build my own Ubuntu 18.04 version and distribute it via PINN.

In the meantime, for those who can't or don't want to build it themselves, PINN can install the Raspex 64-bit version of Ubuntu 18.04.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

FalcoGer
Posts: 35
Joined: Mon Jul 09, 2018 6:35 am

Re: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Fri Aug 10, 2018 12:42 pm

jahboater wrote:
Fri Aug 10, 2018 9:59 am
Does this work for the new Pi3B+ ?
no clue, I don't have one. you can try it out and post your results though.
I don't see why it wouldn't work.

procount
Posts: 1258
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Fri Aug 10, 2018 2:14 pm

The Raspex version works with 3B+ so I suspect this version will too, but I don't know for sure.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

jahboater
Posts: 2917
Joined: Wed Feb 04, 2015 6:38 pm

Re: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Sat Aug 11, 2018 6:13 am

Its complaining about my compiler .....

Code: Select all

$ make CROSS_COMPILE=aarch64-linux-gnu-
scripts/kconfig/conf  --syncconfig Kconfig
  CHK     include/config.h
  UPD     include/config.h
  CFG     u-boot.cfg
  GEN     include/autoconf.mk
  GEN     include/autoconf.mk.dep
*** Your GCC is older than 6.0 and is not supported
arch/arm/config.mk:66: recipe for target 'checkgcc6' failed
make: *** [checkgcc6] Error 1
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --enable-languages=c,c++ --enable-checking=no
Thread model: posix
gcc version 8.2.0 (GCC) 

FalcoGer
Posts: 35
Joined: Mon Jul 09, 2018 6:35 am

Re: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Sat Aug 11, 2018 8:06 am

that's odd.
It worked just fine for me on Ubuntu 18.04 LTS on oracle virtual box. after apt-getting build-essentials.
you might want to try that.

Sosha
Posts: 1
Joined: Wed Aug 08, 2018 3:38 pm

Re: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Sat Aug 11, 2018 8:14 am

jahboater wrote:
Fri Aug 10, 2018 9:59 am
Does this work for the new Pi3B+ ?
i boot ubuntu server 18.04 arm64 successfully on raspberry pi 3B+, but showing message to me: "Net: No Ethernet Found."
This is a similar problem that I had with a ubuntu server 18.04 armhf. The boot time in the "start of network service", stopping and did not continue.

I got really tired :(...

FalcoGer
Posts: 35
Joined: Mon Jul 09, 2018 6:35 am

Re: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Tue Aug 14, 2018 4:18 pm

So did this actually work for anyone but me?

huww98
Posts: 1
Joined: Thu Sep 06, 2018 2:05 pm

Re: Tutorial: How to install Ubuntu 18.04 for ARM64 on Raspberry Pi 3B

Thu Sep 06, 2018 2:16 pm

I have successfully get into GRUB, however I can't select Install, my keyboard is not recognized, I have no idea what goes wrong.
I'm working with Raspberry Pi 3B.

I have tried two keyboard.
with the first one, U-boot reports "USB0: Scanning bus 0 for devices... cannot reset port 3!7"
with the second one, U-boot reports "USB device not accepting new address (error=0)"

Can anyone help me with this? Thanks in advance.

Return to “Other”

Who is online

Users browsing this forum: No registered users and 2 guests