Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added exercise 5 firmware update implementation #190

Merged
merged 5 commits into from
May 31, 2024
Merged

Conversation

malw4
Copy link
Contributor

@malw4 malw4 commented May 10, 2024

No description provided.

@malw4 malw4 requested review from JZimnol and Pantofel102 May 10, 2024 13:15
Copy link
Member

@JZimnol JZimnol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malw4 reviewed. Remember to NOT merge this before the newest pico-client is released.

@@ -1,20 +1,446 @@
# Graduation Project
# Exercise 5: Implement Firmware Update
In this exercise, we implement Object 5 - Firmware Update. It utilizes the pico_fota_bootloader to swap the flash partitions after downloading the appropriate binary file from Coiote IoT DM.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this exercise, we implement Object 5 - Firmware Update. It utilizes the pico_fota_bootloader to swap the flash partitions after downloading the appropriate binary file from Coiote IoT DM.
In this exercise, we implement Object 5 - Firmware Update. It utilizes the [pico_fota_bootloader](https://github.com/JZimnol/pico_fota_bootloader) to swap the flash partitions after downloading the appropriate binary file from Coiote IoT DM.


Your graduation project involves building an application that utilizes the LwM2M standard and the {{ coiote_long_name }}. Whether you choose the Raspberry Pi Pico W or any other IoT device, your task is to effectively gather sensor data and establish a cloud connection.
* A Raspberry Pi Pico W board with a USB cable
* A LM35 temperature sensor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed in this exercise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, copy and paste gone wrong

* [Getting Started guides](https://iotdevzone.avsystem.com/docs/LwM2M_Client/Getting_started/) containing detailed documentation on using different IoT development kits
* [AVSystem Discord](https://discord.avsystem.com/) for support and for submitting your graduation project
!!! Note
This part only describes functions that are in the code. The user doesn’t have to modify the code.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't say where the code can be found.


!!! important "Provide your feedback"
<p style="text-align: center;">firmware_update.h</p>
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All code snippets should start with "```c", this way the syntax can be colored.

Comment on lines 33 to 46
<p style="text-align: center;">main.c</p>
```
#include "lwip/sockets.h"
#include <anjay/anjay.h>
#include <anjay/core.h>
#include <anjay/security.h>
#include <anjay/server.h>
#include <avsystem/commons/avs_list.h>
#include <avsystem/commons/avs_log.h>
#include <avsystem/commons/avs_prng.h>
#include <avsystem/commons/avs_time.h>

#include "firmware_update.h"
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user doesn't need to modify the code, this code snippet that shows the #include "firmware_update.h" is useless and can be removed.

1. Click **Schedule Update** to trigger the Firmware Update process.

!!! Note
After doing so, a Firmware Update process will begin. Check the serial output logs - `the INFO [fw_update] [/anjay-pico-client/firmware_update/firmware_update.c]: Downloaded X bytes` logs should appear.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After doing so, a Firmware Update process will begin. Check the serial output logs - `the INFO [fw_update] [/anjay-pico-client/firmware_update/firmware_update.c]: Downloaded X bytes` logs should appear.
After doing so, a Firmware Update process will begin. Check the serial output logs - the `INFO [fw_update] [/anjay-pico-client/firmware_update/firmware_update.c]: Downloaded X bytes` logs should appear.

![Successful update](images/success.png)

!!! note
While the device is updating its firmware, it will deregister and reboot using the new firmware. This process may time several minutes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reboot using the new firmware sounds... strange

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


### Monitoring the update process

During the update process, the status of the firmware update can be monitored by reviewing the Resources **State** `/5/*/3` and **Update Results** `/5/*/5`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/5 is a single instance object, so no *.

4. **Updated** `state 0` & `update result 1`

!!! important "Update successful?"
Does the **State** `/5/*/3` report `0` and the **Update Results** `/5/*/5` report `1`? Congratulations! You've successfully updated the firmware of your device. 🎉
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Does the **State** `/5/*/3` report `0` and the **Update Results** `/5/*/5` report `1`? Congratulations! You've successfully updated the firmware of your device. 🎉
Does the **State** `/5/*/3` report `0` and the **Update Result** `/5/*/5` report `1`? Congratulations! You've successfully updated the firmware of your device 🎉


We're constantly working on improving the LwM2M Academy. Please share with us your feedback about this module so we can create an even better learning experience.

[Feedback form](https://forms.gle/UAFLJs9LJocAeger9){: .md-button .md-button--big }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feedback form does not include the Module 5 Exercise

Copy link
Member

@JZimnol JZimnol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malw4 re-reviewed.

* [Getting Started guides](https://iotdevzone.avsystem.com/docs/LwM2M_Client/Getting_started/) containing detailed documentation on using different IoT development kits
* [AVSystem Discord](https://discord.avsystem.com/) for support and for submitting your graduation project
!!! Note
This part only describes functions that are in the code in **Anjay-pico-client/firmware_update** folder. The user doesn’t have to modify the code.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This part only describes functions that are in the code in **Anjay-pico-client/firmware_update** folder. The user doesn’t have to modify the code.
This part only describes functions that are in the code in **Anjay-pico-client/firmware_update** directory. The user doesn’t have to modify the code.


<p style="text-align: center;">flash_aligned_writer.c</p>
``` c
#include <assert.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've indented the code, but not the whole section. It renders badly. Applies for other code snippets.

@@ -73,6 +73,11 @@ Learn more about the Firmware Update Object on the [OMA LwM2M Object and Resourc
| `update result 10` | **Firmware update cancelled** |
| `update result 11` | **Firmware update deferred** |


## What is Bootloader and why do I need this here?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no no, this place is z dupy for that in my opinion. THis hsould be in Exercise 5, before Implement Firmware Update for example.

Does the **State** `/5/*/3` report `0` and the **Update Result** `/5/*/5` report `1`? Congratulations! You've successfully updated the firmware of your device. 🎉
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is single instance, so no *.

Copy link
Member

@JZimnol JZimnol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code snippets in firmware_update.c are still not up to date or are incorrect.

out_writer->writer_cb = writer_cb;
}
<p style="text-align: center;">flash_aligned_writer.c</p>
``` c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole code is still indented not the way it should be. The "code section" is OK itself, the code inside is indented unnecessarily.

Comment on lines 221 to 222
void flash_aligned_writer_new(uint8_t *batch_buf,
size_t batch_buf_max_len_bytes,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void flash_aligned_writer_new(uint8_t *batch_buf,
size_t batch_buf_max_len_bytes,
void flash_aligned_writer_new(uint8_t *batch_buf,
size_t batch_buf_max_len_bytes,

And everywhere else, the code is not aligned after copy-paste.

Copy link
Member

@JZimnol JZimnol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malw4 approving in advance, but please make any necessary changes discussed privately

@malw4 malw4 merged commit 3fd28fd into AVSystem:master May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants