platformio / platformio-core

Your Gateway to Embedded Software Development Excellence :alien:
https://platformio.org
Apache License 2.0
7.98k stars 799 forks source link

Using built-in library fails with KeyError: 'framework-stm32cube' #3777

Closed maxgerhardt closed 3 years ago

maxgerhardt commented 3 years ago

What kind of issue is this?

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system: Windows 10 x64

PlatformIO Version (platformio --version): version 5.0.4b1

Description of problem

When adding a built-in library to lib-deps (SD card library for Arduino Uno WiFi rev2 in this case) by the name in the library.properties, which is SD (MegaCore), installation and building of the library fails with a KeyError: 'framework-stm32cube' when the PIO core somehow tries to iterate through all packages / libraries.

Steps to Reproduce

  1. Create a new project for the Arduino Uno WiFi Rev2
  2. Add reference to built-in SD card library by adding lib_deps = SD (MegaCore)
  3. Press Build

Actual Results

> Executing task in folder atmel_hello: C:\Users\Max\AppData\Local\Programs\Python\Python38\Scripts\pio.exe run --environment uno_wifi_rev2 <

Processing uno_wifi_rev2 (platform: atmelmegaavr; board: uno_wifi_rev2; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/uno_wifi_rev2.html
PLATFORM: Atmel megaAVR (1.3.0) > Arduino Uno WiFi Rev2
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 47.50KB Flash
PACKAGES:
 - framework-arduino-megaavr 1.8.6
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Library Manager: Installing SD (MegaCore)
KeyError: 'framework-stm32cube':
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\main.py", line 170:
    env.SConscript("$BUILD_SCRIPT")
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\Users\Max\.platformio\platforms\atmelmegaavr\builder\main.py", line 149:
    target_elf = env.BuildProgram()
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\platformio.py", line 62:
    env.ProcessProjectDeps()
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\platformio.py", line 140:
    project_lib_builder = env.ConfigureProjectLibBuilder()
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\piolib.py", line 1062:
    project.install_dependencies()
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\piolib.py", line 898:
    lm.install(spec)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\package\manager\_install.py", line 48:
    pkg = self._install(
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\package\manager\library.py", line 93:
    if is_builtin_lib(spec.name):
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\commands\lib\helpers.py", line 49:
    for storage in storages or get_builtin_libs():
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\commands\lib\helpers.py", line 34:
    for storage in p.get_lib_storages():
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\platform\base.py", line 214:
    pkg = self.get_package(opts["package"])
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\platform\_packages.py", line 31:
    return self.pm.get_package(self.get_package_spec(name))
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\platform\_packages.py", line 21:
    version = self.packages[name].get("version", "")
=============================================================================================== [FAILED] Took 1.45 seconds ===============================================================================================
Environment    Status    Duration
-------------  --------  ------------
uno_wifi_rev2  FAILED    00:00:01.447

Listing built-in libraries in PIO Home -> Libraries -> Built-in fails similarily

PIO Core Call Error: 
Error: Traceback (most recent call last):
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\__main__.py", line 109, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\commands\__init__.py", line 44, in invoke
    return super(PlatformioCLI, self).invoke(ctx)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\commands\lib\command.py", line 419, in lib_builtin
    items = get_builtin_libs(storage)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\commands\lib\helpers.py", line 34, in get_builtin_libs
    for storage in p.get_lib_storages():
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\platform\base.py", line 214, in get_lib_storages
    pkg = self.get_package(opts["package"])
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\platform\_packages.py", line 31, in get_package
    return self.pm.get_package(self.get_package_spec(name))
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\platformio\platform\_packages.py", line 21, in get_package_spec
    version = self.packages[name].get("version", "")
KeyError: 'framework-stm32cube'

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

An unexpected error occurred. Further steps:

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

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

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

Expected Results

Installing a framework built-in library works.

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:uno_wifi_rev2]
platform = atmelmegaavr
board = uno_wifi_rev2
framework = arduino 
lib_deps = 
    SPI
    SD (MegaCore)

Source file to reproduce issue:

#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
void setup() {}
void loop() {}

Additional info

Can be manually resolved by pointing to the right path

[env:uno_wifi_rev2]
platform = atmelmegaavr
board = uno_wifi_rev2
framework = arduino 
lib_deps = 
    SPI
    SD (MegaCore)=file://C:\Users\Max\.platformio\packages\framework-arduino-avr-megacore\libraries\SD

PIO system info

>pio system info
--------------------------  --------------------------------------------------------------------------
PlatformIO Core             5.0.4b1
Python                      3.8.6-final.0
System Type                 windows_amd64
Platform                    Windows-10
File System Encoding        utf-8
Locale Encoding             cp1252
PlatformIO Core Directory   C:\Users\Max\.platformio
PlatformIO Core Executable  C:\Users\Max\AppData\Local\Programs\Python\Python38\Scripts\platformio.exe
Python Executable           c:\users\max\appdata\local\programs\python\python38\python.exe
Global Libraries            0
Development Platforms       9
Tools & Toolchains          82
--------------------------  --------------------------------------------------------------------------

Platform List

>pio platform list
apollo3blue ~ Apollo 3 Blue
===========================
The Apollo MCU Family is an ultra-low power, highly integrated microcontroller platform based on Ambiq Micro’s patented Sub-threshold Power Optimized Technology (SPOT™) and designed for battery-powered and portable, mobile devices.

Home:
Frameworks: arduino
Packages: toolchain-gccarmnoneeabi, framework-arduinoapollo3
Version: 0.0.1

atmelavr ~ Atmel AVR
====================
Atmel AVR 8-bit MCUs deliver a unique combination of performance, power efficiency and design flexibility. Optimized to speed time to market-and easily adapt to new ones-they are based on the industry's most code-efficient architecture for C and assembly programming

Home: http://www.atmel.com/products/microcontrollers/avr/default.aspx
Frameworks: arduino, simba
Packages: toolchain-atmelavr, framework-arduino-avr, framework-arduino-avr-attiny, framework-arduino-avr-bean, framework-arduino-avr-core13, framework-arduino-avr-digistump, framework-arduino-avr-dwenguino, framework-arduino-avr-megacore, framework-arduino-avr-mightycore, framework-arduino-avr-minicore, framework-arduino-avr-majorcore, framework-arduino-avr-microcore, framework-arduino-avr-nicai, framework-arduino-avr-panstamp, framework-arduino-avr-prusa_rambo, framework-simba, tool-avrdude, tool-micronucleus, tool-simavr
Version: 3.0.0

atmelmegaavr ~ Atmel megaAVR
============================
8-bit MCUs Built for Real-time Control with Core Independent Peripherals combining intelligent hardware peripherals along with the low-power capability of an AVR core, megaAVR microcontrollers (MCUs) broaden the effectiveness of your real-time control systems.

Home: https://www.microchip.com/design-centers/8-bit/avr-mcus/device-selection/atmega4809
Frameworks: arduino
Packages: toolchain-atmelavr, framework-arduino-megaavr, framework-arduino-megaavr-megacorex, tool-avrdude-megaavr
Version: 1.3.0

atmelsam ~ Atmel SAM
====================
Atmel | SMART offers Flash- based ARM products based on the ARM Cortex-M0+, Cortex-M3 and Cortex-M4 architectures, ranging from 8KB to 2MB of Flash including a rich peripheral and feature mix.

Home: https://www.microchip.com/design-centers/32-bit
Frameworks: arduino, mbed, simba, zephyr
Packages: toolchain-gccarmnoneeabi, framework-arduino-sam, framework-arduino-samd, framework-arduino-samd-adafruit, framework-arduino-samd-seeed, framework-arduino-samd-moteino, framework-arduino-samd-reprap, framework-arduino-samd-sodaq, framework-arduino-samd-sparkfun, framework-arduino-samd-tuino0, framework-cmsis, framework-cmsis-atmel, framework-arduino-mbcwb, framework-mbed, framework-simba, framework-zephyr, framework-zephyr-cmsis, framework-zephyr-canopennode, framework-zephyr-civetweb, framework-zephyr-fatfs, framework-zephyr-hal-atmel, framework-zephyr-hal-st, framework-zephyr-libmetal, framework-zephyr-lvgl, framework-zephyr-mbedtls, framework-zephyr-mcuboot, framework-zephyr-mcumgr, framework-zephyr-open-amp, framework-zephyr-loramac-node, framework-zephyr-openthread, framework-zephyr-segger, framework-zephyr-tinycbor, framework-zephyr-tinycrypt, framework-zephyr-littlefs, framework-zephyr-mipi-sys-t, framework-zephyr-trusted-firmware-m, tool-avrdude, tool-bossac, tool-mbctool, tool-openocd, tool-jlink, tool-cmake, tool-dtc, tool-ninja, tool-gperf
Version: 5.0.2

espressif32 ~ Espressif 32
==========================
Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications.

Home: https://espressif.com/
Frameworks: arduino, espidf, pumbaa, simba
Packages: toolchain-xtensa32, toolchain-xtensa32s2, toolchain-esp32ulp, toolchain-esp32s2ulp, framework-arduinoespressif32, framework-arduino-mbcwb, framework-espidf, framework-simba, framework-pumbaa, tool-esptoolpy, tool-mbctool, tool-openocd-esp32, tool-mkspiffs, tool-cmake, tool-ninja, tool-mconf, tool-idf
Version: 2.1.0

espressif8266 ~ Espressif 8266
==============================
Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications.

Home: https://espressif.com/
Frameworks: arduino, esp8266-nonos-sdk, esp8266-rtos-sdk, simba
Packages: toolchain-xtensa, framework-arduinoespressif8266, framework-esp8266-rtos-sdk, framework-esp8266-nonos-sdk, framework-simba, tool-esptool, tool-esptoolpy, tool-mkspiffs, tool-mklittlefs
Version: 2.6.2

nordicnrf52 ~ Nordic nRF52
==========================
The nRF52 Series are built for speed to carry out increasingly complex tasks in the shortest possible time and return to sleep, conserving precious battery power. They have a Cortex-M4F processor and are the most capable Bluetooth Smart SoCs on the market.

Home: https://www.nordicsemi.com/Products/nRF52-Series-SoC
Frameworks: arduino, mbed, zephyr
Packages: toolchain-gccarmnoneeabi, framework-mbed, framework-arduinoadafruitnrf52, framework-arduinonordicnrf5, framework-arduino-nrf52-mbedos, framework-zephyr, framework-zephyr-cmsis, framework-zephyr-canopennode, framework-zephyr-civetweb, framework-zephyr-fatfs, framework-zephyr-hal-nordic, framework-zephyr-hal-st, framework-zephyr-libmetal, framework-zephyr-lvgl, framework-zephyr-mbedtls, framework-zephyr-mcuboot, framework-zephyr-mcumgr, framework-zephyr-open-amp, framework-zephyr-loramac-node, framework-zephyr-openthread, framework-zephyr-segger, framework-zephyr-tinycbor, framework-zephyr-tinycrypt, framework-zephyr-littlefs, framework-zephyr-mipi-sys-t, framework-zephyr-trusted-firmware-m, tool-sreccat, tool-openocd, tool-nrfjprog, tool-jlink, tool-bossac-nordicnrf52, tool-cmake, tool-dtc, tool-ninja, tool-gperf
Version: 5.0.1

ststm32 ~ ST STM32
==================
The STM32 family of 32-bit Flash MCUs based on the ARM Cortex-M processor is designed to offer new degrees of freedom to MCU users. It offers a 32-bit product range that combines very high performance, real-time capabilities, digital signal processing, and low-power, low-voltage operation, while maintaining full integration and ease of development.

Home: http://www.st.com/web/en/catalog/mmc/FM141/SC1169?sc=stm32
Frameworks: arduino, cmsis, libopencm3, mbed, spl, stm32cube, zephyr
Packages: toolchain-gccarmnoneeabi, framework-mbed, framework-cmsis, framework-cmsis-stm32f0, framework-cmsis-stm32f1, framework-cmsis-stm32f2, framework-cmsis-stm32f3, framework-cmsis-stm32f4, framework-cmsis-stm32f7, framework-cmsis-stm32g0, framework-cmsis-stm32g4, framework-cmsis-stm32h7, framework-cmsis-stm32l0, framework-cmsis-stm32l1, framework-cmsis-stm32l4, framework-cmsis-stm32l5, framework-spl, framework-libopencm3, framework-arduinoststm32, framework-arduinoststm32-maple, framework-arduinostm32mxchip, framework-arduinoststm32l0, framework-stm32cubef0, framework-stm32cubef1, framework-stm32cubef2, framework-stm32cubef3, framework-stm32cubef4, framework-stm32cubef7, framework-stm32cubeg0, framework-stm32cubeg4, framework-stm32cubeh7, framework-stm32cubel0, framework-stm32cubel1, framework-stm32cubel4, framework-stm32cubel5, framework-zephyr, framework-zephyr-cmsis, framework-zephyr-canopennode, framework-zephyr-civetweb, framework-zephyr-fatfs, framework-zephyr-hal-st, framework-zephyr-hal-stm32, framework-zephyr-libmetal, framework-zephyr-lvgl, framework-zephyr-mbedtls, framework-zephyr-mcuboot, framework-zephyr-mcumgr, framework-zephyr-open-amp, framework-zephyr-loramac-node, framework-zephyr-openthread, framework-zephyr-segger, framework-zephyr-tinycbor, framework-zephyr-tinycrypt, framework-zephyr-littlefs, framework-zephyr-mipi-sys-t, framework-zephyr-trusted-firmware-m, tool-stm32duino, tool-openocd, tool-jlink, tool-dfuutil, tool-cmake, tool-dtc, tool-ninja, tool-gperf, tool-ldscripts-ststm32
Version: 10.0.1

teensy ~ Teensy
===============
Teensy is a complete USB-based microcontroller development system, in a very small footprint, capable of implementing many types of projects. All programming is done via the USB port. No special programmer is needed, only a standard USB cable and a PC or Macintosh with a USB port.

Home: https://www.pjrc.com/teensy
Frameworks: arduino, mbed
Packages: toolchain-atmelavr, toolchain-gccarmnoneeabi, framework-arduinoteensy, framework-mbed, tool-teensy, tool-jlink
Version: 4.11.1
valeros commented 3 years ago

Thanks for reporting, fixed directly in the ststm32 repository.