Skip to contentSkip to conversation

imx: hab: fix size of IVT+CSF blob tacked on to u-boot.itb

PATCH Applied Rasmus Villemoes 4 participants 13 messages Oct 24, 2024 – Oct 28, 2024 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 imx: hab: fix size of IVT+CSF blob tacked on to u-boot.itb

Loading flash.bin using uuu fails when flash.bin does not have the right size.

When flash.bin is loaded from some storage medium (sd card/emmc), SPL just loads some random garbage bytes from beyond what has been populated when flash.bin was written, but when loaded via uuu, SPL hangs waiting for the host to send the expected number of bytes. Which is (size of FIT image aligned to 0x1000)+CONFIG_CSF_SIZE. The alignment to 0x1000 is already done and is necessary in all cases because that's the exact expected location of the 32 byte IVT header. But the IVT+CSF blob tacked onto the end must be a total of CONFIG_CSF_SIZE.

This is exactly the same fix as 89f19f45d650, except that this time around I don't know how to cleanly get CONFIG_CSF_SIZE.

Fixes bc6beae7c55f (binman: Add nxp_imx8mcst etype for i.MX8M flash.bin signing)

---
Heiko, can you check if this works for you?

And if somebody wants to pick this up and knows how to get at CONFIG_ values, feel free to fix up and take authorship. But perhaps it's not really configurable at all; imx8mimage.c has the value 0x2000 hard-coded, so I don't think anything good could ever come from modifying CONFIG_CSF_SIZE. If so, the right fix is probably just to make that knob non-settable.

 tools/binman/etype/nxp_imx8mcst.py | 2 ++
 1 file changed, 2 insertions(+)
tools/binman/etype/nxp_imx8mcst.py +2 -0
index 8221517b0c4..9a1974cc522 100644
@@ -137,6 +137,8 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
         args = ['-i', cfg_fname, '-o', output_fname]
         if self.cst.run_cmd(*args) is not None:
             outdata = tools.read_file(output_fname)
+            # fixme: 0x2000 should be CONFIG_CSF_SIZE
+            outdata += tools.get_bytes(0, 0x2000 - 0x20 - len(outdata))
             return data + outdata
         else:
             # Bintool is missing; just use the input data as the output
Signature · 1 line
2.47.0
#1 lore raw
Quoted 36 lines · Rasmus Villemoes

Loading flash.bin using uuu fails when flash.bin does not have the right size.

When flash.bin is loaded from some storage medium (sd card/emmc), SPL just loads some random garbage bytes from beyond what has been populated when flash.bin was written, but when loaded via uuu, SPL hangs waiting for the host to send the expected number of bytes. Which is (size of FIT image aligned to 0x1000)+CONFIG_CSF_SIZE. The alignment to 0x1000 is already done and is necessary in all cases because that's the exact expected location of the 32 byte IVT header. But the IVT+CSF blob tacked onto the end must be a total of CONFIG_CSF_SIZE.

This is exactly the same fix as 89f19f45d650, except that this time around I don't know how to cleanly get CONFIG_CSF_SIZE.

Fixes bc6beae7c55f (binman: Add nxp_imx8mcst etype for i.MX8M flash.bin signing)

---
Heiko, can you check if this works for you?

And if somebody wants to pick this up and knows how to get at CONFIG_ values, feel free to fix up and take authorship. But perhaps it's not really configurable at all; imx8mimage.c has the value 0x2000 hard-coded, so I don't think anything good could ever come from modifying CONFIG_CSF_SIZE. If so, the right fix is probably just to make that knob non-settable.

  tools/binman/etype/nxp_imx8mcst.py | 2 ++
  1 file changed, 2 insertions(+)
tools/binman/etype/nxp_imx8mcst.py +0 -0
index 8221517b0c4..9a1974cc522 100644

tools/binman/etype/nxp_imx8mcst.py class Entry_nxp_imx8mcst(Entry_mkimage): · line 144

Quoted 8 lines
tools/binman/etype/nxp_imx8mcst.py +2 -0
@@ -137,6 +137,8 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
          args = ['-i', cfg_fname, '-o', output_fname]
          if self.cst.run_cmd(*args) is not None:
              outdata = tools.read_file(output_fname)
