chipKIT® Development Platform

Inspired by Arduino™

New PIC32-avrdude-bootloader is here!

Created Mon, 29 Oct 2012 18:57:37 +0000 by EmbeddedMan


EmbeddedMan

Mon, 29 Oct 2012 18:57:37 +0000

Thanks to the efforts of the chipKIT/MPIDE development team (particularly Keith Vogel) the new bootloader is ready on Github.

Why is there a new bootloader? Well, the old booloader works pretty darn well. This one just has some nice new features that you can use if you want. It better covers strange error cases, and has some really cool information that you can use from within your sketch. See Keith's post here [url]http://www.chipkit.org/forum/viewtopic.php?f=19&t=1714[/url] for more complete information.

The Github repo holds the source code to the bootloader (both USB and serial varieties), a test sketch to show that a sketch can retrieve information from the bootloader, and sketches (one for each board) that can be used to update the bootloader if your board has an older version of the bootloader already on it. It also has bootloader HEX files for each of the chipKIT/MPIDE boards.

Be very clear: you NEED a hardware programmer (PICKit3, RealIce, ICD3, Microstick II, etc.) and MPLAB 8 or MPLAB X in order to program these HEX files onto a PIC32 chip or board.

Here is the Github repo : [url]https://github.com/chipKIT32/PIC32-avrdude-bootloader[/url]

Note: this is an open source project, with major contributions from Digilent Inc, but it is NOT an official product of Digilent and thus comes with no support from them. Also, this project is NOT the official source of bootloader hex files for any Digilent products. If you need bootloaders for Digilent boards, you can go to their website and download the official HEX files or you can use the ones from this bootloader project. It's up to you. But if you use the ones from here, don't ask Digilent for help. ;-) Ask here instead.

There are MPLAB 8 and MPLAB X projects (and thus HEX files) for many existing boards in this project, as well as some really nice generic examples for new boards as well. Here are some of the commonly used boards and their HEX files from this project:

(Right-click on these links, choose save-as):

UNO32 (not official)

MAX32 (not official)

uC32 (not official)

FubarinoSD MX460

FubarinoSD MX795

FubarinoMini

UBW32 MX460

UBW32 MX795

Please use the Github Issue tracker to submit any bugs, but feel free to use this forum to ask any questions about the bootloader.

*Brian


mballest

Sun, 11 Nov 2012 16:49:27 +0000

Great work with the botloader. :D

Gran trabajo con el gestor de arranque


Dano

Tue, 13 Nov 2012 14:14:25 +0000

Hi,

Great update! The CUI32Stem would greatly appreciate being supported as well... ;-) Or do the generic MX7 versions work already? Probably only one thing to change, if not: make sure to use RE7 for the pin to enter the bootloader (and RE0 as the LED indicating it's in bootloader mode)...

Cheers, Dan


EmbeddedMan

Tue, 13 Nov 2012 15:55:25 +0000

Dan,

I don't think we have a CUI32 bootloader built yet, but it would take just a minute to do it. If you want to give it a shot, go ahead. All you need to do is copy/paste the UBW32 section of BoardConfig.h, edit to suit your buttons/LEDs, then add a new MPLAB X build target with the right define and you'll be set.

I can probably do it too, but not right now.

*Brian


Dano

Tue, 13 Nov 2012 20:35:57 +0000

Brian,

As I don't have the full version of C32, I can't compile with the "-s" flag to optimize for smallest size of the resulting .hex file. If you do find a minute at some point, I'd greatly appreciate your help!

-Dan


EmbeddedMan

Tue, 13 Nov 2012 22:59:27 +0000

Dan,

Of course! Not a problem at all. If you can do a pull request for your file changes, I can get the changes merged and then do a build of the HEX for you.

*Brian


Jimstrong

Fri, 21 Jun 2013 03:45:36 +0000

how to compile the boot loader in MPLAB X? Which program should I open. In the folder, there is no project for MPLAB X


EmbeddedMan

Fri, 21 Jun 2013 03:46:34 +0000

Correct - we only supply Mplab 8 projects for the bootloader right now. You can always import them into X though.

*Brian


Jimstrong

Fri, 21 Jun 2013 03:49:52 +0000

[color=#FF4040]build/default/production/_ext/1472/cdcacm.o: Link Error: Could not allocate section .text, size = 594 PC units, attributes = code build/default/production/_ext/1472/cdcacm.o: Link Error: Could not allocate section .text, size = 594 PC units, attributes = code Link Error: Could not allocate program memory[/color]

I import my project and build it in MPLAB X. The same error appears. I have applied a full licence. But still the problem exists.

I asked the question here.

http://www.chipkit.org/forum/viewtopic.php?f=6&t=2435


caroper

Sat, 22 Jun 2013 23:11:25 +0000

I have run into a problem getting a UART based Bootloader to compile I get:

cdcacm.c:126:26: error: expected '=', ',', ';', 'asm' or 'attribute' before 'reset_cbfn'

even if I choose to build: BOARD_EXAMPLE_MX1

Rather than my own, which will be using UART2

Every USB build I try works fine and I have 3 different ones running on the breadboard, just the UART option throws errors.

any Ideas?

Cheers Chris


EmbeddedMan

Sun, 23 Jun 2013 02:03:07 +0000

Chris,

Did you start from the Example-MX1 project? Or any of the other projects that use UART for communications? If you started with one of the projects that uses USB, you'll have to switch the files around to get the functionality you want. It would be easier to just start from the Example-MX1 project if you are on a MX1/MX2 device and want to use UART.

*Brian


caroper

Sun, 23 Jun 2013 07:54:40 +0000

Thanks Brian,

I started with a USB Bootloader which I wanted to convert to use UART. I will try starting with MX1/2 and feed back later.

Cheers Chris


caroper

Sun, 23 Jun 2013 08:53:51 +0000

Hi Brian,

If I open the Example_MX1 project and build all, I get: "Couldn't locate build tool. Check tool locations.

I have the c32v2.2a installed in the default location and it compiled the others fine. It didn't give me the option to to use the new location, which I recall seeing in the distant past, and I am not sure what location it is expecting to find them.

Any thoughts?

[edit] OK, I went into Project->Select language tool suite and turned off the "Store with project" option, it immediately let me select my tools instead and compiled first time.

Another good reason to use MPIDE rather than MPLAB, and MPLABx is even harder to do things in than MPLAB 8x.

I thought this project would take 5 min, I allocated an Hour and I am now in day 2, making good progress but fighting the damn Development tool every step of the way, an IDE is supposed to be helping me not obstructing :).

By the time they drop support for MPLAB 8 I hope to have my entire tool chain on MPIDE or some other open source platform.

Well, back to the Project - Now to modify it.

Cheers Chris


caroper

Sun, 23 Jun 2013 10:20:27 +0000

Up and running, working fine.

Boot LED on RB3 Download LED on RB2 PROG Button on RB7 Tx on RB10 Rx on RB11

if used with the DP32 board definition use Serial1 rather than Serial in your sketches.

I am contemplating a new Boards Entry but want to get the Bootloaders all done first.

#elif defined(_BOARD_BB32_150_UART_)
 
#if defined(PUT_CONFIG_BITS_HERE)

    //* Oscillator Settings
	#pragma config FNOSC     = FRCPLL
	#pragma config FPLLIDIV  = DIV_2
	#pragma config FPLLMUL   = MUL_20
	#pragma config FPLLODIV  = DIV_2
	#pragma config FPBDIV    = DIV_1
    #pragma config FSOSCEN   = OFF                                   // Secondary oscillator enable
    
    //* Clock control settings
    #pragma config IESO      = OFF                                  // Internal/external clock switchover
    #pragma config FCKSM     = CSECME                               // Clock switching (CSx)/Clock monitor (CMx)
    #pragma config OSCIOFNC  = OFF                                  // Clock output on OSCO pin enable
      
    //* Other Peripheral Device settings
    #pragma config FWDTEN   = OFF                                   // Watchdog timer enable
    #pragma config WDTPS    = PS1024                                // Watchdog timer postscaler
    #pragma config WINDIS   = OFF
    #pragma config JTAGEN   = OFF                          			// JTAG port disabled
    
    //* Code Protection settings
    #pragma config CP       = OFF                                   // Code protection
    #pragma config BWP      = OFF                                   // Boot flash write protect
    #pragma config PWP      = OFF                                   // Program flash write protect
    
    //*    Debug settings
    #pragma config ICESEL   = ICS_PGx1                      		// ICE/ICD Comm Channel Select
    //#pragma config DEBUG    = ON                          		// DO NOT SET THIS CONFIG BIT, it will break debugging

    #pragma config PMDL1WAY = OFF                           		// Allow multiple reconfigurations
    #pragma config IOL1WAY  = OFF                           		// Allow multiple reconfigurations
#endif
    
    #define CAPABILITIES    (blCapDownloadLED | blCapUARTInterface | blCapProgramButton | blCapVirtualProgramButton | CAPCOMMON)

    // Boot LED
    #define EnableBootLED()             (TRISBCLR = (1 << 3))
    #define DisableBootLED()            (TRISBSET = (1 << 3))
    #define BootLED_Toggle()            (LATBINV  = (1 << 3))
    #define BootLED_On()                (LATBSET  = (1 << 3))
    #define BootLED_Off()               (LATBCLR  = (1 << 3))

    // Download LED
    #define EnableDownLoadLED()     (TRISBCLR = (1 << 2))
    #define DisableDownLoadLED()    (TRISBSET = (1 << 2))
    #define DownloadLED_Toggle()    (LATBINV  = (1 << 2))    
    #define DownloadLED_On()        (LATBSET  = (1 << 2))
    #define DownloadLED_Off()       (LATBCLR  = (1 << 2))

    // UART
    #define _USE_UART2_FOR_BOOTLOADER_                      // avrdude program UART
    #define BAUDRATE                    115200              // avrdude baudrate
    #define UARTMapTX()                 (RPB10R = 0x2)		// RB10 --> Tx
    #define UARTMapRX()                 (U2RXR  = 0x3)		// RB11 --> Rx

    // Other capabilities
    #define fLoadFromAVRDudeViaProgramButton        (PORTBbits.RB7 == 1) 
    #define fLoadFromAVRDudeViaVirtualProgramButton (LATBbits.LATB7 == 1) 
    #define ClearVirtualProgramButton()             (LATBCLR = (1 << 7))
  
    #define _CPU_NAME_                  "32MX150F128B"
    #define VEND                        vendUnknown
    #define PROD                        prodUnknown
    #define F_CPU                       40000000UL
    #define F_PBUS                      F_CPU

    #define FLASH_BYTES                 (0x20000-0x1000)		    // Leave room one flash block (for bootloader!)
    #define FLASH_PAGE_SIZE             1024						// In bytes

hex file attached if anyone wishes to try it on a PIC32MX150F128B remove the ".txt" extension included as the Forum will not allow ".hex" attachments.

Thanks for the help Brian.

Cheers Chris


KeithV

Sun, 23 Jun 2013 18:03:55 +0000

FYI: If you are not using the split-flash bootloader (making a UART bootloader/ not USB) you can pick up 4K of flash by changing

#define FLASH_BYTES (0x20000-0x1000)

to

#define FLASH_BYTES 0x20000

You will also need to change the linker script memory map to add the additional 4K.

If these changes are not made, the last 4K of flash will be unusable for your sketch as it is protected for use by the non-existent USB bootloader code.


caroper

Sun, 23 Jun 2013 19:18:35 +0000

Thanks Keirth,

That is useful to Know. I am not sue I a ready to try changing the Linker Script at this stage, especially as I have all 3 versions running at last, but I will definitely do that once I have more experience and confidence with the build tools.

Cheers Chris