Go to Post Oh, for the days of 30-page rulebooks! - EricH [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-12-2004, 16:47
Orborde Orborde is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Apr 2004
Rookie Year: 2003
Location: Indianapolis, IN
Posts: 44
Orborde has a spectacular aura aboutOrborde has a spectacular aura about
Send a message via AIM to Orborde
Recovering code from the RC

For some reason, between the end of last season and now we have managed to lose track of all the source code, hex files, etc. for the software that currently lives in our (2004) robot controller. This wouldn't be a problem except that we want to use said controller to test new ideas with, and the code in it is somewhat specialized (though not TOO different from the default code) and would be annoying to rewrite. So, is there any way to back up the old code off the controller as, say, a HEX file so it can be put back on later if we want?
  #2   Spotlight this post!  
Unread 01-12-2004, 17:03
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Recovering code from the RC

Sorry, I do not believe that an upload is possible.
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #3   Spotlight this post!  
Unread 01-12-2004, 18:57
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Recovering code from the RC

Quote:
Originally Posted by Orborde
So, is there any way to back up the old code off the controller as, say, a HEX file so it can be put back on later if we want?
Try getting in touch with rwaliany or jdong on this board. They've written a loader that talks to the RC for Linux. The command set that the loader uses supports a way to read the FLASH as well, so there's some chance that they could modify their code a little bit so that it would dump out the contents of the FLASH instead of uploading to it.
  #4   Spotlight this post!  
Unread 01-12-2004, 19:34
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Recovering code from the RC

Given that it has been years since I have attempted it, reverse assembly is a pain... You do not have the variable names or constants to reference...
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #5   Spotlight this post!  
Unread 01-12-2004, 19:58
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Recovering code from the RC

I don't think this will help you, but i'm posting it anyway. I know a way to do it, but it requires voiding your warranty as well as a PIC programmer and a bit of know how. If you are willing to be daring and have access to a PIC programmer, then crack open the RC and you will see some pinheaders. One will be labeled somethign like "user" (i don't remember the exact text). This is an ICSP port for the user processor. I'm not sure the order of the pins but it wouldn't be that hard to figure out with an ohmeter and the ICSP spec from the microchip website.
__________________
1139 Alumni
  #6   Spotlight this post!  
Unread 01-12-2004, 20:42
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Recovering code from the RC

Quote:
Originally Posted by Mike Betts
Given that it has been years since I have attempted it, reverse assembly is a pain... You do not have the variable names or constants to reference...
Agreed, but I think the original poster is just looking for a way to save the binary image in the controller so they can restore it later if they want to put their 2004 robot back together again (judging by the request to save it to a .hex file).
  #7   Spotlight this post!  
Unread 01-12-2004, 21:18
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Recovering code from the RC

I think the overall answer to your question is no, and the time you would spend trying to get it to work would be more than that required to rewrite the code.

Although.. this seems like a neat project for any willing able minded programmers!
  #8   Spotlight this post!  
Unread 01-12-2004, 21:32
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
Re: Recovering code from the RC

Quote:
Originally Posted by Rickertsen2
I don't think this will help you, but i'm posting it anyway. I know a way to do it, but it requires voiding your warranty as well as a PIC programmer and a bit of know how. If you are willing to be daring and have access to a PIC programmer, then crack open the RC and you will see some pinheaders. One will be labeled somethign like "user" (i don't remember the exact text). This is an ICSP port for the user processor. I'm not sure the order of the pins but it wouldn't be that hard to figure out with an ohmeter and the ICSP spec from the microchip website.
Before you go and crack it open, give IFI a call, perhaps there's a way to interface the PIC directly with something on the outside of the RC. Don't tell them you're cracking it open though, if they don't answer .

As for retrieving the code in general, you're probably better off just rewriting it, and using the experience two ways. One, teach new programmers how it all works (because it is quite a bit different from writing a generic win32 program), and two, figure out how to use some sort of more robust storage solution, be it backing up your code in several places or something like CVS.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #9   Spotlight this post!  
Unread 01-12-2004, 21:46
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Recovering code from the RC

Quote:
Originally Posted by Ian W.
Before you go and crack it open, give IFI a call, perhaps there's a way to interface the PIC directly with something on the outside of the RC. Don't tell them you're cracking it open though, if they don't answer .

As for retrieving the code in general, you're probably better off just rewriting it, and using the experience two ways. One, teach new programmers how it all works (because it is quite a bit different from writing a generic win32 program), and two, figure out how to use some sort of more robust storage solution, be it backing up your code in several places or something like CVS.
I started to think about this and got excited. Then realized it is not possible to access the necessary 4 pins from the outside. You can only access 3 out of 4 of them from the outside SO CLOSE!!!
Just for the info the 3 are as follow:
GND- any ground anywhere on the RC will do
PGC(program clock)(RB6)- Digital I/O 5
PGD(Program data)(RB7)-Digital I/O 6
MCLR(master clear/reset)- No hope of accesing this from the outside
__________________
1139 Alumni
  #10   Spotlight this post!  
Unread 01-12-2004, 23:04
Orborde Orborde is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Apr 2004
Rookie Year: 2003
Location: Indianapolis, IN
Posts: 44
Orborde has a spectacular aura aboutOrborde has a spectacular aura about
Send a message via AIM to Orborde
Re: Recovering code from the RC

Thanks very much for your help and extremely rapid response, folks. Since there doesn't seem to be an off-the-shelf solution, I'll just overwrite whatever's on there and reconstruct it later from notes, I guess. No warranty-voiding for me. I suppose I'll pm these fellows rwaliany and jdong, and if they've got something clever by tomorrow afternoon, I'll try it. I was planning tomorrow to have a software team meeting and go over compiling and downloading code to the controller, and I'll just overwrite the old code.

Quote:
Agreed, but I think the original poster is just looking for a way to save the binary image in the controller so they can restore it later if they want to put their 2004 robot back together again
Exactly. Though reverse assembly would be quite impressive and even more useful, I just want to maintain the current functionality without having to recreate it from scratch.

Thanks again.

Last edited by Orborde : 01-12-2004 at 23:09.
  #11   Spotlight this post!  
Unread 01-12-2004, 23:25
Venkatesh Venkatesh is offline
Registered User
FRC #0030
 
Join Date: Jan 2003
Rookie Year: 2002
Location: USA
Posts: 260
Venkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to behold
Re: Recovering code from the RC

As an academic challenge, this would be incredibly fun, to force code from an on-core flash/nonvolatile space.

As far as I know, the User processor (PIC) stores its code in an onboard flash region. Since this flash region is not separate from the PIC, it would be incredibly difficult for one to read data from that flash/nonvolatile space. Also since the bus between the nonvolative region and the CPU Core would be inside the IC, it would become even more difficult.

The only possibility I see is:

1) Connect the I/O pins of the PIC to an independent flash/nonvolatile region
2) Then overwrite only a tiny portion of the existing code, which a JMP to code in the external flash
3) Then have the PIC's reset vector targetted at the JMP in the main flash space.
4) The code on the auxiliary flash space should be able to direct the PIC to read code from the main flash space (or read the exact contents of memory, more accurately).
5) The code on the aux. flash should then direct the PIC to forward the recovered data via Serial/other to a PC/other.

