OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 11:36 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Where does Raspberry Pi 4 load the kernel?
PostPosted: Fri Nov 08, 2019 3:57 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
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).


Top
 Profile  
 
 Post subject: Re: Where does Raspberry Pi 4 load the kernel?
PostPosted: Fri Nov 08, 2019 1:17 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: Where does Raspberry Pi 4 load the kernel?
PostPosted: Sun Nov 10, 2019 6:55 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
Oh yeah. I was using code from your tutorial to get video controller going. You did great job on that.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], SemrushBot [Bot] and 60 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group