Building with non-release platform package (framework) results in dependency assertion error

Hi,

First: I have been working with the main release versions of the “arduino” framework for the “nordicnrf52” platform successfully for the past few months. However, due to several reasons,
I included my own fork of the Adafruit nrf52 Arduino Framework via the paltform_packages option via:

platform_packages = 
	framework-arduinoadafruitnrf52 @ https://github.com/CSC-Sendance/Adafruit_nRF52_Arduino

However, this resulted in an Assertion Error during dependency scanning (after the framework was installed):

Processing sensotronic2 (board: adafruit_feather_nrf52840; platform: nordicnrf52; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AssertionError: Traceback (most recent call last):
  File "C:\.platformio\penv\lib\site-packages\platformio\__main__.py", line 103, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "C:\.platformio\penv\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\.platformio\penv\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\.platformio\penv\lib\site-packages\platformio\cli.py", line 85, in invoke
    return super().invoke(ctx)
  File "C:\.platformio\penv\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\.platformio\penv\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\.platformio\penv\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\.platformio\penv\lib\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\.platformio\penv\lib\site-packages\platformio\run\cli.py", line 145, in cli
    process_env(
  File "C:\.platformio\penv\lib\site-packages\platformio\run\cli.py", line 198, in process_env
    result["succeeded"] = EnvironmentProcessor(
  File "C:\.platformio\penv\lib\site-packages\platformio\run\processor.py", line 81, in process
    install_project_env_dependencies(
  File "C:\.platformio\penv\lib\site-packages\platformio\package\commands\install.py", line 131, in install_project_env_dependencies
    _install_project_env_platform(project_env, options),
  File "C:\.platformio\penv\lib\site-packages\platformio\package\commands\install.py", line 148, in _install_project_env_platform
    PlatformPackageManager().install(
  File "C:\.platformio\penv\lib\site-packages\platformio\package\manager\platform.py", line 62, in install
    p.install_required_packages(force=force)
  File "C:\.platformio\penv\lib\site-packages\platformio\platform\_packages.py", line 76, in install_required_packages
    self.install_package(name, force=force)
  File "C:\.platformio\penv\lib\site-packages\platformio\platform\_packages.py", line 70, in install_package
    return self.pm.install(spec or self.get_package_spec(name), force=force)
  File "C:\.platformio\penv\lib\site-packages\platformio\package\manager\_install.py", line 47, in install
    pkg = self._install(spec, skip_dependencies=skip_dependencies, force=force)
  File "C:\.platformio\penv\lib\site-packages\platformio\package\manager\_install.py", line 91, in _install
    self.install_dependencies(pkg, print_header=False)
  File "C:\.platformio\penv\lib\site-packages\platformio\package\manager\_install.py", line 139, in install_dependencies
    self.install_dependency(dependency)
  File "C:\.platformio\penv\lib\site-packages\platformio\package\manager\_install.py", line 151, in install_dependency
    dependency_compatibility = PackageCompatibility.from_dependency(dependency)
  File "C:\.platformio\penv\lib\site-packages\platformio\package\meta.py", line 72, in from_dependency
    assert isinstance(dependency, dict)
AssertionError

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `python -m pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq/index.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================

I also tried using the latest official version from the main repository ( GitHub - adafruit/Adafruit_nRF52_Arduino: Adafruit code for the Nordic nRF52 BLE SoC on Arduino with and without git-hash of the last commit ) with the same message, as well as upgrading to the latest dev version of platformio, full clean, manual platform + framework deletion etc.

My first guess was that there somewhere is some kind of dependency that restricts its compatibility to a specific release. However, when copying the framework’s project to a different (unreleated to the original) git repository and using that, it magically works. With the forked repository, I also noticed I can no longer perform the PIO Task Dependencies - Update, which causes the message:

CSBaseException: VCS: Could not receive an output from `['git', 'branch']` command ({'out': '', 'err': 'fatal: not a git repository (or any of the parent directories): .git\n', 'returncode': 128})

Any hints what could cause this / how to fix it would be greatly appreciated.

But that one doesn’t even have a package.json at the root like a framework-arduinoadafruitnrf52 package should have? That’s gonna mess a lot things up. At least add the previous one and update the version.

{
  "name": "framework-arduinoadafruitnrf52",
  "version": "1.10300.0",
  "description": "Arduino Wiring-based Framework for Nordic Semiconductor nRF52 BLE SoC",
  "keywords": [
    "framework",
    "arduino",
    "nordic semiconductor",
    "nrf52"
  ],
  "repository": {
    "type": "git",
    "url": "https://github.com/adafruit/Adafruit_nRF52_Arduino"
  }
}
1 Like

Wow, that was quick!

That is true - and interestingly, this now works although the original repository also did not have such a file. I now added

{
    "name": "framework-arduinoadafruitnrf52",
    "version": "1.10500.0",
    "description": "Arduino Wiring-based Framework for Nordic Semiconductor nRF52 BLE SoC",
    "keywords": [
        "framework",
        "arduino",
        "nordic semiconductor",
        "nrf52"
    ],
    "repository": {
        "type": "git",
        "url": "https://github.com/adafruit/Adafruit_nRF52_Arduino"
    }
}

but now have the issue that one of the (as git-submodule) included libraries (Adafruit/nRF_Crypto) is not found during building (“Adafruit_nRFCrypto.h: No such file or directory”) - this also works with the released version found in the platformio repository.

I guess since they are included as submodules there is no need to list them as dependencies in the package.json (which I also tried to no success)?

Sorry for the questions, but I am having a hard time finding concrete information on how to build a platform package (or in this matter: adapt an existing ArduinoIDE-one).

PlatformIO should automatically download any submodules recursively. From the previous installation attempts, the installation folder may be messed up. Can you delete any C:\Users\<user>\.platformio\packages\framework-arduinoadafruitnrf52* folder and then press “Build” again in VSCode?

Thanks for the suggestion - I already did so previously without success. Plus, I checked both the logs and actual files that the submodules got downloaded correctly.

Setting

"build": {
        "libLDFMode":"deep"
    }

also did not bring success. Additionally, I crosschecked with some other frameworks and found that they also include some libraries in /libraries but did not explicitly list anything special in package.json.

Link to my package.json: https://github.com/CSC-Sendance/Adafruit_nRF52_Arduino/blob/master/package.json

Link to the libraries folder with nRFCrypto as submodule: https://github.com/CSC-Sendance/Adafruit_nRF52_Arduino/tree/master/libraries

But C:\Users\<user>\.platformio\packages\framework-arduinoadafruitnrf52\libraries\Adafruit_nRFCrypto does exist?

Note that PlatformIO has put a custom library.json and extra_script.py in this folder to fix building issues.

{
    "name": "Adafruit nRFCrypto",
    "build": {
        "extraScript": "extra_script.py"
    }
}
import os

Import("env")

# An extra script is required to properly handle extra link flags set in
# the `library.properties` file
if env.BoardConfig().get("build.mcu", "").startswith("nrf5284"):
    env.Append(
        LIBPATH=[os.path.realpath("src/cortex-m4/fpv4-sp-d16-hard")],
        LIBS=["nrf_cc310_0.9.13-no-interrupts"]
    )

That just fixes linking though. I remember for my fork I had to do additional logic – https://github.com/maxgerhardt/framework-arduinoadafruitnrf52-seeed/tree/main/libraries/Adafruit_nRFCrypto

Yes, the nRFCrypto library does exist.

What do you mean with “PlatformIO has put a custom library.json”? The original (and included in the non-forked-by-you) Adafruit_nRFCrypto dependency does not have that. What logic you changed is a bit hard to follow since you just added the whole library instead of a change history - but I also don’t think there is much needed in terms of logic since it works in the original library with my board.

Side-note: I added lib_ldf_mode=deep in the application platform.ini [env] which seems to have fixed the crypto dependency, just now breaks a different (application, not framework-)library dependency/linking (again, it gets downloaded correctly but not found during compilation ;))

Just look at the latest package version (https://dl.registry.platformio.org/download/platformio/tool/framework-arduinoadafruitnrf52/1.10500.0/framework-arduinoadafruitnrf52-1.10500.0.tar.gz) and open libraries\Adafruit_nRFCrypto and compare to https://github.com/adafruit/Adafruit_nRFCrypto/tree/802d0a6961eae5d1e9bc94a2a570214804e68638.

1 Like

sorry for my late response but I had some higher priorities in the meantime. I tried several things but the only successful thing ended up being replacing the nRFCrypto submodule with your patched version (although I don’t know what the “additional logic” beyond the linking fixes is). This builds!

I guess as long as the nrfCrypto library does not receive significant updates that are then required by the nrf52 framework, this is fine. Let’s hope this won’t be the case? :upside_down_face:

Thanks so much for your amazing support.