libretiny-eu / libretiny

PlatformIO development platform for IoT modules
http://docs.libretiny.eu/
MIT License
382 stars 55 forks source link

PlatformIO is Broken with "KeyError: \"Invalid board option 'build.family'\"" #264

Open cap9qd opened 3 months ago

cap9qd commented 3 months ago

I have been testing the i2c (Wire) implementation for BK72XX chips (so far so good BTW just jamming it into ESPHome i2c component) and wanted to see if I could get SoftWire working on a Temperature-Humidity board before diving into ESPHome. I found that trying to develop in PlatformIO under VSCode is broken if I leave libretiny in the .platformio directory. I thought this was something to do with my fork and developing for ESPHome but does not seem to be the case. If I remove libretiny from C:\User\user\.platformio\platforms\ then PIO goes back to working.

PS C:\Users\user> cd '.\Documents\Projects\BK7233N_SoftWire\'              
PS C:\Users\user\Documents\Projects\BK7233N_SoftWire> pio project init --board generic-bk7231n-qfn32-tuya
KeyError: Traceback (most recent call last):
  File "C:\Users\user\.platformio\penv\lib\site-packages\platformio\__main__.py", line 103, in main       
    cli()  # pylint: disable=no-value-for-parameter
  File "C:\Users\user\.platformio\penv\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\user\.platformio\penv\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\user\.platformio\penv\lib\site-packages\platformio\cli.py", line 85, in invoke
    return super().invoke(ctx)
  File "C:\Users\user\.platformio\penv\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\user\.platformio\penv\lib\site-packages\click\core.py", line 1655, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
  File "C:\Users\user\.platformio\penv\lib\site-packages\click\core.py", line 920, in make_context        
    self.parse_args(ctx, args)
  File "C:\Users\user\.platformio\penv\lib\site-packages\click\core.py", line 1378, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "C:\Users\user\.platformio\penv\lib\site-packages\click\core.py", line 2360, in handle_parse_result
    value = self.process_value(ctx, value)
  File "C:\Users\user\.platformio\penv\lib\site-packages\click\core.py", line 2322, in process_value
    value = self.callback(ctx, self, value)
  File "C:\Users\user\.platformio\penv\lib\site-packages\platformio\project\commands\init.py", line 39, in validate_boards
    pm.board_config(id_)
  File "C:\Users\user\.platformio\penv\lib\site-packages\platformio\package\manager\platform.py", line 136, in board_config
    for manifest in self.get_installed_boards():
  File "C:\Users\user\.platformio\penv\lib\site-packages\platformio\util.py", line 56, in wrapper
    self.cache[key] = (time.time(), func(*args, **kwargs))
  File "C:\Users\user\.platformio\penv\lib\site-packages\platformio\package\manager\platform.py", line 112, in get_installed_boards
    for config in p.get_boards().values():
  File "C:\Users\user\.platformio\platforms\libretiny\platform.py", line 235, in get_boards
    result[key] = self.update_board(value)
  File "C:\Users\user\.platformio\platforms\libretiny\platform.py", line 250, in update_board
    family = board.get("build.family")
  File "C:\Users\user\.platformio\penv\lib\site-packages\platformio\platform\board.py", line 47, in get
    raise KeyError("Invalid board option '%s'" % path)
KeyError: "Invalid board option 'build.family'"

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

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 noticed you pushed some changes to https://registry.platformio.org/platforms/kuba2k2/libretiny/boards recently so maybe I am just jumping into the middle of something that's a work in progress.

I tried updating PIO but my PIO version is latest at v6.1.14b1.

I also tried installing libretiny from PIO CLI command line with the same result.

With the microcontroller stuff I am half useful...but here I am next to useless tracking this down.

kuba2k2 commented 3 months ago

Does it work if you remove LibreTiny from PIO and install it again with pio platform install libretiny? This will install it from PIO registry instead of your forked repo.

Please check if you have all the files in boards/ and boards/_base/ in your forked repo (on your PC).

cap9qd commented 3 months ago

I deleted all the libretiny folders under .platformio/platforms/directory. I reinstalled libretiny via the command you supplied but got the same result.

Here is the dir for the .platformio/platforms/libretiny/boards/; it appears they're all there.

