siwadon / rpi-xboot

Raspberry Pi 3 + xv6

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raspberry Pi 3 & xv6

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).

What you need

Hardware

  1. Raspberry Pi 3 Model B
  2. micro-SD Card
  3. USB Power Cable
  4. USB TTL Serial Cable

Software

  1. Driver for USB TTL Serial cable
  2. Python 3
  3. GNU Arm Embedded Toolchain
  4. xv6
  5. c-kermit

Boot Loader Setup

  1. Clone this repository.
git clone https://github.com/idewz/rpi-xboot.git
  1. Install required python packages.
pip3 install pyserial xmodem
  1. Copy necessary boot files bootcode.bin, start.elf, fixup.dat and config.txt to your SD card (info).
cp firmware/*.* /Volumes/boot
  1. Build the boot loader and the simple uart program.
make
  1. Copy bootloader.img to the SD card with the name kernel7.img.
cp bootloader.img /Volumes/boot/kernel7.img
  1. Connect your serial cable to pin 6, 8 and 10 of your RPi like this

  2. 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!

xv6

To run xv6, please follow these steps.

  1. Clone the xv6_rpi2_port.
git clone https://github.com/zhiyihuang/xv6_rpi2_port
cd xv6_rpi2_port
  1. Update the location of the TOOLCHAIN in the Makefile.

  2. 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));
  1. Also remove gpuinit() in source/main.c to disable the GPU.

  2. Build the xv6 kernel image.

make loader
  1. Now you can send the kernel image to your RPi.
python3 ../rpi-xboot/rpi-install.py /dev/cu.usbserial kernel7.img && kermit

Troubleshooting

Get an SSL error during pip3 install

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.

Cannot see anything in kermit

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

Read failed: device reports readiness to read but returned no data

You need to quit current kermit before running rpi-install.py. In order to do that, just press Ctrl + \ then q.

Send error: expected NAK, CRC, or CAN; got b'H'

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.

Acknowledgements

About

Raspberry Pi 3 + xv6

License:MIT License


Languages

Language:C 96.5%Language:Python 1.4%Language:Assembly 1.1%Language:C++ 0.5%Language:Makefile 0.4%Language:Shell 0.1%