cmarrin
Posts: 15
Joined: Sat Sep 15, 2018 7:19 pm

SD card, emmc and mailboxes

Thu Sep 20, 2018 11:14 pm

I'm writing a boot loader, based on dwelch's code. I've got it do an XModem load just fine. Now I'd like to do a second stage boot. When the bootloader comes up it waits 5 seconds and then loads a kernel binary from the SD card. At least that's what I want to do. My problem is in finding some good SD card code. The de facto standard seems to be emmc.c in the rip-boot repo. The problem is that this (and every other variant and version I've found) is very entwined with the rest of the system it's embedded in. So I've extracted it and all its support logic and got it building. Now I've turned on the debugging printf's and am starting to look. It fails at the very first step - powering on the card. There seems to be issues accessing the power management mailbox.

So my questions are this:

1) Are there any good mailbox resources (i've looked at https://github.com/raspberrypi/firmware/wiki/Mailboxes, but it's pretty thin)?

2) Are there any simple mailbox examples that I can get working to understand how this should all work?

Thanks...

cmarrin
Posts: 15
Joined: Sat Sep 15, 2018 7:19 pm

Re: SD card, emmc and mailboxes

Fri Sep 21, 2018 4:21 pm

Wow, I've made amazing progress, thanks to some code I found here:

https://github.com/moizumi99/RPiHaribote

This came out of a really great thread I found here:

https://www.raspberrypi.org/forums/view ... 3&p=656428

I grabbed the sdcard.c code from moizumi's repo, along with its friends, got it ported to my environment and it worked!!! I was able to read sector 0 of my SD card. I believe it was successful not only because it said it was, but because I looked at the last 2 bytes, which were 0x55, 0xAA, which says that this is the MBR.

My code is up at: https://github.com/cmarrin/placid. It is only tested on the RPi Zero W.

bzt
Posts: 161
Joined: Sat Oct 14, 2017 9:57 pm

Re: SD card, emmc and mailboxes

Sun Sep 30, 2018 9:18 am

Hi,

Take a look at my tutorials https://github.com/bztsrc/raspi3-tutori ... ector/sd.c. I've reimplemented sdcard.c, 10 times smaller (compiled code), much faster, but read-only (which is enough for a bootloader). I also have working examples on Mailboxes, and a basic boot-over-serial with a chainloader (should be straightforward to add XModem protocol to it).

Cheers,
bzt

cmarrin
Posts: 15
Joined: Sat Sep 15, 2018 7:19 pm

Re: SD card, emmc and mailboxes

Sun Sep 30, 2018 2:16 pm

Thanks for the link. I've been meaning to redo sdcard.c. It's the only code in my tree that hasn't been cleaned up. Your code is much cleaner and more clear. I'll work on getting it integrated.

Return to “Bare metal, Assembly language”

Who is online

Users browsing this forum: No registered users and 3 guests