chipKIT® Development Platform

Inspired by Arduino™

DIY chipKIT on breadboard - boot loader

Created Mon, 17 Feb 2014 23:20:23 +0000 by strim


strim

Mon, 17 Feb 2014 23:20:23 +0000

I've built myself a development board with PIC32MX220F032B-50ISP, loosely following this article on the wiki. I'm in a state where I confirmed that it works correctly by uploading some programs via ICSP. However, I'd like to have a chipKIT style serial boot loader on it (to save on-chip USB for other stuff).

It seems that such pre-built boot loader does not currently exist for MX2 series chips. I know the boot loader source is available on GitHub. So a couple of questions follow...

  1. As far as I understand, adding the new board description to BoardConfig,h should be enough to build the boot loader for my board?

  2. Will the boot loader build with the gcc as distributed with MPIDE? Are #pragma config this and #pragma config that handled properly? If not, how can I work around this? Do I really need to install MPLAB and XC32?

  3. While here, which board configuration in BoardConfig.h does chipKIT CMOD use (I have two of these and love them) ?


majenko

Tue, 18 Feb 2014 00:24:02 +0000

  1. As far as I understand, adding the new board description to BoardConfig,h should be enough to build the boot loader for my board?

Yes, just copy and paste, filling in the blanks.

  1. Will the boot loader build with the gcc as distributed with MPIDE? Are #pragma config this and #pragma config that handled properly? If not, how can I work around this? Do I really need to install MPLAB and XC32?

you need MPLAB and either C32 or XC32. That has to be the full version, not the free version, too, as it requires the -mips16 optimization that the free version doesn't have. Without that optimization the bootloader is too big to fit into the MX2 chip.

  1. While here, which board configuration in BoardConfig.h does chipKIT CMOD use (I have two of these and love them) ?

[/quote] Pass.


strim

Tue, 18 Feb 2014 09:21:03 +0000

you need MPLAB and either C32 or XC32. That has to be the full version, not the free version

Honestly, that is a bit disappointing...

as it requires the -mips16 optimization that the free version doesn't have. Without that optimization the bootloader is too big to fit into the MX2 chip.

But how complicated would porting to normal GCC be? Plain gcc has -mips16 switch. Not sure if it provides optimal code as MPLAB, but I saw that gcc as distributed with MPIDE has necessary mips16 object files. I shall experiment with that.

In the worst case I will roll out my own boot loader :? .


majenko

Tue, 18 Feb 2014 10:08:11 +0000

Honestly, that is a bit disappointing...

I am inclined to agree with you there ;)

But how complicated would porting to normal GCC be? Plain gcc has -mips16 switch. Not sure if it provides optimal code as MPLAB, but I saw that gcc as distributed with MPIDE has necessary mips16 object files. I shall experiment with that. In the worst case I will roll out my own boot loader :? .

I would love to see (and tried implementing once, but gave up as it was too hard) the ability to compile the bootloader from within MPIDE. No reliance on external tools would be an absolute dream.

Instead I have been pondering the idea of making a PIC32 bootloader building website, where you feed in the settings you require and a compiled bootloader pops out the other end. I have higher priority tasks on at the moment though, so it hasn't been started yet.


EmbeddedMan

Tue, 18 Feb 2014 15:00:40 +0000

Keith has done some great work (and a proof of concept bootloader) along the idea of breaking up the bootloader into two parts - one that lives in the Bootloader Flash and the second part that lives in normal Flash. The trick is to make the linking process work and to make sure MPIDE doesn't create sketches that stomp on the toes of the bootloader piece in normal Flash.

See, the problem is that Microchip made the bootloader Flash section of the PIC32MX parts way too small. You just can't get any sort of a decent bootloader in that space without lots of optimizations and/or leaving features out.

The chipKIT team made the decision to try and use the Bootloader flash for our bootloader, so this meant we had to have the fully optimizing C compiler in order to get it to fit. The reason for this decision was to leave as much space as possible in normal Flash for people's sketches.

So, there's absolutely no reason you can't build the bootloader with the free version of C32 or XC32, and just use the 'split' idea to spread it across the bootloader and normal sections of Flash. Again, see Keith's split bootloader tests in the bootloader git repo for an example of how to do this.

Now, compiling with the MPIDE compiler should also be possible, but I don't know enough about the differences between it and the normal C32/XC32 to be of much help there. It has been talked about before that it would be so very very cool to be able to compile the bootloaders with the MPIDE compiler. Any forward progress on this would be much appreciated.

*Brian


guymc

Wed, 19 Feb 2014 04:30:37 +0000

I agree; the ability to build bootloaders directly with the MPIDE compiler would be best.

In the meantime, there is a free solution. With the free compiler, you can enable Pro functionality at any time, for 60 days. Or you could build the compiler from source, and make whatever adjustments you want.

Incidentally, please don't interpret this as defending any particular licensing strategy. Just trying to be helpful...

G