agherzan
Posts: 10
Joined: Fri Jul 05, 2019 4:58 pm

Run Raspbian on Raspberry Pi 4 64bits kernel

Fri Jul 05, 2019 5:57 pm

While adding Yocto support for Raspberry Pi 4 (32 and 64bits) I thought that there are a couple of bits that might help others when integrating various other support for this board.

TL;DR
guide for compiling Raspberry Pi kernel, stubs (including toolchain and cross-compiler)
guide for booting Raspberry Pi 4 on a 64bit kernel
guide for switching Raspbian from 32bit kernel to a 64bit one


Read the full post here: https://andrei.gherzan.ro/linux/raspbian-rpi4-64/.

epoch1970
Posts: 3318
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sat Jul 06, 2019 10:25 am

Great info. Thanks !
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
DougieLawson
Posts: 35516
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sat Jul 06, 2019 11:52 am

I assume that'll work for the RPI3B, 3B+ & 3A that are all 64-bit capable (as demostrated with Sakaki's Gentoo64)?
Note: Having anything remotely humorous in your signature is completely banned on this forum. Wear a tinfoil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sat Jul 06, 2019 2:33 pm

DougieLawson wrote:
Sat Jul 06, 2019 11:52 am
I assume that'll work for the RPI3B, 3B+ & 3A that are all 64-bit capable (as demostrated with Sakaki's Gentoo64)?
Hi Dougie,

The issue agherzan is addressing in his (very nice) guide, is how to get the Pi4 booting in 64-bit mode, and further how to convert an existing 32-bit image (Raspbian Buster) to boot under a 64-bit kernel on this device.

Point being (as regards your question), the Pi4 has a different SoC from the Pi3 which (in this case) requires a differently configured 64-bit kernel (bcm2711_defconfig vs bcmrpi3_defconfig). Also, at the moment, you need an armstub8-gic.bin as well (for the Pi4, also dealt with in agherzan's guide), plus a few other changes (to config.txt, etc.) to make it work properly in 64-bit mode.

So, while there isn't, therefore, a direct read-across from his guide to converting 32-bit images for the Pi3 (to 64-bit boot), the process required to cross-compile a 64-bit kernel for the RPi3 is very similar to that agherzan gives (just with a different defconfig). (I also have instructions for building such a 64-bit kernel for the RPi3 (on a Gentoo PC using crossdev) here.) And actually, once you have an appropriate 64-bit Pi3 (bcmrpi3_defconfig -> kernel8.img) kernel+dtb and matching module set compiled and placed on the bootfs and rootfs accordingly, your Pi3 will automagically use them and start up in 64-bit mode, so in a sense the conversion process is simpler (but different) for the RPi3.

Incidentally, I maintain a weekly autobuild of the bcmrpi3_config kernel here (and of a slightly tweaked version, here), should that be of interest (if you follow the Installation instructions on either page when booted into a 32-bit RPi3 system (which has the bootfs mounted at /boot), and restart, you should find you come back up under a 64-bit kernel!)

Finally, in case it is of interest, I have also posted a convenience tarball of the necessary Pi4 64-bit bootfs and rootfs files, and instructions for image conversion using it (if you want to avoid compilation); see here for further details. This can be used to simply adapt most 32-bit (such as Raspbian Buster) RPi3/4-capable or 64bit (such as gentoo-on-rpi3-64bit) RPi3-capable images for 64-bit boot on the Pi4 (the downside is that the compiled kernel in the tarball will rapidly get out-of-date as fixes are applied).

I intend to bring up a bcm2711_defconfig weekly kernel autobuild in due course.

Best,
sakaki

User avatar
DougieLawson
Posts: 35516
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sat Jul 06, 2019 2:39 pm

Thanks Sakaki. So the bottom line is running Raspbian with a 32-bit userspace and a 64-bit kernel should be possible (but needs some hard work).
Note: Having anything remotely humorous in your signature is completely banned on this forum. Wear a tinfoil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sat Jul 06, 2019 2:53 pm

DougieLawson wrote:
Sat Jul 06, 2019 2:39 pm
Thanks Sakaki. So the bottom line is running Raspbian with a 32-bit userspace and a 64-bit kernel should be possible (but needs some hard work).
Indeed. And actually on the RPi3 you don't even need any nerd work for this particular target: I have a prebuilt, bootable image with a 32-bit Raspbian (Stretch) userland, 64-bit kernel, and 64-bit Debian Buster running in a lightweight nspawn container (raspbian-nspawn-64).

Needs updating for Raspbian Buster userland and the Pi4, will do that at some point, but have a play and see what you think ^-^

Best, sakaki

agherzan
Posts: 10
Joined: Fri Jul 05, 2019 4:58 pm

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sat Jul 06, 2019 11:58 pm

DougieLawson wrote:
Sat Jul 06, 2019 2:39 pm
Thanks Sakaki. So the bottom line is running Raspbian with a 32-bit userspace and a 64-bit kernel should be possible (but needs some hard work).
What do you plan doing? You can use the same guide to build yourself a rpi3 64bit kernel too. The only change is the defconfig in that guide and some config.txt bits that dn't apply (as they are currently workarounds for rpi4).

EDIT: I think I got your point, The blog post should be split in a general "raspbian using kernel 64bit" post (for all capable boards) and another post that would only address the quirks currently needed on rpi4. If that is what you meant, it is a very good point and I'll try to address.

User avatar
DougieLawson
Posts: 35516
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sun Jul 07, 2019 6:55 am

I'm simply planning to hack a copy of Raspbian Buster to run with a 64-bit kernel and 32-bit userspace on a 3B+. Just for the mild amusement of doing that.

I'm not planning to buy a RPi4B until a) they're back in stock and b) the RPF/RP(T) folks have shot more of the bugs in the firmware and Buster.
Note: Having anything remotely humorous in your signature is completely banned on this forum. Wear a tinfoil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sun Jul 07, 2019 8:41 am

Given a Raspbian with a 32-bit userspace and a 64-bit kernel, will it be possible to run 64-bit userspace programs?

User avatar
bensimmo
Posts: 4123
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sun Jul 07, 2019 10:23 am

jahboater wrote:
Sun Jul 07, 2019 8:41 am
Given a Raspbian with a 32-bit userspace and a 64-bit kernel, will it be possible to run 64-bit userspace programs?
Not if the x86 RPD is anything to go by, it uses (for me) the AMD64 kernel and the 32bit userspace.
It gets a bit messed up at times trying to compile/whatever in apt when getting programs or autodetecting .deb.
I have to force/specify :i386 installs when it tries to use the 64 bit version.

---
My question is, what do you gain,.what are the benefits of using the 64bit kernel on the Pi3 &4 ?
curiosity as I don't know.

agherzan
Posts: 10
Joined: Fri Jul 05, 2019 4:58 pm

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sun Jul 07, 2019 11:00 pm

DougieLawson wrote:
Sun Jul 07, 2019 6:55 am
I'm simply planning to hack a copy of Raspbian Buster to run with a 64-bit kernel and 32-bit userspace on a 3B+. Just for the mild amusement of doing that.

I'm not planning to buy a RPi4B until a) they're back in stock and b) the RPF/RP(T) folks have shot more of the bugs in the firmware and Buster.
Here you go. https://andrei.gherzan.ro/linux/raspbian-rpi-64/

song_for_zula
Posts: 1
Joined: Wed Jul 10, 2019 6:49 am

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Wed Jul 10, 2019 6:53 am

Hello,

I am new to rpi development, and havent really built a kernel before, so please bear with me..

I tried following all the steps mentioned at https://andrei.gherzan.ro/linux/raspbian-rpi4-64/. The steps have been explained very well and I successfully completed all the steps.

However, when I insert the card into my board and connect the power, I don't see anything on my monitor. Is there a way I can debug what is going on?

Thanks!

agherzan
Posts: 10
Joined: Fri Jul 05, 2019 4:58 pm

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Thu Jul 11, 2019 3:10 pm

song_for_zula wrote:
Wed Jul 10, 2019 6:53 am
Hello,

I am new to rpi development, and havent really built a kernel before, so please bear with me..

I tried following all the steps mentioned at https://andrei.gherzan.ro/linux/raspbian-rpi4-64/. The steps have been explained very well and I successfully completed all the steps.

However, when I insert the card into my board and connect the power, I don't see anything on my monitor. Is there a way I can debug what is going on?

Thanks!
Have you attached a serial console and ran `depmod`? Also, I think there was a bug in the kernel that was fixed lately in regards to vc4. Can you also try to build the latest HEAD?

a.nanos
Posts: 1
Joined: Wed Nov 02, 2016 9:29 am

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Sun Jul 14, 2019 5:36 pm

Following the instructions of the first post, we managed to build a ubuntu-18.04.2-preinstalled-server-arm64+raspi3.img.xz for the rpi4.

Binary image available here: https://cloudkernels.net/ubuntu-18.04.2 ... kvm.img.xz (sha1sum: 0b1d8b72ea5410fb7928925fd76dd0218b4f7a94)

and info (mostly based on the original posts: https://blog.cloudkernels.net/posts/rpi4-64bit-image/).

Hopefully, the serial console is not needed; if you plug the board to a LAN with DHCP cloud-init should do its tricks (user/pass ubuntu/ubuntu).

agherzan
Posts: 10
Joined: Fri Jul 05, 2019 4:58 pm

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Wed Jul 17, 2019 12:58 pm

agherzan wrote:
Thu Jul 11, 2019 3:10 pm
song_for_zula wrote:
Wed Jul 10, 2019 6:53 am
Hello,

I am new to rpi development, and havent really built a kernel before, so please bear with me..

I tried following all the steps mentioned at https://andrei.gherzan.ro/linux/raspbian-rpi4-64/. The steps have been explained very well and I successfully completed all the steps.

However, when I insert the card into my board and connect the power, I don't see anything on my monitor. Is there a way I can debug what is going on?

Thanks!
Have you attached a serial console and ran `depmod`? Also, I think there was a bug in the kernel that was fixed lately in regards to vc4. Can you also try to build the latest HEAD?
I have updated the guide to do the depmod "dance" on the host and not on the target at first boot. This should get you going.

Zanstel
Posts: 27
Joined: Thu Jul 18, 2019 9:05 am

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Thu Jul 18, 2019 11:29 am

jahboater wrote:
Sun Jul 07, 2019 8:41 am
Given a Raspbian with a 32-bit userspace and a 64-bit kernel, will it be possible to run 64-bit userspace programs?
Technically, I guess so. I have no experience with raspberry/ARM on 64 bit mode, but I have with i386 + amd64 on debian and yes, it's possible.
But the problem is the libraries and linker. It has all to have 64 bit support, with the exception of static binaries.
New debians are build to have a good support of mixing 32+64 bit on PC. In practice you need a duplicate of every library on both, 32 and 64 bit for each 32 or 64 bit binary that uses it.

The problem is that there is no raspbian 64 bit libraries, so you could only run static binaries... if all works in the same way than in PC.

I guess it's possible to use linux containers to run another 64 bit distro if the changes to run into a container works, or standalone apps on dockers. It's an assumption. Not real experience here.

A lot of work in any case.

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

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Mon Jul 22, 2019 12:59 am

a.nanos wrote:
Sun Jul 14, 2019 5:36 pm
Following the instructions of the first post, we managed to build a ubuntu-18.04.2-preinstalled-server-arm64+raspi3.img.xz for the rpi4.

Binary image available here: https://cloudkernels.net/ubuntu-18.04.2 ... kvm.img.xz (sha1sum: 0b1d8b72ea5410fb7928925fd76dd0218b4f7a94)

and info (mostly based on the original posts: https://blog.cloudkernels.net/posts/rpi4-64bit-image/).

Hopefully, the serial console is not needed; if you plug the board to a LAN with DHCP cloud-init should do its tricks (user/pass ubuntu/ubuntu).
Did you manage to get the GUI to work?

geev03
Posts: 81
Joined: Thu Jun 07, 2012 12:40 pm
Location: London, UK

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Wed Jul 24, 2019 8:16 am

DougieLawson wrote:
Sun Jul 07, 2019 6:55 am
.....Raspbian Buster to run with a 64-bit kernel and 32-bit userspace on a 3B+.
Used this link https://github.com/sakaki-/raspbian-nspawn-64 for the same, 64 bit LAMP is working on Pi3B.
Attachments
debian_64bit_Pi3B.jpg
debian_64bit_Pi3B.jpg (148.87 KiB) Viewed 1380 times

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

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Wed Jul 24, 2019 8:22 pm

I have just released a pair of weekly 64-bit (bcm2711_defconfig) kernel autobuilds for the Pi4, which may be used to e.g. easily set up a 64-bit kernel, 32-bit Raspbian userland system, without compilation. Screenshot:

Image

For more details, please see my post here.

Best, sakaki

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

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Thu Jul 25, 2019 8:27 pm

For convenience, I've just uploaded a demo bootable 64-bit kernel, 32-bit Raspbian Buster ("with desktop") image for the RPi4.
For details, please see my post here.

Best, sakaki

jdonald
Posts: 264
Joined: Fri Nov 03, 2017 4:36 pm

Re: Run Raspbian on Raspberry Pi 4 64bits kernel

Tue Jul 30, 2019 6:28 am

Zanstel wrote:
Thu Jul 18, 2019 11:29 am
jahboater wrote:
Sun Jul 07, 2019 8:41 am
Given a Raspbian with a 32-bit userspace and a 64-bit kernel, will it be possible to run 64-bit userspace programs?
In practice you need a duplicate of every library on both, 32 and 64 bit for each 32 or 64 bit binary that uses it.vThe problem is that there is no raspbian 64 bit libraries, so you could only run static binaries... if all works in the same way than in PC.

I guess it's possible to use linux containers to run another 64 bit distro if the changes to run into a container works, or standalone apps on dockers.
That's basically all correct. To be more concrete, I've seen 64-bit programs run on Raspbian the following ways:
* chroot/schroot
* systemd-nspawn
* Docker
* LXC
* multiarch

For now, chroot/schroot is probably the most straightforward and sakaki has the sample commands in her post linked just above.

I posted some examples & experiments with Docker, LXC, and multiarch (FrankenDebian Raspbian) back in the long 64-bit OS thread.
bensimmo wrote:
Sun Jul 07, 2019 10:23 am
My question is, what do you gain,.what are the benefits of using the 64bit kernel on the Pi3 &4 ?
curiosity as I don't know.
You get to keep hearing the snarky answer of "if you don't know you probably don't need it"!

Something more specific that builds upon the old thread: people generally agreed that some modern software just isn't supported on 32-bit armhf anymore. Firefox and Chromium had been tentatively on that list but then they got their act together with Buster. Meanwhile, to use MongoDB or CockroachDB on a Pi 4 you'll still need a 64-bit environment.

Return to “Raspbian”