satadru
Posts: 11
Joined: Thu Apr 18, 2013 5:18 pm

Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Mon Jul 29, 2019 9:56 pm

I spent a couple of days hacking together a docker setup to create flashable Ubuntu images for the Raspberry Pi 4B which cross-compile current Raspberry Pi kernels and integrate them into the image.

Note that this runs in privileged mode, so you're going to have to use this on your own servers.

https://github.com/satmandu/docker-rpi4-imagebuilder/

I'm using an ARM64 RPI3 Ubuntu Server 19.10 (Eoan Ermine) Daily Build as a base image, which I get from here:

http://cdimage.ubuntu.com/ubuntu-server ... d/current/

I have the resultant images booting on a 4GB Raspberry Pi 4B, without having to remove initramfs-tools or flash-kernel, and I can see all 4Gb of RAM on the 4Gb RPI 4B.

Instructions were cobbled together from these sites:

https://jamesachambers.com/raspberry-pi ... ion-guide/
https://blog.cloudkernels.net/posts/rpi4-64bit-image/
https://andrei.gherzan.ro/linux/raspbian-rpi-64/
https://andrei.gherzan.ro/linux/raspbian-rpi4-64/
https://github.com/sakaki-/bcm2711-kernel-bis

The docker image is itself hacked off of https://github.com/tsaarni/docker-deb-builder .

Feel free to fork away, or send in useful pull requests.

o635789
Posts: 4
Joined: Tue Jul 16, 2019 4:26 pm

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Tue Jul 30, 2019 4:16 pm

Wow, all 4GB are usable? Thank you very much for the great work! I'll try it out.

User avatar
sakaki
Posts: 324
Joined: Sun Jul 16, 2017 1:11 pm

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Tue Jul 30, 2019 9:48 pm

Nice work satadru!
satadru wrote:
Mon Jul 29, 2019 9:56 pm
I have the resultant images booting on a 4GB Raspberry Pi 4B, without having to remove initramfs-tools or flash-kernel, and I can see all 4Gb of RAM on the 4Gb RPI 4B.
Can you access the USB ports (to read data from a thumb drive etc.) with the full 4GiB enabled? I found I had to set total_mem=3072 at most, even with a rpi-4.19.y kernel built off the tip today; see also this commit comment.

Best, sakaki

cjan
Posts: 719
Joined: Sun May 06, 2012 12:00 am

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Wed Jul 31, 2019 12:11 am

does VC6 work?

User avatar
GuyOthersome
Posts: 3
Joined: Wed Jul 31, 2019 8:41 pm
Contact: Twitter

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Wed Jul 31, 2019 8:43 pm

Is it possible to do this with 18.04.2? Or is this script exclusive to 19.10?

gilius2k15
Posts: 54
Joined: Thu Jul 18, 2019 8:42 am

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Wed Jul 31, 2019 9:59 pm

I don't really understand the concept of this in terms of dockers and server/privileged mode? What has that got to do with making an Ubuntu image for the Raspberry Pi4?

Does the GUI work - or do you get black screen with mouse cursor?

gilius2k15
Posts: 54
Joined: Thu Jul 18, 2019 8:42 am

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Sun Aug 04, 2019 12:44 pm

Had quite a lot of errors and reports of missing packages when I got to this step:
docker build -t docker-rpi4-imagebuilder:19.10 -f Dockerfile-ubuntu-19.10 .

Not sure what host Os and perquisites are recommended?

gilius2k15
Posts: 54
Joined: Thu Jul 18, 2019 8:42 am

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Tue Aug 06, 2019 2:00 pm

It seems like this needs an AMD64 host because one package is not available on ARM64 Linux:
https://packages.ubuntu.com/bionic/cpp- ... -linux-gnu

gilius2k15
Posts: 54
Joined: Thu Jul 18, 2019 8:42 am

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Tue Aug 06, 2019 4:30 pm

Mine got stuck here so I submitted a new issue:
https://github.com/satmandu/docker-rpi4 ... /issues/14
Screenshot from 2019-08-06 15-53-17.jpg
Screenshot from 2019-08-06 15-53-17.jpg (117.2 KiB) Viewed 3430 times

gilius2k15
Posts: 54
Joined: Thu Jul 18, 2019 8:42 am

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Thu Aug 08, 2019 7:03 am

