OVMS3-idf/examples/storage/parttool
Ivan Grokhotkov b1bb90a596 Merge branch 'bugfix/partition_tables_update_note' into 'master'
global: update note in the partition tables

See merge request espressif/esp-idf!5636
2019-07-29 19:00:44 +08:00
..
main examples: use new component registration api 2019-06-21 19:53:29 +08:00
CMakeLists.txt examples: add otatool and parttool examples 2018-11-28 17:28:20 +08:00
example_test.py test: get bin path from dut.app.flash_files instead of dut.download_config 2019-01-03 09:57:47 +08:00
Makefile examples: add otatool and parttool examples 2018-11-28 17:28:20 +08:00
partitions_example.csv global: update note in the partition tables 2019-07-27 10:28:16 +02:00
parttool_example.py examples: create example for both Python and CLI parttool interfaces 2019-06-11 13:17:14 +08:00
parttool_example.sh examples: create example for both Python and CLI parttool interfaces 2019-06-11 13:17:14 +08:00
README.md examples: create example for both Python and CLI parttool interfaces 2019-06-11 13:17:14 +08:00
sdkconfig.defaults examples: remove non-existent options from sdkconfig.defaults 2019-07-29 04:57:38 +02:00

Partitions Tool Example

This example demonstrates common operations the partitions tool parttool.py allows the user to perform:

  • reading, writing and erasing partitions,
  • retrieving info on a certain partition,
  • dumping the entire partition table

Users taking a look at this example should focus on the contents of the Python script parttool_example.py or shell script parttool_example.sh. The scripts contain programmatic invocation of the tool's functions via the Python API and command-line interface, respectively. Note that on Windows, the shell script example requires a POSIX-compatible environment via MSYS2/Git Bash/WSL etc.

The example performs the operations mentioned above in a straightforward manner: it performs writes to partitions and then verifies correct content by reading it back. For partitions, contents are compared to the originally written file. For the partition table, contents are verified against the partition table CSV file. An erased partition's contents is compared to a generated blank file.

How to use example

Build and Flash

Before running either of the example scripts, it is necessary to build and flash the firmware using the usual means:

Make:

make build flash

CMake:

idf.py build flash

Running parttool_example.py

The example can be executed by running the script parttool_example.py or parttool_example.sh.

Python script:

python parttool_example.py

Shell script:

./parttool_example.sh

The script searches for valid target devices connected to the host and performs the operations on the first one it finds. To perform the operations on a specific device, specify the port it is attached to during script invocation:

Python script:

python parttool_example.py --port /dev/ttyUSB2

Shell script:

./parttool_example.sh /dev/ttyUSB2

Example output

Running the script produces the following output:

Checking if device app binary matches built binary
Found data partition at offset 0x110000 with size 0x10000
Writing to data partition
Reading data partition
Erasing data partition
Reading data partition

Partition tool operations performed successfully!