Microblaze port of Arduino 1.5.2 @ 100 MHz


Recommended Posts

I have been working on porting the Arduino 1.5.2 code base to Pipistrello using the Microblaze soft processor running at 100 MHz.  This is definitely a work-in-process but I think it's complete enough to share.  The biggest downside of using the Microblaze core in this project is that it requires an EDK license which is not free.  It's possible to swich to Microblaze_mcs which is part of the free ISE Webpack but it would restrict the processor to 64 KB address space and use the lower-performance 3-stage processor vs. the high-performance 5-stage Microblaze in EDK so at this point I'm sticking with the full Microblaze core since it will also allow full access the the Pipistrello 64 MB DRAM space.


The full arduino-1.5.2-windows version of this can be downloaded here:




The Linux version is almost there, just fighting silly FTDi serial port issues (man, I love Linux but why does it have to be so difficult to do simple things like user-space serial port access)


What works and what's not there yet? 


I think it's easier to answer what's not there instead of what's there.  The following things are not impemented:


analogRead(), analogReference(), analogReadResolution() : No analog input on Pipistrello


tone(), noTone(): the hardware for this is not yet there


attachInterrupt(), detachInterupt(), interrupts(), noInterrupts(): the interrupt system is not yet impemented


hardware for I2C is not yet implemented

SPI hardware is master-mode only


OK, so what does work?


The following Arduino functions are implemented:
pulseIn() (not yet calibrated though)




Wing A pins 0 - 15 has arduino pins 0 - 15.  They can all do digital in/out and analog out.  Analog out has 16 bit resolution but is scaled down to 10 bits for compatibility with the Atmega parts.  However, the new function analogWriteResolution() introduced in arduino-1.5 for Due allows you to change the resolution to 16 bit.

Wing B pins 0 - 7 has arduino pins 16 - 23.  They are digital only or SPI ports (if enabled).

The LEDs on the board are mapped to pins 12,13,14 and 15 but can be remapped to any of pins 0 - 15 by writing to a register (the arduino code for this is not there yet).

Just like for Mega there are 4 serial ports - Serial, Serial1, Serial2 and Serial3.  Serial is connected to the FTDI chip and Serial1 - 3 are connected to Wing B pins (8,9), (10,11) and  (12,13).

There are 3 SPI ports in hardware - the default is connected to the SD card socket and is using arduino pin 53 as chip select. The 2 extra SPI ports are not yet exposed in the Arduino code.


The library SPI is working as well as the SD library that uses the SPI library

Things to try:
Examples -> 01.Basic -> Blink (should run without any changes and blink the red LED L2)
Examples -> 03.Analog -> Fading (change the LED pin from 9 one of pins 12 - 15)
Examples -> SD -> CardInfo (needs a microSD card, change chipSelect from pin 4 to pin 53 and enable a serial console)


Link to comment
Share on other sites

  • 3 years later...

This is a very cool post !

I am trying to port to Arduino a board with Artix-7(fpga from xilinx) and Microblaze(comes free with Vivado). I have no problem doing the development on the Xilinx side of tools(Vivado SDK) but i am a bit stuck on the Arduino side. In order to make arduino work it needs a bootloader. Also in Arduino when you build for your board(microblaze in my case) you need mb-gcc. Could you point me in the right direction ? What bootloader is needed and how do you integrate mb-gcc with Arduino ? Some references will be highly appreciated :)

Thanks !

Link to comment
Share on other sites

This is a quite complex undertaking and I'm not sure a forum post can explain all the aspects of doing a Arduino port for a different processor but I will try to give you a few hints on how to do this.

1) You need to create the hardware platform so that you can support the basic Arduino system, i.e. processor, memory, timer, digital I/O with optional PWM, uarts, SPI controller etc.  The nice thing with creating your own I/O modules is that you can make them so that the porting of the Arduino core code is easier than if you use the Xilinx IP or other open-source I/O modules.  For instance, if you make the SPI controller work the same as the AVR SPI controller (same registers and control bits) then you can use the already available SPI library with minimal modifications.

2) You need to understand the Arduino build system and create the necessary files and folders to support a new processor.  The added files and folders will go in the <Arduino>/hardware folder.  You can see how they added support for the ARM processor (i.e. sam) and create the same structure for microblaze.  Part of this will be to port the core arduino code to your hardware platform and create the files platform.txt and boards.txt that will control how the build is done.  This is the hard part of doing the port.  The gcc compiler will be in the <Arduino>/hardware/tools directory.

3) For bootloader there are several possibility.  One is to have bootloader code resident on the hardware platform that talks to a bootloader running on the development system (Linux or Windows) like how the did it for ZPUino (this mimics the Arduino way of loading code).  Another alternative is to use the data2mem program and merge in the generated arduino sketch code directly to the bit file and download the resulting bitfile using JTAG (no bootloader needed but only works if the system memory is in BRAM).  A third alternative is the store the arduino sketch code in elf format in the flash memory after the bit file and have an elf loader resident on the hardware platform that will load the elf code from flash to main memory and execute it (works for both BRAM and external memory).  I have implemented the last two options for my systems.

For Vivado, mb-gcc can be found in the Xilinx SDK directory.  On my Windows install it can be found at C:/Xilinx/SDK/2015.3/gnu/microblaze/nt.  I have not installed Vivado on my Ubuntu system so I can't say the exact path but my guess would be /opt/Xilinx/2015.3/SDK/gnu/microblaze/lin64 or something like that.

Hope this helps.


Link to comment
Share on other sites

BTW, here is a link to a complete project using Microblaze_MCS: http://www.saanlima.com/download/pipistrello-v2.0/waveplayer_complete.zip

The folder ise has has a complete xilinx project to build the hardware platform, including all the rtl files needed (the processor and all the custom I/O modules).

The folder arduino-1.5.2-mcs contains the complete arduino environment for Windows with added microblaze support, including the gcc compiler and core arduino code for the microblaze hardware platform.

The file waveplayer.ino is an arduino sketch for this system that plays wave files stored on a sd-card.  It uses standard arduino libraries for SPI and sd-card support.


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.