This procedure is very difficult to accomplish, since it depends on partial-erase of a flashchip attached directly to a CPU. Also it depends on the CPU being able to execute code directly out of an external region and map that external region as part of the main memory space.

Manufacturers spend time defending chips against code hijacking, so Microchip might be able to help... Other than that, good luck.

And btw, I am interested in the details of the read technique you detail, Rickertsen2. Please enlighen me. Thanks

And good luck with the controller.
__________________
-- vs, me@acm.jhu.edu
Mentor, Team 1719, 2007
Team 30, 2002-2005
  #12   Spotlight this post!  
Unread 02-12-2004, 00:21
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Recovering code from the RC

Quote:
Originally Posted by Venkatesh
As an academic challenge, this would be incredibly fun, to force code from an on-core flash/nonvolatile space.

As far as I know, the User processor (PIC) stores its code in an onboard flash region. Since this flash region is not separate from the PIC, it would be incredibly difficult for one to read data from that flash/nonvolatile space. Also since the bus between the nonvolative region and the CPU Core would be inside the IC, it would become even more difficult.

The only possibility I see is:

1) Connect the I/O pins of the PIC to an independent flash/nonvolatile region
2) Then overwrite only a tiny portion of the existing code, which a JMP to code in the external flash
3) Then have the PIC's reset vector targetted at the JMP in the main flash space.
4) The code on the auxiliary flash space should be able to direct the PIC to read code from the main flash space (or read the exact contents of memory, more accurately).
5) The code on the aux. flash should then direct the PIC to forward the recovered data via Serial/other to a PC/other.

This procedure is very difficult to accomplish, since it depends on partial-erase of a flashchip attached directly to a CPU. Also it depends on the CPU being able to execute code directly out of an external region and map that external region as part of the main memory space.

Manufacturers spend time defending chips against code hijacking, so Microchip might be able to help... Other than that, good luck.

And btw, I am interested in the details of the read technique you detail, Rickertsen2. Please enlighen me. Thanks

And good luck with the controller.

Grrr!!! I just spent quite a bit of time typing a long detailed explanation of how the method you mentioned could work, and how my method works, but it was lost due to a bug in the forum software that occurs when you try to post something and are not logged in.

Since i really don't feel like rewriting everything, here is the cliff's notes version

*the pic does have support for external memory up to 2Mb and has external pins that connect to the memory bus. thye are multiplexed with some other things and must be configured as memory bus pins.
*the pic can execute code from ecternal memory and can even boot from it
*read sections 6 and 4.1 of the datasheet for more info on external memory
*the problem lies in configuring the pic to boot off of external memory. this requires changing a few bits in the configuration section of the onboard FLASH. In order to write to flash, it must first be erased. I'm not sure whether or not ICSP supports selectively erasing little bits of the FLASH at a time. I know it supports killing the entire thing at once but i doubt you can erase little bits at a time. This would pose a huge security risk as it would allow you te reset the code protect bit as well. keep reading if you don't know what the code protect bit is.


*pics are usually programmed through a synchronous serial interface microchip calls ICSP (in circuit serial programming)
*details on ICSP and the 18f8520 are at: http://ww1.microchip.com/downloads/e...Doc/39583b.pdf
*ICSP has facilities for reading back the data from the onboard FLASH. This is usually done after programming the chip to verify that everything was written correctly, but it can be done at any time. You can do this with any PIC programmer.
*there is a bit in the configuration section of the flash that prevents you from being able to read back the contents of the FLASH. It is called the "code protect bit"
*I'm pretty sure the code protect bit isn't set in our case. There is a setting the in MPLAB project setting that toggles it. Its not set in the default code project, but it could always be overided by IFILoader before the .hex file is uploaded, although i doubt this. There is no point in protecting us from our own code.

I think a really interesting project would be to add a 2mb FLASH chip to the RC. Think of what you could do with that much program space!
__________________
1139 Alumni
  #13   Spotlight this post!  
Unread 02-12-2004, 08:59
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Recovering code from the RC

Quote:
Originally Posted by Rickertsen2
I think a really interesting project would be to add a 2mb FLASH chip to the RC. Think of what you could do with that much program space!
Sorry if this was said already in the above jumble of pin designations, but are the necessary pins needed to tag memory on accessible without cracking open the RC? Would it be FIRST legal to use this in a competition? The possiblities...
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #14   Spotlight this post!  
Unread 02-12-2004, 17:34
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Recovering code from the RC

Quote:
Originally Posted by Matt Krass
Sorry if this was said already in the above jumble of pin designations, but are the necessary pins needed to tag memory on accessible without cracking open the RC? Would it be FIRST legal to use this in a competition? The possiblities...
Unfortunately they are not
__________________
1139 Alumni
  #15   Spotlight this post!  
Unread 04-12-2004, 19:25
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Recovering code from the RC

Quote:
Originally Posted by Rickertsen2
I started to think about this and got excited. Then realized it is not possible to access the necessary 4 pins from the outside. You can only access 3 out of 4 of them from the outside SO CLOSE!!!
Just for the info the 3 are as follow:
GND- any ground anywhere on the RC will do
PGC(program clock)(RB6)- Digital I/O 5
PGD(Program data)(RB7)-Digital I/O 6
MCLR(master clear/reset)- No hope of accesing this from the outside
Would you only need these for downloading to the PIC? or just uploading from?
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is your most prefered programming language? Hailfire Programming 156 19-01-2005 21:42
Sourceforge for Code Repository and other stuff SilverStar Programming 9 15-01-2005 21:16
heres the code. y this not working omega Programming 16 31-03-2004 15:18
Inserting Naviagation code into Default code? actorindp Programming 3 28-01-2004 18:12
Does your team use the Default code. Jeff McCune General Forum 2 09-01-2003 14:46


All times are GMT -5. The time now is 06:00.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi