PlatformIO Community

Access framework path in

Hey all!
Is there a way to get the currently used framework path as variable inside an extra script invoked from the platformio,ini file?
What i’m trying to achieve is:

  1. I’m using the megatinycore for a project using attiny806.
  2. Inside the framework (~/.platformio/packages/framework-arduino-megaavr-megatinycore/) there is a tools directory containing the pymcuprog based uploader, which as far as i know is not implemented as an option for upload_protocol.
  3. I’d like to use that program together with my own designed UPDI programmer. In my platformio.ini file i add an extra script:
    extra_scripts =
    with the content:
Import("env", "projenv")
# Python callback
def on_upload(source, target, env):
    firmware_path = str(source[0])
    # here invoke the  from 
    # ~/.platformio/packages/framework-arduino-megaavr-megatinycore/tools/ 
    # with pio's pyenv and other params

Is there a way i can get the path to the currently used framework as a variable
inside my script, thus getting the path to the ?
I know i can get the python path using env.subst("$PYTHONEXE")


Just execute the same logic as the builder script

(edit: corrected to MegaAVR, not AVR script)

Thank you! Got it working.

Interestingly, i’ve discovered that opening any CH330/340x serial port from PlatformIO creates a pulse on the RTS line, even with hardware flow disabled. Probably relates to the pyserial and the ch3xx driver.
This is actually very convenient, since my programmer uses the CH330 and it’s single flow control line RTS to automaticaly switch between the serialUPDI mode and normal TX/RX.

Initially i planned to do it manually using pyserial within the upload callback, but it seems it won’t be necessary. So right now i have an UPDI programmer that switches into updi mode when i click “upload” and then automatically back into serial when the monitor is open.