Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Apr 29, 2021

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

Co-authored by @AGlass0fMilk

@ghost ghost requested a review from pan- April 29, 2021 18:48
@ghost ghost mentioned this pull request Apr 29, 2021
@ghost ghost requested review from AGlass0fMilk and paul-szczepanek-arm April 29, 2021 18:58
@ghost
Copy link
Author

ghost 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?

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.

@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.

2 participants