It is currently Tue Sep 16, 2014 10:26 pm



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Can I load MPLAB hex files somehow via bootloader?
PostPosted: Mon Jun 06, 2011 1:21 am 
Offline
User avatar

Joined: Mon Jun 06, 2011 1:16 am
Posts: 79
Location: Boulder, CO USA
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 .....


Top
 Profile  
 
 Post subject: Re: Can I load MPLAB hex files somehow via bootloader?
PostPosted: Mon Jun 06, 2011 8:36 pm 
Offline

Joined: Fri May 27, 2011 7:24 pm
Posts: 45
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


Top
 Profile  
 
 Post subject: Re: Can I load MPLAB hex files somehow via bootloader?
PostPosted: Mon Jun 06, 2011 9:12 pm 
Offline
User avatar

Joined: Mon Jun 06, 2011 1:16 am
Posts: 79
Location: Boulder, CO USA
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 .....


Top
 Profile  
 
 Post subject: Re: Can I load MPLAB hex files somehow via bootloader?
PostPosted: Mon Jun 06, 2011 9:44 pm 
Offline
User avatar

Joined: Mon Jun 06, 2011 1:16 am
Posts: 79
Location: Boulder, CO USA
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$

_________________
Embedded Systems Made Easy: http://www.cpustick.com .....


Last edited by rtestardi on Mon Jun 06, 2011 10:49 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Can I load MPLAB hex files somehow via bootloader?
PostPosted: Mon Jun 06, 2011 10:37 pm 
Offline

Joined: Sat May 21, 2011 4:26 pm
Posts: 116
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


Top
 Profile  
 
 Post subject: Re: Can I load MPLAB hex files somehow via bootloader?
PostPosted: Mon Jun 06, 2011 10:47 pm 
Offline
User avatar

Joined: Mon Jun 06, 2011 1:16 am
Posts: 79
Location: Boulder, CO USA
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 .....


Top
 Profile  
 
 Post subject: Re: Can I load MPLAB hex files somehow via bootloader?
PostPosted: Wed Jan 16, 2013 5:33 pm 
Offline

Joined: Mon Dec 12, 2011 1:28 pm
Posts: 10
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


Top
 Profile  
 
 Post subject: Re: Can I load MPLAB hex files somehow via bootloader?
PostPosted: Mon Feb 18, 2013 7:23 am 
Offline
User avatar

Joined: Sat May 28, 2011 6:34 am
Posts: 648
Location: Southern California
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.


Top
 Profile  
 
 Post subject: Re: Can I load MPLAB hex files somehow via bootloader?
PostPosted: Wed Feb 20, 2013 2:06 pm 
Offline

Joined: Mon Dec 12, 2011 1:28 pm
Posts: 10
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Theme designed by stylerbb.net © 2008
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All times are UTC [ DST ]