+            # fixme: 0x2000 should be CONFIG_CSF_SIZE
+            outdata += tools.get_bytes(0, 0x2000 - 0x20 - len(outdata))
              return data + outdata
          else:
              # Bintool is missing; just use the input data as the output

I have to admit, I never really figured out this binman stuff, but shouldn't the fix be also in tools/binman/etype/nxp_imx8mimage.py ? And ... shouldn't it somehow use SetImagePos() ?

reviewer
#2 lore raw

Adding Simon.

Quoted 50 lines · Marek Vasut
Quoted 36 lines · Rasmus Villemoes

Loading flash.bin using uuu fails when flash.bin does not have the right size.

When flash.bin is loaded from some storage medium (sd card/emmc), SPL just loads some random garbage bytes from beyond what has been populated when flash.bin was written, but when loaded via uuu, SPL hangs waiting for the host to send the expected number of bytes. Which is (size of FIT image aligned to 0x1000)+CONFIG_CSF_SIZE. The alignment to 0x1000 is already done and is necessary in all cases because that's the exact expected location of the 32 byte IVT header. But the IVT+CSF blob tacked onto the end must be a total of CONFIG_CSF_SIZE.

This is exactly the same fix as 89f19f45d650, except that this time around I don't know how to cleanly get CONFIG_CSF_SIZE.

Fixes bc6beae7c55f (binman: Add nxp_imx8mcst etype for i.MX8M flash.bin signing)

---
Heiko, can you check if this works for you?

And if somebody wants to pick this up and knows how to get at CONFIG_ values, feel free to fix up and take authorship. But perhaps it's not really configurable at all; imx8mimage.c has the value 0x2000 hard-coded, so I don't think anything good could ever come from modifying CONFIG_CSF_SIZE. If so, the right fix is probably just to make that knob non-settable.

  tools/binman/etype/nxp_imx8mcst.py | 2 ++
  1 file changed, 2 insertions(+)
tools/binman/etype/nxp_imx8mcst.py +0 -0
index 8221517b0c4..9a1974cc522 100644

tools/binman/etype/nxp_imx8mcst.py class Entry_nxp_imx8mcst(Entry_mkimage): · line 144

Quoted 8 lines
tools/binman/etype/nxp_imx8mcst.py +2 -0
@@ -137,6 +137,8 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
          args = ['-i', cfg_fname, '-o', output_fname]
          if self.cst.run_cmd(*args) is not None:
              outdata = tools.read_file(output_fname)
+            # fixme: 0x2000 should be CONFIG_CSF_SIZE
+            outdata += tools.get_bytes(0, 0x2000 - 0x20 - len(outdata))
              return data + outdata
          else:
              # Bintool is missing; just use the input data as the output

I have to admit, I never really figured out this binman stuff, but shouldn't the fix be also in tools/binman/etype/nxp_imx8mimage.py ? And ... shouldn't it somehow use SetImagePos() ?

#3 lore raw
In reply to Marek Vasut
Quoted 38 lines · Marek Vasut
Quoted 37 lines · Rasmus Villemoes

Loading flash.bin using uuu fails when flash.bin does not have the right size.
When flash.bin is loaded from some storage medium (sd card/emmc), SPL
just loads some random garbage bytes from beyond what has been populated when flash.bin was written, but when loaded via uuu, SPL hangs waiting for the host to send the expected number of bytes. Which is (size of FIT image aligned to 0x1000)+CONFIG_CSF_SIZE. The alignment to 0x1000 is already done and is necessary in all cases because that's the exact expected location of the 32 byte IVT header. But the IVT+CSF blob tacked onto the end must be a total of CONFIG_CSF_SIZE.
This is exactly the same fix as 89f19f45d650, except that this time around I don't know how to cleanly get CONFIG_CSF_SIZE.

Fixes bc6beae7c55f (binman: Add nxp_imx8mcst etype for i.MX8M

flash.bin signing)

---
Heiko, can you check if this works for you?
And if somebody wants to pick this up and knows how to get at CONFIG_
values, feel free to fix up and take authorship. But perhaps it's not really configurable at all; imx8mimage.c has the value 0x2000 hard-coded, so I don't think anything good could ever come from modifying CONFIG_CSF_SIZE. If so, the right fix is probably just to make that knob non-settable.

  tools/binman/etype/nxp_imx8mcst.py | 2 ++
  1 file changed, 2 insertions(+)
tools/binman/etype/nxp_imx8mcst.py +0 -0
index 8221517b0c4..9a1974cc522 100644
@@ -137,6 +137,8 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
          args = ['-i', cfg_fname, '-o', output_fname]
          if self.cst.run_cmd(*args) is not None:
              outdata = tools.read_file(output_fname)
Quoted 8 lines

tools/binman/etype/nxp_imx8mcst.py class Entry_nxp_imx8mcst(Entry_mkimage): · line 144

Quoted 5 lines
tools/binman/etype/nxp_imx8mcst.py +2 -0
+            # fixme: 0x2000 should be CONFIG_CSF_SIZE
+            outdata += tools.get_bytes(0, 0x2000 - 0x20 - len(outdata))
              return data + outdata
          else:
              # Bintool is missing; just use the input data as the output

I have to admit, I never really figured out this binman stuff, but shouldn't the fix be also in tools/binman/etype/nxp_imx8mimage.py ?

No, why? That logic is all about generating the imx-specific header in front of SPL.bin, there's no CSF being generated. Or maybe mkimage tacks on some dummy bytes, but then that's explicitly ignored by the signing step, I think that's what the

signbase -= 0x40
signsize = struct.unpack('<I', data[24:28])[0] - signbase # Remove mkimage generated padding from the end of data data = data[:signsize]

is about, so the signing step generates a new IVT and a new (real) CSF for the SPL. And none of that matters for the size of the final flash.bin, because the FIT image is located far ahead at a fixed 0x58000 position.

Quoted 1 line

And ... shouldn't it somehow use SetImagePos() ?

Again, why? I'm padding a blob (in this case the CSF data) to a required size before tacking it on. Exactly as the existing code does

            # Align fitImage to 4k
            signsize = tools.align(len(data), 0x1000)
            data += tools.get_bytes(0, signsize - len(data))

before writing out the (padded FIT image + 32 byte IVT) for cst to chew on and generate the CSF data.

This is all about ensuring that the FIT+IVT+CSF blob has (exactly) the size computed by board_spl_fit_size_align, which is

        size = ALIGN(size, 0x1000);
        size += CONFIG_CSF_SIZE;

The 0x1000 part is done in the existing code, I'm just making sure that the data we append after that is exactly CONFIG_CSF_SIZE. The CSF blob itself is what is originally in outdata, and because the IVT must be included in the data which is signed, the IVT has already been appended after the 0x1000 padded FIT image; that's why the computation of the extra bytes ends up being a little complicated. [If we just appended a full CONFIG_CSF_SIZE bytes, the board would boot, but then uuu would be hanging while waiting to deliver the remaining part of the file, so the size should match exactly.]

I also don't grok the binman stuff, but there's really no separate image to set a "position" for, the csf blob (or ivt+csf blob) is not represented as its own image in the binman description.

Rasmus

#4 lore raw
Quoted 49 lines · Rasmus Villemoes
Quoted 38 lines · Marek Vasut
Quoted 37 lines · Rasmus Villemoes

Loading flash.bin using uuu fails when flash.bin does not have the right size.
When flash.bin is loaded from some storage medium (sd card/emmc), SPL
just loads some random garbage bytes from beyond what has been populated when flash.bin was written, but when loaded via uuu, SPL hangs waiting for the host to send the expected number of bytes. Which is (size of FIT image aligned to 0x1000)+CONFIG_CSF_SIZE. The alignment to 0x1000 is already done and is necessary in all cases because that's the exact expected location of the 32 byte IVT header. But the IVT+CSF blob tacked onto the end must be a total of CONFIG_CSF_SIZE.
This is exactly the same fix as 89f19f45d650, except that this time around I don't know how to cleanly get CONFIG_CSF_SIZE.

Fixes bc6beae7c55f (binman: Add nxp_imx8mcst etype for i.MX8M

flash.bin signing)

---
Heiko, can you check if this works for you?
And if somebody wants to pick this up and knows how to get at CONFIG_
values, feel free to fix up and take authorship. But perhaps it's not really configurable at all; imx8mimage.c has the value 0x2000 hard-coded, so I don't think anything good could ever come from modifying CONFIG_CSF_SIZE. If so, the right fix is probably just to make that knob non-settable.

   tools/binman/etype/nxp_imx8mcst.py | 2 ++
   1 file changed, 2 insertions(+)
tools/binman/etype/nxp_imx8mcst.py +0 -0
index 8221517b0c4..9a1974cc522 100644
@@ -137,6 +137,8 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
           args = ['-i', cfg_fname, '-o', output_fname]
           if self.cst.run_cmd(*args) is not None:
               outdata = tools.read_file(output_fname)
Quoted 8 lines

tools/binman/etype/nxp_imx8mcst.py class Entry_nxp_imx8mcst(Entry_mkimage): · line 144

Quoted 5 lines
tools/binman/etype/nxp_imx8mcst.py +2 -0
+            # fixme: 0x2000 should be CONFIG_CSF_SIZE
+            outdata += tools.get_bytes(0, 0x2000 - 0x20 - len(outdata))
               return data + outdata
           else:
               # Bintool is missing; just use the input data as the output

I have to admit, I never really figured out this binman stuff, but shouldn't the fix be also in tools/binman/etype/nxp_imx8mimage.py ?

Quoted 2 lines

No, why? That logic is all about generating the imx-specific header in front of SPL.bin, there's no CSF being generated.

This patch is modifying tools/binman/etype/nxp_imx8mcst.py which is the Code-Signing-Tool binman etype, the thing used for generating SIGNED images during HAB use.

Shouldn't this patch modify tools/binman/etype/nxp_imx8mimage.py which is the etype used when generating flash.bin itself ?

My understanding was that the problem Heiko reported was alignment of flash.bin , independently of it being signed or not ?

Quoted 42 lines

Or maybe mkimage tacks
on some dummy bytes, but then that's explicitly ignored by the signing step, I think that's what the

signbase -= 0x40
signsize = struct.unpack('<I', data[24:28])[0] - signbase # Remove mkimage generated padding from the end of data data = data[:signsize]

is about, so the signing step generates a new IVT and a new (real) CSF for the SPL. And none of that matters for the size of the final flash.bin, because the FIT image is located far ahead at a fixed 0x58000 position.

Quoted 1 line

And ... shouldn't it somehow use SetImagePos() ?

Again, why? I'm padding a blob (in this case the CSF data) to a required size before tacking it on. Exactly as the existing code does

             # Align fitImage to 4k
             signsize = tools.align(len(data), 0x1000)
             data += tools.get_bytes(0, signsize - len(data))

before writing out the (padded FIT image + 32 byte IVT) for cst to chew on and generate the CSF data.

This is all about ensuring that the FIT+IVT+CSF blob has (exactly) the size computed by board_spl_fit_size_align, which is

         size = ALIGN(size, 0x1000);
         size += CONFIG_CSF_SIZE;

The 0x1000 part is done in the existing code, I'm just making sure that the data we append after that is exactly CONFIG_CSF_SIZE. The CSF blob itself is what is originally in outdata, and because the IVT must be included in the data which is signed, the IVT has already been appended after the 0x1000 padded FIT image; that's why the computation of the extra bytes ends up being a little complicated. [If we just appended a full CONFIG_CSF_SIZE bytes, the board would boot, but then uuu would be hanging while waiting to deliver the remaining part of the file, so the size should match exactly.]

Quoted 3 lines

I also don't grok the binman stuff, but there's really no separate image to set a "position" for, the csf blob (or ivt+csf blob) is not represented as its own image in the binman description.

It is probably best to let Simon comment on this.

#5 lore raw
Quoted 53 lines · Marek Vasut
Quoted 48 lines · Rasmus Villemoes
Quoted 38 lines · Marek Vasut
Quoted 37 lines · Rasmus Villemoes

