Remotely rebooting NB device

Discussion to talk about software related topics only.
Post Reply
craiglindley
Posts: 19
Joined: Sat Apr 26, 2008 6:19 am

Remotely rebooting NB device

Post by craiglindley »

During code development I periodically loose control of my NB device and would to reboot it remotely (if possible). Under these conditions I can usually use autoupdate to load a new image which reboots the device upon completion giving me back control.

Is it possible to leverage this autoupdate facility to trigger a remote reboot or is there a better way?
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: Remotely rebooting NB device

Post by Chris Ruff »

int DoReboot()
{
AUPRINT( DB_AU, "Reboot\r\n" );
OSTimeDly( TICKS_PER_SECOND * 1 );

/* We need to initialize a number of Coldfire registers and then jump to the reset vector */
USER_ENTER_CRITICAL();
SetSR_IntLevel( 7 );
ForceReboot();
return 1;
}

this is how autoupdate does it....

Do a little experimenting, see what it takes to do it from your app

Chris
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
thomastaranowski
Posts: 82
Joined: Sun May 11, 2008 2:17 pm
Location: Los Angeles, CA
Contact:

Re: Remotely rebooting NB device

Post by thomastaranowski »

I exposed this function via a web interface, and handle it that way.
Adding the USER_ENTER_CRITICAL looks like it would generally be a good
idea. I've never had any problems with it. A more automated approach
might listen on a UDP port for a reboot message. Anyway you look at
it, you're going to need to roll some amount of custom code, as
there's not a built-in way to do it automagically.

int webResetCpuPost(int sock, char* url, char* pData, char* rxBuffer) {
EventLog::post("User initiated reset","");
RedirectResponse( sock, pageNames[FACTORY_DIAG] );
//wait for the response and event log to get out.
OSTimeDly(TICKS_PER_SECOND);
ForceReboot();
return 1;
- Show quoted text -
}


On Tue, Nov 4, 2008 at 12:24 PM, NetBurner Community Forum
<support@embeddedethernet.com> wrote:
> User: Chris Ruff (chris@ruffdesigns.com)
> Subject: Re: Remotely rebooting NB device
> Thread: Remotely rebooting NB device
> Forum: General NetBurner Forums « NetBurner Software
> Mode: reply
> Actions: [reply] [quote] [edit] [delete] [info] [pm] [email]
> int DoReboot()
> {
> AUPRINT( DB_AU, "Reboot\r\n" );
> OSTimeDly( TICKS_PER_SECOND * 1 );
>
> /* We need to initialize a number of Coldfire registers and then jump to the
> reset vector */
> USER_ENTER_CRITICAL();
> SetSR_IntLevel( 7 );
> ForceReboot();
> return 1;
> }
>
> this is how autoupdate does it....
>
> Do a little experimenting, see what it takes to do it from your app
>
> Chris
> Real Programmers don't comment their code. If it was hard to write, it
> should be hard to understand
>
>
>



--
Thomas Taranowski
Certified netburner consultant
baringforge.com
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: Remotely rebooting NB device

Post by lgitlitz »

There are two options I can think of. The first one requires that the NetBurner is aware when it has "lost control".

option 1)
Look at the example:
C:\Nburn\examples\AutoUpdateFeatures
There is a built in call-back function called update_shutdown_func. If you point this to a function it will run every time you do an autoupdate or tcpupdate. You can have this function then check if you "lost control" to perform a reboot with the code provided in the other posts. This can also tell autoupdate to not perform a real update by returning FALSE from your function.


option 2)
Send a _APP.s19 file that has no real data to program. Autoupdate requires that there be at least one S3 and one s7 line in the file but these dont need any real data and should look like this:

S30500000000FA
S70500000000FA

Basically this says that the starting address is 0 with no data to program and the ending address is 0. This will reboot any NetBurner device with autoupdate enabled without programming flash. You can also put an S0 at the top of the file if you want to limit this file to specific module types... for example if you only want this file to work for a MOD5234:

S0MOD5234
S30500000000FA
S70500000000FA

Hope this helps,
-Larry Gitlitz
craiglindley
Posts: 19
Joined: Sat Apr 26, 2008 6:19 am

Re: Remotely rebooting NB device

Post by craiglindley »

You guys are great. I took the approach Larry proposed by building a file called Reboot_APP.s19 with his two line content and it reboots my device right now.

Thanks to all for the help (yet again)
Post Reply