Pre Built platform.ini How to Use a diffrent Partitions.csv File

Tying to figure out how to use a different partitions file in INI.
it is a pre built by esphome
i would like to use build flags or
some sort of advanced scripting to replace the orginle in the {env}
this is the ini

; Auto generated code by esphome

lib_deps =
build_flags =
upload_flags =

; ========== AUTO GENERATED CODE BEGIN ===========
board = m5stack-fire
board_build.partitions = partitions.csv  
board_upload.maximum_ram_size = 8388608
build_flags =
framework = arduino
lib_deps =
platform =
upload_speed = 115200
; =========== AUTO GENERATED CODE END ============
; ========= YOU CAN EDIT AFTER THIS LINE =========
extra_scripts =

I’am not sure how to format the
to substitute my custom_partitions file for the partitions.csv that is generated automaticaly
ideas for script?


partitions = partions_custom.csv

board_build.partitions = partitions

Pretty new to Platformio any help would be greatly appreciated

Do I understand you correctly that you have a custom script that generates a custom partitions CSV file on every run, and that you want to use that in the build process? Why not have the script output it in a file of known filename then and refer to it as documented in the platformio.ini, not via a script?

a custom script is creating the the partition.csv file and platform.ini file on every run.
It also overwrites any changes to partitions.csv file
what i would like to accomplish is to replace the created partition file that the first script creates,
with i custom_partition.csv

So your script will just need to overwrite the contents of the custom_parititon.csv created in the first run and the platformio.ini can jus statically point at

board_build.partitions = custom_parititon.csv


that sounds like what i would like to do
just lost on how to accomplish this.
pretty new to platmormio.

You already have this line in your platformio.ini, change the filename to what your script will create and have your script create it, and you’re done.

ok added this to script

board_build.partitions = custom_parititon.csv

compiler complains with custom partition not defined.
where do i define this?
Thank you very much for your help!

You can’t change it in a Python script like this, it’s a configuration option in the platformio.ini.

Any other thoughts on how i should proceed?
Is there anyway to simply replace partitions.csv file with my custom_partitions.csv in a different way?
I am unable to simple change the first generated INI file board_build.partitions = #it is genarated by first script
what i can do is add to bottom of INI

If you are for whatever reason restricted by this, the easiest way is that your script will have to overwrite the contents of partitions.csv, since that is what will be used during compilation.

I’ve looked in to the builder script and

so you might also be able to redirect the partitions table by writing an extra_script that does


env["PARTITIONS_TABLE_CSV"] = "some_other_filename.csv" 

# make sure some_other_filename.csv has valid content

Though it would have to be a pre: script (docs) so that it runs before the platform’s script…

You are a genius Maxgerhardt, that works perfect!
Exactly what I wanted!
Thank you for all the help!