Can it run BSD? The story of a MIPS-based PIC32 microcontroller
When someone brings up the topic of open source software, many think of the GNU/Linux operating system and the vast community of developers formed around it. However, there are several other active open source software projects that deserve equal attention; one example is the BSD operating system – a group of popular Unix-like operating systems (e.g. FreeBSD, OpenBSD, NetBSD) developed and distributed freely.
Parts of BSD are also incorporated in multiple mobile and PC operating systems in use today, including Apple’s OS X and iOS.
RetroBSD on PIC32MX
The RetroBSD project was started five years ago by Serge Vakulenko, a MIPS developer who wanted to see whether it’s technically possible to port a 16-bit 2.11BSD operating system to a modern PIC32 microcontroller. It turned out this was not only perfectly possible, but the resulting system could also include a full set of drivers for GPIO, UART, SPI, LCD displays etc.
Soon more people started taking notice and soon RetroBSD grew into a standalone platform used for real-world applications like weather data gathering; for example, a RetroBSD demo posted on Hackaday.io a few months ago got more than 3,500 views and 27 followers.
Earlier this month, DIY electronics mavericks Olimex released PIC32-RETROBSD, a new development board designed specifically for the RetroBSD operating system. This open source kit includes a PIC32MX microcontroller and represents a testament to the benefits of the MIPS architecture, allowing developers to run a Unix-based, sophisticated operating system in as low as 128 KB of RAM – including a C compiler!
LiteBSD on PIC32MZ
When Microchip introduced the PIC32MZ family, Serge started investigating whether there was an opportunity to create software magic again. I am very excited to report that he has been able to port the much more powerful, but still compact 4.4BSD operating system to it – and kick-start the LiteBSD project. Since the PIC32MZ MCU includes 512 KB of RAM, developers can run even more sophisticated applications using LiteBSD.
Currently about 200 KB of memory is available for the user space, and due to TLB and paging support this amount can be doubled or even tripled. The LiteBSD kernel has a fully-featured networking TCP/IP stack and the Ethernet driver is ready and functional. A Wi-Fi driver for the chipKIT WiFIRE board is currently under development (presently 80% of the work is complete).
In addition, the RetroBSD kernel has been updated so that drivers have a similar organization and can be easily ported from LiteBSD to RetroBSD and back. This should reduce the amount of work for the driver developers.
The combination of the LiteBSD operating system and the MIPS architecture can become an attractive new solution for the growing IoT market. In addition to the Microchip PIC32 family, developers can also target other platforms like the Samsung ARTIK 1 dev kit, the Creator Ci20 and Ci40 development boards or the Ingenic X1000 SoC.
There is still a lot of work to be done for LiteBSD on the C compiler and shared libraries, as well as improving the VM subsystem and adding IPv6 support. If you want to get involved, have a look at the main project page and the list of recommended development boards.