0
votes

I'm new with Microchip programming and I'm getting some troubles. I need to write a bootloader application using MPLAB X IDE but I don't know how to set up the compiler/linker in order to create an executable mapped in the right regions of memory.

Consuting the datasheet of the component, I can see this addresses:

Program Flash --> 0x1D000000 - 0x1D1FFFFF
Boot Flash --> 0x1FC00000 - 0x1FC73FFF

How can I create a program that uses the boot flash? Which parameters have I to change? Over the net I've read that maybe I should use a linker script but I can't figure out how to use them.

Can you please provide me some information?

2
there is an example bootloader code here for pic. You can check it out. microchip.com/wwwAppNotes/AppNotes.aspx?appnote=en554836Gürtaç Kadem
Hi, thanks a lot for the tip. However I saw the example and the scripts, but are for MX family and I'm having an PIC32MZ ... can I use an MX script and only change the addresses?Marco Semenzato
i think you can use example code for mz chips with small changes.Gürtaç Kadem

2 Answers

0
votes

I went through similar issue.

The best way to do it is to use the Harmony framework to generate the linker script for the bootloader with the correct memory regions for your chip.

Just create a dummy project with the bootloader setup and compile, it will generate the linker script.

Once you get the linker script, you can import it on your project.

You also need to do the same for the application code as the linker is different as well for it because of the initialisation regions.

0
votes

The best way is using an ezbl project as base then change it to your needs. Ezbl bootloader is not trivial but it is the most secure way.

from https://www.microchip.com/SWLibraryWeb/product.aspx?product=Microchip%20Easy%20Bootloader

EZBL Features

Targets supported

• Single and Dual Partition bootloading topology examples on Dual Partition capable targets

• Common code set supports all 32-bit PIC32MM and 16-bit PIC24/dsPIC33 devices, excluding PIC24F[V]xxKxx families

• Dual Partition with Live Update for time and state sensitive application continuity

Code reuse

• Transparent Bootloader function, ISR and variable access from executing Application

• Existing code can be integrated into a Bootloader or Application project without significant changes

• File-oriented push/pull and onboard-memory bootloaders ready to use - can be adapted to Over The Air (OTA) and chip-to-chip designs

Automatic linker script creation

• No .gld/.ld file maintenance or understanding of GNU ld syntax required

Decoupled communications

• 2-wire UART and I2C Slave protocols exampled

• USB Mass Storage thumb drive bootloading (USB Host/MSD Class)

• Passive, self-recognizing protocol scalable to multi-node broadcast oriented communications buses

• Multiple peripheral instances and peripheral types can simultaneously listen for firmware updates

• Partitioned to facilitate customer and 3rd party protocol additions

Robust self-preservation

• Flash erase/write routines self-aware of Bootloader geometry

• Bootloader will not erase or corrupt itself when externally given destructive commands

• Will not attempt to execute a corrupt or partially bootloaded Application

• CRC32 communications and image integrity checking with reusable API

Interrupt vector management

• IVT entries forwarded to optimized Interrupt Goto Table in Application space

• Bootloader and Application can share any Interrupt Vector with individual run-time selection

• No AIVT or Boot Segment (BS) hardware support required

Application support functionality

• Optimized general purpose 64-bit time measurement and task scheduling API

• Flash Erase/Write APIs for data EEPROM emulation and content survival independent of application upgrades

• Multi-instance FIFO buffering API with interrupt/non-blocking, polled, timeout and callback notification functions

Designed for performance without hardware luxuries

• Latency adaptive software flow control tolerates Bluetooth or TCP/Internet propagation delays without hardware RTS/CTS or sideband signaling

• .hex contents automatically converted at build time to smaller binary .bl2 image with improved identification, version and error detection features

• Software FIFOs on Bootloader communications interrupts permit high throughput

Code secrecy compatible

• Operation unaffected by ICSP Code Protect

• Bootloader does not expose program memory or RAM for external read back

• External program verification/version identification facilitated by internal CRC32 computation

Full source with no-cost Microchip license

• No GNU GPL code contamination or 3rd party code requiring independent licensing

• Script-accessible, portable C PC command line communications executable ready for branded GUI wrapping and redistribution