chipKIT® Development Platform

Inspired by Arduino™

Boot-loader on bare PIC32 non-responsive

Created Tue, 25 Mar 2014 14:26:03 +0000 by drpap


drpap

Tue, 25 Mar 2014 14:26:03 +0000

I am having a hard time loading a functioning bootloader to a bare Pic32 chip and was hoping for some pointers. I have a relatively large program which runs on a chipKIT Max32 board and want to port it to a custom board equipped with the same Pic32MX795F512L chip, except that board has no on-board USB-to-serial converter, instead it provides access to the U1ARX and U1ATX pins on a header; the idea is to plug an external USB-to-serial onto that header, download the program using mpide and then remove the USB-to-serial. The USB-to-serial gadget I'm using has 4 pins: Tx, Rx, Gnd and \Reset.

I have installed MPLAB X with a chipKIT PGM Programmer/Debugger. I can successfully connect to the programmer, erase the chip, compile and download MPLAB X programs to the chip. However, in order to use mpide, I need to download the appropriate bootloader, and this is where I am having a problem.

I started by downloading the 'official' hex file on the chipKIT MAX32 web page, Doc # DSD-0000313. The download goes fine, but if I try to use mpide through the external usb-to-serial, I get no response. I can see the usb/serial activity LED blink once every few seconds, but no response from the PIC, so I think what is happening the boot-loader is not responding.

After that, I have tried downloading several boot-loaders from GitHub, none of which have worked.

From https://github.com/chipKIT32/PIC32-avrdude-bootloader under bootloaders/chipKIT-Bootloaders/dist, I used:

MAX32/production/chipKIT-Bootloaders.production.hex, 
MX7_UART/production/chipKIT-Bootloaders.production.hex, 
MX7_USB/production/chipKIT-Bootloaders.production.hex, 
MX7cK/production/chipKIT-Bootloaders.production.x

As I do not have the 'pro' version of the mplab x, I cannot compile from source and try to debug the boot-loader itself, but I was hoping this would be simpler.

In all cases, the same issue occurs, the mpide hangs, while the USB-to-serial activity light (the PC->PIC direction) blinks but no response on the led that shows PIC->PC direction.

I even tried 'bricking' a Max32 board by erasing it using the programmer and then re-load the bootloader using MPLABX to confirm the process, and indeed that worked, so I suspect there is something else going on.

On the custom board, the Tx pin of the USB-to-serial converter is routed to U1ARX, pin 52 and the Rx pin is routed to U1ATx, pin 53, which is the same as the MAX32 board. The grounds are of course connected and the \Reset from the usb-to-serial ties to the MCLR line on the PIC. I have used a scope to visualize the MCLR line while mpide downloads a sketch and can see the same on the MCLR line on the custom board while mpide downloads a sketch. I can also see the initial 'byte' transmitted on pin 52 (U1ARx) and up to that point all is the same. But after that, on the MAX32 there is activity on pin 53, whereas on the custom board, there is nothing.

I could abandon mpide and program the chip directly using MPLAB X but I do not want to redo the code that depends on mpide libraries (and I am using CAN and ethernet libraries on top of that). Also I want to maintain the ability to continue using chipKIT boards with the same software, all reasons to avoid abandoning mpide.

Any ideas what I should try next?


majenko

Tue, 25 Mar 2014 15:02:46 +0000

I would suggest knocking up a small MPLAB-X program to test the serial port and USB-UART adapter. Make sure all that's working right.


drpap

Fri, 28 Mar 2014 15:44:30 +0000

I had done that before and assumed it worked ok by seeing both of the lights on the serial-to-usb blink. I went back to it but realized that the data was garbled, suspected wrong baud rate, and finally figured it out, the board was using a different oscillator setup and the binary boot-loaders were setup with a different oscillator setup. Changing the oscillator mode on the boot-loader fixed it.