I finally got it working - but there's no KVM enabled in the kernel! :x

There's only 3GB RAM enabled at the moment as per sakaki's method.

VC4 seems turned off but should work because of Ubuntu 19.10 having Mesa 19.1

chideki
Posts: 1
Joined: Mon Aug 19, 2019 3:00 pm

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Mon Aug 19, 2019 3:04 pm

can confirm doing this with bionic. all 4gb working . no need to remove kernel flash etc ... compiling took 6minutes on vmware. rasp pi 4 rouns smoth so far.

User avatar
GuyOthersome
Posts: 3
Joined: Wed Jul 31, 2019 8:41 pm
Contact: Twitter

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Mon Aug 19, 2019 6:23 pm

I'm unable to build 18.04 on macOS Mojave...are there instructions on how to do this? I thought just using "docker-rpi4-imagebuilder:18.04" was supposed to work? Am I blind and not seeing what I'm supposed to do in the instructions?

blu33agl3
Posts: 1
Joined: Mon Aug 19, 2019 10:58 pm

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Mon Aug 19, 2019 11:00 pm

For everyone try
Ubuntu Bionic
Raspberry Pi 4B
https://drive.ddnsthailand.com/index.ph ... zBg6aXm2Ad
password: Bondon1234

mirror 1: https://yadi.sk/d/fXsUZY4qaryEfQ

mirror 2: https://bit.ly/2HeT12J

user/password for login : ubuntu/ubuntu
Last edited by blu33agl3 on Fri Aug 23, 2019 6:16 am, edited 1 time in total.

gilius2k15
Posts: 54
Joined: Thu Jul 18, 2019 8:42 am

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Thu Aug 22, 2019 8:35 pm

Does it have KVM enabled?

sparticle
Posts: 26
Joined: Wed Aug 13, 2014 12:47 pm

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Thu Aug 22, 2019 8:47 pm

This is great but is only 1GB is there an updated version that does not suffer from the 1gb problem and can see 3072 + working USB ports?

Cheers
Spart

sparticle
Posts: 26
Joined: Wed Aug 13, 2014 12:47 pm

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Fri Aug 23, 2019 9:00 am

chideki wrote:
Mon Aug 19, 2019 3:04 pm
can confirm doing this with bionic. all 4gb working . no need to remove kernel flash etc ... compiling took 6minutes on vmware. rasp pi 4 rouns smoth so far.
Can you post the recipe or a lin kto the image file. Is this 18.04 based?

I am looking for a 18.04 LTS image that works with the 4GB Pi 4B.

Cheers
Spart

sparticle
Posts: 26
Joined: Wed Aug 13, 2014 12:47 pm

Re: Docker Raspberry Pi 4B ARM64 Ubuntu Image Builder

Fri Aug 23, 2019 9:45 am

When trying this with Bionic with the following command line: git pull ; time default_base_dist="bionic" base_dist=bionic ./build-image

This is what I get. It successfully downloads the rpi3 image then falls over .

Code: Select all

Successfully tagged docker-rpi4-imagebuilder-v4:18.04
            "docker-rpi4-imagebuilder-v4:18.04"
            "LastTagTime": "2019-08-23T10:32:02.901738619+01:00"
* Downloading bionic-preinstalled-server-arm64+raspi3.img.xz .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  441M  100  441M    0     0  3600k      0  0:02:05  0:02:05 --:--:-- 4088k
* Checking image hash.
local: 754844708a857073e4ebc18efa6caeae3954fbb1
current: 754844708a857073e4ebc18efa6caeae3954fbb1
754844708a857073e4ebc18efa6caeae3954fbb1
* bionic-preinstalled-server-arm64+raspi3.img.xz hash verified.
* Now have local bionic-preinstalled-server-arm64+raspi3.img.xz .
* Extracting /home/sparticle/docker-rpi4-imagebuilder/bionic-preinstalled-server-arm64+raspi3.img .
/home/sparticle/docker-rpi4-imagebuilder/bionic-preinstalled-server-arm64+raspi3.img.xz (1/1)
  100 %     441.1 MiB / 2,404.5 MiB = 0.183    50 MiB/s       0:48             
Creating docker cache volume rpi4-imagebuilder-cache if it does not exist.
rpi4-imagebuilder-cache

