DaveAitch
Posts: 14
Joined: Thu Mar 24, 2016 6:06 pm
Contact: Website

Bare metal multi-core Pi-3 with u-boot?

Sun Apr 22, 2018 4:23 pm

Hi,

I've got my Pi-3 booting u-boot in 64-bit (aarch64) mode from the SD card. Seems to work OK, but it isn't clear what cores 1,2 and 3 are doing.

I load my simple & stupid bare metal startup program over tftp and run it. The load address is 0x10800000 --- well away from u-boot and anything else that might be there. It runs and writes stuff to the uart (same uart as u-boot uses).

The Pi-3 seems to be running in EL-2 at that point (the currentEL register contains 0x8). The affinity register contains 0x0000000800000000.

My problem is that I can't get the other 3 cores to start.

According to the u-boot sources, they ought to be looping around a wfe instruction, waiting for a non-zero address to appear in the CPU_RELEASE_ADDR location. But I put my core1 start address there and execute SEV - nothing happens. :(

Can anyone give me any hint about what I'm doing wrong?

LizardLad_1
Posts: 126
Joined: Sat Jan 13, 2018 12:29 am

Re: Bare metal multi-core Pi-3 with u-boot?

Wed May 09, 2018 10:13 am

I'm not sure why this is happening but you have a similar issue to me there is more info in this thread: viewtopic.php?f=72&t=212930

DaveAitch
Posts: 14
Joined: Thu Mar 24, 2016 6:06 pm
Contact: Website

Re: Bare metal multi-core Pi-3 with u-boot?

Thu May 10, 2018 2:57 pm

LizardLad_1 wrote:
Wed May 09, 2018 10:13 am
I'm not sure why this is happening but you have a similar issue to me there is more info in this thread: viewtopic.php?f=72&t=212930
Hi LizardLad,
are you using u-boot? I think most of those comments (and the code in the Circle project) assume that the code is booting directly from the SD card.
In my case, u-boot boots from the SD card and then loads my code from my tftp server. So there's another layer in the way.
U-boot seems to have some code for catching cores 1,2 and 3 and sending them to sleep. It isn't clear whether this code ever gets executed. If it does, then the wakeup method for u-boot doesn't work.
It would be nice if it turns out that u-boot just runs on the core that starts - because then I've just got to start the cores "as normal". (whatever that is). However, none of the suggested methods seems to work. :-(

LdB
Posts: 910
Joined: Wed Dec 07, 2016 2:29 pm

Re: Bare metal multi-core Pi-3 with u-boot?

Thu May 10, 2018 3:50 pm

Looking at start.S for U-BOOT the ability to release core1,2,3 depends on defines being set as per this code

https://github.com/u-boot/u-boot/blob/m ... v8/start.S

Code: Select all

#if defined(CONFIG_ARMV8_SPIN_TABLE) && !defined(CONFIG_SPL_BUILD)
	branch_if_master x0, x1, master_cpu
	b	spin_table_secondary_jump
	/* never return */
#elif defined(CONFIG_ARMV8_MULTIENTRY)
	branch_if_master x0, x1, master_cpu

	/*
	 * Slave CPUs
	 */
slave_cpu:
	wfe
	ldr	x1, =CPU_RELEASE_ADDR
	ldr	x0, [x1]
	cbz	x0, slave_cpu
	br	x0			/* branch to the given address */
#endif /* CONFIG_ARMV8_MULTIENTRY */
The definitions look like they are passed in via make files in a build setting

The standard make file seems on only include the spintables without a setting CONFIG_SPL_BUILD

Code: Select all

ifndef CONFIG_SPL_BUILD
obj-$(CONFIG_ARMV8_SPIN_TABLE) += spin_table.o spin_table_v8.o
endif
That is all I can really work out by just looking, I don't use it and can't help beyond that.

DaveAitch
Posts: 14
Joined: Thu Mar 24, 2016 6:06 pm
Contact: Website

Re: Bare metal multi-core Pi-3 with u-boot?

Sun May 13, 2018 7:50 pm

LdB wrote:
Thu May 10, 2018 3:50 pm
Looking at start.S for U-BOOT the ability to release core1,2,3 depends on defines being set as per this code [...]
Hi LdB,

thanks very much for your hints.

I just downloaded the latest u-boot and configured it for the rpi3 (64-bit). Disassembling the ELF file, I can see that there's no spin table and nowhere that catches cores 1-3.

That must mean that the cores are in the state that the Rpi bootloader left them (i.e. just like if my program had booted directly from the SD card.

Back to the drawing board. ...

Return to “Bare metal, Assembly language”