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

Add FOTA Service mock example #370

Merged
merged 23 commits into from
May 14, 2021
Merged

Conversation

noonfom
Copy link

@noonfom noonfom commented Apr 29, 2021

This PR adds a mock (i.e. no bootloader) example for the FOTA service.

Co-authored by @AGlass0fMilk

@noonfom
Copy link
Author

noonfom commented Apr 30, 2021

For now, let's use my mbed-os fork as ARMmbed/mbed-os#14574 is stuck in review.

Add comments for the update BlockDevice hook and demo FOTA event handler
Copy link
Member

@pan- pan- left a comment

Choose a reason for hiding this comment

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

Excellent submission @noonfom. Once it passes CI we can merge and iterate.

FOTA_OP_CODE_SET_FRAGMENT_ID = bytearray(b'\x43')

# Number of bytes in a single BSC packet, excluding fragment ID
FRAGMENT_SIZE = 128
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be to 19 so it will work on all targets. Ideally we would get the MTU of the link and derive fragment size from it. There's a PR open in Bleak for that: hbldh/bleak#525 .

Copy link
Author

Choose a reason for hiding this comment

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

It can't be 19 as that is not a multiple of the program block size (= 4 for nRF & DISCO). In general, this is a QSPIF configuration option that we can override in mbed_app.json:

{
    "target_overrides": {
        "*": {
            "QSPI_MIN_READ_SIZE": "19",
            "QSPI_MIN_PROG_SIZE": "19"
        }
    }
}

Since 19 is prime. That will only work for nRF and DISCO which use QSPIF. Targets with a different default block device instance will require separate overrides.

Copy link
Member

Choose a reason for hiding this comment

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

That's interesting, we probably need some sort of buffering in the client side to accommodate between the block size and packet length.

Copy link
Author

Choose a reason for hiding this comment

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

I'll leave this open as it's a good observation and the bleak PR is worth keeping an eye. However, a fragment size of 128 data bytes + 1 fragment ID byte (=129 bytes) should work on nRF and DISCO due to the cordio.desired-att-mtu override in our mbed-app.json. Making this 19 would also affect the transfer speed. We can iterate on this PR once it lands in the FOTA service example branch. For now, perhaps we can simply add a note about hardware support in the README?

BLE_GattServer_FOTAService/scripts/test_fota.py Outdated Show resolved Hide resolved
packet_data = bytearray(get_chunk_n(data, FRAGMENT_SIZE, n))
packet_size = len(packet_data)
if packet_size < FRAGMENT_SIZE:
binary_sent = True
Copy link
Member

Choose a reason for hiding this comment

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

How do you handle the case where the last fragment is not received ? It seems to go out of this loop but a new status can be posted by the server.

BLE_GattServer_FOTAService/mbed_app.json Outdated Show resolved Hide resolved
BLE_GattServer_FOTAService/README.md Outdated Show resolved Hide resolved
BLE_GattServer_FOTAService/README.md Outdated Show resolved Hide resolved
BLE_GattServer_FOTAService/README.md Show resolved Hide resolved
BLE_GattServer_FOTAService/README.md Show resolved Hide resolved
Abbas Bracken Ziad and others added 4 commits May 14, 2021 09:04
Co-authored-by: Vincent Coubard <vincent.coubard@arm.com>
Co-authored-by: Vincent Coubard <vincent.coubard@arm.com>
@pan- pan- merged commit c494857 into ARMmbed:fota-service-example May 14, 2021
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.

3 participants