Comments (7)
No, 32 bit code won't run in 64 bit mode. And I'm not planning to backport it, I've gave up programming for 32 bit more than a decade ago.
But you can backport easily though, here are my thoughts on it: there's only a minimal assembly in start.S, other than that everything is in C, should compile for 32 bit out-of-the-box and have a kernel7.img. (I'm not sure as I haven't tried 32 bit on RPi3 but maybe you have to change the base address of MMIO. RPi had it at different address, and I don't know whether that mapping is BCM specific or CPU mode specific. I'd guess it's BCM specific, so no need to change).
Also it is possible to load a 32 bit kernel with a 64 bit loader: alternatively you can copy the EL switch from one of the other tutorials (to where you hand over the control to the kernel), without setting the AArch64 flag. That way the loader would run in 64 bit mode, but the kernel would be executed in 32 bit mode in EL1 as you transfer control to it with an eret
. In this case you'd have to relocate your loader code to 0x8000-1024 as 32 bit kernels are expected to be loaded at 0x8000 and not 0x80000. I think that's all, everything else should be fine. (Assuming you don't care your kernel is started in EL1 and not EL2. Linux switches to EL1 as soon as possible, so shouldn't be a problem)
Btw I don't see any reason why the original raspbootin shouldn't run on the RPi3 as kernel7.img, if the MMIO is BCM specific, you only have to change the MMIO base address to the one I use in raspbootin64 and good to go.
Good luck
bzt
from raspi3-tutorial.
I take it back, it seems that the original raspbootin autodetects the MMIO address, so no change needed at all.
https://github.com/mrvn/raspbootin/blob/master/raspbootin/main.cc#L39
You should be able to boot it as kernel7.img on a RPi3.
bzt
from raspi3-tutorial.
Thanks for your help and suggestions.
I just get garbled tty output booting as kernel7.img on a Pi3...
from raspi3-tutorial.
Oh I see. That's definitely means incorrect baud rate, and taking a look at the original raspbootin's source I've found the problem. In
https://github.com/mrvn/raspbootin/blob/master/raspbootin/uart.cc#L80
it sets up the divisor for the baud rate (IBRD=1,FBRD=40), but incorrectly assumes that UART_CLOCK = 3000000. That's not necessairly the case (at least not on RPi3).
To fix it, you should add a mailbox call in UART::init() at line 84 to anchor the UART clock at a known frequency. Here's an example how to do that (I've used 4MHz in my tutorial, but to be compatible with the original raspbootin, either you should use 3MHz, or keep 4MHz and change the divisor value to IBRD=2,FBRD=11):
https://github.com/bztsrc/raspi3-tutorial/blob/master/05_uart0/uart.c#L49
The mailbox interface is quite straigthforward, you need a 16 bytes aligned uint array and one function to pass the array's reference to the GPU (see mbox.c), once you've filled the array up with values (see uart.c).
https://github.com/bztsrc/raspi3-tutorial/blob/master/05_uart0/mbox.c
Once the UART clock is at a known freq, the baud rate should be consistent. With a little luck, this is the last and only obsticle you have to come around.
bzt
from raspi3-tutorial.
A few more hints:
- your mbox array needs to hold no more than 8 ints
- because we are not interested in the return value, all you need from the mbox_call is line 49 and line 51, which resemblances the UART::putc() very very much.
That's all. So something like
volatile unsigned int __attribute__((aligned(16))) mbox[8];
// in uart.cc at line 84
mbox[0]=8*4;
mbox[1]=0;
mbox[2]=0x38002;
mbox[3]=12;
mbox[4]=8;
mbox[5]=2;
mbox[6]=3000000;
mbox[7]=0;
while (true) {
if (MMIO::read(0x0000B880 + 0x18) & 0x80000000) {
break;
}
}
MMIO::write(0x0000B880 + 0x20, &mbox | 8);
should do the trick. (Note I haven't tested this code, just put it together to give you the idea on a minimalistic modification).
bzt
from raspi3-tutorial.
Hi,
It's been a while, but if you're still interested in this, I've finally implemented a multi-platform version of the boot loader which supports AArch32 (on RPi3 and RPi4 too).
https://gitlab.com/bztsrc/imgrecv
As for the image sender, see
https://gitlab.com/bztsrc/usbimager (you'll have to start it with the "-S" flag)
Cheers,
bzt
from raspi3-tutorial.
Wow, great!
Thanks for the update :)
from raspi3-tutorial.
Related Issues (20)
- Reference document to understand code and commands in 0B_readsector HOT 1
- 0x1C2 no longer has 0xE or 0xC partition type HOT 2
- 0B ReadSector - Stable clock troubleshooting HOT 8
- Typos - bareminimum readme HOT 3
- Using sd_readblock() for reading directories HOT 9
- 0A PCScreenFont only works in QEMU HOT 7
- 0B_readsector stuck after EMMC: Sending command 33220010 arg 00000000 HOT 1
- Segmentation fault on execution of 09_framebuffer and 0A_pcscreenfont HOT 6
- Using U-boot to boot kernel8.img HOT 2
- about the uart HOT 4
- Emulating the raspi 3 on jetson nano failed with a black screen. HOT 1
- Explanation for mailboxes HOT 4
- How to tune the booting parameters of Lineage 16 for Raspi 3 to boot it with qemu / kvm on the Jetson nano... HOT 1
- 14_raspbooin64 HOT 5
- Please help to understand the load address 0x800000 in the linker file HOT 2
- uart0 tutorial issue HOT 1
- Why *EMMC_INTERRUPT=*EMMC_INTERRUPT; in sd.c? HOT 1
- How do you debugger with gdb-multiarch? HOT 6
- Why ptr+=4 or ptr+=3? HOT 7
- qemu emulation not working HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raspi3-tutorial.