GSoC 2024 Final Submission: BSP Improvements for RPi4
Project Proposal: https://docs.google.com/document/d/1NjlUSWhqwUvrsQPBISU05ah0I0IGkEuq6BIThrkMBsg/edit?usp=sharing
GitLab Epic Tracking Project: https://gitlab.rtems.org/groups/rtems/-/epics/6
GitLab activity: https://gitlab.rtems.org/users/yangn0/activity
Goal
This project aims to improve the Raspberry Pi 4B BSP support on RTEMS. Project intends to add the following supports to the Raspberry Pi 4B BSP: SPI support, Watchdog support and SD card support.
Work Done
GPIO Driver
The gpio driver is necessary for the development of other peripheral drivers.
Merge requests:
- 59 - aarch64/raspberrypi: Add gpio driver (merged)
- 18 - raspberrypi4.rst: Documation for the gpio driver(merged)
issues:
Repository:
The GPIO driver was mainly completed by GSOC 2023 student Utkarsh Verma, but I had to address issues needed to make it mergeable and fully functional. The work now lists both of us as authors.
Refactor the PL011 Peripheral Controller Driver
- Refactor the pl011 driver to be extensible.
- Add IRQ support and baudrate configuration support for pl011 driver. (GSOC 2023 completed)
- Modify related BSP.
This was an unplanned task, but it is very meaningful and will be an improvement that is shared by many arm BSPs.
Merge requests:
- 43 - Add new PL011 driver with IRQ support (Closed)
- 47 - dev/serial: Refactor the pl011 driver to be extensible (Open)
issues:
The PL011 driver was mainly completed by GSOC 2023 student Utkarsh Verma, but I had to address issues needed to make it mergeable and fully functional. The work now lists both of us as authors.
SPI Driver
Finished the SPI driver for Raspberry Pi 4B BSP and SSD1306 driver. I connected a 1306 OLED screen to RPi4 via SPI and output the RTEMS logo.
Merge requests:
issues:
SSD1306 Driver:
Blog Post:
Timer
Finished the system timer support and the Wathdog Timer driver.
Merge requests:
- bsps/aarch64/raspberrypi: Add system timer support (Merged)
- 120 - aarch64/raspberrypi: Add Watchdog Timer driver (Merged)
WDT test:
Blog Post:
FDT support for sdhci
FDT support for sdhci (Unmerged)
Bugs
Some bugs I found and fixed.
5012 - termios: scanf() is not blocking in UART interrupt mode (Closed)
51 - bsps/xilinx-versal: fix BSP_INTERRUPT_VECTOR_COUNT too large (Merged)
64 - dev/pl011: Fix incorrect macro definition (Merged)
Current State
I completed most of the tasks in the proposal such as SPI support (polling mode and interrupt mode), watchdog support, and some unplanned tasks such as improving and merging gpio and pl011 driver.
Work Left
1. sdhci driver
The sdhci driver in freebsd requires BSP to support DMA, FDT, and mailbox. If I want to port it to libbsd, I need to implement DMA support, FDT support, and mailbox support first. There is a lot of work to support sd card. I only implemented FDT support for sdhci (Unmerged). So the left work is DMA support, mailbox support and SD card support. And the FDT support for sdhci may still need improvement.
2. GSOC2023 unmerged code
There is still some unmerged code from Utkarsh Verma.
- Incomplete mailbox driver
- I2C support
- Make the rpi4 console support any of the six UARTs
- Miniuart driver
For details, please see Utkarsh Verma’s blog.
I will focus on RTEMS in the next two years, continue to work and complete them.
Unmerged MR
Conclusion
I was very lucky. RTEMS was migrated to gitlab in the early stage of GSOC2024. This greatly reduced the difficulty of code merging. All my questions were answered promptly. I learned more about RTEMS and embedded development. Contributed to a very worthy cause and worked with many RTEMS people and great mentors from various parts of the world. I really enjoy working with RTEMS.
I would like to thank my mentors (Kinsey and Utkarsh), and the whole RTEMS community for every suggestion, discussion, and comment which helps me to deal with all the difficulties and problems. I would also like to thank Google for providing this opportunity.