I'm getting started with contiki on the sky mote through a project. I'm trying to get over the air programming to work right now.
I've been looking through examples/sky-shell-exec and apps/shell/. I feel that I need some combination of the functionality that is provided through sky-shell-exec and possibly test-deluge or codeprop. However, reading through the code has lead to me some conceptual roadblocks concerning what code needs to be implemented and what code is already provided in order to get some over the air programming functionality (I'm very new to this and haven't had much embedded systems exposure at all). I apologize for my questions being at sometimes vague and unclear but this is due to my general confusion and don't really know how to proceed any better. I am mainly looking to get something small (example program) working right now that simply can send code to a mote and then that mote be reprogrammed using the sent code (e.g. sent code maybe being just hello-world).
1) How do I simply send code to the mote over the air? I feel like test-deluge is the "wireless" transmission part of the over the air programming problem, but don't fully understand it from the code.
2) What code should be running on a mote in order to receive over the air code?
3) How do I know where this code is stored and then know how to load it? I feel like this step is the sky-shell-exec more or less but again don't fully understand it from the code.
4) I'm reading a lot of things around the web saying that over the air programming is difficult if the code base is large since ram is limited. Where in general am I storing my code when it is wirelessly transmitted and how do I know/verify that it is there? Also, how can I simply know if I will have memory storage problems due to code size (eventually for the project a large code base will need to be transmitted and not just single modules)?
I apologize again for any unwarranted ignorance and I realize there is another thread similar to this one but I've found that I need a more detailed explanation of each component that is mentioned there (thread is: On the Air programming for Contiki).
Thanks
To get over the air (OTA) Programming
working, your own codebase needs to work on top of another layer ( thus other users mentioning too look into the shell examples ).
It is comparable to the Windows kernel that runs an executable and needs to update.
1: Kernel downloads foo and saves this on its filesystem.
2: The kernel terminates the old foo program and starts the new foo program after some required file validation.
3: If everything is ok, the old foo program gets removed.
Now as you can see that at the time of updating your program needs to be twice on the same device ( the old one and the new one ).
I hope this gives more insight in how OTA programming works.
So i will try to answer your questions one by one now:
1) To distribute the files to all other nodes, deluge is used. Now using deluge is indeed quite tricky to use. The following post in the mailing list of contiki gives a basic idea what the code example for sky does. http://permalink.gmane.org/gmane.os.contiki.devel/4884 .
2) Every mote needs a shell needs to run that runs the deluge application. And one sink node ( the one transmitting the newest file ) needs to call the deluge_dessiminate() function to distribute (dessiminate) the new program.
3) The code will be stored in the coffee file system. Deluge will automatically ( behind the scenes of deluge_dessiminate and the deluge app on your sky node ) save the new file on the flash of the sky node. After this is done, you need to run this program by using the ELF loader. Since you need your program to be an ELF compiled file to be run by the contiki ELF_LOADER.
4) I think you mean ROM? But yes, you need extra code to support OTA programming and you need twice the space of the size of your application. All of the modules you say you need you probably need to program yourself on the shell side. file verification can be done by CRC checking your file.
This is indeed a lot of work and I suggest doing this is small steps.
1: Run a program using the ELF loader that is saved on the coffee file system.
2: dessiminate (deluge) your own (random) file from a sink node to the other nodes
3: dessiminate an ELF file.
4: run a deluge_dessiminated file using ELF loader.
and 5: Create a tutorial for the other guys and share the knowledge!
I hope this will help you in any way.
I can't tell you how many times I came back to this post while I was trying to implement OTA in Contiki myself. I know this is an old question, but for anyone looking for a working example, I implemented OTA via CoAP (originally HTTP) for the CC2650, with the server being in NodeJS.
I could be more wordy, but you can just read the tutorial: http://marksolters.com/programming/2016/06/07/contiki-ota.html
It discusses the image architecture, transport mechanism and download validation abstractly, so the information is not really bound to the CC2650 uniquely.
I did not use dynamic linking. I statically linked my binaries and developed a bootloader which writes them to a known flash address. I've never seen elfloader work in Contiki.
Hopefully this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With