Tuesday, 22 October 2013

PICKit2 and Fubarino SD

If you've been playing with a Fubarino SD, then you probably already know it's designed to be Arduino code compatible (as long as direct hardware access is avoided). However, I wanted to do something else with it, using MPLABX (The Microchip IDE). This is where things get a bit more interesting, and I haven't figured out all the answers yet. Basically, I wanted to update the firmware on a Roland Juno-D keyboard, and wanted some way of sending the data over.

To do this, you send the MIDI files that Roland provide to the keyboard, after you've put the keyboard in firmware upgrade mode. I've already got a cheap ebay USB to MIDI, so it seemed to make sense to use this, but when I tried, I had no joy for some reason. I'd heard rumours that Sysex dumps can cause issues for these cheap devices, so I figured I could use the USB MIDI interface code that Microchip provide and hack that around a bit.

The downside is that a) I need to program the Fubarino SD outside the normal MPIDE environment and; b) I need/like to be able to restore the bootloader afterwards. At first I figured that programming would be easy, but the hex output I get from the USB to MIDI seems to start at the bootloader, not the main program code. I didn't really want to overwrite the bootloader if I could help it.

I didn't figure that out, although I found out I can use pic32prog with a PICKit2 to read/write the PIC32MX795F512L on the Fubarino SD. That's just as well, as PICKit2 software won't read/write the PIC32 on the Fubarino - maybe that's an excuse to move to a PICKit3? I duly backed up the bootloader memory, and blatted it with the new code from MPLAB. Figured I should check to see I can restore it, and discovered that although pic32prog can read the code back out, it won't write binary files. So, I'm left with two choices... Convert the bootloader binary back into Intel hex or Motorola srec format, or dig up the right bootloader.

I chose the hard path first, trying to convert the binary back into Intel hex format. I thought I'd had some joy, but the bootloader didn't actually work when I tried it, although I'm not sure why. Having wasted 30 minutes doing this, I realised I already had the bootloader for the Fubarino SD on my machine (!!). If you're in such a position and you lose the bootloader, you can find them here: https://github.com/EmbeddedMan/PIC32-avrdude-bootloader/tree/master/update-sketches. For the Fubarino SD you want MPIDE-bootloader-SD.X.production.hex.

Oh, the MIDI code? The USB side enumerates just fine. Now I need to add the code to actually push out the bytes on the serial port!

No comments:

Post a Comment