I want to design a boot application for my MCU RA6 controller.
I can generate project and build it correctly the boot project, but when i build the primary project it's built OK but then
when generates the signed file it cannot generate it and i have some error messages. These are the messages:
15:51:48 **** Boot Image Build of configuration Debug for project app_ra6m3_primary ****python "C:\\Proyectos\\MCUboot_Encrypted_Initial_Projects\\ra_mcuboot_ra6m3_swap_testmode/ra/fsp/src/rm_mcuboot_port/rm_mcuboot_port_sign.py" sign --header-size 0x200 --align 128 --max-align 128 --slot-size 0x20000 --max-sectors 4 --pad --pad-header app_ra6m3_primary.elf app_ra6m3_primary.bin.signed C:\Proyectos\MCUboot_Encrypted_Initial_Projects\ra_mcuboot_ra6m3_swap_testmode\ra\fsp\src\rm_mcuboot_port\rm_mcuboot_port_sign.py:19: DeprecationWarning: pkg_resources is deprecated as an API. See setuptools.pypa.io/.../pkg_resources.html import pkg_resourcesTraceback (most recent call last):ERROR: Required python packages are missing. Run the following command to install: File "C:\Proyectos\MCUboot_Encrypted_Initial_Projects\ra_mcuboot_ra6m3_swap_testmode\ra\fsp\src\rm_mcuboot_port\rm_mcuboot_port_sign.py", line 20, in <module>pip install -r ra/mcu-tools/MCUboot/scripts/requirements.txt pkg_resources.require(mcuboot_requirements) File "C:\Users\TL\.local\lib\python3.10-mingw_x86_64\site-packages\pkg_resources\__init__.py", line 968, in require needed = self.resolve(parse_requirements(requirements)) File "C:\Users\TL\.local\lib\python3.10-mingw_x86_64\site-packages\pkg_resources\__init__.py", line 829, in resolve dist = self._resolve_dist( File "C:\Users\TL\.local\lib\python3.10-mingw_x86_64\site-packages\pkg_resources\__init__.py", line 870, in _resolve_dist raise DistributionNotFound(req, requirers)pkg_resources.DistributionNotFound: The 'cbor2' distribution was not found and is required by the application15:51:49 Build finished
Can you please help me to resolve this problem? it seems that some python resources are outdated.
Thanks and best regards.
It seems that you have not installed some dependencies to be able to run successfully the necessary python scripts for this projects.
First of all make sure that you have installed Python make sure that the python version is 3.9.0 or later.
Type in the command prompt py --version to check which python version you have installed:
If you navigate the bootloader project you will that there is a txt called requirements.txt. This includes all the dependencies you need to install.
So you have to go to the bootloader project. Go to MCUboot folder of the project right click and select Command Prompt:
1. Make sure you have upgraded pip version by typing:
python -m pip install --upgrade pip
2. And then install the requirements by typing again in the command prompt:
pip3 install --user -r scripts/requirements.txt
This also described in this pdf document of the application note you got the sample code:
Thanks for your quick response.
I had done all the procedures as you said that are written in the application note, but the messages given by the IDE and compiler are always the same. I have Python 3.12 installed, and all the dependencies in the requirements file are satisfied. Can you give me some clues or solutions to this problem? Thanks in advance.
I had a similar issue and just commented out the cbor2 import as the signing script doesn't actually need to use the library to function, we use the script to sign our files when compiling a bootloader version.
Python CBOR library; cbor2 is deprecating Python 2.7 and 3.5 support : r/CBOR (reddit.com)
Please send me a screenshot when you execute this command
pip3 install --user -r scripts/requirements.txt
To check if all the packages that are in reuirements.txt file are installed.
Also have you tried to install cbor2 package by simply typing:
pip install cbor2
What are the results you are getting? Since it seems that this is the package missing.
Here are the snapshot with the error i have now.
For your convenience, here are the error messages copied:
Extracting support files...
14:49:22 **** Incremental Build of configuration Debug for project app_ra6m3_primary ****
make -r -j8 all
make --no-print-directory pre-build
rm -f app_ra6m3_primary.elf
make --no-print-directory main-build
Building target: app_ra6m3_primary.elf
arm-none-eabi-objcopy -O srec "app_ra6m3_primary.elf" "app_ra6m3_primary.srec"
arm-none-eabi-size --format=berkeley "app_ra6m3_primary.elf"
text data bss dec hex filename
14528 12 4892 19432 4be8 app_ra6m3_primary.elf
14:49:23 Build Finished. 0 errors, 0 warnings. (took 880ms)
14:49:23 **** Boot Image Build of configuration Debug for project app_ra6m3_primary ****
python "C:\\Proyectos\\MCUboot_Encrypted_Initial_Projects\\ra_mcuboot_ra6m3_swap_testmode/ra/fsp/src/rm_mcuboot_port/rm_mcuboot_port_sign.py" sign --header-size 0x200 --align 128 --max-align 128 --slot-size 0x20000 --max-sectors 4 --pad --pad-header app_ra6m3_primary.elf app_ra6m3_primary.bin.signed
Traceback (most recent call last):
File "C:\Proyectos\MCUboot_Encrypted_Initial_Projects\ra_mcuboot_ra6m3_swap_testmode\ra\fsp\src\rm_mcuboot_port\rm_mcuboot_port_sign.py", line 143, in <module>
Packaging application image with version from environment variable MCUBOOT_IMAGE_VERSION: 1.0.0 and key from MCUBOOT_IMAGE_SIGNING_KEY: C:\Proyectos\MCUboot_Encrypted_Initial_Projects\ra_mcuboot_ra6m3_swap_testmode/ra/mcu-tools/MCUboot/root-ec-p256.pem
from imgtool import main
File "C:\Proyectos\MCUboot_Encrypted_Initial_Projects\ra_mcuboot_ra6m3_swap_testmode/ra/mcu-tools/MCUboot/scripts\imgtool\main.py", line 21, in <module>
ModuleNotFoundError: No module named 'click'
14:49:23 Build finished
In the python script i substituted pkg_resources for importlib.resources
and deleted the next line ("pkg_resources.requires(...)"). I also ran e2studio in administrator mode.
Can you please tell me what's the next step to finally resolve the problem?
Thanks in advance
Yes its clear that the python scripts on your PC are not running, since there are some packages that have not been installed in your PC.
If you open the requirements.txt you will see that it includes some python packages that need to be installed on your PC to run the python scripts included in the project with no problems.
I wouldn't suggest to you to modify the python scripts already existing in the project.
What I have asked you before is to send me a screenshot of the message you get when trying to install these packages included in the requirements.txt file.
For example in my PC when I run the command pip3 install --user -r scripts/requirements.txt
I see these messages. Saying to me that the requirements are already satisfied since the packages have been already installed.
I want you to send me this screenshot to check what messages you get and find out what might be going wrong in your PC and your OS, so that you can finally install them.
And run the python scripts with no issues.
Thanks for your message
I give you the output from the pip3 command in my project
Thank you Luis,
It seems that the packages have been installed as they should. Could you please provide me the FSP version and the e2studio version you are using? Also as far I can understand you are trying to create for RA6M3 a bootloader using Swap Upgrade mode, is that right?
I finally resolved the problem, substituting in rm_mcuboot_port_sign.py script the line 19 import pkg_resources by import importlib and commenting the next line 20 (.requires(...)), and generating again with fsp version 4.3.0, and also reinstalling python v3.12.2 and configuring correctly the path
Thanks for your support and suggestions