Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

adding protection to final binary image

adding protection to final binary image

2004-06-29 by Gus

Hi all,

I am trying to add the protection word to my final binary image. I 
need to place 0x87654321 at location 0x1fc. I don't know and 
couldn't figure out how to tell the linker to place a word at 
absolute(fixed) memory location.

Any help is appreciated.

Thanks,

Re: adding protection to final binary image

2004-06-29 by Tutors of ESAcademy

--- In lpc2000@yahoogroups.com, "Gus" <gus_is_working@y...> wrote:
> I am trying to add the protection word to my final binary image. I 
> need to place 0x87654321 at location 0x1fc. I don't know and 
> couldn't figure out how to tell the linker to place a word at 
> absolute(fixed) memory location.

1. Generate an Intel hex file instead of a binary image
2. Place an additional line in the file with your keyword in Intel hex
format
3. (optional) Convert the Intel hex file into a binary image

Chris
Tutor at ESAcademy
www.esacademy.com

Re: adding protection to final binary image

2004-06-30 by Gus

Chris,

That would take care of the problem assuming the linker didn't use 
that memory location. I looked in the hex file and there is some 
data at that location!

Any more ideas?

Thanks,
Gus
--- In lpc2000@yahoogroups.com, "Tutors of ESAcademy" 
<esacademy@y...> wrote:
> --- In lpc2000@yahoogroups.com, "Gus" <gus_is_working@y...> wrote:
> > I am trying to add the protection word to my final binary image. 
I 
> > need to place 0x87654321 at location 0x1fc. I don't know and 
> > couldn't figure out how to tell the linker to place a word at 
> > absolute(fixed) memory location.
> 
> 1. Generate an Intel hex file instead of a binary image
> 2. Place an additional line in the file with your keyword in Intel 
hex
Show quoted textHide quoted text
> format
> 3. (optional) Convert the Intel hex file into a binary image
> 
> Chris
> Tutor at ESAcademy
> www.esacademy.com

Re: [lpc2000] Re: adding protection to final binary image

2004-06-30 by Robert Adsett

At 04:14 PM 6/30/04 +0000, you wrote:
>That would take care of the problem assuming the linker didn't use
>that memory location. I looked in the hex file and there is some
>data at that location!
>
>Any more ideas?

What's your tool set?  I would expect that the download program would 
normally take care of this and depending on the program it is conceivable 
that even if you set it in the binary file it will be overridden.

If the download does not change it, then how you set it depends in part on 
what tools you are using.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Re: adding protection to final binary image

2004-06-30 by Tutors of ESAcademy

> --- In lpc2000@yahoogroups.com, "Tutors of ESAcademy" 
> <esacademy@y...> wrote:
> > --- In lpc2000@yahoogroups.com, "Gus" <gus_is_working@y...> wrote:
> > > I am trying to add the protection word to my final binary
image. 
> I 
> > > need to place 0x87654321 at location 0x1fc. I don't know and 
> > > couldn't figure out how to tell the linker to place a word at 
> > > absolute(fixed) memory location.
> > 
> > 1. Generate an Intel hex file instead of a binary image
> > 2. Place an additional line in the file with your keyword in
Intel 
> hex
> > format
> > 3. (optional) Convert the Intel hex file into a binary image
> 
> That would take care of the problem assuming the linker didn't use 
> that memory location. I looked in the hex file and there is some 
> data at that location!
> 
> Any more ideas?

Yes - reserve that memory location during linking. Any linker that I
have worked with so far has an option exclude memory areas (or to
not-include some). Sometimes this option is not available directly
from the IDE but you have to set up a linker command file to do it.

Chris
Tutor at ESAcademy
www.esacademy.com
www.canopenbook.com

Re: adding protection to final binary image

2004-06-30 by Gus

I am using GCC-ELF-ARM

