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 independent70% 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 driver100% Done
PCM driver99% Done
PWM mini jack driver99% Done

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 SDcard is very important driver, because it allows us to place whole system and binaries on the SDcard, which surely makes the MINIX more useful and comfortable. Lionel Sambuc wrote a new script, which place whole system on the SDCard.

There are not very big difference between the RPI and the OMAP, if we talk about the driver structure.

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 new I2C driver is similar with the previous drivers, because the MINIX has the I2C stack, which requires definition of specific functions. The RPI may be as slave or master, but the current version of I2C driver supports only the master mode. It supports the 7 and 10 bits address. Plan - how to add the new I2C driver was added to the README. It's very simple, because the I2C stack was created as portable driver.

The PCM driver

The PCM driver is audio driver. The special device can be connected to RPI usage the I2S interface. The PCM driver uses the 5th DMA channel to send data to the I2S. It doesn't support recording audio and 24 and 32 bits audio.

The SPI driver

The MINIX hasn't had the SPI stack yet, so we decided to develop the SPI driver as the chardriver. Communications with it carried out by open/close, read/write for sending data and ioctls for the setting SPI mode and speed. The current SPI driver can work only as a master.

The PWM analog audio 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.1503627136.txt.gz · Last modified: 2017/08/25 04:12 by nekorobov