Lab 3: Mailboxes

Raspberry Pi Firmware

Note that the firmware for the Videocore is closed source, so there is no source code for it available in this repository. The Code section contains precompiled binaries only.

Mailboxes

Mailboxes are the primary means of communication between the ARM and the VideoCore firmware running on the GPU.

You need a mailbox before you can use UART0.
Use this to query the board serial number and output it to UART1.

NOTE: qemu does not redirect UART1 to terminal by default, only UART0, so you have to use -serial null -serial stdio.

The mailbox interface. First we fill up the message in mbox array, then we call mbox_call(ch) to pass it to the GPU, specifying the mailbox channel. In this example we have used the property channel, which requires the message to be formatted as:

โ€‹โ€‹โ€‹โ€‹0. size of the message in bytes, (x+1)*4
โ€‹โ€‹โ€‹โ€‹1. MBOX_REQUEST magic value, indicates request message
โ€‹โ€‹โ€‹โ€‹2-x. tags
โ€‹โ€‹โ€‹โ€‹x+1. MBOX_TAG_LAST magic value, indicates no more tags

Where each tag looks like:

โ€‹โ€‹โ€‹โ€‹ n+0. tag identifier
โ€‹โ€‹โ€‹โ€‹ n+1. value buffer size in bytes
โ€‹โ€‹โ€‹โ€‹ n+2. must be zero
โ€‹โ€‹โ€‹โ€‹ n+3. optional value buffer

How to run

make : From Source Code to Kernel Image
make run : Run on qemu

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

On Pi

make pi or sudo screen /dev/ttyUSB0 115200

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

References

https://github.com/raspberrypi/firmware/wiki/Accessing-mailboxes

https://jsandler18.github.io/extra/mailbox.html

https://blog.csdn.net/suz_cheney/article/details/86027172
https://grasslab.github.io/osdi/en/hardware/mailbox.html#mailbox


Previous Lab : UART1

Next Lab : UART0


Project Source Code: Bare-Metal-Mini-PiOS
Author : andykuo8766