espressif / esp-mdf

Espressif Mesh Development Framework, limited maintain, recommend to use https://github.com/espressif/esp-mesh-lite
Other
773 stars 253 forks source link

ota update of different device type and firmware in same mesh #60

Open Kasuhikdas opened 5 years ago

Kasuhikdas commented 5 years ago

I have multiple esp-32 in mesh network. There are different types of firmware across the devices. In mupgrade it updated all the devices with same firmware as written in document. Is there any way to update few devices in mesh with a particular ota and others with different ota??

zhanzhaocheng commented 5 years ago

Different types of devices need to be upgraded separately, and each time only the same type of device can be upgraded. For example, there are two types of devices in the network: Type 1 (A, B), Type (C, D), you call mupgrade_firmware_send, just pass in the address of (A, B), wait until A, B is upgraded and then give C, D upgrade

Kasuhikdas commented 5 years ago

way to set one address is like below uint8_t dest_mac_addr[] = {0x30,0xae,0xa4,0x04,0xc0,0xf4};

but there is provision of sending multiple addresses. mupgrade_firmware_send(const uint8_t dest_addrs, size_t dest_addrs_num, mupgrade_result_t result)

how to send multiple addresses?

zhanzhaocheng commented 5 years ago

uint8_t dest_mac_addr[] = {0x30,0xae,0xa4,0x04,0xc0,0xf4, 0x30,0xae,0xa4,0x04,0xc0,0xf3, 0x30,0xae,0xa4,0x04,0xc0,0xf2}; mupgrade_firmware_send(dest_mac_addr, sizeof(dest_mac_addr) / 6, NULL);

Kasuhikdas commented 5 years ago

thanks,that worked. What about firmware version? I dont want to push same firmware version like the ota example in esp-idf. But mupgrade same firmware is getting updated. Any solution for that?

zhanzhaocheng commented 5 years ago

Mupgrade does not verify the firmware version of the device You need to add a version identifier at the application layer and compare it with the server version before the upgrade.

Kasuhikdas commented 5 years ago

I understand that. But i have different fimwares. So,if root is different type of device then can not check roots firmware version for the upgrade and if we do the checking in node and stopes the update in node then upgrade process in root will keep sending packets and fail eventually.

zhanzhaocheng commented 5 years ago

Mupgrade temporarily does not support the child node to actively stop the upgrade, I will add this function as soon as possible, currently using the following two ways:

  1. The root node first asks for the type and version number of all devices, and then the root node sends the package to the device that needs to be upgraded.
  2. After the child node is powered on, it sends the device type and version number to the server actively, and the server upgrades the device in batches.
zhanzhaocheng commented 5 years ago
  1. You can enable firmware type checking by make menuconfig. You can add type identifiers to different types of device firmware. After the upgrade is completed, this flag will be checked. Only the identifier will be used for version switching. image

  2. You can also determine the firmware name (ie version) when you receive the MDF_EVENT_MUPGRADE_STARTED event, if the firmware of the device is not called mupgrade_stop()

Kasuhikdas commented 5 years ago

In case root is not the device I want to upgrade then the ota is not sent to other nodes. Root type ABC Node type CDE Update for CDE is not getting sent.

Kasuhikdas commented 5 years ago

How do I find the version of incoming ota binary. I have device configuration in sdkconfig??

rkashi commented 5 years ago

@zhanzhaocheng As per my understanding, to allow selective upgrade of a particular device node recommended by you in the post below, device type check should be done in the node device. Currently, the "device type" check is made in the root node as soon as the binary is downloaded from the cloud. This causes the upgrade task to terminate with error code "MDF_ERR_MUPGRADE_FIRMWARE_INVALID" in case the root is not of the set device type.

What is your recommendation on this proposed implementation? https://github.com/espressif/esp-mdf/issues/60#issuecomment-506695476

zhanzhaocheng commented 5 years ago

@Kasuhikdas @rkashi

The current version is root will check CONFIG_MUPGRADE_FIRMWARE_FLAG, you can delete the root check, we will modify it in the next version. This feature is to prevent the firmware generated by this project from being upgraded to the device. For example, hello_world.bin

image

It is recommended to use the ota name to distinguish between device type and version checking. For example, the name can include the version number and device type. Determined in MDF_EVENT_MUPGRADE_STARTED if mupgrade_stop() is called for non-self version

image

rkashi commented 5 years ago

@zhanzhaocheng I have network with more than 2 layers, meaning root -> Layer_1 nodes -> Layer_2 nodes. How does mupgrade handle this situation?