Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Self-updating Netduino application ?


  • Please log in to reply
12 replies to this topic

#1 Pyt

Pyt

    Member

  • Members
  • PipPip
  • 18 posts

Posted 14 January 2014 - 06:45 PM

Hello,

 

I have quite a few Netduino devices (2 and +2) deployed in the field. For reasons specific to the installation, I don't have direct access to any of the ports on the devices (usb or serial) and yet I need to perform a remote update of my application.

Through the protocol implemented to communicate with the devices, I have the ability to download just about any content to those devices. That content could be whatever's needed to upgrade the application.

So is there a way to make the application self-updating. The operations that would be required are :

 

1. Get the update code from the server

2. Do whatever's needed to perform the update

3. Reboot into the new application

 

Is there a way of performing step 2 above ? If so, how ? Would you have any pointers to a similar implementation ?

 

Thanks,

Pyt.

 

PS : not sure this is the best forum to post this, but I had to pick one...



#2 MrSmoofy

MrSmoofy

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts
  • LocationOdessa, FL

Posted 14 January 2014 - 06:58 PM

I'm new to netdunio so I don't have all your answers but I have thought about this myself.  I also read about running your program from the SD card on these forums.

 

I'm not sure if there would be a way to update the netdunio's memory where you typically publish your program to while it's running however a thought I had was if what was on the netduino's memory was just code that allowed itself to download program updates and run the program and then the program itself was on an SD card then that would be easier to have the netduino download updates and stop and start the running program.

 

Your still stuck if you need to update the main program that is doing the launching of the program on the SD card and getting the updates but figured I'd pass along my idea.  

 

Again I'm new I've not tried this but based on what I've read it should work.



#3 ShVerni

ShVerni

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationNew York, New York

Posted 14 January 2014 - 07:29 PM

I agree with MrSmoofy: The only way I'm aware to change code without reprograming the Netduino is to use a program loaded off an SD card. It should be possible to have the Netduino connect to a server, download the new code file, reboot itself, and then launch the new code. You would probably want to unload the code from memory first before updating.

 

The downside is that I believe the code is loaded entirely in RAM (though I may be wrong), which would drastically reduce the amount of free RAM you have available, so any RAM intensive programs may be problematic. Your program would have to be small, or split up into multiple code files that could be loaded as needed.

 

For more information on loading programs from the SD card, please see this post:

 

http://forums.netdui...ino/#entry54843

 

There may be other solutions out there that I'm not aware of, and as MrSmoofy said, you couldn't update the program on the Netduino that loads the other programs using this method, so it would be best to make that part as simple and robust as possible.

 

I'd love to hear about any solutions you implement, and best of luck!



#4 Pyt

Pyt

    Member

  • Members
  • PipPip
  • 18 posts

Posted 14 January 2014 - 08:17 PM

Hmmm, interesting thoughts. I will give it a try, but I'm afraid I might run out of ram space.

If we push the concept one step further, is it possible to update the flash from a program that runs entirely in ram and doesn't need the flash ?

Because in that particular case, we could do something like:

 

1. Flash app downloads new binary and loader from the server into the SD card

2. Flash app loads the loader from SD and executes it in RAM

3. Loader updates the flash with the new binary

4. Loader reboots the device

5. We're now running the updated app from flash

 

Any thoughts on step 3 ?

 

Thanks.



#5 MrSmoofy

MrSmoofy

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts
  • LocationOdessa, FL

Posted 14 January 2014 - 08:19 PM

I like your idea, I don't know if it's possible but if so I'd like to know how myself.



#6 ShVerni

ShVerni

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationNew York, New York

Posted 14 January 2014 - 08:35 PM

That sounds intriguing, but I'm not sure about the [font="calibri, sans-serif;"]feasibility[/font]. As I understand it (and I'm by no means an expert), the app on the Netduino flash creates the assembly and method objects when loading a program from the SD card, so they are part of the flash application's RAM. So if the flash application exited (which is probably necessary to write to the flash memory), it would dispose of the assembly and method objects as well. I'm also not sure if the firmware would allow for direct access to the flash memory from managed code, though it may be possible to modify the firmware to allow this.

 

All that is purely speculative on my part, and the only way to know for sure is to try. I look forward to hearing about your results!



#7 Pyt

Pyt

    Member

  • Members
  • PipPip
  • 18 posts

Posted 15 January 2014 - 06:33 AM

That sounds intriguing, but I'm not sure about the [font="calibri, sans-serif;"]feasibility[/font]. As I understand it (and I'm by no means an expert), the app on the Netduino flash creates the assembly and method objects when loading a program from the SD card, so they are part of the flash application's RAM. So if the flash application exited (which is probably necessary to write to the flash memory), it would dispose of the assembly and method objects as well. I'm also not sure if the firmware would allow for direct access to the flash memory from managed code, though it may be possible to modify the firmware to allow this.

The point is that the flash application wouldn't need to exit. The loader would just hard reboot the system. And the loader might have to be partially unmanaged.

Any body has any idea what the flash layout is, where to put the application assemblies and how to burn the thing ? or should I reverse engineer the firmware and/or bootloader ?

Thanks.

 



#8 ShVerni

ShVerni

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationNew York, New York

Posted 15 January 2014 - 05:10 PM

It's certainly worth a try, I don't know much about the flash layout, so I'm afriad I can't help you there.



#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 15 January 2014 - 05:48 PM

Pyt, It's certainly possible to create custom firmware which can store your new app in spare flash, reboot, write that custom firmware into the main app flash and then reboot again to run it. We do something like that on AGENT...although with dual-bank flash and two micros. Chris

#10 Pyt

Pyt

    Member

  • Members
  • PipPip
  • 18 posts

Posted 16 January 2014 - 10:29 AM

Hello, Chris,

 

where can I find the information about the flash, its layout, how it is programmed, the format of the file used to program it, etc... Would you have any sample code ?

 

thanks,

Pyt.



#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 17 January 2014 - 03:53 PM

Hi Pyt, The best resource for information about the MCU, its flash, programming the flash, etc. can be found in: Datasheet (from our Downloads page) STM32F405RG Design Resources (more docs, code, etc.) Chris

#12 Pyt

Pyt

    Member

  • Members
  • PipPip
  • 18 posts

Posted 17 January 2014 - 05:38 PM

I'll try that and report to the forum if/when I've made progress.

 

Thanks

Pyt.



#13 ShVerni

ShVerni

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationNew York, New York

Posted 18 January 2014 - 07:42 PM

I look foraward to hearing what you do, self updating code would be awesome!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.