Reinstall and Update Bootloaders on chipKIT Boards

A while back I posted my tutorial on MPLAB for Arduino Users. I’ve also written a couple tutorials on Instructables that show you how to install MPLAB X IDE and use it to program your board. In those tutorials, I mention that using MPLAB X to program your board will overwrite its bootloaders, but Arduino and MPIDE both need those bootloaders in order to program the board!

That means that after you use MPLAB X, you can’t switch back to Arduino or MPIDE! Gasp!

Don’t worry! I’m going to show you how to use MPLAB IPE to reinstall the bootloaders, and even update them to the latest version!

Let’s get started!

What’s This About Updating?

Chances are good that your uC32 has a bootloader installed that’s too old to work with Arduino, even if you install chipKIT core. Thankfully this only is a problem with the uC32 and the old bootloader will still work with MPIDE. However, if you want to continue getting support and updates from chipKIT and Digilent, you’ll have to update your bootloader.

There are two ways you can do this. In this section, I’ll show you how to use the uC32‘s update sketch. It’s the simplest method, because it uses MPIDE, and doesn’t require external hardware like the chipKIT PGM. But it does require that your uC32 to still have the old bootloader installed.

The second method involves using the MPLAB IPE and an ICSP programmer (like the chipKIT PGM) to re-install your bootloader entirely. This method can also be used to re-install bootloaders on boards that had been overwritten (usually by the MPLAB IDE), I’ll show you how to do that in the next section.

uC32 Update Sketch

Like I mentioned before, this first method of updating your uC32‘s bootloader uses MPIDE, and doesn’t require an ICSP programmer like the chipKIT PGM.

Resource Center 2 (mod1)

 

You’ll want to start by downloading the uC32 update sketch from the Digilent resources wiki. Don’t worry about downloading the bootloader image, because the update sketch doesn’t need it.

UpdBluC32

Use MPIDE to open up the sketch titled UpdBluC32.pde. Recall that the old bootloader that’s on your board currently will only work with MPIDE, so we can’t use Arduino for this. Upload it to your uC32, then open the serial monitor. You should see text appear that’s similar to the text below.

Serial Monitor 1

This step exists because the old bootloader has no way of informing the sketch what board it’s installed on. That means you could potentially install this update sketch on a different board (like the WF32) and cause some serious problems! To help mitigate this problem, this sketch prompts the user to confirm that it really is a uC32 that you’re working with here.

Copy the text inside the quotes, and paste it into the terminal’s input window (like I’ve done above), then hit “Send”. You should see a stream of text as the updates install, similar to the text below.

Serial Monitor 2

Now that we’ve run the update sketch, we should verify that it’s installed correctly. Close the serial monitor, and hit the reset button on your uC32. Then re-open serial, and wait for the text to appear. You should see something like the text pictured below, which states that your board is up to date!

Serial Monitor 3

Now your board is ready to be programmed by Arduino and the chipKIT Core…almost. Before you switch from MPIDE to Arduino, you’ll need to power cycle your board. That means more than just hitting the reset button! You need to totally reset your board’s hardware, so you’ll have to unplug it from power, and plug it back in again, before you can program with Arduino. I’ll explain why later.

Reinstalling Bootloaders

Any board that gets programmed by MPLAB X IDE will have its bootloaders wiped. This means that in order to use Arduino or MPIDE again, you’ll have to reinstall those bootloaders.

If you want to update your uC32’s bootloaders this is a good method to use, as I mentioned before.

It’s worth noting that the update sketch will only update your bootloaders to version 1000301. The latest version is 1000303, and that’s what this next method will update to. However, both versions are exactly the same. When Keith Vogel rebuilt version 1000303, he used all the same resources as the previous version, but because it was a rebuild the version number still went up.

Downloading the Bootloaders

Each board we sell has a link to its resource page on the store site. Simply scroll down until you see a button that says “Resource Center” and click that. It will take you to that board’s page on the Digilent Resource Wiki.

Resource Center 1 (mod1)

From there, you can scroll down until you see a section titled “Design Resources”, which will have a link where you can download the bootloader image specific to your board. Once it’s finished, unzip it to whatever folder is most convenient.

Resource Center 2 (mod2)
This is the bootloader for the uC32. If you’re using a differen’t board, you’ll need to get that board’s bootloader instead.

Using MPLAB X IPE

If you followed my tutorial on installing the MPLAB X IDE, you will have also installed the IPE as well. I included that step specifically because it makes reinstalling bootloaders much easier.

Start by connecting your programmer to the ICSP port of your board. I’m using the chipKIT PGM, but we sell several ICSP programmers and you can use any of them.

IMG_7466(edt1)

 

Make sure the arrow lines up with the square terminal on your board, as pictured above.

Plug both your ICSP and board into your computer. I’ve gotten away with only plugging in my ICSP before, which can supply enough current to power the board as well, but it’s probably best if you plug both in.

IPE 1

Now open up the MPLAB X IPE. Your programmer should be automatically selected for you in the “Tool” category, but you’ll have to specify which device you’re using. You can either read the small print on the chip in the center of your board, or you can find that information in your board’s retail page, or the reference manual section of your board’s resource page.

uC32 PIC32 Closeup
Closeup of the PIC32MX340F512H onboard the uC32.

Once you’ve entered that information, hit “connect”. The first time the MPLAB X IPE connects to a specific board, it will need to download updates for the drivers. This can take a long while, but future connections will be much faster.

Once you’re connected, you will need to locate your bootloader’s binary file. Click the “browse” button next to the “Source” field, and browse to where you put your bootloader.

IPE 2

Now hit program, and wait for the board to be programmed! Once that’s done, you can close MPLAB X IPE and remove the ICSP programmer.

IPE 3

Switching to Arduino IDE

At this point, your board is almost ready to be programmed by the Arduino IDE, you just need to unplug it from power, and plug it back in again. If you used the uC32 update sketch to make your uC32 ready for Arduino IDE, you also have to power cycle your board before you can use Arduino. This is true for all chipKIT boards, and you’ll need to power cycle it this way whenever you switch from Arduino to MPIDE or back.

Arduino 1

The reason for this is tied to how the FTDI chip in these boards connects to the programmers used by Arduino and MPIDE. Arduino (more specifically the chipKIT Core) uses a program called PIC32Prog to program the PIC32 microchip on our boards, while MPIDE uses AVRDude.

When PIC32Prog, or AVRDude begin programming the board, they set the FTDI chip to a state that prevents the other from initializing properly. Furthermore, the reset button on chipKIT boards will reset the microcontroller, but not the FTDI chip, which is where the malfunction occurs.

In order to get a board-wide power cycle, you have to unplug the board.

Now, it’s true that the latest version of the chipKIT Core comes with a newer version of PIC32Prog that fixes some of the problems that cause this glitch to happen. That means that with the latest version of Arduino IDE and chipKIT Core, it should be possible to switch back and forth without issue. However, we don’t know if these new versions have introduced new behavior that causes problems or not.

Either way, it’s simple enough to power cycle between MPIDE and Arduino, and will probably save headaches in the long run.

Happy Making!

That about wraps it up for my tutorials on MPIDE and Arduino. They’re both extremely useful tools with their own strengths and weaknesses, and knowing how to use both can be a great advantage! Hopefully you found my these guides useful!

Be the 1st to vote.

Leave a Reply

Your email address will not be published. Required fields are marked *