Hi Daniele,

TBBR specification, from where fip format was introduced, is not very clear about usage of serial number and it can be used in IMP DEFINED manner
"ToC Serial Number -  32 - The serial number of this ToC".

So, theoretically it's possible to use serial number for the purpose you described and it's a valid use of currently (un)used serial number.
Currently, at boot time serial number is checked against a non-zero value, which certainly will hold true if you put a valid timstamp instead of "0x12345678".

IMO you can go ahead and implement a mechanism to feed Build timestamp to be used as serial number.

Thanks
Manish P




From: TF-A <tf-a-bounces@lists.trustedfirmware.org> on behalf of Manish Badarkhe via TF-A <tf-a@lists.trustedfirmware.org>
Sent: 11 February 2021 11:39
To: Daniele Alessandrelli <daniele.alessandrelli@linux.intel.com>; tf-a@lists.trustedfirmware.org <tf-a@lists.trustedfirmware.org>
Subject: Re: [TF-A] Getting BUILD_STRING from FIP file
 

Hi Daniele

 

Please see my replies inline.

 

Thanks

Manish Badarkhe

 

From: Daniele Alessandrelli <daniele.alessandrelli@linux.intel.com>
Date: Thursday, 11 February 2021 at 11:22
To: Manish Badarkhe <Manish.Badarkhe@arm.com>, tf-a@lists.trustedfirmware.org <tf-a@lists.trustedfirmware.org>
Subject: Re: [TF-A] Getting BUILD_STRING from FIP file

Hi Manish,

Thank you very much for the information.

16 bits are not enough to store an epoch, but I'll see if I can encode
some other unique build information into 16 bits.

Just a question, from your answer I assume that I shouldn't use the
'serial_number' field for what I want to do; so I wonder: what is that
field meant to be used for?

'serial_number' field is non-zero number provided by the fip creation tool.
It is hardcoded value i.e. TOC_HEADER_SERIAL_NUMBER=0x12345678 as of now.
Specifically used during the validation of the TOC header in the code.


Regards,
Daniele

On Thu, 2021-02-11 at 10:14 +0000, Manish Badarkhe wrote:
> Hi Daniele

> You can use the ‘flag’ field to mention the platform-specific data(in
> your case, a build number). Usage of the ‘flag’ field(64 bit) in the
> toc_header are as below:
> Bits 0-31 -> reserved
> Bits 32-47 -> platform defined data
> Bits 48-63 -> reserved
> You can make use of the flag[32:47] to put build information. I am
> not sure if you can accommodate epoch (converted timestamp) into this
> field but, you can encode any data to fit into this 16bit flag field
> to identify the FIP build.

> You can use a build command: fiptool update/create --plat-toc-flags
> <platform defined data> <your fip bin path> to put the platform
> defined data in the FIP image.

> Thanks
> Manish Badarkhe
> From: TF-A <tf-a-bounces@lists.trustedfirmware.org> on behalf of
> Daniele Alessandrelli via TF-A <tf-a@lists.trustedfirmware.org>
> Date: Wednesday, 10 February 2021 at 17:04
> To: tf-a@lists.trustedfirmware.org <tf-a@lists.trustedfirmware.org>
> Subject: [TF-A] Getting BUILD_STRING from FIP file
>
> Hi,
>
> Is there a way to get BUILD_STRING (or a similar string / number that
> uniquely identifies the TF-A build, e.g., BUILD_MESSAGE_TIMESTAMP)
> from
> the FIP file?
>
> Basically, I'm trying to find a way to know the build number of a FIP
> without flashing it.
>
> I've seen that the FIP TOC header has a 32-bit field named
> 'serial_number'. Can it be used to this end? I'm considering
> converting BUILD_MESSAGE_TIMESTAMP into an epoch and adding it as
> 'serial number', but I'm worried that might be an unintended usage of
> the 'serial_number' field.
>
> Regards,
> Daniele
>
>
>