Page 1 of 1
u-boot port on RaspberryPi 4
Posted: Fri Jul 05, 2019 5:07 pm
by agherzan
I started to work on supporting RaspbverryPi 4 in u-boot and now I'm at a point where u-boot boots, I have serial output but I but it dies as it follows:
Code: Select all
DRAM: mbox: Timeout waiting for send space
bcm2835: Could not query ARM memory size
initcall sequence 00000000000d1a18 failed at call 0000000000083214 (err=-1)
### ERROR ### Please RESET the board ###
I was fighting with this for a while now so I'm wondering if you guys have any idea while I keep debugging it. There relevant code is
https://github.com/agherzan/u-boot/blob ... mbox.c#L29. I currently suspect that I have a wrong `BCM2835_MBOX_PHYSADDR`. Can anyone confirm me the value of this address on Raspberry Pi 4?
Re: u-boot port on RaspberryPi 4
Posted: Fri Jul 05, 2019 7:08 pm
by agherzan
Found it: `fe00b880`.
Re: u-boot port on RaspberryPi 4
Posted: Sat Jul 06, 2019 9:02 pm
by jens.maus
Sorry, but I just stumbled over your post here and I actually wonder if you have any working u-boot version at hand now that actually boots correctly with a raspberrypi4? Could you please share some information with us or point us at the right position where we could find a u-boot version for the raspberrypi4? Thanks.
Re: u-boot port on RaspberryPi 4
Posted: Sat Jul 06, 2019 11:52 pm
by agherzan
jens.maus wrote: ↑Sat Jul 06, 2019 9:02 pm
Sorry, but I just stumbled over your post here and I actually wonder if you have any working u-boot version at hand now that actually boots correctly with a raspberrypi4? Could you please share some information with us or point us at the right position where we could find a u-boot version for the raspberrypi4? Thanks.
Hi. I'm currently stuck a little and I think I will be needing a hardware debugger from here on. Currently I have logs on the serial but uboot hangs as soon as MMU is enabled (again this is only in 64bit, I haven't tried it on 32). I pushed a branch in github (
https://github.com/agherzan/u-boot/tree/ag/rpi4). If you guys have any ideas, feel free to send patches on top of the branch - I do have some more local changed but not cleaned up to be pushed. It would be nice if we could centralize the effort to add this support and as soon as we have something useful, I can push them upstream (obviously keeping the authoring). I will most probably resume debugging on Monday.
Re: u-boot port on RaspberryPi 4
Posted: Sun Jul 07, 2019 8:30 am
by jens.maus
agherzan wrote: ↑Sat Jul 06, 2019 11:52 pm
Hi. I'm currently stuck a little and I think I will be needing a hardware debugger from here on. Currently I have logs on the serial but uboot hangs as soon as MMU is enabled (again this is only in 64bit, I haven't tried it on 32). I pushed a branch in github (
https://github.com/agherzan/u-boot/tree/ag/rpi4). If you guys have any ideas, feel free to send patches on top of the branch - I do have some more local changed but not cleaned up to be pushed. It would be nice if we could centralize the effort to add this support and as soon as we have something useful, I can push them upstream (obviously keeping the authoring). I will most probably resume debugging on Monday.
Thanks for the link and info. This indeed looks promising. However, have you also seen the following resources/discussions about getting u-boot working for a raspberrypi4?
https://github.com/raspberrypi/firmware ... -506706177
https://github.com/u-boot/u-boot/compar ... du:patch-1
These might be helpful to get things going. What I do not understand, however, is why your patch seems to be somewhat way larger with far more changes compare to the simple patch/workaround the above links are suggesting to get u-boot going. I will, however, try to test your branch and see if I can get u-boot going on a rpi4.
Re: u-boot port on RaspberryPi 4
Posted: Sun Jul 07, 2019 10:51 am
by swahren
Honestly i didn't expect a u-boot port thread in Troubleshooting. I started to work on the upstream work for the Linux kernel and i hope this helps for the u-boot port:
https://github.com/lategoodbye/rpi-zero/issues/43
(Don't ask about the confusing repo name i'm just to lazy to create a new one

)
So i hope you get the idea, that much more changes are required for RPi 4 support. I hope the peripheral documentation of the BCM2711 will be released soon.
Re: u-boot port on RaspberryPi 4
Posted: Sun Jul 07, 2019 11:44 am
by agherzan
Thumbs up for documentation. Life would be much easier with that. In my case I think the memory map is wrong or I have a bug somewhere. As soon as the MMU is enabled `set_sctlr(get_sctlr() | CR_M);` everything goes silent. I'm not sure if it's an abort or it's just the console. In other words I ordered a JTAG debugger.
Re: u-boot port on RaspberryPi 4
Posted: Fri Jul 12, 2019 5:31 pm
by agherzan
U-Boot support is available now in both 32 and 64 mode Raspberry Pi 4*. Fork branch mentioned above (
https://github.com/agherzan/u-boot/commits/ag/rpi4) includes support for both targets - tested them on a 4G variant. You can also use [this](
https://andrei.gherzan.ro/linux/uboot-on-rpi/) small guide to use/test u-boot with Raspbian.
*Credits also to Matthias Brugger (
mbrugger@suse.com) for his work on the mbox support.
EDIT: Forgot to mention that the uboot support comes in Yocto as well:
https://github.com/agherzan/meata-raspberrypi/pull/437
Re: u-boot port on RaspberryPi 4
Posted: Fri Jul 12, 2019 6:16 pm
by epoch1970
Super cool. Thanks a lot!
Re: u-boot port on RaspberryPi 4
Posted: Tue Aug 20, 2019 3:52 pm
by neoXite
Excellent job, agherzan! Can't wait to test this on my lab RPi4 and eventually seeing it upstreamed!
I'm primarily interested in using U-Boot to netboot a kernel/initrd via Ethernet, with just U-Boot and the firmware blobs residing on the SD card, this already works beautifully on RPi2/3.
I understand the RPi4 has a completely new Ethernet setup with the PHY now hooked up directly via PCIe rather than USB.
Do any usable Ethernet driver bits exist in U-boot yet? Thank you for any insight!
Re: u-boot port on RaspberryPi 4
Posted: Tue Aug 20, 2019 4:01 pm
by agherzan
neoXite wrote: ↑Tue Aug 20, 2019 3:52 pm
Excellent job, agherzan! Can't wait to test this on my lab RPi4 and eventually seeing it upstreamed!
I'm primarily interested in using U-Boot to netboot a kernel/initrd via Ethernet, with just U-Boot and the firmware blobs residing on the SD card, this already works beautifully on RPi2/3.
I understand the RPi4 has a completely new Ethernet setup with the PHY now hooked up directly via PCIe rather than USB.
Do any usable Ethernet driver bits exist in U-boot yet? Thank you for any insight!
That is one bit missing. We don't have a PICe driver at this point.
Re: u-boot port on RaspberryPi 4
Posted: Tue Aug 20, 2019 4:35 pm
by rpdom
neoXite wrote: ↑Tue Aug 20, 2019 3:52 pm
I understand the RPi4 has a completely new Ethernet setup with the PHY now hooked up directly via PCIe rather than USB.
No. The new USB chip on the Pi 4B uses the PCIe channel.
Ethernet now uses a dedicated Ethernet channel from the SoC to the PHY chip.
Re: u-boot port on RaspberryPi 4
Posted: Tue Aug 20, 2019 4:38 pm
by agherzan
rpdom wrote: ↑Tue Aug 20, 2019 4:35 pm
neoXite wrote: ↑Tue Aug 20, 2019 3:52 pm
I understand the RPi4 has a completely new Ethernet setup with the PHY now hooked up directly via PCIe rather than USB.
No. The new USB chip on the Pi 4B uses the PCIe channel.
Ethernet now uses a dedicated Ethernet channel from the SoC to the PHY chip.
I misread. This is correct.
Re: u-boot port on RaspberryPi 4
Posted: Tue Aug 20, 2019 5:33 pm
by neoXite
Thank you for confirming that the RPi4 Ethernet setup is still a To-Do in U-Boot.
Now would it make sense to bring this feature to attention on the U-Boot mailing list? Most likely someone with the required skill will pick this up sooner or later regardless, but wishful thinking on my behalf suggests it may happen sooner than later that way.
Re: u-boot port on RaspberryPi 4
Posted: Mon Sep 09, 2019 1:00 pm
by sanMeh
Hello All,
I try to build the WIP branch of agherzan (
https://andrei.gherzan.ro/linux/uboot-on-rpi/ )
But got an below error. Does anyone has any working branch of uboot for RPI4.
I think master branch (
https://gitlab.denx.de/u-boot/u-boot/find_file/master) of U-boot is also not supporting RPI4 yet.
In file included from include/common.h:46,
from cmd/bootefi.c:8:
include/dm/of.h: At top level:
./arch/arm/include/asm/global_data.h:110:58: error: invalid register name for ‘gd’
#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("x18")
^~
include/dm/of.h:86:1: note: in expansion of macro ‘DECLARE_GLOBAL_DATA_PTR’
DECLARE_GLOBAL_DATA_PTR;
^~~~~~~~~~~~~~~~~~~~~~~
./arch/arm/include/asm/global_data.h:110:58: error: invalid register name for ‘gd’
#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("x18")
^~
cmd/bootefi.c:22:1: note: in expansion of macro ‘DECLARE_GLOBAL_DATA_PTR’
DECLARE_GLOBAL_DATA_PTR;
Re: u-boot port on RaspberryPi 4
Posted: Tue Sep 17, 2019 11:15 am
by rpinewbie01
Hello All,
I am a newbie in raspberry pi world but some background on windows desktop driver development, just got hold of a rpi4b.
Read few posts and found that it is good to learn by doing everything from scratch!!!
I found that there is a bootloader called uboot which is booted after power on, I guess something called firmware stored in board flash (not on sd card) is booted prior to that.
Hoping to do everything from scratch need help from the forum for guidance / steps
- How to compile uboot for rpi4.
- Which device description/configutation tree to use for kernel
- How to partition and program the SD card. where to put uboot binary and linux binary and distribution compressed image and the dts.
Also Need some pointers to
- Is there a reference manual of the board, where I can get details of interrupt controller / memory map
- I read that bcm2711 does support PCIe, but it is not exposed on the board,
any idea if a rpi4 hat cab be used somehow....
-Thanks
ben
Re: u-boot port on RaspberryPi 4
Posted: Thu Sep 19, 2019 8:05 am
by rpinewbie01
I was able to boot 64 bit uboot from tot denx.
Code: Select all
U-MMC: emmc2@7e340000: 0, mmcnr@7e300000: 1
Loading Environment from FAT... OK
In: serial
Out: serial
Err: serial
Net: Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot: 0
U-Boot> bdinfo
arch_number = 0x0000000000000000
boot_params = 0x0000000000000100
DRAM bank = 0x0000000000000000
-> start = 0x0000000000000000
-> size = 0x000000003b400000
current eth = unknown
ip_addr = <NULL>
baudrate = 115200 bps
TLB addr = 0x000000003b3f0000
relocaddr = 0x000000003b369000
reloc off = 0x000000003b2e9000
irq_sp = 0x000000003af59b50
sp start = 0x000000003af59b50
FB base = 0x0000000000000000
Early malloc usage: 420 / 2000
fdt_blob = 0x000000003af59b60
bdinfo seems to show incorrect DRAM size,
Has anyone faced this issue ?
Re: u-boot port on RaspberryPi 4
Posted: Thu Sep 19, 2019 8:54 am
by jamesh
rpinewbie01 wrote: ↑Tue Sep 17, 2019 11:15 am
Hello All,
I am a newbie in raspberry pi world but some background on windows desktop driver development, just got hold of a rpi4b.
Read few posts and found that it is good to learn by doing everything from scratch!!!
I found that there is a bootloader called uboot which is booted after power on, I guess something called firmware stored in board flash (not on sd card) is booted prior to that.
Hoping to do everything from scratch need help from the forum for guidance / steps
- How to compile uboot for rpi4.
- Which device description/configutation tree to use for kernel
- How to partition and program the SD card. where to put uboot binary and linux binary and distribution compressed image and the dts.
Also Need some pointers to
- Is there a reference manual of the board, where I can get details of interrupt controller / memory map
- I read that bcm2711 does support PCIe, but it is not exposed on the board,
any idea if a rpi4 hat cab be used somehow....
-Thanks
ben
What is your aim? As standard the Pi does NOT use Uboot so is there a specific need you have for Uboot?
Re: u-boot port on RaspberryPi 4
Posted: Thu Sep 19, 2019 12:13 pm
by rpinewbie01
jamesh wrote: ↑Thu Sep 19, 2019 8:54 am
rpinewbie01 wrote: ↑Tue Sep 17, 2019 11:15 am
Hello All,
I am a newbie in raspberry pi world but some background on windows desktop driver development, just got hold of a rpi4b.
Read few posts and found that it is good to learn by doing everything from scratch!!!
I found that there is a bootloader called uboot which is booted after power on, I guess something called firmware stored in board flash (not on sd card) is booted prior to that.
Hoping to do everything from scratch need help from the forum for guidance / steps
- How to compile uboot for rpi4.
- Which device description/configutation tree to use for kernel
- How to partition and program the SD card. where to put uboot binary and linux binary and distribution compressed image and the dts.
Also Need some pointers to
- Is there a reference manual of the board, where I can get details of interrupt controller / memory map
- I read that bcm2711 does support PCIe, but it is not exposed on the board,
any idea if a rpi4 hat cab be used somehow....
-Thanks
ben
What is your aim? As standard the Pi does NOT use Uboot so is there a specific need you have for Uboot?
I am working on a small microkernel which boots off uboot.
if DDR init is done in uboot, I have to add less code in microkernel.
Re: u-boot port on RaspberryPi 4
Posted: Thu Sep 19, 2019 1:00 pm
by jamesh
rpinewbie01 wrote: ↑Thu Sep 19, 2019 12:13 pm
jamesh wrote: ↑Thu Sep 19, 2019 8:54 am
rpinewbie01 wrote: ↑Tue Sep 17, 2019 11:15 am
Hello All,
I am a newbie in raspberry pi world but some background on windows desktop driver development, just got hold of a rpi4b.
Read few posts and found that it is good to learn by doing everything from scratch!!!
I found that there is a bootloader called uboot which is booted after power on, I guess something called firmware stored in board flash (not on sd card) is booted prior to that.
Hoping to do everything from scratch need help from the forum for guidance / steps
- How to compile uboot for rpi4.
- Which device description/configutation tree to use for kernel
- How to partition and program the SD card. where to put uboot binary and linux binary and distribution compressed image and the dts.
Also Need some pointers to
- Is there a reference manual of the board, where I can get details of interrupt controller / memory map
- I read that bcm2711 does support PCIe, but it is not exposed on the board,
any idea if a rpi4 hat cab be used somehow....
-Thanks
ben
What is your aim? As standard the Pi does NOT use Uboot so is there a specific need you have for Uboot?
I am working on a small microkernel which boots off uboot.
if DDR init is done in uboot, I have to add less code in microkernel.
DDR init is done by the Pi bootloader. This gets loaded by the first stage loader (<Pi4, baked in to SoC, Pi4, in EEPROM), sets up the SoC, loads the GPU firmware, runs that, then that loads and runs the Linux kernel. I believe that a Uboot system replaces the kernel with Uboot, in effect adding that extra stage.
However, if you just want to run a microkernel, you could just make it look like a Linux kernel image and drop it in there instead rather than using Uboot.
You should probably be reading the bare metal forum for information on all this.
Re: u-boot port on RaspberryPi 4
Posted: Fri Sep 20, 2019 8:39 am
by rpinewbie01
jamesh wrote: ↑Thu Sep 19, 2019 1:00 pm
rpinewbie01 wrote: ↑Thu Sep 19, 2019 12:13 pm
jamesh wrote: ↑Thu Sep 19, 2019 8:54 am
What is your aim? As standard the Pi does NOT use Uboot so is there a specific need you have for Uboot?
I am working on a small microkernel which boots off uboot.
if DDR init is done in uboot, I have to add less code in microkernel.
DDR init is done by the Pi bootloader. This gets loaded by the first stage loader (<Pi4, baked in to SoC, Pi4, in EEPROM), sets up the SoC, loads the GPU firmware, runs that, then that loads and runs the Linux kernel. I believe that a Uboot system replaces the kernel with Uboot, in effect adding that extra stage.
However, if you just want to run a microkernel, you could just make it look like a Linux kernel image and drop it in there instead rather than using Uboot.
You should probably be reading the bare metal forum for information on all this.
Thanks, I think I can totally do away with uboot then.
I have posted a query in bare metal forum "Raspberry Pi4 firmware questions".
Could you please check it
Re: u-boot port on RaspberryPi 4
Posted: Tue Oct 08, 2019 6:03 am
by bigal.nz
I also have a need for the updated version of uboot which supports the Rasp Pi 4.
I would like to use the image for Venus OS
https://github.com/victronenergy/venus/wiki which uses a old version of uboot not compatiable with Rasp Pi 4 - so at this stage the download images (
https://updates.victronenergy.com/feeds ... pberrypi2/ ) dont even boot.
How would I get a updated version of uboot into one of these images?
Thanks
Al
Re: u-boot port on RaspberryPi 4
Posted: Sat Jun 06, 2020 9:27 pm
by jens.maus
@agherzan
agherzan wrote: ↑Tue Aug 20, 2019 4:01 pm
neoXite wrote: ↑Tue Aug 20, 2019 3:52 pm
Excellent job, agherzan! Can't wait to test this on my lab RPi4 and eventually seeing it upstreamed!
I'm primarily interested in using U-Boot to netboot a kernel/initrd via Ethernet, with just U-Boot and the firmware blobs residing on the SD card, this already works beautifully on RPi2/3.
I understand the RPi4 has a completely new Ethernet setup with the PHY now hooked up directly via PCIe rather than USB.
Do any usable Ethernet driver bits exist in U-boot yet? Thank you for any insight!
That is one bit missing. We don't have a PICe driver at this point.
Almost one year later there still doesn't seem to be PCIe support in U-Boot for the RaspberryPi4, hence no USB2/USB3 support yet and thus the new raspberrypi bootloader USB mass storage boot support cannot be used for systems that use U-Boot as a second level bootloader. Do you have any progress on that or do you know if someone is working on getting PCIe support for the RaspberryPi4 integrated in U-Boot?
Re: u-boot port on RaspberryPi 4
Posted: Sun Jun 07, 2020 10:09 am
by lingon
Ubuntu is using uboot. In this post it is described how to boot Ubuntu 20.04 on a Raspberry Pi 4 with a patched uboot:
viewtopic.php?f=131&t=268476#p1671050