Welcome, Guest

Author Topic: Uploading HEX file via bootloader  (Read 3923 times)

Gregor1971

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
Uploading HEX file via bootloader
« 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

LubOlimex

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1947
  • Karma: +50/-3
Re: Uploading HEX file via bootloader
« Reply #1 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. 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.

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

Gregor1971

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
Re: Uploading HEX file via bootloader
« Reply #2 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


« Last Edit: December 08, 2013, 11:09:16 PM by Gregor1971 »

Stanimir5F

  • Jr. Member
  • **
  • Posts: 80
  • Karma: +2/-0
Re: Uploading HEX file via bootloader
« Reply #3 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.
May the Source be with You!

JohnS

  • Hero Member
  • *****
  • Posts: 1723
  • Karma: +33/-48
Re: Uploading HEX file via bootloader
« Reply #4 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

Gregor1971

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
Re: Uploading HEX file via bootloader
« Reply #5 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

JohnS

  • Hero Member
  • *****
  • Posts: 1723
  • Karma: +33/-48
Re: Uploading HEX file via bootloader
« Reply #6 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