Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twister "FLASH overflow" does not account for imgtool trailer. #50386

Closed
fabiobaltieri opened this issue Sep 19, 2022 · 6 comments · Fixed by #50449
Closed

Twister "FLASH overflow" does not account for imgtool trailer. #50386

fabiobaltieri opened this issue Sep 19, 2022 · 6 comments · Fixed by #50449
Assignees
Labels
area: Tests Issues related to a particular existing or missing test bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@fabiobaltieri
Copy link
Member

fabiobaltieri commented Sep 19, 2022

Describe the bug
Twister has a check for skipping (rather than failing) builds that trigger a flash overflow error. That does not work for board that call imgtool through, where the build image is under the flash size, but the image + imgtool trailer is not. The build fails CI with an error like:

...
Memory region         Used Size  Region Size  %age Used
           FLASH:       97780 B        96 KB     99.47%
            SRAM:       27544 B       136 KB     19.78%
        USB_SRAM:          0 GB        16 KB      0.00%
        IDT_LIST:          0 GB         2 KB      0.00%
Usage: wrapper.py [OPTIONS] INFILE OUTFILE
Try 'wrapper.py --help' for help.

Error: Image size (0x1819e) + trailer (0x1b0) exceeds requested size 0x18000
sign the payload
ninja: build stopped: subcommand failed.

To Reproduce
Steps to reproduce the behavior:

  1. git checkout v3.2.0-rc2
  2. ./scripts/twister -v -p lpcxpresso55s69_ns -T samples/net/sockets/http_get

Expected behavior
The test should be skipped.

Impact
Annoyance, unrelated CI failures.

Logs and console output
n/a

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: Zephyr SDK 0.15.0
  • Commit SHA: v3.2.0-rc2
@fabiobaltieri fabiobaltieri added bug The issue is a bug, or the PR is fixing a bug area: Tests Issues related to a particular existing or missing test labels Sep 19, 2022
@nordicjm
Copy link
Collaborator

This links with #46194 in that depending on mcuboot configuration, a generated firmware image might be useless because of mcuboot swap status data, but there would need to be a way for the application (at build time) to know details of the mcuboot configuration

@fabiobaltieri fabiobaltieri added the priority: low Low impact/importance bug label Sep 20, 2022
@fabiobaltieri
Copy link
Member Author

fabiobaltieri commented Sep 20, 2022

Adding mcuboot maintainers, you have any ideas? I'm thinking either reducing the flash size in the board config when imgtool is enabled or detecting the specific error in twister. @nashif

@d3zd3z
Copy link
Collaborator

d3zd3z commented Sep 20, 2022

Unfortunately, the trailer size isn't easy to determine as it depends on signature sizes and other things. But, imgtool should fail if the image is too large, is that not happening?

@fabiobaltieri
Copy link
Member Author

It is, the problem is that then twister detects that as a generic "build failure" and fails the test, while normally it would skip instead in case of flash overflow. So I guess the other option is for twister to detect this specific error condition and detect it as flash overflow.

@d3zd3z
Copy link
Collaborator

d3zd3z commented Sep 20, 2022

Do you have any ideas on how this could be done? I think that imgtool just raises an exception.

@fabiobaltieri
Copy link
Member Author

fabiobaltieri commented Sep 20, 2022

Yeah actually it seems fairly easy, something like:

--- a/scripts/pylib/twister/twisterlib/runner.py
+++ b/scripts/pylib/twister/twisterlib/runner.py
@@ -220,10 +220,14 @@ class CMake:
 
             if log_msg:
                 overflow_found = re.findall("region `(FLASH|ROM|RAM|ICCM|DCCM|SRAM|dram0_1_seg)' overflowed by", log_msg)
+                imgtool_overflow_found = re.findall("Error: Image size \(.*\) \+ trailer \(.*\) exceeds requested size", log_msg)
                 if overflow_found and not self.options.overflow_as_errors:
                     logger.debug("Test skipped due to {} Overflow".format(overflow_found[0]))
                     self.instance.status = "skipped"
                     self.instance.reason = "{} overflow".format(overflow_found[0])
+                elif imgtool_overflow_found and not self.options.overflow_as_errors:
+                    self.instance.status = "skipped"
+                    self.instance.reason = "imgtool overflow"
                 else:
                     self.instance.status = "error"
                     self.instance.reason = "Build failure"

I'll send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Tests Issues related to a particular existing or missing test bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants