Combining app and boot with AS7

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This should be a quick simple yes or no (i hope ha!)

 

I'm trying to create a .elf file for production, and in order to combine my bootloader and my application firmware, am I right in thinking I can simply program them both into a uC separately as normal (in AS7 with a JTAGICE3), then once both boot and app are in just read back the flash and save it as another .hex, then create my .elf from that?

 

(PS I'm aware srec_cat does this but after downloading it and trying it, only to find I have to first download a bunch of prerequisite software seemed fairly long winded the above will do the job)

This topic has a solution.
Last Edited: Wed. Oct 26, 2016 - 02:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Howard_Smith wrote:
am I right in thinking I can simply program them both into a uC separately as normal (in AS7 with a JTAGICE3), then once both boot and app are in just read back the flash and save it as another .hex, then create my .elf from that?
it's a nice idea but when you program one the whole chip will be erased so it's difficult to get both in at once. Of course you could ISP the bootloader then use it to deliver the app into the flash then read out the composite image. But most people would just take app.hex and boot.hex and join them. Either use srec_cat from the Srecord utilities or the "poor man's method" is simply to edit one and paste the boot code on the end of the app code and finally remove the

:00000001FF

line from the boundary in the middle (but not the one at the end)

Howard_Smith wrote:
(PS I'm aware srec_cat does this but after downloading it and trying it, only to find I have to first download a bunch of prerequisite software seemed fairly long winded the above will do the job)
I have no idea what that comment means. Joining two .hex files using srec_cat should be nothing more than:

srect_cat app.hex -intel boot.hex -intel -o joined.hex -intel

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did try this after posting as curiosity got the better of me, however I used WinMerge to compare my application firmware .hex with the combined .hex and the data did appear different :/

 

clawson wrote:

I have no idea what that comment means. Joining two .hex files using srec_cat should be nothing more than:

srect_cat app.hex -intel boot.hex -intel -o joined.hex -intel

 

That's what I thought, so I downloaded it from SourceForge and tried it and I got some weird error...

 

and then I noticed in the readme it says there are some prerequisites to download and install first, which I guess I'll have to do now!

Last Edited: Wed. Oct 26, 2016 - 01:13 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just downloaded it (nothing else) and tried this simple test (it's the same code built twice - once at 0x0000, once at 0x7000):

C:\SysGCC\avr\bin>cat test.hex
:100000000C9434000C943E000C943E000C943E0082
:100010000C943E000C943E000C943E000C943E0068
:100020000C943E000C943E000C943E000C943E0058
:100030000C943E000C943E000C943E000C943E0048
:100040000C943E000C943E000C943E000C943E0038
:100050000C943E000C943E000C943E000C943E0028
:100060000C943E000C943E0011241FBECFEFD8E04C
:10007000DEBFCDBF0E9443000C945A000C940000D8
:100080008FEF84B908958FEF84B98EEF8F3F79F0A9
:10009000982F9170919595B92FE33DE093E0215011
:1000A00030409040E1F700C000008150EFCF80E089
:0800B00090E00895F894FFCFE1
:00000001FF

C:\SysGCC\avr\bin>cat avr.hex
:107000000C9434380C943E380C943E380C943E3832
:107010000C943E380C943E380C943E380C943E3818
:107020000C943E380C943E380C943E380C943E3808
:107030000C943E380C943E380C943E380C943E38F8
:107040000C943E380C943E380C943E380C943E38E8
:107050000C943E380C943E380C943E380C943E38D8
:107060000C943E380C943E3811241FBECFEFD8E06C
:10707000DEBFCDBF0E9443380C945A380C940038C0
:107080008FEF84B908958FEF84B98EEF8F3F79F039
:10709000982F9170919595B92FE33DE093E02150A1
:1070A00030409040E1F700C000008150EFCF80E019
:0870B00090E00895F894FFCF71
:040000030000700089
:00000001FF

C:\SysGCC\avr\bin>srec_cat.exe test.hex -intel avr.hex -intel -o both.hex -intel

C:\SysGCC\avr\bin>cat both.hex
:020000040000FA
:200000000C9434000C943E000C943E000C943E000C943E000C943E000C943E000C943E00FA
:200020000C943E000C943E000C943E000C943E000C943E000C943E000C943E000C943E00D0
:200040000C943E000C943E000C943E000C943E000C943E000C943E000C943E000C943E00B0
:200060000C943E000C943E0011241FBECFEFD8E0DEBFCDBF0E9443000C945A000C94000094
:200080008FEF84B908958FEF84B98EEF8F3F79F0982F9170919595B92FE33DE093E021504A
:1800A00030409040E1F700C000008150EFCF80E090E00895F894FFCF1A
:207000000C9434380C943E380C943E380C943E380C943E380C943E380C943E380C943E38CA
:207020000C943E380C943E380C943E380C943E380C943E380C943E380C943E380C943E38A0
:207040000C943E380C943E380C943E380C943E380C943E380C943E380C943E380C943E3880
:207060000C943E380C943E3811241FBECFEFD8E0DEBFCDBF0E9443380C945A380C9400380C
:207080008FEF84B908958FEF84B98EEF8F3F79F0982F9170919595B92FE33DE093E02150DA
:1870A00030409040E1F700C000008150EFCF80E090E00895F894FFCFAA
:040000050000700087
:00000001FF

Seems to have worked out just fine for me. Wonder if it's your exciting looking filenames it's not keen on? (I tend to be an 8.3 man to this day!). Or is there something off the end of the line in that picture we're not seeing?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just noticed that I cannot help myself using "cat" not "type". Thank goodness for gnuwin32 utilities. One day I'll get the hopping from Linux to Windows thing sorted!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just noticed you included the .exe in the command so I did the exact same thing and it's worked - happy days ha! Thanks for your input

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That has NO bearing on it. MS-DOS uses PATHEXT:

C:\>set | grep PATHEXT
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

So if you type "foo". It looks for and tries to execute foo.com, then foo.exe, then foo.bat then foo.cmd and so on. So if you just type "srec_cat" it will try "srec_cat.com" (seems unlikely in this day and age) then "srec_cat.exe" etc.

 

Do you either have an srec_cat.com or is your PATHEXT= something unusual?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Howard_Smith wrote:
am I right in thinking I can simply program them both into a uC separately as normal (in AS7 with a JTAGICE3), then once both boot and app are in just read back the flash and save it as another .hex, then create my .elf from that?
it's a nice idea but when you program one the whole chip will be erased so it's difficult to get both in at once.
avrdude has a do not erase option.
Quote:
Of course you could ISP the bootloader then use it to deliver the app into the flash then read out the composite image. But most people would just take app.hex and boot.hex and join them. Either use srec_cat from the Srecord utilities or the "poor man's method" is simply to edit one and paste the boot code on the end of the app code and finally remove the

:00000001FF

line from the boundary in the middle (but not the one at the end)

Howard_Smith wrote:
(PS I'm aware srec_cat does this but after downloading it and trying it, only to find I have to first download a bunch of prerequisite software seemed fairly long winded the above will do the job)
I have no idea what that comment means.
The issue complained of was installing srec, not using it.

Moderation in all things. -- ancient proverb

Last Edited: Thu. Oct 27, 2016 - 05:45 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

That has NO bearing on it. MS-DOS uses PATHEXT:

C:\>set | grep PATHEXT
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

So if you type "foo". It looks for and tries to execute foo.com, then foo.exe, then foo.bat then foo.cmd and so on. So if you just type "srec_cat" it will try "srec_cat.com" (seems unlikely in this day and age) then "srec_cat.exe" etc.

 

Do you either have an srec_cat.com or is your PATHEXT= something unusual?

 

Not that I noticed, I did move the directory containing srec_cat.exe so that the file path was shorter? Either way it works now and I've got a .elf file for production 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I should mention that objcopy has an --update-section option to insert contents from an arbitrary file into an ELF. See http://senthilthecoder.com/post/...

Regards

Senthil

 

blog | website

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's a recent thread on this very subject: (and commenting here will help me find this one in the future)

https://www.avrfreaks.net/forum/how-can-i-get-bootloader-embedded-hexelf-main-application

 

BTW: Because some imbecilic [sic, from manpage] programs don't accept the longer records produced by default (I'm looking at you AVRStudio4 debugger)  I now use:

 srec_cat SP350v2.1.4.hex -intel ReBoot_v1.1.0.hex -intel -o Production.hex -intel -address-length=2 -output-block-size=16

--Nigel