Loading flash.bin using uuu fails when flash.bin does not have the right size.
When flash.bin is loaded from some storage medium (sd card/emmc), SPL
just loads some random garbage bytes from beyond what has been populated when flash.bin was written, but when loaded via uuu, SPL hangs waiting for the host to send the expected number of bytes. Which is (size of FIT image aligned to 0x1000)+CONFIG_CSF_SIZE. The alignment to 0x1000 is already done and is necessary in all cases because that's the exact expected location of the 32 byte IVT header. But the IVT+CSF blob tacked onto the end must be a total of CONFIG_CSF_SIZE.
This is exactly the same fix as 89f19f45d650, except that this time around I don't know how to cleanly get CONFIG_CSF_SIZE.

Fixes bc6beae7c55f (binman: Add nxp_imx8mcst etype for i.MX8M

flash.bin signing)

---
Heiko, can you check if this works for you?
And if somebody wants to pick this up and knows how to get at CONFIG_
values, feel free to fix up and take authorship. But perhaps it's not really configurable at all; imx8mimage.c has the value 0x2000 hard-coded, so I don't think anything good could ever come from modifying CONFIG_CSF_SIZE. If so, the right fix is probably just to make that knob non-settable.

   tools/binman/etype/nxp_imx8mcst.py | 2 ++
   1 file changed, 2 insertions(+)
tools/binman/etype/nxp_imx8mcst.py +0 -0
index 8221517b0c4..9a1974cc522 100644
@@ -137,6 +137,8 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
           args = ['-i', cfg_fname, '-o', output_fname]
           if self.cst.run_cmd(*args) is not None:
               outdata = tools.read_file(output_fname)
Quoted 8 lines

tools/binman/etype/nxp_imx8mcst.py class Entry_nxp_imx8mcst(Entry_mkimage): · line 144

Quoted 5 lines
tools/binman/etype/nxp_imx8mcst.py +2 -0
+            # fixme: 0x2000 should be CONFIG_CSF_SIZE
+            outdata += tools.get_bytes(0, 0x2000 - 0x20 - len(outdata))
               return data + outdata
           else:
               # Bintool is missing; just use the input data as the output

I have to admit, I never really figured out this binman stuff, but shouldn't the fix be also in tools/binman/etype/nxp_imx8mimage.py ?

Quoted 3 lines

No, why? That logic is all about generating the imx-specific header in
front of SPL.bin, there's no CSF being generated.

Quoted 6 lines

This patch is modifying tools/binman/etype/nxp_imx8mcst.py which is the Code-Signing-Tool binman etype, the thing used for generating SIGNED images during HAB use.

Shouldn't this patch modify tools/binman/etype/nxp_imx8mimage.py which is the etype used when generating flash.bin itself ?

No, because this is not about flash.bin per se, but about the (u-boot FIT+IVT+CSF) blob that forms part of flash.bin, in the IMX_HAB case.

Quoted 2 lines

My understanding was that the problem Heiko reported was alignment of flash.bin , independently of it being signed or not ?

Read the thread again. Heiko's problem was very much related to IMX_HAB being enabled. I've already explained what the problem actually is and why this fixes it. Not only once, but as I said, this is equivalent to a fix I sent for the shell script implementation, so to answer a question you asked elsewhere: Yes, this is missing in the binman implementation.

Extending the size of flash.bin in the !IMX_HAB case will have the opposite problem (as will adding the wrong amount of padding bytes in the IMX_HAB case), namely that the board will boot, but uuu on the host will "hang" waiting for the target to consume the remaining bytes.

Rasmus

#6 lore raw
Quoted 75 lines · Rasmus Villemoes
Quoted 53 lines · Marek Vasut
Quoted 48 lines · Rasmus Villemoes
Quoted 38 lines · Marek Vasut
Quoted 37 lines · Rasmus Villemoes

Loading flash.bin using uuu fails when flash.bin does not have the right size.
When flash.bin is loaded from some storage medium (sd card/emmc), SPL
just loads some random garbage bytes from beyond what has been populated when flash.bin was written, but when loaded via uuu, SPL hangs waiting for the host to send the expected number of bytes. Which is (size of FIT image aligned to 0x1000)+CONFIG_CSF_SIZE. The alignment to 0x1000 is already done and is necessary in all cases because that's the exact expected location of the 32 byte IVT header. But the IVT+CSF blob tacked onto the end must be a total of CONFIG_CSF_SIZE.
This is exactly the same fix as 89f19f45d650, except that this time around I don't know how to cleanly get CONFIG_CSF_SIZE.

Fixes bc6beae7c55f (binman: Add nxp_imx8mcst etype for i.MX8M

flash.bin signing)

---
Heiko, can you check if this works for you?
And if somebody wants to pick this up and knows how to get at CONFIG_
values, feel free to fix up and take authorship. But perhaps it's not really configurable at all; imx8mimage.c has the value 0x2000 hard-coded, so I don't think anything good could ever come from modifying CONFIG_CSF_SIZE. If so, the right fix is probably just to make that knob non-settable.

    tools/binman/etype/nxp_imx8mcst.py | 2 ++
    1 file changed, 2 insertions(+)
tools/binman/etype/nxp_imx8mcst.py +0 -0
index 8221517b0c4..9a1974cc522 100644
@@ -137,6 +137,8 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
            args = ['-i', cfg_fname, '-o', output_fname]
            if self.cst.run_cmd(*args) is not None:
                outdata = tools.read_file(output_fname)
Quoted 8 lines

tools/binman/etype/nxp_imx8mcst.py class Entry_nxp_imx8mcst(Entry_mkimage): · line 144

Quoted 5 lines
tools/binman/etype/nxp_imx8mcst.py +2 -0
+            # fixme: 0x2000 should be CONFIG_CSF_SIZE
+            outdata += tools.get_bytes(0, 0x2000 - 0x20 - len(outdata))
                return data + outdata
            else:
                # Bintool is missing; just use the input data as the output

I have to admit, I never really figured out this binman stuff, but shouldn't the fix be also in tools/binman/etype/nxp_imx8mimage.py ?

Quoted 3 lines

No, why? That logic is all about generating the imx-specific header in
front of SPL.bin, there's no CSF being generated.

Quoted 6 lines

This patch is modifying tools/binman/etype/nxp_imx8mcst.py which is the Code-Signing-Tool binman etype, the thing used for generating SIGNED images during HAB use.

Shouldn't this patch modify tools/binman/etype/nxp_imx8mimage.py which is the etype used when generating flash.bin itself ?

No, because this is not about flash.bin per se, but about the (u-boot FIT+IVT+CSF) blob that forms part of flash.bin, in the IMX_HAB case.

Quoted 2 lines

My understanding was that the problem Heiko reported was alignment of flash.bin , independently of it being signed or not ?

Read the thread again. Heiko's problem was very much related to IMX_HAB being enabled. I've already explained what the problem actually is and why this fixes it. Not only once, but as I said, this is equivalent to a fix I sent for the shell script implementation, so to answer a question you asked elsewhere: Yes, this is missing in the binman implementation.

Quoted 4 lines

Extending the size of flash.bin in the !IMX_HAB case will have the opposite problem (as will adding the wrong amount of padding bytes in the IMX_HAB case), namely that the board will boot, but uuu on the host will "hang" waiting for the target to consume the remaining bytes.

Oh, I see, all right then. Thanks for clarifying.

#7 lore raw
In reply to Rasmus Villemoes

Hello Rasmus,

Quoted 13 lines · Rasmus Villemoes

Loading flash.bin using uuu fails when flash.bin does not have the right size.

When flash.bin is loaded from some storage medium (sd card/emmc), SPL just loads some random garbage bytes from beyond what has been populated when flash.bin was written, but when loaded via uuu, SPL hangs waiting for the host to send the expected number of bytes. Which is (size of FIT image aligned to 0x1000)+CONFIG_CSF_SIZE. The alignment to 0x1000 is already done and is necessary in all cases because that's the exact expected location of the 32 byte IVT header. But the IVT+CSF blob tacked onto the end must be a total of CONFIG_CSF_SIZE.

Quoted 7 lines

This is exactly the same fix as 89f19f45d650, except that this time around I don't know how to cleanly get CONFIG_CSF_SIZE.

Fixes bc6beae7c55f (binman: Add nxp_imx8mcst etype for i.MX8M flash.bin signing)

---
Heiko, can you check if this works for you?

Works fine for me, thanks!

Quoted 6 lines