Running build in docker:
rm -f /home/sparticle/docker-rpi4-imagebuilder/build.cid ; docker run -dt -e BUILDHOST_ARCH=x86_64 -v /dev:/dev --privileged -dt -v /home/sparticle/docker-rpi4-imagebuilder:/source-ro:ro -v /home/sparticle/docker-rpi4-imagebuilder/output:/output -v /home/sparticle/docker-rpi4-imagebuilder/in-image-script.sh:/in-image-script.sh:ro -e USER=0 -e GROUP=0 --rm -e kernel_branch=rpi-4.19.y -e kernelgitrepo=https://github.com/raspberrypi/linux.git -e CCACHE_DIR=/cache/ccache -v rpi4-imagebuilder-cache:/cache -e src_cache=/cache/src_cache -e apt_cache=/cache/apt_cache -e workdir=/build/source -e base_url=http://cdimage.ubuntu.com/ubuntu-server/bionic/daily-preinstalled/current/ -e base_image=bionic-preinstalled-server-arm64+raspi3.img.xz -e base_dist=bionic -v /home/sparticle/docker-rpi4-imagebuilder/bionic-preinstalled-server-arm64+raspi3.img.xz:/bionic-preinstalled-server-arm64+raspi3.img.xz --tmpfs /flag --tmpfs /tmp -e COLS=112 --cidfile=/home/sparticle/docker-rpi4-imagebuilder/build.cid  docker-rpi4-imagebuilder-v4:18.04 /bin/bash -c "/in-image-script.sh ;  [ -e "/tmp/build.log" ] && (ls -crGg /flag > /tmp/build_fail_status.log ; grep "" /flag/* >> /tmp/build_fail_status.log ; mv /tmp/build.log /tmp/build_fail.log; cp /tmp/*.log /output/ ; chown $USER:$GROUP /output/*.log;  )  || exit 0"

c15dfadea4c99afe35c4077475acc0abb7dbc9a86eff3f517b30da761fda9ee4


cat: '/proc/31406/task/*/children': No such file or directory
Using sudo to renice build container to lowest priority:
(Some renices are expected to fail.)
Note that the command to open a shell into this docker instance would be:

docker exec -it c15dfadea4c99afe35c4077475acc0abb7dbc9a86eff3f517b30da761fda9ee4 /bin/bash

Or run ./shellbuild from this directory.

Tailing build log:

secondary config      (readonly)    /etc/ccache.conf
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                             0
cache hit rate                      0.00 %
cleanups performed                     0
files in cache                         0
cache size                           0.0 kB
Performing cache volume apt autoclean.

                                                                                  Started: base_image_check [ ] 
                                                                                    Started: compiler_setup [ ] 
* Checking for downloaded bionic-preinstalled-server-arm64+raspi3.img.xz .
                                                                                   Started: utility_scripts [ ] 
* Downloaded bionic-preinstalled-server-arm64+raspi3.img.xz exists.
                                                                     utility_scripts waits for: image_mount [/] 
                                                                                     Done: base_image_check [X] 
/in-image-script.sh: line 142: ts: command not found
/in-image-script.sh: line 142: ts: command not found
                                                                              Started: git_get.armstub8-gic [ ] 
                                                                       image_mount waits for: image_extract [/] 
                                                           image_apt_installs waits for: arm64_chroot_setup [/] 
                                                                         Started: git_get.kernelbuild_setup [ ] 
/in-image-script.sh: line 142: ts: command not found
/in-image-script.sh: line 142: ts: command not found
                                                       rpi_cmdline_txt_configuration waits for: image_mount [/] 
                                                          wifi_firmware_modification waits for: image_mount [/] 
                                                        rpi_config_txt_configuration waits for: image_mount [/] 
/in-image-script.sh: line 142: ts: command not found
                                                                         Started: andrei_gherzan_uboot_fork [ ] 
                                                                 Started: git_get.andrei_gherzan_uboot_fork [ ] 
                                                                              Started: git_get.rpi_userland [ ] 
                                                                         Started: git_get.non-free_firmware [ ] 
                                                                              Started: git_get.rpi_firmware [ ] 
/in-image-script.sh: line 142: ts: command not found
                                                            first_boot_scripts_setup waits for: image_mount [/] 
🤔 Build failed. Tailing output/build_fail.log :   😬

                                                            first_boot_scripts_setup waits for: image_mount [/] 
                                                                  image_extract waits for: base_image_check [/] 
                                                                       added_scripts waits for: image_mount [/] 
                                                                  arm64_chroot_setup waits for: image_mount [/] 
/in-image-script.sh: line 142: ts: command not found
/in-image-script.sh: line 142: ts: command not found
/in-image-script.sh: line 142: ts: command not found
/in-image-script.sh: line 142: ts: command not found
/in-image-script.sh: line 142: ts: command not found
/in-image-script.sh: line 142: ts: command not found

real	10m0.900s
user	0m44.920s
sys	0m8.997s
build-fail-status.log says this:

Code: Select all

-rw-r--r-- 1 0 Aug 23 09:35 wait.wifi_firmware_modification_for_image_mount
-rw-r--r-- 1 0 Aug 23 09:35 wait.utility_scripts_for_image_mount
-rw-r--r-- 1 0 Aug 23 09:35 wait.rpi_config_txt_configuration_for_image_mount
-rw-r--r-- 1 0 Aug 23 09:35 wait.rpi_cmdline_txt_configuration_for_image_mount
-rw-r--r-- 1 0 Aug 23 09:35 wait.image_mount_for_image_extract
-rw-r--r-- 1 0 Aug 23 09:35 wait.image_extract_for_base_image_check
-rw-r--r-- 1 0 Aug 23 09:35 wait.image_apt_installs_for_arm64_chroot_setup
-rw-r--r-- 1 0 Aug 23 09:35 wait.first_boot_scripts_setup_for_image_mount
-rw-r--r-- 1 0 Aug 23 09:35 wait.arm64_chroot_setup_for_image_mount
-rw-r--r-- 1 0 Aug 23 09:35 wait.added_scripts_for_image_mount
-rw-r--r-- 1 3 Aug 23 09:35 start.utility_scripts
-rw-r--r-- 1 2 Aug 23 09:35 start.spinnerwait
-rw-r--r-- 1 3 Aug 23 09:35 start.git_get.rpi_userland
-rw-r--r-- 1 3 Aug 23 09:35 start.git_get.rpi_firmware
-rw-r--r-- 1 3 Aug 23 09:35 start.git_get.non-free_firmware
-rw-r--r-- 1 3 Aug 23 09:35 start.git_get.kernelbuild_setup
-rw-r--r-- 1 3 Aug 23 09:35 start.git_get.armstub8-gic
-rw-r--r-- 1 3 Aug 23 09:35 start.git_get.andrei_gherzan_uboot_fork
-rw-r--r-- 1 3 Aug 23 09:35 start.compiler_setup
-rw-r--r-- 1 3 Aug 23 09:35 start.andrei_gherzan_uboot_fork
-rw-r--r-- 1 2 Aug 23 09:35 main
-rw-r--r-- 1 2 Aug 23 09:35 done.ok_to_umount_image_after_build
-rw-r--r-- 1 2 Aug 23 09:35 done.ok_to_exit_container_after_build
-rw-r--r-- 1 2 Aug 23 09:35 done.ok_to_continue_after_mount_image
-rw-r--r-- 1 2 Aug 23 09:35 done.ok_to_continue_after_here
-rw-r--r-- 1 2 Aug 23 09:35 done.base_image_check
/flag/done.base_image_check:6
/flag/done.ok_to_continue_after_here:1
/flag/done.ok_to_continue_after_mount_image:1
/flag/done.ok_to_exit_container_after_build:1
/flag/done.ok_to_umount_image_after_build:1
/flag/main:6
/flag/start.andrei_gherzan_uboot_fork:59
/flag/start.compiler_setup:32
/flag/start.git_get.andrei_gherzan_uboot_fork:59
/flag/start.git_get.armstub8-gic:53
/flag/start.git_get.kernelbuild_setup:60
/flag/start.git_get.non-free_firmware:56
/flag/start.git_get.rpi_firmware:52
/flag/start.git_get.rpi_userland:58
/flag/start.spinnerwait:6
/flag/start.utility_scripts:33
Any help appreciated.

Cheers
Spart

Return to “Other”