• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

main/11-Mar-2024-3514

CMakeLists.txtD11-Mar-2024231 75

MakefileD11-Mar-2024178 92

README.mdD11-Mar-20242.4 KiB7855

example_test.pyD11-Mar-2024909 3622

get_running_partition.pyD11-Mar-20242.8 KiB8846

otatool_example.pyD11-Mar-20243.8 KiB11966

otatool_example.shD11-Mar-20242.7 KiB9661

sdkconfig.defaultsD11-Mar-2024160 54

README.md

1# OTA Tool Example
2
3This example demonstrates common operations the OTA tool [otatool.py](../../../../components/app_update/otatool.py) allows the user to perform:
4
5- reading, writing and erasing OTA partitions,
6- switching boot partitions, and
7- switching to factory partition.
8
9Users taking a look at this example should focus on the contents of the Python script [otatool_example.py](otatool_example.py) or shell script [otatool_example.sh](otatool_example.sh). The scripts contain
10programmatic invocation of the tool's functions via the Python API and command-line interface, respectively. Note
11that on Windows, the shell script example requires a POSIX-compatible environment via MSYS2/Git Bash/WSL etc.
12
13The built application in this example outputs the currently running partition, whose output is used to verify if the tool switched OTA
14partitions succesfully. The built application binary is written to all OTA partitions at the start of the example to be able to determine the running
15partition for all switches performed.
16
17## How to use example
18
19### Build and Flash
20
21Before running either of the example scripts, it is necessary to build and flash the firmware using the usual means:
22
23Make:
24```bash
25make build flash
26```
27
28CMake:
29```bash
30idf.py build flash
31```
32
33### Running [otatool_example.py](otatool_example.py)
34
35The example can be executed by running the script [otatool_example.py](otatool_example.py) or [otatool_example.sh](otatool_example.sh).
36
37Python script:
38```bash
39python otatool_example.py
40```
41
42Shell script:
43```
44./otatool_example.sh
45```
46
47The script searches for valid target devices connected to the host and performs the operations on the first one it finds. This could present problems if there
48are multiple viable target devices attached to the host. To perform the operations on a specific device, specify the port it is attached to during script invocation ("/dev/ttyUSB2" for example):
49
50Python script:
51```bash
52python otatool_example.py --port /dev/ttyUSB2
53```
54
55
56Shell script:
57```
58./otatool_example.sh /dev/ttyUSB2
59```
60
61## Example output
62
63Running the script produces the following output:
64
65```
66Writing factory firmware to ota_0
67Writing factory firmware to ota_1
68Switching to factory app
69Switching to OTA slot 0
70Switching to OTA slot 1 (twice in a row)
71Switching to OTA slot 0 (twice in a row)
72Switching to factory app
73Switching to OTA slot 1
74
75Partition tool operations performed successfully
76
77```
78