ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.67k stars 2.98k forks source link

regions.py fails to handle large gaps in data with Python 3 #11576

Closed maclobdell closed 3 years ago

maclobdell commented 5 years ago

Description

Currently regions.py is used in the process to generate a binary file that can be used in a firmware update campaign (called *_update.bin). One thing it does is to take the data regions from the hex file and pad the gaps in order to generate a binary (since binaries cannot have gaps). When using Python 3, I have found that if there is a sufficiently large gap in the flash regions (exact limit to be quantified), the IntelHex python library will fail to pad the data. It reports a MemoryError.

This specifically occurs when the application hex file contains code/data flash regions at multiple different base addresses. (e.g. as of Mbed OS 5.14.0, the Cypress targets are including code starting at 0x1000_0000 and a new supervisory flash data section at 0x1600_0000).

When compiling mbed-os-example-pelion Target: CY8CPROTO_062_4343W Toolchain: doesn't matter mbed OS: mbed-os-5.14 Python version 3.7

[DEBUG] Return: 0
Elf2Bin: mbed-os-pelion-example
FromELF: D:\Tools\GCC_ARM\6 2017-q2-update\bin\arm-none-eabi-objcopy -O ihex .\BUILD\CY8CPROTO_062_4343W\GCC_ARM-RELEASE\mbed-os-pelion-example_application.elf .\BUILD\CY8CPROTO_062_4343W\GCC_ARM-RELEASE\mbed-os-pelion-example_application.hex
[DEBUG] Return: 0
Merging Regions
  Filling region bootloader1 with D:\maclobdell\mbed-os-pelion-example\bootloader/mbed-bootloader_cy8cproto.hex
  Skipping bootloader2 as it is merged previously
  Filling region header with .\BUILD\CY8CPROTO_062_4343W\GCC_ARM-RELEASE\mbed-os-pelion-example_header.hex
  Filling region application with .\BUILD\CY8CPROTO_062_4343W\GCC_ARM-RELEASE\mbed-os-pelion-example_application.hex
Space used after regions merged: 0x6007e00
Merging Regions
  Filling region application with .\BUILD\CY8CPROTO_062_4343W\GCC_ARM-RELEASE\mbed-os-pelion-example_application.hex
Traceback (most recent call last):
  File "D:\maclobdell\mbed-os-pelion-example\mbed-os\tools\make.py", line 78, in wrapped_build_project
    *args, **kwargs
  File "D:\maclobdell\mbed-os-pelion-example\mbed-os\tools\build_api.py", line 598, in build_project
    res = toolchain.link_program(resources, build_path, name)
  File "D:\maclobdell\mbed-os-pelion-example\mbed-os\tools\toolchains\mbed_toolchain.py", line 785, in link_program
    name, full_path, ext
  File "D:\maclobdell\mbed-os-pelion-example\mbed-os\tools\toolchains\mbed_toolchain.py", line 716, in _do_region_merge
    restrict_size=self.config.target.restrict_size
  File "D:\maclobdell\mbed-os-pelion-example\mbed-os\tools\regions.py", line 169, in merge_region_list
    merged.puts(begin, padding * pad_size)
  File "d:\python\lib\site-packages\intelhex\__init__.py", line 745, in puts
    self._buf[addr+i] = a[i]
MemoryError
[mbed] ERROR: "d:\python\python.exe" returned error.
       Code: 1
       Path: "D:\maclobdell\mbed-os-pelion-example"
       Command: "d:\python\python.exe -u D:\maclobdell\mbed-os-pelion-example\mbed-os\tools\make.py -t GCC_ARM -m CY8CPROTO_062_4343W --profile release --source . --build .\BUILD\CY8CPROTO_062_4343W\GCC_ARM-RELEASE -v"
       Tip: You could retry the last command with "-v" flag for verbose output
---
[mbed] WARNING: Using Python 3 with Mbed OS 5.8 and earlier can cause errors with compiling, testing and exporting

Issue request type

[ ] Question
[ ] Enhancement
[X] Bug
ciarmcom commented 4 years ago

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. Internal Jira reference: https://jira.arm.com/browse/IOTOSM-2292

ciarmcom commented 3 years ago

We closed this issue because it has been inactive for quite some time and we believe it to be low priority. If you think that the priority should be higher, then please reopen with your justification for increasing the priority.