-
-
Notifications
You must be signed in to change notification settings - Fork 698
Custom partition table #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@ivankravets. I moved the issue as requested. I saw that you labelled the old issue as wontfix? Why? Is it not possible to change partition sizes on PlatformIO? I remember on ESP8266 it was possible for spiffs with flags in platformio.ini. If not possible at the moment it is ok , But then it should be mentioned somewhere. |
See https://github.com/espressif/arduino-esp32/blob/master/tools/platformio-build.py#L185 Do you modify the correct file? |
Yes, that is the file I changed. Content of default.csv at C:\Users\beegee.platformio\packages\framework-arduinoespressif32\tools\partitions:
which should give me 2 app partitions with the size of 0x1F0000 and 0x200000. But using the code // Get Partitionsizes
size_t ul;
esp_partition_iterator_t _mypartiterator;
const esp_partition_t *_mypart;
ul = spi_flash_get_chip_size(); Serial.print("Flash chip size: "); Serial.println(ul);
Serial.println("Partition table:");
_mypartiterator = esp_partition_find(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, NULL);
if (_mypartiterator) {
Serial.println("App Partition table:");
do {
_mypart = esp_partition_get(_mypartiterator);
printf("Type: %02x SubType %02x Address 0x%06X Size 0x%06X Encryption %i Label %s\r\n", _mypart->type, _mypart->subtype, _mypart->address, _mypart->size, _mypart->encrypted, _mypart->label);
} while (_mypartiterator = esp_partition_next(_mypartiterator));
}
esp_partition_iterator_release(_mypartiterator);
_mypartiterator = esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, NULL);
if (_mypartiterator) {
Serial.println("Data Partition table:");
do {
_mypart = esp_partition_get(_mypartiterator);
printf("Type: %02x SubType %02x Address 0x%06X Size 0x%06X Encryption %i Label %s\r\n", _mypart->type, _mypart->subtype, _mypart->address, _mypart->size, _mypart->encrypted, _mypart->label);
} while (_mypartiterator = esp_partition_next(_mypartiterator));
}
esp_partition_iterator_release(_mypartiterator); gives me
Found (maybe) the problem!Playing around a little bit I found out that if I change
Any other info you need, let me know. |
PlatformIO does not depend on Arduino IDE. It seems that you didn't clean project after modification. Please run |
Tried both Then (getting desperate) I tried to see if there is a difference if I flash through USB/serial or OTA. And there I got finally lucky. Result:Flashing through OTA with a changed partition table DOESN'T change the partitions. |
InfoI added an entry to the ESP32 Wiki I am creating: Change partition size |
@beegee-tokyo your wiki link doesnt work. I'm trying to figure this out under platformio in Visual Studio Code on OSX. I changed the default and it still giving me the program size is greater than maximum allowed error. I'm only trying to program via cable, so no OTA here. |
@theproxy I know, I need to change the Wiki. I submitted this issue because I run into the problem. First it seem to work on PlatformIO but now I see the partition size never change when using PlatformIO. @ivankravets why is it not working? Why is PlatformIO ignoring the changes even when flashing over USB? Is there something I missed to change? |
Thank you for your reply. I got it working correctly in the Arduino IDE, but not in the platformio IDE. So, I'm developing in PlatformIO and programming it through Arduino IDE. Not ideal, but not sure how to fix at the moment. If anyone has an pointers I can help test any fixes. |
@theproxy @ivankravets question regarding the partition tables
The board esp32maxapp is defined in boards.txt with the entry
Other entries are the same as for board ESP32 Dev Module I created the esp32maxapp.json with the correct But the partition size never changes with this setup (Flashing over USB). When I run
So it looks like Any ideas why always default.csv is used? What is wrong with my board definition? From where is gen_esp32part.py called? Couldn't find it. |
FOUND MY PROBLEM!I needed to add a "partitions" entry in my esp32maxapp.json in the boards folder.
And now the correct partition definition is loaded. HURRAY! @theproxy |
@beegee-tokyo looks good so far! Thanks for putting the work in. Wish there was an easier way in platformio to change the parititon table, looks like if we could have a platformio.ini variable that provides a path to partition csv file, and setting maximum_size that would make it enough to just generate the command lines dynamically for every project. Thanks for your help :) |
@ivankravets
I tested it with following changes and it works without problems:
Changes inside platformio-build.py:
If you think this idea is good and could be implemented, I can create a pull request for it. |
Why not just call the file "partition.csv" instead of "custompart.csv"? |
@BorisFR on ArduinoIDE there seems now to be a solution, but not for PlatformIO :( |
Surely, but PlatformIO + Visual Studio Code is awesome! I could not come back to Arduino IDE ;) |
Please re-test:
platformio.ini [env:myenv]
extra_scripts = post:extra_script.py extra_script.py Import("env")
env.Replace(PARTITION_TABLE_CSV="/path/to/custom/partition.csv") Does it work? |
@ivankravets I am using I will try the custom post script tomorrow, played around with them before, but does that solve the problem with max app size error while flashing? Is there another env. variable that can be changed in the script to get around that problem as well? |
My test:
partitions.py
Still having the problem for max size
I change the json file... but finally: it does not work. Partitions are still as default. I have found that in platformio-build.py, PARTITION_TABLE_CSV is replace by env.BoardConfig().get("build.partitions", "default") (line 186), just before generating the partitions.bin file. |
For the featheresp32.json file: |
@ivankravets
platformio.ini
Result:
Only if I create a folder boards and put a changed esp32dev.json in there the upload works. The problem with using only extra_script.py is that this function in pioupload.py
The line |
Found a way to do it with just the
To get the Here is the import sys
from os import environ
from platformio import util
from os.path import isfile, join
Import("env")
################################################################
#
# put your new app partition size to newPartSize
# put your custom partition table file name to customPartFile
#
################################################################
newPartSize = 1966080
customPartFile = "custompart.csv"
print "Checking app size against custom partition table!"
targetfirm = env.subst("$BUILD_DIR") + "\\" + env.subst("$PROGNAME") + ".elf"
sysenv = environ.copy()
sysenv['PATH'] = str(env['ENV']['PATH'])
cmd = [
env.subst("$SIZETOOL"), "-B",
targetfirm
]
result = util.exec_command(cmd, env=sysenv)
if result['returncode'] == 0:
print result['out'].strip()
line = result['out'].strip().splitlines()[1]
values = [v.strip() for v in line.split("\t")]
used_size = int(values[0]) + int(values[1])
if used_size > newPartSize:
sys.stderr.write("Error: The program size (%d bytes) is greater "
"than maximum allowed (%s bytes)\n" % (used_size, newPartSize))
env.Exit(1)
env.Replace(SIZETOOL=env.subst("$PIOHOME_DIR") + "\\penv\\scripts\\wheel.exe")
env.Replace(PARTITION_TABLE_CSV=env.subst("$PROJECT_DIR") + "\\" + customPartFile) Tested only on Windows, not sure if it works on Linux or MacOS because of the line I think it should be possible to actually search for the custom partition table from within the extra_script.py, get the app partition size and fill the two variables automatically. But for now I have enough of this Python language nightmare (which programming language fails if you intent the codes sometimes with spaces and sometimes with tabs :( ). |
Anyone, please provide me a custom partition table which raises an error. I'll fix. Also, if you provide complete project which should work, I would be thankful! |
My "ultimate" solution ;) 1/ create folder "boards" in the project root folder and copy the json file in it. edit value (corresponding to your partition) in section "upload" 2/ create your "partitions.csv" file in the project root folder. 3/ edit platformio.ini 4/ add file partitions.py in the project root folder. featheresp32.json.txt |
@BorisFR could you try in extra script this ? env.BoardConfig().manifest['upload']['maximum_size'] = 4063232 ? |
Just test: it does not work. in both cases, I have
|
* develop: Custom Partition Tables // Resolve #58
Please re-test and confirm. The final release of dev/platform is planned for the next week. Thanks! |
@ivankravets |
Uh oh!
There was an error while loading. Please reload this page.
See http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
Configuration
Operating system: Windows 7 Ultimate 64bit Service Pack 1
PlatformIO Version (
platformio --version
): 3.5.0rc10Visual Studio Code Version: 1.18.0
Atom Version: 1.23.1 x64
Description of problem
Partition sizes doesn't change even if default.csv is changed.
Steps to Reproduce
Following this issue I tried to change the partition sizes on my ESP32 Dev Module.
The changed default.csv:
But after uploading the partition sizes are still the default ones:
Then I tried the exact same procedure on Arduino IDE and the partition size changed to:
Going back to PlatformIO, I uploaded my code again from there and the changed partition sizes are still valid.
It seems that PlatformIO doesn't change the partition size at all. Or is my method to change the partition sizes wrong?
The text was updated successfully, but these errors were encountered: