Programming the Fubarino RetroBSD Bootloader via JTAG

As a result of the Hackaday Fubarino contest, I am the proud owner of a V1.5 Fubarino from Microchip. This version is based on the Microchip PIC32MX795F512H with 128 KB of RAM and 512KB of Flash memory.

I already have a variety of Arduinos and wanted to do something different with this one so I decided to install RetroBSD on it. Following the instructions on the RetroBSD installation page, I downloaded the source and compiler packages and managed to get it built. However, when it came time to load the image into the Fubarino I realized I had a problem.

The Fubarino comes with a bootloader compatible with MPIDE and the stk500V2 protocol already installed. However, much as I tried, I couldn’t use this bootloader to load the RetroBSD image. I finally decided I would need to load the Microchip HID bootloader but didn’t really want to spend $40-$50 on an new programmer just to program one file.

JTAG To The Rescue

While casting about for alternatives I ran across the ArduPIC32 software. This Arduino software provides a way to program PIC32 chips using JTAG and was just the thing I needed.

The software requires connections between the Arudino and Fubarino as shown in the figure below (Arduino on the left, Fubarino on the right). The direct connections shown assume the use of a 3.3V Arduino like the 3.3V Arudino Pro Mini. Using the 3.3V version is critical because the pins on the PIC32 chip used for the Fubarino are not 5V tolerant. If you use a 5V Arudino you’ll need level shifters between the Arudino and Fubarino.

Fubarino Connections

Once I had the hardware connections worked out it was time to tackle the software. The first problem I ran into was the software not recognizing the Fubarino PIC32 device. To resolve this, it’s necessary to add the PIC32MX795F512H and appropriate information to the list of devices included in the software. Open the file Pic32.h in the ArduPIC32 package, locate the Pic32DevIDList[] array, and add the entry

{ 0x4430E053, "795F512H", 128, 12, 512 },

to the bottom of the list.

The cause of the second problem was more difficult to find but just as easy to resolve. Each time I tried to send the Intel HEX file containing the bootloader to the Arduino, I got an error indicating a problem with the HEX file format. However when I looked at the file in an editor no format problem was apparent.

I finally realized the error was caused by a serial buffer overrun. With the Arduino Pro Mini running at 8 MHz the hex data was being downloaded faster than it could be processed. To fix it I added XON/XOFF flow control to the JTAG programming loop (XOFF immediately before programming/verifying data, XON upon completion), which solved the problem by suspending hex data downloads while JTAG commands were being sent to the Fubarino.

Using the Software

To program the Fubarino bootloader you’ll need terminal sofware capable of sending a file in ASCII format. I used cutecom on my Linux machine but Hyperterminal on a Windows machine should work as well.

Program the Arduino with the ArduPIC32 software that’s been modified as described above. Fire up your terminal software and set it to 1200 8N1 with software flow control. Reset the Arduino and use the terminal software to connect to it via the appropriate serial connection. Once you’ve connected:

Press ‘H’ to display the ArduPIC32 menu.

Press ‘c’ to connect to the Fubarino board.

Press ‘e’ to erase the flash memory (this is unrecoverable).

Press ‘p’ to go into programming mode.

At this point use the command appropriate to your terminal software to send the Intel HEX file containing the bootloader to the programmer. For the Fubarino the file is located at $RETROBSD/sys/pic32/fubarino/usbboot.hex where $RETROBSD is the directory where RetroBSD is installed.

Upon completion, disconnect the Fubarino from the Arudino and plug it in via USB. Execute the command ‘sudo pic32prog’ and you should get the output shown below. (You may have to download and build the pic32prog utility if you don’t already have it on your system.)

pic32prog

Final Comments

This programmer will set no speed records I wouldn’t recommend it for general use. However, if you don’t have access to a PIC32 programmer this is a viable alternative for programming the Fubarino RetroBSD bootloader and best of all, you can reuse the parts for other projects.

Advertisements

Comments are closed.

Tabula Candida

Doodles of a distracted historian

rtl-sdr.com

A blog about RTL-SDR (RTL2832) and cheap software defined radio

DuWayne's Place

Computers, Electronics, and Amateur Radio from KC3XM

QRP HomeBuilder - QRPHB -

Computers, Electronics, and Amateur Radio from KC3XM

Open Emitter

Computers, Electronics, and Amateur Radio from KC3XM

Ripples in the Ether

Emanations from Amateur Radio Station NT7S

m0xpd's 'Shack Nasties'

Computers, Electronics, and Amateur Radio from KC3XM

%d bloggers like this: