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

RPI 3 B+ startup

Sat Dec 31, 2016 7:38 pm

Has anyone got code to startup a RPI 3 B+.

There is something quirky or different you have to do with it's startup. I have not found anyone's code that will actually pick it not even David Welches or any of the usual sources. It starts with a cutdown raspbian disk image with these files

bcm2710-rpi-3-b.dtb
bcm2710-rpi-cm3.dtb
bootcode.bin
start.elf
kernel7.img

First I don't know whats in the dtb files (it wont start without them) and why they are needed and second I can not replace the kernel7.img file with any baremetal file and get it to start. I have checked the start address as 0x8000 on my replacement and even trying to just poke some GPIO pins nothing happens. A working RPI2 file which just starts poking the video or gpio won't work either.

It appears there is now something new you have to do on a RPI3 B+ that no other version of PI needs.

User avatar
Truewar
Posts: 2
Joined: Tue Jan 03, 2017 4:45 pm
Location: Czech Republic
Contact: ICQ Website

Re: RPI 3 B+ startup

Tue Jan 03, 2017 5:16 pm

I am currently trying to do the same.

bootcode.bin must be loaded by GPU after you power up the device. It should read and start kernel file with start.elf.

Kernel file name could be changed by kernel= directive from config.txt.

I've also added

core_freq=250
enable_uart=1

to make UART working on standart raspbian, so hardware part is OK.

But my baremetal kernel file, that must init and send some stuff to UART does not work. In minicom I see greetings from rescue system and some trash.

Do you have any progress with this?
Ilja K.

User avatar
Truewar
Posts: 2
Joined: Tue Jan 03, 2017 4:45 pm
Location: Czech Republic
Contact: ICQ Website

Re: RPI 3 B+ startup

Wed Jan 04, 2017 7:29 am

Well it was simple enough and already solved by mentioned David Welches.

To try bare metal RPI3 startup you can do following:
  1. Format SD card in FAT32. You will need just one partition.
  2. Put on this SD card just two files (bootcode.bin and start.elf) from the official repo.
  3. Write your kernel file and config.txt. For the first test you may try David's example
    (You will also need to connect your RPI3 to host machine using USB TTL cable and sniff results using minicom or something)
I was interested in development for aarch64. So to ask bootcode to swith processor to this mode, you must add following setting to config.txt:

Code: Select all

arm_control=0x200
Ilja K.

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

Re: RPI 3 B+ startup

Sun Jan 08, 2017 3:01 pm

Tried it none of his samples will pick a RPI3 B up you just get the stupid coloured screen they will pick up a normal RPI3.

I also repeat I know the SD card is okay because I have the kernel file from Raspbian usually called Kernel7.img and it works. I again also repeat strangely you need a couple of extra files on the SD card you don't need on a straight Pi 3 to pick it up. Whether this is a raspbian thing or something needed by the boot file I can't say.

I have simply renamed the raspbian kernel file to akernel7.img and replaced it with my file called kernel7.img which won't boot. I mean not even the first couple of instructions which just punch a GPIO port get executed.

So can we please stick to the code it has absolutely nothing to do with the SD card and the problem is specific to the B version. It would appear you have to do something different to all other RPI's to pick it up.

User avatar
Ultibo
Posts: 135
Joined: Wed Sep 30, 2015 10:29 am
Location: Australia
Contact: Website

Re: RPI 3 B+ startup

Mon Jan 09, 2017 12:33 am

LdB wrote:Tried it none of his samples will pick a RPI3 B up you just get the stupid coloured screen they will pick up a normal RPI3
Hi Ldb,

Exactly what do you mean by a RPI3 B versus a normal RPI3?

As far as I know there is only one version of the Pi3 so far and it has printed on the board "Raspberry Pi 3 Model B V1.2".

Do you have a different one to that? Has a new one been released already?
Ultibo.org | Make something amazing
https://ultibo.org

Threads, multi-core, OpenGL, Camera, FAT, NTFS, TCP/IP, USB and more in 3MB with 2 second boot!

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

Re: RPI 3 B+ startup

Mon Jan 09, 2017 2:17 am

Your reply sort of lead me to a partial solution an interesting observation and even more shaking of my head at the undocumented stuff on the Pi.

I had a Pi3 starter kit which was marketed as a cheap startup and I mistook it as being different to the Pi3 B+ I had purchased as just the bare board (they were close to same cost). Easy to do I have 5 different board currently on my desk. The Pi3 kit worked and the solo purchased board doesn't. Pulling the case apart the two boards are identical so that really had me scratching my head and I assumed the individual board was dead.

Now the story takes a twist so I decided to load linux onto the solo purchase board to run some diagnostics and everything works and reported fine. So now I was really confused. What got even more weird was when I now inserted my baremetal file it started.

What had changed is I had never installed or linux beyond the start up to the first point on this board before. It would appear the first startup of linux does something to the board internally or in the firmware. There are vague references to firmware updating on the internet but I haven't found anything definitive.

So I solved my board starting but I have no idea what the linux install did to fix it. Yet another mystery in the great piles of PI undocumented stuff.

So for others I strongly recommend you install Raspbian on the board before you start playing around with baremetal on it and save yourself some headaches like I went thru.

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

Re: RPI 3 B+ startup

Wed Jan 11, 2017 5:48 am

Argg nope I spoke to soon, still have something weird going on with this board and my toolchain, my code will compile and work one minute and not the next.

Can I beg if anyone has a running baremetal kernel7.img file that does something basic they can link me. I can't decide if the board is flakey or my toolchain is flakey. If I can get a known good baremetal kernel7.img file I can at least eliminate the board being the issue.

The raspbian image starts but that boot process is very different to baremetal file.

User avatar
Gavinmc42
Posts: 2093
Joined: Wed Aug 28, 2013 3:31 am

Re: RPI 3 B+ startup

Wed Jan 11, 2017 7:38 am

Use Ultibo to make a kernel7.img for you.
Just use one of the examples.

Have not had a bad Pi yet.
Usually it's the SD card.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: RPI 3 B+ startup

Wed Jan 11, 2017 9:10 am

Okay got it consistently picking up correctly using kernel_old=1 in config.txt and taking it from address $x0. I had forgotten about that ability until I saw some samples from Peter Lemon. I can even compile my sample in 64bit aarch64 call it kernel8.img and pick it up like some of Peters samples.

So it's not the toolchain or the image file it's the normal boot process that is playing RNG

So what happens in the normal boot code that would be flakey like this or what I have forgotten to do?

Return to “Bare metal, Assembly language”

Who is online

Users browsing this forum: No registered users and 5 guests