phil95
Posts: 141
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris

RPI3 baremetal

Fri Mar 11, 2016 11:28 am

Hello,
I'm trying to adapt my baremetal progs to RPI3.
- I build a SD card with Jessie of 26/02. The card boot Jessie correctly.
- I replace kernel.img and kernel7.img with a small prog to flash red and green leds.
- I try that SD on a RPI2 and it is working well.
- When I try that SD on RPI3, I have only a green flash then nothing more
Any idea ?
Has someone a small prog runing on RPI 3 ?
Thanks for your answers
Philippe

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: RPI3 baremetal

Fri Mar 11, 2016 11:42 am

On the Pi3B the red & green LEDs are no longer connected to bcm GPIOs; instead they are driven from an i2c GPIO expander: U20 located near the DSI connector.

I suggest you toggle GPIOs on the 40-pin header instead as a hello world example for your bare metal code.

That initial flash is likely from start.elf showing that it is loading your custom kernel7.img.

phil95
Posts: 141
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris

Re: RPI3 baremetal

Fri Mar 11, 2016 1:32 pm

Many thanks for that information.
Do you know where I can found the differences between RPI 3 and RPI 2 ?
Philippe

User avatar
Arjan
Posts: 265
Joined: Sat Sep 08, 2012 1:59 pm

Re: RPI3 baremetal

Sun Mar 13, 2016 3:06 pm

gregeric wrote:On the Pi3B the red & green LEDs are no longer connected to bcm GPIOs; instead they are driven from an i2c GPIO expander: U20 located near the DSI connector..
Example of driving the Act LED can found here https://github.com/vanvught/rpidmx512/b ... pio_virt.c

Change with respect to PL011 and RPi 3 -> viewtopic.php?p=927917#p927917

Arjan
http://www.raspberrypi-dmx.com/
http://www.raspberrypi-dmx.org/
Open Source DMX/RDM/MIDI/OSC/Art-Net/sACN solutions

phil95
Posts: 141
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris

Re: RPI3 baremetal

Sun Mar 13, 2016 6:10 pm

Thanks for your links, I want to
analyse them ...
Philippe

dwelch67
Posts: 1006
Joined: Sat May 26, 2012 5:32 pm

Re: RPI3 baremetal

Tue Mar 15, 2016 1:21 am

are you saying that we cannot get to the i2c expander from gpio pins? only thruogh the gpu?

dwelch67
Posts: 1006
Joined: Sat May 26, 2012 5:32 pm

Re: RPI3 baremetal

Tue Mar 15, 2016 1:31 am

my bootloader07 example works fine on the pi3 (just got mine today), in the default 32 bit mode (you asked about simple bare metal programs). Going to mess with 64 bit here soon. Once info on the expander (part number if available. are there schematics?) can provide an led blinker...

David

dwelch67
Posts: 1006
Joined: Sat May 26, 2012 5:32 pm

Re: RPI3 baremetal

Tue Mar 15, 2016 5:28 am

https://github.com/dwelch67/raspberrypi ... er/aarch64

I have some 64 bit examples working, a simple bootloader and an example that uses the uart. If you dont use a config.txt then it boots into 32 bit mode (as of this writing)(32 bit compatibility mode basically) and you treat it basically like a raspberry pi 2 for bare metal except for the LED(s).

David

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: RPI3 baremetal

Tue Mar 15, 2016 6:21 am

dwelch67 wrote:Once info on the expander (part number if available. are there schematics?) can provide an led blinker...

David
i2c addresss is reported as 0x43 (0x86/7 inc R/W bit) here: viewtopic.php?f=44&t=138897&p=923243#p922961.

Haven't been able to pin it down to a part number matching that address, but the XQFN16 package limits it to an 8-bit GPIO expander, something like PCA6408 or PCA9534.

User avatar
Arjan
Posts: 265
Joined: Sat Sep 08, 2012 1:59 pm

Re: RPI3 baremetal

Tue Mar 15, 2016 4:45 pm

dwelch67 wrote:are you saying that we cannot get to the i2c expander from gpio pins? only thruogh the gpu?
I am saying that I have a working example controlling the ACT Led using the mailbox.

I have no idea if we can address the I/O expander directly. I assume not, otherwise we should not have this mailbox property.

- Arjan
http://www.raspberrypi-dmx.com/
http://www.raspberrypi-dmx.org/
Open Source DMX/RDM/MIDI/OSC/Art-Net/sACN solutions

dwelch67
Posts: 1006
Joined: Sat May 26, 2012 5:32 pm

Re: RPI3 baremetal

Tue Mar 15, 2016 7:34 pm

the pi 3 at least 64 bit comes up with gpio 0/1 28/29 44/45 all set as inputs, not set to i2c so they are in theory not orred together.

I didnt find anything on gpio 0/1 28/29 everything acks so that is no good. 44/45 also everything hits so nothing there either. Will have to examine the code again and/or put it on a scope.

phil95
Posts: 141
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris

Re: RPI3 baremetal

Fri Mar 18, 2016 2:58 pm

Hello,
I have simplified and adapted software of Vanvught to blink ACT led of PI3
Thanks to Arjan for the reference
Philippe

Code: Select all

		org 	$8000
main:
		mov 	sp, #0x8000
		bl		LedInit
Boucle:
		bl		LedOn
		mov 	r0, #500
		bl		Delay
		bl		LedOff
		mov 	r0, #500
		bl		Delay
		b		Boucle


		align	16
Request:
		dw		0x1c
		dw		0
		dw		0x00040010
		dw		4
		dw		0
		dw		0
		dw		0

pLed:	dw		0
pBal:	dw		0x3f00b880
pHtr:	dw		0x3f003004
LedInit:
		push	{r0, r1, lr}
		ldr 	r1, [pBal]
LedInit1:
		ldr 	r0, [r1, #0x18]
		ands	r0, #0x80000000
		bne 	LedInit1
		adr 	r0, Request + 8
		str 	r0, [r1, #0x20]
LedInit2:
		ldr 	r0, [r1, #0x18]
		ands	r0, #0x40000000
		bne 	LedInit2
		ldr 	r0, [Request + 0x14]
		bic 	r0, #0xc0000000
		str 	r0, [pLed]
		pop 	{r0, r1, pc}


LedOn:
		push	{r0, r1, lr}
		ldr 	r1, [pLed]
		ldr 	r0, [r1]
		add 	r0, #0x00010000
		str 	r0, [r1]
		pop 	{r0, r1, pc}


LedOff:
		push	{r0, r1, lr}
		ldr 	r1, [pLed]
		ldr 	r0, [r1]
		add 	r0, #0x00000001
		str 	r0, [r1]
		pop 	{r0, r1, pc}

Delay:
;		r0 = mS
		push	{r0, r1, r2, lr}
		mov 	r1, #1000
		mul 	r0, r1
		ldr 	r1, [pHtr]
		ldr 	r2, [r1]
Delay1:
		ldr 	r3, [r1]
		sub 	r3, r2
		cmp 	r3, r0
		blo 	Delay1
		pop 	{r0, r1, r2, pc}

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

Re: RPI3 baremetal

Fri Dec 23, 2016 6:09 pm

Scratching my head with Pi3 B.

I have a number of baremetal samples that work on a Pi2, PiZero (and even recompiled on a Pi 1) but won't come up on a Pi3 B.

I put Jessie on my SD card and it worked. I just deleted all the folders and put my kernel.img file on but the Pi3 just puts up the faithful multicoloured screen and sits there.

I tried directly hitting the mailboxes and screen straight after boot with a tight code sequence and even that doesn't seem to get called. So it would appear for whatever reason it doesn't see kernel.img as valid and refuses to load it.

I thought code for a PI2 should run on a Pi3 but looks like I was wrong. Anyone have a clue whats going on with it?

User avatar
DougieLawson
Posts: 42177
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: RPI3 baremetal

Fri Dec 23, 2016 7:52 pm

LdB wrote: I thought code for a PI2 should run on a Pi3 but looks like I was wrong. Anyone have a clue whats going on with it?
You'll need to lift a copy of the latest /boot stuff from https://github.com/Hexxeh/rpi-firmware to get the RPi3B videocore running.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Return to “Bare metal, Assembly language”