Can I load MPLAB hex files somehow via bootloader?

User avatar
rtestardi
Posts: 79
Joined: Mon Jun 06, 2011 1:16 am
Location: Boulder, CO USA
Contact:

Can I load MPLAB hex files somehow via bootloader?

Postby rtestardi » Mon Jun 06, 2011 1:21 am

Is there any way to load a hex file created with MPLAB (not MPIDE) via the bootloader? With or without MPIDE? I'm looking for a way to do this without a pickit3 (which I have, but which I assume most people don't have).

Also, if this is possible, what linker file should I use in MPLAB to make a "bootloader compatible" hex file? I know the entry point has to be 0x9D001000, and I think I can rewrite any interrupt vectors since the bootloader does not use them.

Thanks for any advice.

-- Rich
Embedded Systems Made Easy: http://www.cpustick.com .....

Addidis
Posts: 48
Joined: Fri May 27, 2011 7:24 pm

Re: Can I load MPLAB hex files somehow via bootloader?

Postby Addidis » Mon Jun 06, 2011 8:36 pm

It is possible, and the answer I got when I asked was

you'd have to use the chipKIT application linker script when you build the app in MPLAB

User avatar
rtestardi
Posts: 79
Joined: Mon Jun 06, 2011 1:16 am
Location: Boulder, CO USA
Contact:

Re: Can I load MPLAB hex files somehow via bootloader?

Postby rtestardi » Mon Jun 06, 2011 9:12 pm

Thanks! I found the application linker script -- I assume it is: chipKIT-UNO32-application-32MX320F128L.ld

But that only solves half of my problem, I think... I need something to translate a HEX/elf file into the stk500v2 communication protocol which I assume the bootloader is using... Obviously MPIDE can already do this, but I'm not sure how I can coax it into pushing my own HEX file across the wire (vs a HEX file it just built).

I am actually considering writing an Arduino sketch to do this (i.e., accept a HEX file from the serial port and load it to flash), but that seems somewhat circuitous for what I want (not to mention two steps rather than one)...

Any ideas on the protocol conversion? Thanks!
Embedded Systems Made Easy: http://www.cpustick.com .....

User avatar
rtestardi
Posts: 79
Joined: Mon Jun 06, 2011 1:16 am
Location: Boulder, CO USA
Contact:

Re: Can I load MPLAB hex files somehow via bootloader?

Postby rtestardi » Mon Jun 06, 2011 9:44 pm

PS just in case someone else is looking for this, it looks like avrdude will do the trick!

[edited command below so as to not mislead anyone not reading further in the thread]

sh-4.1$ ./avrdude -C ../etc/avrdude.conf -c stk500v2 -p pic32-360 -P COM16 -U flash:w:rich.cpp.hex

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude.exe: Device signature = 0x504943
avrdude.exe: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude.exe: current erase-rewrite cycle count is -1145324613 (if being tracked)
avrdude.exe: erasing chip
avrdude.exe: reading input file "rich.cpp.hex"
avrdude.exe: input file rich.cpp.hex auto detected as Intel Hex
avrdude.exe: writing flash (11536 bytes):

Writing | ################################################## | 100% 2.64s

avrdude.exe: 11536 bytes of flash written
avrdude.exe: verifying flash memory against rich.cpp.hex:
avrdude.exe: load data flash data from input file rich.cpp.hex:
avrdude.exe: input file rich.cpp.hex auto detected as Intel Hex
avrdude.exe: input file rich.cpp.hex contains 11536 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 1.94s

avrdude.exe: verifying ...
avrdude.exe: 11536 bytes of flash verified

avrdude.exe: safemode: Fuses OK

avrdude.exe done. Thank you.

sh-4.1$
Last edited by rtestardi on Mon Jun 06, 2011 10:49 pm, edited 1 time in total.
Embedded Systems Made Easy: http://www.cpustick.com .....

Mark
Posts: 116
Joined: Sat May 21, 2011 4:26 pm

Re: Can I load MPLAB hex files somehow via bootloader?

Postby Mark » Mon Jun 06, 2011 10:37 pm

Couple more comments

#1, its stk500v2 not stk500, thats the version of the protocol.

