Some notes on PI development

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
AndrewIsOffline
Posts: 2
Joined: Sat Feb 09, 2019 8:43 pm

Some notes on PI development

Post by AndrewIsOffline »

Hello everyone! This is my first post on the forum, but I've been using the Pi development page for a while, and it's helped me a lot. Since then I've made a good amount of progress, and I wanted to share what I've found:
  • I don't know if it's a Cygwin thing, but my gcc setup doesn't seem to like "org" without a "." before it.
  • I think Qemu fixed the binary loading issue. The latest version loads the binary at 0x8000.
  • Using Qemu's "raspi2" (and, I'm guessing, using an actual PI 2) gives you a 32-bit ARM with 4 cores, even if you override the cpu setting (and it rejects any number of cores below 4). There isn't any code for shutting off the extra cores, and letting them run can crash or mess up the kernel, so I rewrote the ARM64 cores code to work with raspi2's cortex-A7 (and also my 4-core arm1176 setup):

    Code: Select all

    	mrc p15, 0, r5, c0, c0, 5
    	and r5, r5, #3
    	cmp r5, #0
    	bne halt
    
    	ldr r5, =_start
    	mov sp, r5
    This goes right after "_start:" in the ARM32 code and replaces the "mov sp, #0x8000" line.
I hope this helps people here! I would post it on the wiki, but since I'm new I wanted to get feedback first.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Some notes on PI development

Post by bzt »

AndrewIsOffline wrote:Hello everyone! This is my first post on the forum, but I've been using the Pi development page for a while, and it's helped me a lot. Since then I've made a good amount of progress, and I wanted to share what I've found:
  • I don't know if it's a Cygwin thing, but my gcc setup doesn't seem to like "org" without a "." before it.
Don't think so. Keywords should be keywords under Cygwin too, so there should be a ".".
[*]I think Qemu fixed the binary loading issue. The latest version loads the binary at 0x8000.
Yes, and I have also fixed the ARM64 loading issue with "raspi3". Thanks to Pekka, now it's in the qemu mainline, since 2.12.
[*]Using Qemu's "raspi2" (and, I'm guessing, using an actual PI 2) gives you a 32-bit ARM with 4 cores, even if you override the cpu setting (and it rejects any number of cores below 4).
You can't override the cpu setting because number of cores is fixed on the real machine. There is no way to use less cores on real hw, and qemu emulates that (correctly).
There isn't any code for shutting off the extra cores, and letting them run can crash or mess up the kernel, so I rewrote the ARM64 cores code to work with raspi2's cortex-A7 (and also my 4-core arm1176 setup): ... This goes right after "_start:" in the ARM32 code and replaces the "mov sp, #0x8000" line.[/list]
Yes, that's needed, because ARM32 uses 4 cores now too.
I hope this helps people here! I would post it on the wiki, but since I'm new I wanted to get feedback first.
I'm sure it will help people. I'd say go ahead, update the wiki. We always welcome contributions!

Cheers,
bzt
AndrewIsOffline
Posts: 2
Joined: Sat Feb 09, 2019 8:43 pm

Re: Some notes on PI development

Post by AndrewIsOffline »

Okay, I'll post the changes. Thanks!
Also, the reason for my weird setup is because I'm using a Pi Zero for this project, so I tried to emulate as close to that. Right now I'm using raspi2 and overriding the cpu with the Pi Zero's cpu.
Post Reply