About RetroBSD: A Port of BSD Unix to a Microchip PIC32 Microcontroller


Serge V.

About RetroBSD: A Port of BSD Unix to a Microchip PIC32 Microcontroller

By Serge Vakulenko

I started this work a year ago as a hobby project. Now I can demonstrate a demo, running real Unix on a tiny development board.

The project is hosted on Google Code: http://code.google.com/p/retrobsd/.

The system is targeted to a market of small embedded systems. Main features include:

  • Small resource requirements: RetroBSD requires only 128 kbytes of RAM to be up and running user applications.
  • Memory protection: Using hardware mechanisms, kernel memory is fully protected from the user application.
  • Open functionality: Usually, a user application is fixed in Flash memory, but in the case of RetroBSD, any number of applications could be placed into the SD card, and run as required.
  • Real multitasking: Standard POSIX API is implemented (fork, exec, wait4 etc).
  • Development system on-board: It is possible to have a C compiler in the system, and to recompile the user application (or the whole operating system) when needed.

RetroBSD is based on 2.11BSD: the last in the series of Berkeley Unixes for the PDP-11 architecture. I ported the kernel, C library and a set of basic utilities to the MIPS32 architecture, using GCC/Linux as a development environment. I also created a PIC32 simulator based on the VirtualMIPS opensource project (http://code.google.com/p/virtualmips/).

There exists a similar system named uCLinux that is widely used for similar purposes. But uCLinux requires ten times more RAM than RetroBSD. It also has a limited multitasking capability (no fork), no memory protection and no C compiler on-board.

I believe that RetroBSD could be quite popular for small embedded systems. For example, it’s possible to make something like a ‘Unix stamp’, as opposed to the widely known Basic stamp.

  1. #1 by haiqu on August 7, 2011 - 1:12 am

    Hey Serge,

    Awesome work! I’m going to try porting it to the Maximite board, wish me luck.

    http://geoffg.net/Maximite_Story.html

    Rob

    • #2 by Serge V. on August 9, 2011 - 11:02 pm

      Thank you, Rob!
      Port to Maximite board is a great idea. I also ordered one, but it’s out of stock yet. It has no bootloader, so some changes in startup code are needed. Good luck!
      ___
      Serge

  2. #3 by haiqu on August 12, 2011 - 3:23 am

    I got the HID bootloader working tonight. Soon, very soon.

    Dontronics has a Maximite derivative called the SV1 if you need a board in a hurry. They’re SMD and well made. That’s what I’m using while I wait for Altronics to get more stock, they ran out of SD card slots and power switches and don’t expect any more for 6-8 weeks.

    Rob

  3. #4 by haiqu on August 12, 2011 - 11:01 am

    UBW32 firmware now loaded and serial comms working. I need to remap the reset button, LEDs and SD card for full functionality. Also built the BSD code under VMWare and made an SD card image with DD for Windows.

    I’ll have this done by the finish of the weekend. :-)

    Rob

  4. #5 by novorado on August 15, 2011 - 12:03 am

    Great, Serge, that development has a huge potential. PIC’s have very well developed periphery but so far it was lacking CPU power.

    What can be interesting for your board, is to see wheather PIC specific PIC linux drivers could be implemented – USB OTG support (so you can directly plug per say GPS or Flash or H.264 Video USB pen sticks);

    128K footprint is quite okay to fit in USB stack (32k) + 802.15.4 (ZigBee or MiWI). I managed to compile both together in less than 64k. Please note – dirver can be very primitive, few lines of the code, cause it’s essentially an integration of Microchip codebase with Linux. Should be pretty straightforward. Various radio cards provided by Microchip for mesh / wifi networking. I see here inifinite possibilities in using Microchip code coupled with Linux dynamic code loading.

    PIC’s have embedded SPI line. Thus, you can add exteremely chip video card ($20) with composite overlay capabilities, base on MAX7456, or, standalone ethernet controllers such as ENC28J60.

    Good luck, overall, great effort. Will watch tight your development and may be help if I could better understand your solution.
    There are few attempts, most notable one IMHO is http://www.pic24.ru/doku.php/tnkernel/mchp_c30_16bit_port
    And video game on PIC, another project fun to play with http://www.pic24.ru/doku.php/osa/articles/vga_game

  5. #6 by zabooh on August 19, 2011 - 6:05 am

    Hi Serge,

    is it possible to use an open source TCPIP stack together with RetroBSD?

    I mean, when the RetroBSD gave the chance to use all the network stuff which is available as open source, this would be very interesting.

    Martin

  6. #7 by Diogenes on September 15, 2011 - 12:26 pm

    Congratulations Serge !!! Very nice and magnific job !!!

  7. #8 by parthiv.shah on November 6, 2011 - 1:10 am

    I want sqlite in PIC32 microcontroller for effectively handling the database. Is it possible. If yes than please help me. Is there any other method to do so. Please guide me. Thank you.

  8. #9 by Serge V. on December 1, 2011 - 7:18 pm

    Hi Parthiv,
    I doubt sqlite could be used on PIC32, neither with RetroBSD, nor without. The code size of a library is about 550 kbytes, which exceeds the total flash memory size of a microcontroller.
    Regards,
    Serge

You must be logged in to post a comment.