#2 As far as the linker goes, it would be best to use the supplied linker. However other linker scripts could work provided that the linker script has to NOT put anything in the bootloader space and leave the top of flash empty.


Mark

User avatar
rtestardi
Posts: 79
Joined: Mon Jun 06, 2011 1:16 am
Location: Boulder, CO USA
Contact:

Re: Can I load MPLAB hex files somehow via bootloader?

Postby rtestardi » Mon Jun 06, 2011 10:47 pm

Thanks! I actually successfully used the .ld file from the mpide directory in mplab and it worked fine (using the mplab linker). I'll double-check the .hex file I'm generating to make sure I'm not dropping anything in flash anywhere other than the interrupt vectors and code after 0x9d001000. I am able to successfully use mpide after avrdude, which is good, though I know that might not be an exhaustive check of the bootloader dependencies... Thanks -- this is all really cool.
Embedded Systems Made Easy: http://www.cpustick.com .....

manut
Posts: 10
Joined: Mon Dec 12, 2011 1:28 pm

Re: Can I load MPLAB hex files somehow via bootloader?

Postby manut » Wed Jan 16, 2013 5:33 pm

rtestardi wrote:Thanks! I actually successfully used the .ld file from the mpide directory in mplab and it worked fine (using the mplab linker).


Hi Rich,

It seems that's exactly what I'm trying to do!
Can you attach a mplab skeleton project with the linker script?
If I'm right, you can write code in mplab, create a .hex file with the proper linker script (in order not to override the bootloader flash space) and transfer via avrdude to the board. Isn'it.

I'd like to do this with my uno32 board for 2 reasons:
- while I'm debugging, I keep using pickit3 for breakpoints and other stuffs
- I'd like to update my firmware via USB, because the board is in a waterproof case with only USB available (not the icsp connector) and i cannot open it for firmware updates.

Do you know if there is a wiki page or a tutorial on that? (my google searchs aren't very successful on that point...)

Thanks,
Manu

User avatar
Jacob Christ
Posts: 693
Joined: Sat May 28, 2011 6:34 am
Location: Southern California
Contact:

Re: Can I load MPLAB hex files somehow via bootloader?

Postby Jacob Christ » Mon Feb 18, 2013 7:23 am

Rich,

Here is a write up on using a moded version of avrdude gui to upload hex files without mpide.

http://pontech.dyndns.org/pontech/uav10 ... Mar-17.pdf

If you look iin that same dir on the server you will find a zip with the avrdude gui.

Jacob
PONTECH Quick240 an industrial form factor platform for chipKIT and Arduino users.

manut
Posts: 10
Joined: Mon Dec 12, 2011 1:28 pm

Re: Can I load MPLAB hex files somehow via bootloader?

Postby manut » Wed Feb 20, 2013 2:06 pm

manut wrote:
rtestardi wrote:Thanks! I actually successfully used the .ld file from the mpide directory in mplab and it worked fine (using the mplab linker).


Hi Rich,

It seems that's exactly what I'm trying to do!
Can you attach a mplab skeleton project with the linker script?
If I'm right, you can write code in mplab, create a .hex file with the proper linker script (in order not to override the bootloader flash space) and transfer via avrdude to the board. Isn'it.

I'd like to do this with my uno32 board for 2 reasons:
- while I'm debugging, I keep using pickit3 for breakpoints and other stuffs
- I'd like to update my firmware via USB, because the board is in a waterproof case with only USB available (not the icsp connector) and i cannot open it for firmware updates.

Do you know if there is a wiki page or a tutorial on that? (my google searchs aren't very successful on that point...)

Thanks,
Manu


It seems that the linker script file chipKIT-UNO32-application-32MX320F128L.ld doesn't properly work with MPLAB 8.80 and my uno32 board:
Avrdude is ok until it checks fuses then I have a bad checksum error.
If I uncheck the linker option "don't link startup code", avrdude is ok but I cannot start the application, of course.
I will check and compare hex files to see if something is missing, but at the time nothing obvious.
I probably have to switch to MPLAB X.

An other path to explore:
Maybe it would be easier to learn how to write my code under mpide in plain C rather than writing my application in MPLAB and try to link it with the pre-programmed bootloader.
What do you think about that?


Return to “chipKIT Boards”

Who is online

Users browsing this forum: No registered users and 1 guest