User Tools

Site Tools


soc:2017:portrpi

This is an old revision of the document!


Porting MINIX3 to Raspberry PI

Student: Nikita Korobov
Mentors: Jean-Baptiste Boric, Sambuc Lionel
git repository: https://github.com/nekorobov/minix/tree/rpi_clean

Abstract

The MINIX3 has already supported the ARM-based platforms such as the BeagleBoard. The goal of this project is port the MINIX3 to the RaspberryPi. The task requires changing the booting process, because it doesn't allow have more than one platform. The MINIX3 should be more flexible OS, port to the new platform shouldn't require change boot process, kernel files, etc. Only drivers must be written. A device tree is suitable technology for this purpose.

Also, some of the RaspberryPi drivers such as USB, SDCard, SPI, I2C, etc. must be implemented. It's the most long-term issue.

Current Status

DoneItemPercentage CompleteComments
Remove the dirty hack from kernel100% Done
Make kernel platform independent60% Add device-tree parsing
Cleanup booting process60%
Mailbox driver100% Done
Resolve tty issues100% Done
SDCard driver80% Add general and logical system
SPI driver60% Debug
I2C driver60% Debug
USB driver0%
PCM driver60% Debug

Design

Booting process

First bootloader reincarnation

The previous implementation of booting doesn't allow to have more than the one platform, because there were the different phys_base constants, the different hardware initialization functions with conflict names, which prevent compiling all sources of the MINIX into one .elf.

Now the kernel sets a page table on the early bootstrap stage in assembly and only the one file is unmapped. The all hardware-dependent functions called from exemplar of a special table. This table is initialized at runtime depending on platform, where the MINIX runs. We know the platform-depending constants and other platform information from a device-tree. I've imported external libfdt under BSD license to parse the dev-tree quickly.

The device tree is parsed in the pre_init stage. Machine type, memory constants, CPU amount and some necessary platform information are set up in this stage. Each driver, which use the platform depending constants (almost all drivers) should get these constants from the device tree. The earm/fdt.c allows get some parameters without knowledge how the device tree works and how parse it.

Second bootloader reincarnation

It will be good to have the general bootloader for all platforms, we thought. And it will be better to have a general structure in main with information about memory size, platform, framebuffer, etc.for each architecture.

Thus, a kernel-loader parse the device tree on the ARM, packs information into a multiboot2 format, which are compatible with any architecture. Other information(which can't be packed into the multiboot2) the kernel-loader packs into special structure, which is available only for the ARM platforms. The loader passes these structs to kmain, where multiboot2 format unpacks and constants are set.

The paging is also enabled in the kernel-loader. It means that the kernel doesn't contain unpaged code anymore. It makes the linker script easier and the kernel more consistent for each architecture.

The SDcard driver

The Mailbox driver

The mailbox driver is a character device. Other servers can communicate with it by open/read/write/close. Servers have to make structure with request to the Mailbox driver according to rules, which is described https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface. They have to open /dev/mailbox with read/write permissions and firstly write there request, then read it. You can find an example https://github.com/nekorobov/minix/blob/rpi_clean_driver/minix/drivers/video/fb/arch/earm/fb_arch_rpi.c

The I2C driver

The PCM driver

The SPI driver

Schedule

May

  • Cleanup existing pull request to MINIX proof of concept port
  • Remove dirty hack from kernel
  • Make loader more independent

Week 1, 2 (June 1 - June 14)

  • Improve tty
  • Clean up booting process

Week 3, 4 (June 15 - June 29)

  • I2C driver
  • Mailbox driver

End of the first phase

Week 5, 6 (June 30 - July 13)

  • SD card driver

Week 7, 8 (July 14 - July 28)

  • PCM audio driver
  • SPI driver

End of the second phase

Week 9, 10 (July 29 - August 12)

  • USB driver

Week 11, 12 (August 13 - August 27)

  • Cleanup code, etc.

End of the third phase

Resources

soc/2017/portrpi.1502273612.txt.gz · Last modified: 2017/08/09 12:13 by nekorobov