Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Numeric stability is probably not all that important when you're guessing.


devel / comp.arch.embedded / Re: Patch fixed strings in .hex file

SubjectAuthor
* Patch fixed strings in .hex filepozz
+* Re: Patch fixed strings in .hex fileDavid Brown
|`* Re: Patch fixed strings in .hex filepozz
| +* Re: Patch fixed strings in .hex fileDavid Brown
| |`- Re: Patch fixed strings in .hex filepozz
| `* Re: Patch fixed strings in .hex filedalai lamah
|  `- Re: Patch fixed strings in .hex fileDavid Brown
+* Re: Patch fixed strings in .hex fileHerbert Kleebauer
|`- Re: Patch fixed strings in .hex filepozz
+* Re: Patch fixed strings in .hex fileGrant Edwards
|+* Re: Patch fixed strings in .hex fileDavid Brown
||`- Re: Patch fixed strings in .hex fileGrant Edwards
|`- Re: Patch fixed strings in .hex filepozz
+* Re: Patch fixed strings in .hex fileDavid Brown
|`- Re: Patch fixed strings in .hex fileTauno Voipio
+* Re: Patch fixed strings in .hex fileStefan Reuther
|+- Re: Patch fixed strings in .hex fileGrant Edwards
|`- Re: Patch fixed strings in .hex fileMichael Schwingen
+* Re: Patch fixed strings in .hex fileHans-Bernhard Bröker
|`* Re: Patch fixed strings in .hex filepozz
| +- Re: Patch fixed strings in .hex filepozz
| +* Re: Patch fixed strings in .hex fileDavid Brown
| |`* Re: Patch fixed strings in .hex filepozz
| | +- Re: Patch fixed strings in .hex fileDavid Brown
| | `* Re: Patch fixed strings in .hex fileStefan Reuther
| |  +- Re: Patch fixed strings in .hex fileDavid Brown
| |  +- Re: Patch fixed strings in .hex fileGrant Edwards
| |  `- Re: Patch fixed strings in .hex filepozz
| `- Re: Patch fixed strings in .hex fileHans-Bernhard Bröker
+- Re: Patch fixed strings in .hex filepozz
+- Re: Patch fixed strings in .hex fileDon Y
`- Re: Patch fixed strings in .hex filePaul Rubin

Pages:12
Re: Patch fixed strings in .hex file

<uo919i$24auv$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1748&group=comp.arch.embedded#1748

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: blockedo...@foo.invalid (Don Y)
Newsgroups: comp.arch.embedded
Subject: Re: Patch fixed strings in .hex file
Date: Wed, 17 Jan 2024 10:03:40 -0700
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <uo919i$24auv$1@dont-email.me>
References: <uo5s8d$1cjl8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 17 Jan 2024 17:03:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4bf02256a7ec5fe43bef3a9ff1f4a05e";
logging-data="2239455"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yFt2U3ZQReR2HM+3Pnv6J"
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.2.2
Cancel-Lock: sha1:QMtPPqBvRBbjwQNsRN3p2J2lrsQ=
Content-Language: en-US
In-Reply-To: <uo5s8d$1cjl8$1@dont-email.me>
 by: Don Y - Wed, 17 Jan 2024 17:03 UTC

On 1/16/2024 5:19 AM, pozz wrote:
> In one project I have many quasi-fixed strings that I'd like to keep in non
> volatile memory (Flash) to avoid losing precious RAM space.
>
> static const char s1[] = "/my/very/long/string/of/01020304";
> static const char s2[] = "/another/string/01020304";
> ...
>
> Substring "01020304" is a serial number that changes during production with
> specific device. It has the same length in bytes (it's a simple hex
> representation of a 32-bits integer).
>
> Of course it's too difficult and slow to rebuild the firmware during production
> passing to the compiler the real serial number. I think a better solution is to
> patch the .hex file generated by the compiler.
>
> I'm wondering how to detect the exact positions (addresses) of serial numbers
> to fix.

Don't "detect" (i.e., "find"); rather, *place* it/them in a specific location
that your code already knows about. How else would you force vector tables
to reside at specific locations, jump tables, etc.?

You will also code this "hole" into any checksum routine that your
code executes at POST and cover it with a check of its own (that you
will have to ensure is satisfied by whatever tool you use to "patch"
the binary image).

> The build system is gcc, so I could search for s1 in the elf file. Do you know
> of a tool that returns the address of a symbol in the elf or map file?
>
> Could you suggest a better approach?

When faced with *small* memory regions (e.g., 100 bytes) of a particular
resource (e.g., NVRAM), I prefer a tagged format that allows the available
space to be dynamically traded among uses -- much like cramming a variable
number of parameters in a BOOTP packet.

The downside is that you have to parse the region to extract any specific
parameter. But, it eliminates the need to define static structures
that might change from instance to instance:

STRING1, "/my/very/long/string/of/01020304",
STRING8, "Some Guy's Really long name or address",
STRING9, "/another/string/01020304",
etc.

Note that the tag can be designed to act as the delimiter of a field.
E.g., if all tags (STRING1, STRING8, etc.) have values outside the valid
range of the data being stored (e.g., > 0x7F for ASCII), then the
parse can know that a string terminates when any value > 0x7F is
encountered. (you know that the first value in the region is a tag)

A more versatile approach is to have each tag invoke it's own parse
algorithm:

CITY, "Cañon City\0", ZIPCODE, (long) 81212, AREACODE, ...

Note that 'ñ' is outside the ASCII code points but the CITY parse
routine could rely on some other mechanism ('\0') to detect the end
of that field; similarly, ZIPCODE can expect a 4-byte integer to
immediately follow it; AREA code can expect three BSD digits, etc.

One can insist that tags appear in some fixed order (like TIFF
files) so encountering anything that violates that rule where a
tag is expected can act as a terminator for the field. Or, you
can add a tag that is ENDOFDATA, etc.

This makes the task of replacing any *individual* datum a bit
harder as the fields aren't rigidly defined -- just the start
of the region and its TOTAL length.

OTOH, it's a win when the design evolves to require yet another
parameter without altering the space available to that COLLECTION
of parameters (like a network protocol trying to cram more functionality
into a single packet)

Protecting the integrity of this section can be accomplished with
an error *correcting* code instead of just an error DETECTING
checksum. E.g., I often create nonvolatile instances of the
state of a pseudo-random number generator (because you don't
want a user to be able to "reinitialize" it just by cycling
power) with it's own ECC -- as *it* is often far more valuable than
any other "settings" in the device.

Re: Patch fixed strings in .hex file

<uo92n6$24ip2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1749&group=comp.arch.embedded#1749

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!usenet.network!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch.embedded
Subject: Re: Patch fixed strings in .hex file
Date: Wed, 17 Jan 2024 18:28:06 +0100
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <uo92n6$24ip2$1@dont-email.me>
References: <uo5s8d$1cjl8$1@dont-email.me> <l0o0kcFat0kU1@mid.dfncis.de>
<uo80im$1t6mh$1@dont-email.me> <uo8a1l$1v1eq$1@dont-email.me>
<uo8f5k$1veo9$1@dont-email.me> <uo93cq.3ec.1@stefan.msgid.phost.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 17 Jan 2024 17:28:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e5d003c4907c1c313df779ab33f575b8";
logging-data="2247458"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9/qumaiIVYFGP+qLsilsE+UTGFieJn54="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:Y5tLpTyqpAdT7eJWKOaOiN9CyKA=
In-Reply-To: <uo93cq.3ec.1@stefan.msgid.phost.de>
Content-Language: en-GB
 by: David Brown - Wed, 17 Jan 2024 17:28 UTC

On 17/01/2024 17:39, Stefan Reuther wrote:
> Am 17.01.2024 um 12:54 schrieb pozz:
>> Il 17/01/2024 11:27, David Brown ha scritto:
>>> While it is possible to do all this using patching of odd places in
>>> your file, using specific locations is often a better choice.  Since
>>> you haven't already said "Thanks for the advice - I tried it that way,
>>> it worked, and I'm happy" in response to any post, I would say that
>>> now is the time to take fixed location solutions seriously.
>>
>> There are many suggested solutions and I think all of them can be used
>> with success. Just for sake of curiosity and studying, I'm exploring all
>> of them.
>>
>> Sincerely I don't *like* solutions where you need to choose a fixed
>> location by yourself. Why you should make a job that can be done by the
>> linker?
>
> It's not you vs. the linker. You co-operate. You need to tell the linker
> about your chip anyway ("code is from 0x1000 to 0xc000, data is from
> 0xc000 to 0xd000"). So you can as well tell it "version stamp is from
> 0xcc00 to 0xd000, data only before 0xcc00".
>
> If you have your identification information in a fixed place, you can,
> for example, more easily analyze field returns. It's easy for your field
> service has to change something, and it's easy to do software updates
> that preserve the identification information. You don't need to figure
> out which software build is running on the chip and what the address of
> the structure happens to be in that one.
>
>>> Now your post-build scripts have a simple fixed address to patch the
>>> binaries.
>>
>> How the post-build script should know the exact address of a certain
>> field in the struct?
>
> By defining the struct in a compatible way. For example....
>
>> volatile const struct post_build_data {
>>   uint32_t serial_number;
>>   uint64_t mac_address;
>
> ...this is a bad idea, because in most (but probably not all) chips,
> uint64_t after uint32_t means there's 32 bits of padding, so if you need
> serial-before-mac, you should at least make the padding explicit. There
> also might be endian problems.
>
> Using only char/uint8_t fields gives you a very high chance of identical
> structure layout everywhere (`uint8_t mac_address[8]`).
>

You can also keep things safe by making sure that you are aligned by
"natural" alignment, at least to size 8 bytes (I have never heard of a
platform that has more than 8 byte alignment for anything). So two
uint32_t's followed by an uint64_t is fine.

#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wpadded"
volatile const struct ...
#pragma GCC diagnostic pop

is a useful check (if you are using gcc or clang).

And a static assert on the size of the struct is another important
safe-guard.

Re: Patch fixed strings in .hex file

<uo95o3$2542a$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1750&group=comp.arch.embedded#1750

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!news.1d4.us!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tauno.vo...@notused.fi.invalid (Tauno Voipio)
Newsgroups: comp.arch.embedded
Subject: Re: Patch fixed strings in .hex file
Date: Wed, 17 Jan 2024 20:19:46 +0200
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <uo95o3$2542a$1@dont-email.me>
References: <uo5s8d$1cjl8$1@dont-email.me> <uo67vv$1ggju$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 17 Jan 2024 18:19:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9e62869f056464a611383822cf59dd08";
logging-data="2265162"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18eKyYUEusK0LZKqSYvw2YORUkDhCXFOOo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:8m+Xr39pVT8JHRh5611bUiVDMdM=
In-Reply-To: <uo67vv$1ggju$2@dont-email.me>
Content-Language: en-US
 by: Tauno Voipio - Wed, 17 Jan 2024 18:19 UTC

On 16.1.2024 17.39, David Brown wrote:
> On 16/01/2024 13:19, pozz wrote:
>> In one project I have many quasi-fixed strings that I'd like to keep
>> in non volatile memory (Flash) to avoid losing precious RAM space.
>>
>> static const char s1[] = "/my/very/long/string/of/01020304";
>> static const char s2[] = "/another/string/01020304";
>> ...
>>
>> Substring "01020304" is a serial number that changes during production
>> with specific device. It has the same length in bytes (it's a simple
>> hex representation of a 32-bits integer).
>>
>> Of course it's too difficult and slow to rebuild the firmware during
>> production passing to the compiler the real serial number. I think a
>> better solution is to patch the .hex file generated by the compiler.
>>
>> I'm wondering how to detect the exact positions (addresses) of serial
>> numbers to fix.
>>
>> The build system is gcc, so I could search for s1 in the elf file. Do
>> you know of a tool that returns the address of a symbol in the elf or
>> map file?
>>
>> Could you suggest a better approach?
>>
>
> Another - perhaps more reliable - method would be to put the string in
> its own section with __attribute__((section('serial_number'))), and then
> have a linker file entry to fix it at a specific known address.
>

My vote for this.

If there are many strings, they could be set into
a const volatile struct which then is located into
a known place.

--

-TV

Re: Patch fixed strings in .hex file

<uo984n$5km$2@reader1.panix.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1751&group=comp.arch.embedded#1751

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!news.chmurka.net!weretis.net!feeder6.news.weretis.net!panix!.POSTED.24-152-157-105.fttp.usinternet.com!not-for-mail
From: inva...@invalid.invalid (Grant Edwards)
Newsgroups: comp.arch.embedded
Subject: Re: Patch fixed strings in .hex file
Date: Wed, 17 Jan 2024 19:00:39 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <uo984n$5km$2@reader1.panix.com>
References: <uo5s8d$1cjl8$1@dont-email.me> <l0o0kcFat0kU1@mid.dfncis.de>
<uo80im$1t6mh$1@dont-email.me> <uo8a1l$1v1eq$1@dont-email.me>
<uo8f5k$1veo9$1@dont-email.me> <uo93cq.3ec.1@stefan.msgid.phost.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 17 Jan 2024 19:00:39 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="24-152-157-105.fttp.usinternet.com:24.152.157.105";
logging-data="5782"; mail-complaints-to="abuse@panix.com"
User-Agent: slrn/1.0.3 (Linux)
 by: Grant Edwards - Wed, 17 Jan 2024 19:00 UTC

On 2024-01-17, Stefan Reuther <stefan.news@arcor.de> wrote:
> Am 17.01.2024 um 12:54 schrieb pozz:
>> Il 17/01/2024 11:27, David Brown ha scritto:
>>> While it is possible to do all this using patching of odd places in
>>> your file, using specific locations is often a better choice.  Since
>>> you haven't already said "Thanks for the advice - I tried it that way,
>>> it worked, and I'm happy" in response to any post, I would say that
>>> now is the time to take fixed location solutions seriously.
>>
>> There are many suggested solutions and I think all of them can be used
>> with success. Just for sake of curiosity and studying, I'm exploring all
>> of them.
>>
>> Sincerely I don't *like* solutions where you need to choose a fixed
>> location by yourself. Why you should make a job that can be done by the
>> linker?
>
> It's not you vs. the linker. You co-operate. You need to tell the linker
> about your chip anyway ("code is from 0x1000 to 0xc000, data is from
> 0xc000 to 0xd000"). So you can as well tell it "version stamp is from
> 0xcc00 to 0xd000, data only before 0xcc00".
>
> If you have your identification information in a fixed place, you can,
> for example, more easily analyze field returns. It's easy for your field
> service has to change something, and it's easy to do software updates
> that preserve the identification information. You don't need to figure
> out which software build is running on the chip and what the address of
> the structure happens to be in that one.
>
>>> Now your post-build scripts have a simple fixed address to patch the
>>> binaries.
>>
>> How the post-build script should know the exact address of a certain
>> field in the struct?
>
> By defining the struct in a compatible way. For example....
>
>> volatile const struct post_build_data {
>>   uint32_t serial_number;
>>   uint64_t mac_address;
>
> ...this is a bad idea, because in most (but probably not all) chips,
> uint64_t after uint32_t means there's 32 bits of padding, so if you need
> serial-before-mac, you should at least make the padding explicit.

Yes, defintely that. Or make the packing explicit. And add compile
time checks to verify the offsets of fields withing the structure and
fail if they're not what is expected. That has saved my many times.

Re: Patch fixed strings in .hex file

<87mst3w62z.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1752&group=comp.arch.embedded#1752

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.arch.embedded
Subject: Re: Patch fixed strings in .hex file
Date: Wed, 17 Jan 2024 21:42:12 -0800
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <87mst3w62z.fsf@nightsong.com>
References: <uo5s8d$1cjl8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4560fc94e50b7ffed77928eea18904c7";
logging-data="2610535"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+MzFgIVHz/d9A6gREQvS1L"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:Q0ry0+UmC1fbsGGXiSu8t32ihak=
sha1:CapUgAkwFaaSO0fUw3PIZtgICMo=
 by: Paul Rubin - Thu, 18 Jan 2024 05:42 UTC

pozz <pozzugno@gmail.com> writes:
> The build system is gcc, so I could search for s1 in the elf file. Do
> you know of a tool that returns the address of a symbol in the elf or
> map file?

The nlist command line tool is for that, and iirc there are some library
functions that do similar.

Re: Patch fixed strings in .hex file

<l0t6l3Fj9lpU1@mid.dfncis.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1753&group=comp.arch.embedded#1753

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!news.neodome.net!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail
From: HBBroe...@gmail.com (Hans-Bernhard Bröker)
Newsgroups: comp.arch.embedded
Subject: Re: Patch fixed strings in .hex file
Date: Thu, 18 Jan 2024 18:49:24 +0100
Lines: 37
Message-ID: <l0t6l3Fj9lpU1@mid.dfncis.de>
References: <uo5s8d$1cjl8$1@dont-email.me> <l0o0kcFat0kU1@mid.dfncis.de>
<uo80im$1t6mh$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.dfncis.de g00owFM3LkSpr6SAf2bQdAkkavploI/bgHImr9TmoVr6OTyNEfKOcMMESW
Cancel-Lock: sha1:6kdzv1UxB6yVRhfKVS+imaG3LzI= sha256:3pbF3nF8XJigYFZyTCnhq1n6nodIbbIexSJnKePl8t0=
User-Agent: Mozilla Thunderbird
Content-Language: de-DE, en-US
In-Reply-To: <uo80im$1t6mh$1@dont-email.me>
 by: Hans-Bernhard Bröke - Thu, 18 Jan 2024 17:49 UTC

Am 17.01.2024 um 08:45 schrieb pozz:
> Il 16/01/2024 19:35, Hans-Bernhard Bröker ha scritto:
>> Am 16.01.2024 um 13:19 schrieb pozz:
>>
>>> I'm wondering how to detect the exact positions (addresses) of serial
>>> numbers to fix.
>>
>> You do not.
>>
>> Instead, you set up linker scripts, linker options and/or add
>> __attribute(()) to the variables' definitions to _place_ them at a
>> predetermined, fixed, known-useful location.
>
> Do you mean to choose by yourself the exact address of *each* string?

Of each st4ring that needs this kind of post-build treatment? Oh yes,
absolutely. The key insight is that these are not just ordinary strings
like any other: they're post-build configuration data.

> And where would you put them, at the beginning, in the middle or at the
> end of the Flash?

That discussion is what hides behind the term "known-useful", above.
Typically such elements end up near pre-existing memory region
boundaries, with some additional space reserved near them for future
expansion.

> You need to calculate the address of the next string
> from the address *and length* of the previous string.

You didn't seriously plan on having the length of this kind of string
actually changing willy-nilly, did you? These actually have to be
fixed-size arrays, i.e.

volatile const char foo[D_LENGTH];

or equivalent.

Re: Patch fixed strings in .hex file

<uodaq4$31rbg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1754&group=comp.arch.embedded#1754

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: pozzu...@gmail.com (pozz)
Newsgroups: comp.arch.embedded
Subject: Re: Patch fixed strings in .hex file
Date: Fri, 19 Jan 2024 09:10:44 +0100
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <uodaq4$31rbg$1@dont-email.me>
References: <uo5s8d$1cjl8$1@dont-email.me> <l0o0kcFat0kU1@mid.dfncis.de>
<uo80im$1t6mh$1@dont-email.me> <uo8a1l$1v1eq$1@dont-email.me>
<uo8f5k$1veo9$1@dont-email.me> <uo93cq.3ec.1@stefan.msgid.phost.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 19 Jan 2024 08:10:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9dfe92970e6371b81a34114fe5a06f84";
logging-data="3206512"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zQUM+F8U8GVsFWLXqOsAF5Hhg+mxVZm8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qUtt3Lb3EyXLnahftari4mz1DpI=
Content-Language: it
In-Reply-To: <uo93cq.3ec.1@stefan.msgid.phost.de>
 by: pozz - Fri, 19 Jan 2024 08:10 UTC

Il 17/01/2024 17:39, Stefan Reuther ha scritto:
> Am 17.01.2024 um 12:54 schrieb pozz:
>> Il 17/01/2024 11:27, David Brown ha scritto:
>>> While it is possible to do all this using patching of odd places in
>>> your file, using specific locations is often a better choice.  Since
>>> you haven't already said "Thanks for the advice - I tried it that way,
>>> it worked, and I'm happy" in response to any post, I would say that
>>> now is the time to take fixed location solutions seriously.
>>
>> There are many suggested solutions and I think all of them can be used
>> with success. Just for sake of curiosity and studying, I'm exploring all
>> of them.
>>
>> Sincerely I don't *like* solutions where you need to choose a fixed
>> location by yourself. Why you should make a job that can be done by the
>> linker?
>
> It's not you vs. the linker. You co-operate. You need to tell the linker
> about your chip anyway ("code is from 0x1000 to 0xc000, data is from
> 0xc000 to 0xd000"). So you can as well tell it "version stamp is from
> 0xcc00 to 0xd000, data only before 0xcc00".
>
> If you have your identification information in a fixed place, you can,
> for example, more easily analyze field returns. It's easy for your field
> service has to change something, and it's easy to do software updates
> that preserve the identification information. You don't need to figure
> out which software build is running on the chip and what the address of
> the structure happens to be in that one.

Good point, firmware upgrade. I wasn't thinking about it.

If the addresses of post-builds strings weren't fixed over all the
versions, it would be more complex for the software that manages the
upgrade.

>
>>> Now your post-build scripts have a simple fixed address to patch the
>>> binaries.
>>
>> How the post-build script should know the exact address of a certain
>> field in the struct?
>
> By defining the struct in a compatible way. For example....
>
>> volatile const struct post_build_data {
>>   uint32_t serial_number;
>>   uint64_t mac_address;
>
> ...this is a bad idea, because in most (but probably not all) chips,
> uint64_t after uint32_t means there's 32 bits of padding, so if you need
> serial-before-mac, you should at least make the padding explicit. There
> also might be endian problems.
>
> Using only char/uint8_t fields gives you a very high chance of identical
> structure layout everywhere (`uint8_t mac_address[8]`).
>
>
> Stefan

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor