feat(partition_table): Update partition table script and OTA example

1. APP binary supports 4KB align instead of 64KB align

2. Add options to sdkconfig.defaults:
2.1. using 1MB flash
2.2. use custom partition table "partitions_two_ota.1MB.mini.csv"
2.3. custom partition table base address is 0x4000

3. "make ota flash" using APP1_OFFSET as app downloading address
This commit is contained in:
Dong Heng
2018-12-25 15:53:42 +08:00
parent 5bd4b2e075
commit 3d63a6ca52
11 changed files with 138 additions and 39 deletions

View File

@ -16,6 +16,65 @@ In this example, the ESP8266 has 2 images in flash: OTA_0, OTA_1. Each of these
Flashing the example over serial with "make flash" updates the OTA_0 app image. On first boot, the bootloader loads this OTA_0 app image which then performs an OTA update (triggered in the example code). The update downloads a new image from an http server and saves it into the OTA_1 partition. At this point the example code updates the ota_data partition to indicate the new app partition, and reboots. The bootloader reads ota_data, determines the new OTA image has been selected, and runs it.
# Custom partition configuration
If customers want to use their own partition tables with specific partition location. Please see following steps:
## Step 1: Create partition file
Create a partition managment file with "cvs" formate, please refer to "doc/en/api-guides/partition-tables.rst"
## Step 2: Select custom partition mode
1. Select custom partition tables at "menuconfig":
```
Partition Table --->
Partition Table (XXXXXX) --->
(X) Custom partition table CSV
```
2. Configurate custom partition location at:
```
(XXXXXX)Custom partition CSV file
```
Note: System will add the absolute path of the project to the head of the "Custom partition CSV file" automatically when compling.
3. Configurate patition table location if necessary:
```
(XXXXXX)Partition table offset address at flash
```
## Step 3: Configurate application location:
Configurate application location at "mennuconfig" like following base on partition table file.
If you select 1MB flash, application location configuration menu is like following:
```
Partition Table --->
[*] Support to setup partition parameter of APP2
(0x5000) App1 offset address
(0x7B000) App1 size by bytes
(0x85000) App2 offset address
(0x7b000) App2 size by bytes
```
If you select 2MB flash and above size, application location configuration menu is like following:
```
Partition Table --->
(0x10000) APP1 partition offset
(0xF0000) APP1 partition size(by bytes)
```
Note: The firmware location information must be same as partition table file. **make ota flash** will only download the app1 at **APP1 partition offset**.
# Workflow
The OTA_workflow.png diagram demonstrates the overall workflow:
@ -84,6 +143,8 @@ Serial flasher config --->
(X) 1 MB
```
Configurate the application location information and it must be same as the OTA example's information, how to do refer to **Step 3: Configurate application location** of **Custom partition configuration**.
Save your changes, and type `make` to build the example.
## Step 4: Flash OTA Example

View File

@ -0,0 +1,9 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
# Bootloader is at 0x0000 - 0x4000, total 16KB
# Partition table is at 0x4000 - 0x5000, total 4KB
phy_init, data, phy, 0x5000, 0x1000
ota_0, 0, ota_0, 0x6000, 0x7A000
nvs, data, nvs, 0x80000, 0x4000
otadata, data, ota, 0x84000, 0x2000
ota_1, 0, ota_1, 0x86000, 0x7A000
1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
3 # Bootloader is at 0x0000 - 0x4000, total 16KB
4 # Partition table is at 0x4000 - 0x5000, total 4KB
5 phy_init, data, phy, 0x5000, 0x1000
6 ota_0, 0, ota_0, 0x6000, 0x7A000
7 nvs, data, nvs, 0x80000, 0x4000
8 otadata, data, ota, 0x84000, 0x2000
9 ota_1, 0, ota_1, 0x86000, 0x7A000

View File

@ -1,4 +1,12 @@
# Default sdkconfig parameters to use the ESP8266 OTA
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
CONFIG_PARTITION_TABLE_TWO_OTA=y
CONFIG_LWIP_SOCKET_MULTITHREAD=
CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_two_ota.1MB.mini.csv"
CONFIG_PARTITION_TABLE_OFFSET=0x4000
CONFIG_APP1_OFFSET=0x6000
CONFIG_APP1_SIZE=0x7A000
CONFIG_APP2_OFFSET=0x86000
CONFIG_APP2_SIZE=0x7A000