Shop OBEX P1 Docs P2 Docs Learn Events
Retrieving user code from microcontroller — Parallax Forums

Retrieving user code from microcontroller

travismettravismet Posts: 2
edited 2007-03-22 01:33 in BASIC Stamp
Several months ago I wrote code for a few different versions of a program, which I still have in my computer, but cannot remember which version is in my microcontroller eeprom. I need to know how to retrieve the code from the controller.

Thank you

Comments

  • boeboyboeboy Posts: 301
    edited 2007-03-21 20:49
    It is imposible to get back your code once it is in the basic stamp

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lets see what this does... KA BOOM (note to self do not cross red and black)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-03-21 21:47
    This happened to me once, and I was told the same thing: "Can't be done." But that's not entirely true. If your program is long enough, you can dump enough of it to figure out which version it is. Below is a short program that will dump all but the last 64 bytes of EEPROM to the debug screen:

    '{$STAMP BS2}
    '{$PBASIC 2.5}
    
    i   VAR Word
    dat VAR Word
    
    FOR i = 0 TO $7BF STEP 2
      READ i, dat.HIGHBYTE
      READ i+1, dat.LOWBYTE
      DEBUG HEX4 dat
      IF i & 15 = 14 THEN DEBUG CR ELSE DEBUG " "
    NEXT
    
    
    


    When you upload this program to the BASIC Stamp, it will overwrite about 64 bytes of your program at the beginning (i.e. in upper memory), but will leave the rest of it undisturbed. So when you run it, all but the first 64 bytes of your program will get dumped to the DEBUG screen. You can then copy and paste this data to a file.

    Next upload each of your candidate programs to the Stamp and run the dump program, copying the results of each to separate files. Then you can compare the candidate dumps to your mystery dump to see which one matches.

    -Phil
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-03-22 00:19
    Phil, very clever!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • travismettravismet Posts: 2
    edited 2007-03-22 01:33
    Phil;

    Thanks for the suggestion. I'll try it.

    Travis
Sign In or Register to comment.