Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
Andre_B
PostPosted: Nov 10, 2005 - 10:02 PM
Rookie


Joined: Apr 19, 2004
Posts: 33
Location: Berlin, Germany

Hello,
is there a way to merge the Bootloader Hex-file with the Application Hex-File to one Hex-File (Intel-Hex)?
So I could program both in one step.

Regards

Andre
 
 View user's profile Send private message  
Reply with quote Back to top
dl8dtl
PostPosted: Nov 10, 2005 - 10:27 PM
Raving lunatic


Joined: Dec 20, 2002
Posts: 7374
Location: Dresden, Germany

Supposedly using the Srecord tool.

_________________
Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
dkinzer
PostPosted: Nov 10, 2005 - 11:23 PM
Posting Freak


Joined: Mar 12, 2004
Posts: 1237
Location: Portland, OR, USA

Here is the rule in the makefile that I use to produce a combined .hex file:
Code:
$(DOWNLOAD) : $(TARGET).hex $(BOOTLDR)
   cat $(TARGET).hex $(BOOTLDR) | awk -f combine.awk > $(DOWNLOAD)
   rm $(BOOTLDR:.hex=.elf)


This rule just copies the two .hex files to stdout which is piped to an awk script that strips out the extra end record. The awk script, shown below, actually strips out both end records and then adds one at the end. Simple but effective.

Code:

BEGIN {}

# add a record end marker
END { print ":00000001FF" }

# delete the record end marker
/^:00000001FF/{ $0 = ""}

# default action: output all non-blank lines
{ if ($0 != ""){ print } }


_________________
Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
dl8dtl
PostPosted: Nov 11, 2005 - 09:25 AM
Raving lunatic


Joined: Dec 20, 2002
Posts: 7374
Location: Dresden, Germany

Hint: "awk" is spelled "gawk" in WinAVR.

_________________
Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Astaroth
PostPosted: Nov 11, 2005 - 12:03 PM
Wannabe


Joined: Apr 03, 2003
Posts: 57


You could also link the bootloader object file with the program and avoid awk scripting.

It would look like:
Code:

LDFLAGS=bootloader.o \
  -Wl,-Map=$(TRG).map,--section-start=.bls=$(BOOTLOADER_START)

where .bls is the name of your bootloader section.

_________________
___()^()___
A(VR)staroth
 
 View user's profile Send private message  
Reply with quote Back to top
baer.ac
PostPosted: Nov 11, 2005 - 12:12 PM
Hangaround


Joined: Jan 17, 2004
Posts: 174
Location: Olpe / Germany

with hex2bin and bin2hex it sould also work:

hex2bin /q /L75000 Code.hex CodeBoot.bin
hex2bin /q /O60000 /M Boot.hex CodeBoot.bin
bin2hex /q /4 CodeBoot.bin CodeBoot.hex

/q is quite
/L is length (of the binfile)
/O is origin/Offset
/4 is Extended Adress (>64k)
/M is merge file into the other

You must flash then CodeBoot.hex....
This solution is fine, also if you want to link other binary data to your hexfile....
write it down in a bacthfile.
perhaps :
make all
make extcoff

and all your stuff is done automatically.... Smile
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
dkinzer
PostPosted: Nov 11, 2005 - 03:25 PM
Posting Freak


Joined: Mar 12, 2004
Posts: 1237
Location: Portland, OR, USA

[quote="Astaroth"]You could also link the bootloader object file with the program and avoid awk scripting.[quote]

In my case, I need to build two .hex files: one with the bootloader and one without. The one without the bootloader is used to produce an encrypted "field update" file and the combined one is used to initially program devices.

_________________
Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Astaroth
PostPosted: Nov 11, 2005 - 03:35 PM
Wannabe


Joined: Apr 03, 2003
Posts: 57


And what about
Code:

BIN=avr-objcopy

%.hex: %.elf
   $(BIN) -O $(FORMAT) -R .eeprom $< $@

