-
Notifications
You must be signed in to change notification settings - Fork 8
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
Service Proposal: FOTAService #46
Comments
Thanks for the comprehensive description. It looks excellent and it is easy to understand how the software would work thanks to the diagrams you provided. I'm afraid of an overflow of the sequential fragment ID. Maybe we can pack fragments into block (not in the sense of BockDevice block) or packet of data that should not exceed a size of To extend on that idea, it should be possible for a server to indicate to the client the recommended block size to avoid When One last thing: it would be useful to report to the client the version of the update service so it can adapt if something has to be changed in the flow. |
Thanks 😄
What is your fear of the overflow? The DFUService (#13) I tested worked fine with an overflow at 127. For anything bad to happen, 256 I don't like the idea of introducing another complexity, the "block size" parameter. @pan- Can you expand on what your fear of the fragment ID roll over is? I might be convinced 😁
I think this is a reasonable and simple change.
Also reasonable and simple change. Should it be a separate characteristic or something like an op-code with a status notification response? |
I'm afraid of clients with high latency which might miss the We can try what is proposed for a start and let integrity checking to the firmware installer. The client should be able to go backward if the fragment id reported in SYNC_LOSS is greater than the current fragment id on the server. |
@pan- Added |
I'm having trouble writing unit tests for the FOTA service. The service requires Right now I have it at the point where this is the build error:
I had to add mbed-os-experimental-ble-services/tests/UNITTESTS/FOTA/CMakeLists.txt Lines 10 to 15 in 59c6bb2
to get the service to compile -- the I've pushed up my most recent changes to the fota-service branch so you can try to build/run the tests yourself if necessary. Any assistance would be greatly appreciated! I will have to move onto integration testing at this point -- I have customer projects that need this service. |
That's odd, I was thinking |
|
maybe the solution is to have a mbed_assert.h replacement |
@AGlass0fMilk It looks like the assert stub is not being compiled. It's a bit strange because other files in the same location are being linked. Also, we appear to include all stubs in the top-level unit testing cmake. We will need to investigate this further... For now, can you add target_sources(${TEST_NAME}
PRIVATE
test_FOTA.cpp
${SERVICES_PATH}/FOTA/source/FOTAService.cpp
${MBED_PATH}/UNITTESTS/stubs/mbed_assert_stub.cpp
) In relation to the config macros, I think you have to use |
Misunderstood the problem, turns out there's an issue with mbed-os stubs. This is now tracked in jira. |
Add The bigger problem is rebase onto github-ci. Are you OK with me recreating this branch with your code changes squashed on a branch from the github-ci? |
@pan- @paul-szczepanek-arm @noonfom |
I enabled the tests on the new branch: ARMmbed:fota-service-github-ci please use that for your PR |
@AGlass0fMilk Thanks for adding the integration tests. I ran them on Windows 10; and, except for the usual problems with the bleak .NET backend, everything worked fine. However, I am curious: why do you wrap BSC writes in an await asyncio.wait_for(self.client.write_gatt_char(UUID_BINARY_STREAM_CHAR, packet), timeout=0.2) Other comments:
By the way, I really like the README. The sequence diagrams make it easy to understand the service and tests. IMO, we should add similar documentation for the other services. |
In my time working with the bleak library, I've encountered a strange issue where writes can take a very long time. The delay seems to be arbitrary and adding a small delay using See this comment here: hbldh/bleak#338 (comment)
Essentially what I'm trying to accomplish with these configurations is to set the preferred MTU to 128 bytes. Can you comment on what similar configuration parameters for the other BLE-enabled targets would be? I should mention I do all my testing on nRF52-based targets. I do have a Nucleo WB55 that I could test on however.
We can remove it.
This is application-specific behavior and so I didn't think it should be tested. There is no real firmware update happening, just a testing of the transfer and error correction mechanisms.
I think we can open the scope of this library a little bit to include things like
Thanks! I based the basic format off of the LinkLossService documentation. The README served as a guide as I developed the service and tests. |
@AGlass0fMilk We really like the proposal and are willing to help to get this through. I think a first step would be to open a pull request, it is easier to comment code here. A second step could be to tell us which area you would need help with. We've been thinking of several:
|
Hi @pan-, I just got back from a long weekend holiday. I will also be out the 9th through the 19th FYI. I will open a pull request this week so your team can continue work on this.
Yes, that would be useful. Are you planning to actually showcase firmware being updated? If so, do you plan on bringing in something like mcuboot or something simpler (ie: not secure, for demonstration only)?
I was going to base the unit tests of those for the
The easiest client to make would be to simply take the integration test python code and instead make a real FOTA client for it. This would cover use cases on Windows, Linux, and Mac, since I would love to have example clients for Android/iOS. I actually got a Macbook set up recently to play with this on iOS but I haven't had time to yet. Ultimately, what I'd like to do is make a cookiecutter or copier template that would let users quick start an Mbed application that uses the Mbed-OS mcuboot bootloader, BLE, and the FOTAService here. |
I think we would start with a mock then replace it with an mcuboot implementation. A decent client written in python and bleak could be a good first step and it shouldn't be too complex to write. I really like the idea of a template generator for a Bluetooth project where all the boilerplate for firmware update and setting up BLE is made for you. |
@pan- Can you create an ARMMbed repository for the BLE DFU example? I'm working on the implementation now and I can put the work there so your team can view it and work on it as well. |
I created one here and invited you for collaboration. As soon as we have something ready we will move it into mbed-os-example-ble. |
@AGlass0fMilk I hope you enjoyed your vacation! @pan- and I were thinking that it would be good to add two FOTA Service examples to mbed-os-example-ble:
I started working on (1) during our last team sprint. Basically, I took your example and stripped out MCUboot. I also encountered the issue you reported here. Turns out the BLE trace helper for UUIDs was performing rogue memory accesses. Perhaps, you could cherry-pick this commit and try your example again? Please let me know what you think of our plan for the examples and if there's anyway we can help with the FOTA Service PR. |
@noonfom Sorry for the long delay, I've been working on customer projects constantly since I got back. I agree with the path forward that you've set -- it makes complete sense to have a basic example that doesn't put any constraints on the bootloader. As for the FOTA service PR, I will open one soon. According to the Mbed roadmap (and as was discussed on the governance call), there's a plan to integrate mcuboot into Mbed in Q4 of this year. I'm hoping we can move that up as that's what I've been working on at present. I think it's relevant to this service as well. I have a bunch of scripts to automate building the bootloader and application, signing the application, and creating factory programming binaries (bootloader + signed app merged) as well as OTA update binaries (just signed application). These are all shell scripts written on Ubuntu though and I think we can streamline the whole process using CLI2/cmake. I am not yet familiar enough with cmake to come up with exactly how though. @pan- @noonfom would you be interested in setting up a call where I can demo the state of my mcuboot + Mbed integration and we can formulate a plan to refine it so it's up to Mbed's quality standards and is easier to use? |
Definitely, that's why I don't want to wait Q4 to start working on the Mbed OS example with MCU boot, what you've done, what has been done with the CSPs example should help in moving MCU boot integration into Mbed faster. So what happen in Q4 is mostly upstreaming.
Please send an invite. I would be interested in discussing about MCUboot but also continuous integration and CMake integration. |
BLE Standard Service:
Proposed UUID(s) or link to specification document:
See specification and documentation on fota-service branch here:
https://github.com/ARMmbed/mbed-os-experimental-ble-services/tree/5328cacea69452901a691b7380366b6a188cf503/services/FOTA
@pan- @noonfom @paul-szczepanek-arm I took aspects from our discussion in #13 and wrote up a more formal specification README, taking the LinkLossService as an example.
The newly-renamed
FOTAService
strips out some complexity from my original DFUService proposal. I think the new specification covers the most basic use cases while providing for more advanced features and extensions in the future.I have yet to refactor the code, but I'm planning to split off the
BlockDevice
dependency into standardFOTAService::EventHandlers
that we provide. A user can implement their own custom logic if they wish, but we can provide a basic event handler for writing to a given block device. This also serves as a way for us to provide modular extensions (eg: delta updates, trigger connection parameter updates, etc) in the future as part of our standard library of event handlers.Before I go much further on the code and tests, I wanted to get your feedback.
Let me know what you think and if I missed any corner cases.
The text was updated successfully, but these errors were encountered: