OSDev.org
https://forum.osdev.org/

Where does Raspberry Pi 4 load the kernel?
https://forum.osdev.org/viewtopic.php?f=1&t=36060
Page 1 of 1

Author:  pvc [ Fri Nov 08, 2019 3:57 am ]
Post subject:  Where does Raspberry Pi 4 load the kernel?

I've recently bought RPI4 and it seems to be quite powerful board, but lack of any kind of technical documentation in just painful.
I've had problems running bare metal code on it because of memory corruption, or so I thought. I don't have any 3V compatible serial adapter and no one seems to be able to debug it over JTAG yet.
After I've got video controller to be able to display some text, I've found that my kernel8.img seems to be loaded at address 0 instead of 0x80000. kernel_base and old_kernel options seem to be ignored. Can anyone confirm that behaviour? BTW. I am booting it over network using built-in bootcode.bin (no SD card).

Author:  bzt [ Fri Nov 08, 2019 1:17 pm ]
Post subject:  Re: Where does Raspberry Pi 4 load the kernel?

Hi,

Yes, finding the latest documentation for Raspberry is not an easy job. It is quite nice for Pi3 and older models, but not for the Pi4. I'd suggest to start here raspi3-tutorial, although it's for the Pi3, there's a bunch of links on the readme to other tutorials, some of which already ported to Pi4. Maybe you can find a clue. If you're not afraid of Pascal, it definitely worth checking out https://ultibo.org as it has the most comprehensive bare metal support (Pi4 included).

I'm not surprised it does not recognize kernel_old options, the bootcode.bin was almost entirely rewritten for the RPi4. Unfortunately the stub does not help either. https://github.com/raspberrypi/linux/blob/rpi-4.19.y/arch/arm64/include/asm/memory.h refers to VA only, and the code to set up paging https://github.com/raspberrypi/linux/blob/rpi-4.19.y/arch/arm64/kernel/head.S is not something I would call clean and readable source (I'd not suggest to check the linker script because that's even worse). Maybe you should start by deleting config.txt, name your kernel kernel8.img, then the firmeware should load it at 0x80000 from SD. Offset 0 is suspicious, I don't think that should be, not with network boot either. Not sure config.txt is loaded correctly if not loaded from SD, it may depend on what server you use? (I mean maybe some config pushed in dhcp overrides perhaps? Just guessing here.)

About the serial, I'd suggest to get one. You'll get debug messages sooner with RS232 than with JTAG. Also try SD card first, and when it's working properly then you can compare it to the network boot, that way you can confirm if the problem is indeed with the configuration loaded over the network, or something else.

Cheers,
bzt

Author:  pvc [ Sun Nov 10, 2019 6:55 am ]
Post subject:  Re: Where does Raspberry Pi 4 load the kernel?

Oh yeah. I was using code from your tutorial to get video controller going. You did great job on that.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/