--- In lpc2000@yahoogroups.com, Robert Adsett <subscriptions@a...> 
wrote:
> At 04:14 PM 6/30/04 +0000, you wrote:
> >That would take care of the problem assuming the linker didn't use
> >that memory location. I looked in the hex file and there is some
> >data at that location!
> >
> >Any more ideas?
> 
> What's your tool set?  I would expect that the download program 
would 
> normally take care of this and depending on the program it is 
conceivable 
> that even if you set it in the binary file it will be overridden.
> 
> If the download does not change it, then how you set it depends in 
part on 
> what tools you are using.
> 
> Robert
> 
> " 'Freedom' has no meaning of itself.  There are always 
restrictions,
> be they legal, genetic, or physical.  If you don't believe me, try 
to
Show quoted textHide quoted text
> chew a radio signal. "
> 
>                          Kelvin Throop, III

Re: adding protection to final binary image

2004-06-30 by Gus

Have you ever done that with ARM-ELF-GCC compiler or do you know how 
to do it?

Gus

--- In lpc2000@yahoogroups.com, "Tutors of ESAcademy" 
<esacademy@y...> wrote:
> > --- In lpc2000@yahoogroups.com, "Tutors of ESAcademy" 
> > <esacademy@y...> wrote:
> > > --- In lpc2000@yahoogroups.com, "Gus" <gus_is_working@y...> 
wrote:
> > > > I am trying to add the protection word to my final binary
> image. 
> > I 
> > > > need to place 0x87654321 at location 0x1fc. I don't know and 
> > > > couldn't figure out how to tell the linker to place a word 
at 
> > > > absolute(fixed) memory location.
> > > 
> > > 1. Generate an Intel hex file instead of a binary image
> > > 2. Place an additional line in the file with your keyword in
> Intel 
> > hex
> > > format
> > > 3. (optional) Convert the Intel hex file into a binary image
> > 
> > That would take care of the problem assuming the linker didn't 
use 
> > that memory location. I looked in the hex file and there is some 
> > data at that location!
> > 
> > Any more ideas?
> 
> Yes - reserve that memory location during linking. Any linker that 
I
Show quoted textHide quoted text
> have worked with so far has an option exclude memory areas (or to
> not-include some). Sometimes this option is not available directly
> from the IDE but you have to set up a linker command file to do it.
> 
> Chris
> Tutor at ESAcademy
> www.esacademy.com
> www.canopenbook.com

Re: [lpc2000] Re: adding protection to final binary image

2004-06-30 by Robert Adsett

At 06:56 PM 6/30/04 +0000, you wrote:
>I am using GCC-ELF-ARM

Something like this might work.  Warning this is completely untested.

In your crt0.s add something like the following:

.section .protection,"ax"
         .code 32
         .align 0

         .word   0x87654321

to create the word holding the protection value.

In your ld script add something like:

  protect 0x1fc: { *(.protect)} /*  Place protection .   */

to the sections area.  You will probably have to modify other areas.

There will probably be a gap created.

Hmm, I suspect the best solution might be to create three sections in the 
flash 1- holds the interrupt table and maybe a little FIQ code, 2- holds 
the protection vector and maybe has a little room for system constants, 3 - 
everything after to hold the regular code.

You could do as Chris suggested and modify the ld script to exclude that 
area, and then modify the hex. I think that in effect takes you back to the 
3 section alternative above.

I'm a little leary about simply modifying the hex file since I have seen 
tools that fill the gaps in created hex files appropriately (usually 
meaning fill with FF).  I wouldn't be surprised if it worked with GCC 
though and it might be worth checking.

Robert


" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Re: adding protection to final binary image

2004-07-01 by Tutors of ESAcademy

--- In lpc2000@yahoogroups.com, Robert Adsett <subscriptions@a...>
wrote:
> >I am using GCC-ELF-ARM
> You could do as Chris suggested and modify the ld script to exclude
> that area, and then modify the hex. I think that in effect takes
> you back to the 3 section alternative above.
> 
> I'm a little leary about simply modifying the hex file since I have
> seen tools that fill the gaps in created hex files appropriately
> (usually meaning fill with FF).

True, but this will hopefully leave the flash cells in their erased
state, and the added word could still be programmed successfully.
But yes, it would not be exactly pretty... :)

I prefer a 'native' solution like the one that you outlined for
GNU-ARM, too, if possible. Here it is easy since the constant data
never changes, but if for example you have to rely on a separate tool
to generate a checksum to be stored at a fixed location it becomes
trickier. This is where I have used the hex file modification.

Chris
Tutor at ESAcademy
www.esacademy.com
www.canopenbook.com

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.