This repository contains the XMODEM-based boot loader that allows us to send a binary image to execute on Raspberry Pi. The boot loader supports LZMA compressed kernel image to reduce transfer time (in our case, from 60s to 10s).
- Raspberry Pi 3 Model B
- micro-SD Card
- USB Power Cable
- USB TTL Serial Cable
- Driver for USB TTL Serial cable
- Python 3
- GNU Arm Embedded Toolchain
- xv6
- c-kermit
- Clone this repository.
git clone https://github.com/idewz/rpi-xboot.git
- Install required python packages.
pip3 install pyserial xmodem
- Copy necessary boot files
bootcode.bin
,start.elf
,fixup.dat
andconfig.txt
to your SD card (info).
cp firmware/*.* /Volumes/boot
- Build the boot loader and the simple uart program.
make
- Copy
bootloader.img
to the SD card with the namekernel7.img
.
cp bootloader.img /Volumes/boot/kernel7.img
-
Connect your serial cable to pin 6, 8 and 10 of your RPi like this
-
Now we can test it with our simple uart program.
python3 rpi-install.py /dev/cu.usbserial uart.img && kermit
Then you should see Hello, UART
on your screen!
To run xv6, please follow these steps.
- Clone the
xv6_rpi2_port
.
git clone https://github.com/zhiyihuang/xv6_rpi2_port
cd xv6_rpi2_port
-
Update the location of the
TOOLCHAIN
in the Makefile. -
Decrease the memory size in
source/main.c
to get the shorter boot time.
// before
kinit2(P2V((8*1024*1024)+PHYSTART), P2V(pm_size));
// after
kinit2(P2V((8*1024*1024)+PHYSTART), P2V((40*1024*1024)+PHYSTART));
-
Also remove
gpuinit()
insource/main.c
to disable the GPU. -
Build the xv6 kernel image.
make loader
- Now you can send the kernel image to your RPi.
python3 ../rpi-xboot/rpi-install.py /dev/cu.usbserial kernel7.img && kermit
It is probably because you have an outdated version of OpenSSL. You can verify that using the following command.
python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.0.2o 27 Mar 2018
If you have an older version, for example, 0.9.8zh 14 Jan 2016
, please update to a newer version of Python via homebrew or get it from the official website.
Make sure you format your SD card in FAT32 (On MacOS, it is MS-DOS (FAT)
). Then, verify the contents of the SD card. It should have
/Volumes/boot
├── bootcode.bin
├── config.txt
├── fixup.dat
├── kernel7.img # a copy of bootloader.img
└── start.elf
You need to quit current kermit before running rpi-install.py
. In order to do that, just press Ctrl + \
then q
.
After turn it on, you need to wait a few seconds before running rpi-install.py
because the script expects valid characters, not "Hello" from the bootloader.
- xv6 RPi port by Zhiyi Huang and Mahdi Amiri Kordestany
- rpi-install.py by Pat Hanrahan, Julie Zelenski, Omar Rizwan from Standford CS107e
- LZMA SDK by Igor Pavlov
- bootloader by David Welch