03/12/2024  07:50 AM    <DIR>          .
03/12/2024  07:50 AM    <DIR>          ..
02/29/2024  08:17 AM               468 bw12.json
02/29/2024  08:17 AM               521 bw15.json
02/29/2024  08:17 AM               358 cb1s.json
02/29/2024  08:17 AM               396 cb2l.json
02/29/2024  08:17 AM               396 cb2s.json
02/29/2024  08:17 AM               377 cb3l.json
02/29/2024  08:17 AM               360 cb3s.json
02/29/2024  08:17 AM               383 cb3se.json
02/29/2024  08:17 AM               364 cblc5.json
02/29/2024  08:17 AM               420 cbu.json
02/29/2024  08:17 AM             1,304 generic-bk7231n-qfn32-tuya.json
02/29/2024  08:17 AM             1,320 generic-bk7231t-qfn32-tuya.json
02/29/2024  08:17 AM             2,285 generic-bk7252.json
02/29/2024  08:17 AM             1,241 generic-rtl8710bn-2mb-468k.json
02/29/2024  08:17 AM             1,241 generic-rtl8710bn-2mb-788k.json
02/29/2024  08:17 AM             2,040 generic-rtl8710bx-4mb-980k.json
02/29/2024  08:17 AM             1,365 generic-rtl8720cf-2mb-992k.json
02/29/2024  08:17 AM               940 lsc-lma35-t.json
02/29/2024  08:17 AM               922 lsc-lma35.json
03/12/2024  07:50 AM    <DIR>          shapes
02/29/2024  08:17 AM               353 t102-v1.1.json
02/29/2024  08:17 AM               530 t103-v1.0.json
02/29/2024  08:17 AM               353 t112-v1.1.json
03/12/2024  07:50 AM    <DIR>          templates
03/12/2024  07:50 AM    <DIR>          variants
02/29/2024  08:17 AM               309 wa2.json
02/29/2024  08:17 AM               376 wb1s.json
02/29/2024  08:17 AM               353 wb2l-m1.json
02/29/2024  08:17 AM               405 wb2l.json
02/29/2024  08:17 AM               412 wb2s.json
02/29/2024  08:17 AM               393 wb3l.json
02/29/2024  08:17 AM               393 wb3s.json
02/29/2024  08:17 AM               380 wblc5.json
02/29/2024  08:17 AM               354 wr1.json
02/29/2024  08:17 AM               350 wr1e.json
02/29/2024  08:17 AM               413 wr2.json
02/29/2024  08:17 AM               410 wr2e.json
02/29/2024  08:17 AM               423 wr2l.json
02/29/2024  08:17 AM               380 wr2le.json
02/29/2024  08:17 AM               402 wr3.json
02/29/2024  08:17 AM               408 wr3e.json
02/29/2024  08:17 AM               422 wr3l.json
02/29/2024  08:17 AM               418 wr3le.json
02/29/2024  08:17 AM               401 wr3n.json
03/12/2024  07:50 AM    <DIR>          _base

and _base dir:

03/12/2024  07:50 AM    <DIR>          .
03/12/2024  07:50 AM    <DIR>          ..
02/29/2024  08:17 AM               119 beken-7231-tuya.json
02/29/2024  08:17 AM               153 beken-7231.json
02/29/2024  08:17 AM               612 beken-7231n.json
02/29/2024  08:17 AM               376 beken-7231q.json
02/29/2024  08:17 AM               492 beken-7231t.json
02/29/2024  08:17 AM               731 beken-7252.json
02/29/2024  08:17 AM             1,113 beken-72xx.json
02/29/2024  08:17 AM                72 generic.json
03/12/2024  07:50 AM    <DIR>          ic
03/12/2024  07:50 AM    <DIR>          pcb
02/29/2024  08:17 AM               262 realtek-ambz-2mb-468k.json
02/29/2024  08:17 AM               261 realtek-ambz-2mb-788k.json
02/29/2024  08:17 AM               263 realtek-ambz-4mb-980k.json
02/29/2024  08:17 AM                42 realtek-ambz-bx.json
02/29/2024  08:17 AM                48 realtek-ambz-tuya.json
02/29/2024  08:17 AM             1,019 realtek-ambz.json
02/29/2024  08:17 AM               207 realtek-ambz2-2mb-900k.json
02/29/2024  08:17 AM               174 realtek-ambz2-2mb-992k.json
02/29/2024  08:17 AM               114 realtek-ambz2-8710.json
02/29/2024  08:17 AM               142 realtek-ambz2-8720.json
02/29/2024  08:17 AM             2,247 realtek-ambz2-image.json
02/29/2024  08:17 AM                48 realtek-ambz2-tuya.json
02/29/2024  08:17 AM               736 realtek-ambz2.json

Not that it's surprising but I get the same issue trying the GUI "New Project" in PIO-Home page.

I also checked the forked repo and they all appear there too. I have been working on a few things (BK72xx deep_sleep and I2C/soft_i2c) in a local ESPHome venv environment on the same PC without issue. IDK if this could be causing issues?

cap9qd commented 3 months ago

Wow sorry for the trouble on this one!

I found the issue by adding some print(...) statements in platform.py; I have an old custom esp32 board defined from before the esp32-s3 was included in the esp32 platform...which doesn't have the build.family in the JSON.

kuba2k2 commented 3 months ago

Oh. I hate that PIO seems to call platform.py files with OTHER platforms' boards... this is a mess. Anyway, LT should be able to handle such a case (e.g. filter out/ignore all non-LibreTiny boards), so I'll reopen this as a bug. Thanks for finding the issue!