Eclipse-IoT / eclipsecon-2022-hackathon

Firmware, application and documentation for the hackathon
7 stars 7 forks source link

Add --device-key to provision command #35

Closed danbev closed 1 year ago

danbev commented 1 year ago

This commit updates the provision command to include the --device-key option. It also adds a second execution of this command with the only difference being the value of the flash-address. I noticed that this is done in ../preprovision.sh, but I don't understand why this is required , but I was not able to get the firmware to work without doing this.


I'm mainly opening this PR as question as I'm curious as to the "double" writing, can anyone help me understand that part?

Signed-off-by: Daniel Bevenius daniel.bevenius@gmail.com

jbtrystram commented 1 year ago

I think that's because the bootloader allows to update the config over the air while keeping the old version in case something goes wrong. So the preprovision make sure both are populated. I think @lulf will confirm or correct me on this :)

danbev commented 1 year ago

I think that's because the bootloader allows to update the config over the air while keeping the old version in case something goes wrong. So the preprovision make sure both are populated.

Ah that makes sense, thanks for that!

lulf commented 1 year ago

There is no bootloader involved in this firmware, but the firmware keeps the provisioning config in two places, to prevent configuration to be lost during a erase + write cycle of the configuration, which happens every 10 seconds by default (this is to ensure sequence counter is persisted). If power is lost during the erase+write, the configuration is gone. By keeping the configuration in two flash pages, writing it twice, we ensure that we have at least one configuration that is not wiped.

danbev commented 1 year ago

@lulf Thanks for the detailed explanation!