Support DFU for main chip

hoainguyen265
Posts: 10
Joined: Tue Nov 13, 2018 8:17 am

Support DFU for main chip

Postby hoainguyen265 » Tue Dec 25, 2018 3:17 am

In my production, I have to support DFU for main chip over I2C communication by ESP32.
But I don't want to do it in ESP32 main app. I want main app just downloading firmware from server and save to flash. After that, ESP32 reboot, boot loader will read firmware from flash and connect to main chip to do DFU.

But i found in document that boot loader can not use the drivers and functions from other components and boot loader size is also limited.

So anyone here have experience in customize boot loader can give me some advice? Thanks so much.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Support DFU for main chip

Postby ESP_igrr » Tue Dec 25, 2018 9:27 am

Instead of modifying the bootloader to use the drivers, you may create a separate small application which will handle the DFU, and place it into one of the app partitions. Then in the main app, use esp_ota_set_boot_partition function to boot the DFU application, and call "esp_restart". Bootloader will boot the DFU application. In the DFU application, do the work you need and switch back to the main app using esp_ota_set_boot_partition.

hoainguyen265
Posts: 10
Joined: Tue Nov 13, 2018 8:17 am

Re: Support DFU for main chip

Postby hoainguyen265 » Tue Dec 25, 2018 10:30 am

ESP_igrr wrote:
Tue Dec 25, 2018 9:27 am
Instead of modifying the bootloader to use the drivers, you may create a separate small application which will handle the DFU, and place it into one of the app partitions. Then in the main app, use esp_ota_set_boot_partition function to boot the DFU application, and call "esp_restart". Bootloader will boot the DFU application. In the DFU application, do the work you need and switch back to the main app using esp_ota_set_boot_partition.
Thanks for your response ESP_igrr,
With your response i have more question that if i use

Code: Select all

esp_ota_set_boot_partition
, my DFU partition subtype is ota_x right?
And if my DFU partition subtype is ota_x, my DFU app may be erased for ota process?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Support DFU for main chip

Postby ESP_igrr » Tue Dec 25, 2018 11:08 am

You probably need to use another subtype, such as 'test'. I think the partition table generator will also accept other integer values which are not used by defined subtypes.

hoainguyen265
Posts: 10
Joined: Tue Nov 13, 2018 8:17 am

Re: Support DFU for main chip

Postby hoainguyen265 » Wed Dec 26, 2018 8:49 am

ESP_igrr wrote:
Tue Dec 25, 2018 11:08 am
You probably need to use another subtype, such as 'test'. I think the partition table generator will also accept other integer values which are not used by defined subtypes.
I tried with subtype 'test' and 0xFF and failed.
This is my partition table
https://drive.google.com/file/d/1Tx98pW ... sp=sharing
I flash the same .bin file to ota_1 and dfu_app
When i'm in ota_0 i try to use esp_ota_set_boot_partition with dfu_app and failed, but with ota_1 is ok.

hoainguyen265
Posts: 10
Joined: Tue Nov 13, 2018 8:17 am

Re: Support DFU for main chip

Postby hoainguyen265 » Wed Dec 26, 2018 9:05 am

So think that i will set the subtype of dfu_app to ota_2.
And the i will custom ota process.
I don't use

Code: Select all

esp_ota_get_next_update_partition
I will use:

Code: Select all

esp_partition_find
esp_partition_find_first
to get the ota partition i want to update.
It's mean when i'm in ota_0, i update to ota_1, when i'm in ota_1 i update to ota_0,
and when i want to do dfu, i will use

Code: Select all

 esp_ota_set_boot_partition
to boot to dfu_app (ota_2)

Who is online

Users browsing this forum: Baidu [Spider] and 116 guests