Olimex Support Forum

Microcontrollers => PIC => Topic started by: Gregor1971 on December 05, 2013, 01:39:40 PM

Title: Uploading HEX file via bootloader
Post by: Gregor1971 on December 05, 2013, 01:39:40 PM
Hi,
i'm trying to write some c base programm for a pic32-T975H. I'm using the actual version of MPLab for developing. Instead of writing the programm to the board using a pickit, i'd like to use the bootloader via the usb connector.

Since i've been searching the web and this forum for several days without finding a sufficient answer, i would appreciate any hint to solve the folowing two questions:

Which programm to use for uploading the hex file to the board?
Are there special addressranges to be set in MPLap X?

Many thanks in advance...

Gregor
Title: Re: Uploading HEX file via bootloader
Post by: LubOlimex on December 06, 2013, 08:39:15 AM
Hey Greg,

Which programm to use for uploading the hex file to the board?

Download this one: https://www.olimex.com/Products/Duino/Duinomite/_resources/Olimex-Bootloader_Applicatoin-for-Duinomite.zip (https://www.olimex.com/Products/Duino/Duinomite/_resources/Olimex-Bootloader_Applicatoin-for-Duinomite.zip). To be able to enter bootloader mode - disconnect the board from the mini USB, press and hold down button BUT, connect the board to the mini USB, release the button BUT, <if asked for drivers point the installer to the folder where you extracted the zip>.

Voila! You are now able to program with binaries via the obootloader application.

Note by using this method of programming you can wipe the Duinomite and Pinguino bootloaders. Most importantly, you might also overwrite the bootloader that connects to the application in the archive - this would be irreversible without a PIC32-compatible debugger. 

Are there special addressranges to be set in MPLap X?

You might check the addresses in the document here: http://ww1.microchip.com/downloads/en/AppNotes/01388B.pdf (http://ww1.microchip.com/downloads/en/AppNotes/01388B.pdf).

Best regards,
Lub/OLIMEX
Title: Re: Uploading HEX file via bootloader
Post by: Gregor1971 on December 07, 2013, 09:17:28 PM
Hi Lub,

thank you for your tips.

Just to clarify my ideas:

The mmbasic, which is originally installed on the board, is called firmware? If so i would like to replace it with my own binaries. To do so i would have to replace the flash area (0x1d000000 - 0x1d07FFFF). Am i right?

By the way, at witch address does the cpu expect the first instruction to execute after power up? I would gues it is the first address (0x1FC00000) of the bootloader section, but I'm not sure. If the first instuction is placed in the programm flash section (0x1d000000), which is the first address my own binaries should use to avoid overwritng the calling code for the bootloader?

Regards and thanks for helping in advance
Gregor


Title: Re: Uploading HEX file via bootloader
Post by: Stanimir5F on December 10, 2013, 01:06:12 PM
Hi Gregor!

You are right about address mapping:
0x00000000 - 0x0001FFFF - RAM Memory
0x1D000000 - 0x1D07FFFF - Program memory
0x1FC00000 - 0x1FC02FEF - Boot memory

The Boot memory should not be overwritten unless you want to use another bootloader. And the main program should be placed in the Program Memory.
Title: Re: Uploading HEX file via bootloader
Post by: JohnS on December 17, 2013, 11:12:11 AM
You really do need to read the Microchip data sheet because it explains the virtual and physical address ranges.  The ones mentioned so far are physical but not what the program sees.

With a suitable USB HID bootloader you can then use programs like mphidflash but in a way you're already trying to use an odd combination (MPLAB but without PICkit).  Generally people either do it Microchip's way (MPLAB and PICkit) or go with a C complier (like gcc) and a hex or bin uploader like mphidflash.

If you want to single step, breakpoint etc you might like to go with PICkit.

John
Title: Re: Uploading HEX file via bootloader
Post by: Gregor1971 on January 10, 2014, 07:53:39 PM
Hi John,

sorry for the long time to answer.

The idea is to develope with pickkit. I agree to you so far.

In the wild a pickit seldomly will be awailable. So it would be easier to have a bootloader writing the new version to flash via usb-sreial mode. This will be possible more often.

Regards
Gregor
Title: Re: Uploading HEX file via bootloader
Post by: JohnS on January 10, 2014, 10:59:15 PM
You could use any of the HID bootloaders.  Microchip publish one and some others have been made, such as used with Pinguinos.  DP have one too I think.

John