espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.28k stars 7.35k forks source link

[solution] platformio upload offset #8093

Open chegewara opened 1 year ago

chegewara commented 1 year ago

Related area

upload offset

Hardware specification

any

Is your feature request related to a problem?

I know this is for platformio environment, and probably the place i am posting this is not the best place, but most esp32 users is reading this issue tracker anyway. This is simple solution to change upload offset if you want to use custom partition_table.csv with non-standard offsets for app partitions.

Describe the solution you'd like

add to platformio.ini

extra_scripts = 
    flash_offset.py

create flash_offset.py

Import("env")

env.Replace(
    ESP32_APP_OFFSET=env.get("ESP32_APP_OFFSET").replace(
        "0x10000", "0x210000") <---- 0x210000 is new offset value
)

Describe alternatives you've considered

No response

Additional context

If anyone has info about uploading additional bin, for example ffat image, it would be nice to share info.

Ive been trying to change FLASH_EXTRA_IMAGES, but that does not work, because UPLOADERFLAGS is using original values.

Thanks

I have checked existing list of Feature requests and the Contribution Guide

chegewara commented 1 year ago

Flashing fat partition together with firmware in one upload run is also possible.

Import("env")

__UPLOADERFLAGS=env["UPLOADERFLAGS"]

# file generated with esp-idf master branch https://github.com/espressif/esp-idf/blob/master/components/fatfs/wl_fatfsgen.py
# ./wl_fatfsgen.py --partition_size PARTITION_SIZE --long_name_support path_to_data_folder
# copy fatfs_image.img to project folder
__UPLOADERFLAGS.append(str('0x410000')) # ffat partition start address
__UPLOADERFLAGS.append(str('fatfs_image.img'))

env.Replace(
   UPLOADERFLAGS =__UPLOADERFLAGS
)
me-no-dev commented 1 year ago

@chegewara @pedrominatel @valeros should this go to our docs or to PIO's docs as well?

chegewara commented 1 year ago

Honestly, no idea, its espressif decision. I found this and i thought i can share. Maybe with arduino-esp32 v3.x it will be easier to create fatfs image, but this is not the worst case scenario. Also app partition is useful, as i saw some questions about it already.

That trick with fat partition is useful on S3 with USB MSC.

me-no-dev commented 1 year ago

@chegewara I agree this is useful. Let's see what PIO and our team think about where to place it.

valeros commented 1 year ago

@chegewara Have you tried the board_upload.offset_address option in your project config? Something like this:

[env:esp32-s3-devkitc-1]
platform = espressif32
framework = arduino
board = esp32-s3-devkitc-1
board_upload.offset_address = 0x210000

As for an additional image, using an extra script is the right approach.

pedrominatel commented 1 year ago

IMHO, the right place for this is here.

chegewara commented 1 year ago

@valeros No, i didnt know that option, its also cool.

Thanks