And if somebody wants to pick this up and knows how to get at CONFIG_ values, feel free to fix up and take authorship. But perhaps it's not really configurable at all; imx8mimage.c has the value 0x2000 hard-coded, so I don't think anything good could ever come from modifying CONFIG_CSF_SIZE. If so, the right fix is probably just to make that knob non-settable.

Hmm... I don not know if it is a fix value... added Simon, may he knows how to use a CONFIG_ option in buildman. If I find time, I will take a look...

bye,
Heiko

Quoted 18 lines
  tools/binman/etype/nxp_imx8mcst.py | 2 ++
  1 file changed, 2 insertions(+)
tools/binman/etype/nxp_imx8mcst.py +2 -0
index 8221517b0c4..9a1974cc522 100644
@@ -137,6 +137,8 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
          args = ['-i', cfg_fname, '-o', output_fname]
          if self.cst.run_cmd(*args) is not None:
              outdata = tools.read_file(output_fname)
+            # fixme: 0x2000 should be CONFIG_CSF_SIZE
+            outdata += tools.get_bytes(0, 0x2000 - 0x20 - len(outdata))
              return data + outdata
          else:
              # Bintool is missing; just use the input data as the output
Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
reviewer Applied
#8 lore raw
Quoted 20 lines · Heiko Schocher

Hello Rasmus,

Quoted 16 lines · Rasmus Villemoes

Loading flash.bin using uuu fails when flash.bin does not have the right size.

When flash.bin is loaded from some storage medium (sd card/emmc), SPL just loads some random garbage bytes from beyond what has been populated when flash.bin was written, but when loaded via uuu, SPL hangs waiting for the host to send the expected number of bytes. Which is (size of FIT image aligned to 0x1000)+CONFIG_CSF_SIZE. The alignment to 0x1000 is already done and is necessary in all cases because that's the exact expected location of the 32 byte IVT header. But the IVT+CSF blob tacked onto the end must be a total of CONFIG_CSF_SIZE.

This is exactly the same fix as 89f19f45d650, except that this time around I don't know how to cleanly get CONFIG_CSF_SIZE.

Quoted 6 lines
Quoted 4 lines
Fixes bc6beae7c55f (binman: Add nxp_imx8mcst etype for i.MX8M flash.bin signing)

---
Heiko, can you check if this works for you?

Works fine for me, thanks!

Applied, thanks.

reviewer
#9 lore raw
Quoted 5 lines · Fabio Estevam
Quoted 3 lines
Quoted 1 line

Heiko, can you check if this works for you?

Works fine for me, thanks!

Applied, thanks.

Sorry, applied it too soon. I see there is an ongoing discussion.

I will wait for more time.

#10 lore raw
Quoted 11 lines · Fabio Estevam
Quoted 5 lines · Fabio Estevam
Quoted 3 lines
Quoted 1 line

Heiko, can you check if this works for you?

Works fine for me, thanks!

Applied, thanks.

Sorry, applied it too soon. I see there is an ongoing discussion.

I will wait for more time.

Go ahead, nothing to add from my side, but it would be good to get a TB from Heiko maybe ?

Tested-by
#11 lore raw

Hello Marek,

Quoted 7 lines · Marek Vasut
Quoted 6 lines · Fabio Estevam
Quoted 4 lines · Fabio Estevam
Quoted 3 lines
Quoted 1 line

Heiko, can you check if this works for you?

Works fine for me, thanks!

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Applied, thanks.

Sorry, applied it too soon. I see there is an ongoing discussion.

I will wait for more time.

Go ahead, nothing to add from my side, but it would be good to get a TB from Heiko maybe ?

I tested it already, ah, and forgot the TB, so

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#12 lore raw
Quoted 14 lines · Heiko Schocher

Hello Marek,

Quoted 11 lines · Marek Vasut
Quoted 10 lines · Fabio Estevam
Quoted 5 lines · Fabio Estevam
Quoted 3 lines
Quoted 1 line

Heiko, can you check if this works for you?

Works fine for me, thanks!

Applied, thanks.

Sorry, applied it too soon. I see there is an ongoing discussion.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

I will wait for more time.

Go ahead, nothing to add from my side, but it would be good to get a TB from Heiko maybe ?

I tested it already, ah, and forgot the TB, so

Understood, thank you. Nothing to add from my side.