%.field.hex: %.elf
   $(BIN) -O $(FORMAT) -R .eeprom -R .bls $< $@

_________________
___()^()___
A(VR)staroth
 
 View user's profile Send private message  
Reply with quote Back to top
EW
PostPosted: Nov 11, 2005 - 06:29 PM
Raving lunatic


Joined: Mar 01, 2001
Posts: 5013
Location: Rocky Mountains

dl8dtl wrote:
Hint: "awk" is spelled "gawk" in WinAVR.

For those who don't know, that's because it is the Gnu AWK program.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Andre_B
PostPosted: Nov 11, 2005 - 06:38 PM
Rookie


Joined: Apr 19, 2004
Posts: 33
Location: Berlin, Germany

I try some some of your solutions

regards

Andre
 
 View user's profile Send private message  
Reply with quote Back to top
mvc-freak
PostPosted: Jun 12, 2010 - 05:32 PM
Newbie


Joined: Jan 15, 2006
Posts: 5
Location: Connecticut USA

OK, I know this is an old thread, but I got here looking for help so others may still end up here as well.

There is another solution, the manual one: Use a text editor to cut off the last line of each file, copy and past the second file into the end of the first, and add pack an end of file record ":00000001FF".

Don's response using AWK hints at this as well.

Maybe this is too obvious, but I thought it was worth adding to the thread.

Dave.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jun 12, 2010 - 08:29 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 71162
Location: (using avr-gcc in) Finchingfield, Essex, England

Except that, as Joerg hinted, Srecord is the most obvious way to do this (srec_cat in fact)

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
teddrao
PostPosted: Oct 06, 2010 - 10:31 AM
Newbie


Joined: Oct 06, 2010
Posts: 7


Hi All,
I have a USB bootloader image in .a90 format (no source code for USB bootloader )and the application image in .abs format (from avr studio).
Can anybody guide me and tell how to merge both the images into one.
Is this possible using s-record tool?
Please help me out.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Oct 06, 2010 - 11:05 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 71162
Location: (using avr-gcc in) Finchingfield, Essex, England

Quote:

the application image in .abs format (from avr studio).

Studio does not have a .abs file type? It does use .aps but that's actually an XML project settings file - nothing to do with source or binary.

Anyway srec_cat can read virtuall every hex format there is so start by identifying what format is in the .a90 - looking at some I've built on my machine with the IAR trial version it looks like Motorola S-Record format. srec_cat has no problem reading this format.

From AVR Sudio it's very likely that what you actually have is a .hex file containing Intel Hex records. srec_cat can read that too. So just use it to read both files and join them to an output format of your choice (probably Intel Hex).

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
teddrao
PostPosted: Oct 08, 2010 - 10:21 AM
Newbie


Joined: Oct 06, 2010
Posts: 7


Hi clawson,
You were right. The image of the application generated by the AVR studio is in .hex format.
I will try using S-record tool to merge the application(.hex) and the bootloader(.a90).

Thanks for the post.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Oct 08, 2010 - 10:23 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 71162
Location: (using avr-gcc in) Finchingfield, Essex, England

The key thing is to have a peek inside the .a90 and just confirm that it is in Srecord format - the clue is in the name - each line starts with "S" followed by a lot of ASCII hex couplets. You then need to specify to srec_cat the format of the two input files based on this knowledge together with specifying which format you want output.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
ficeto
PostPosted: Mar 17, 2014 - 09:53 AM
Newbie


Joined: Mar 14, 2014
Posts: 1


Code:
full.hex: main.hex boot.hex
   @cat main.hex | awk '/^:00000001FF/ == 0' > $@
   @cat boot.hex >> $@
   @$(AVR_SIZE) $@
 
 View user's profile Send private message  
Reply with quote Back to top
skotti
PostPosted: Mar 18, 2014 - 11:19 PM
Hangaround


Joined: Sep 10, 2003
Posts: 334
Location: 51,25° / Germany

Great!
Code:

all: full.hex
...code from above...
Code:

PHONY: full.hex
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits