Shop OBEX P1 Docs P2 Docs Learn Events
Extracting a program from basic stamp2 — Parallax Forums

Extracting a program from basic stamp2

matt_burrowsmatt_burrows Posts: 6
edited 2005-09-09 21:31 in BASIC Stamp
I lost the only version of the program that I wrote·(I was working from a floppy) and the only place it resides is the memory of the basic stamp 2. I really don't want to have to re-write the program, as I'm sure I'll never get it working quite the same again. How do I extract my program back out of the stamp?

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-06 17:56
    It will be far easier to rewrite your program than to remove the EEPROM, pull the contents out manaully (with a proper EEPROM reader), then attempt to decifer the tokens back into a usable program. Trust me, there is no practical (emphasis on practical) way to do what you're asking. The source code is compiled into tokens and all of your symbolic names and comments are lost in the process.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-09-06 20:00
    Yup, while not designed this way to deter reverse-engineering, the BS2 has a pretty good way of protecting intellectual property. It CAN be done, as Jon indicated above, along with the steps necessary. However, for a $50 part, which has 2 K Bytes of program storage space, programmed in PBasic, it's usually not cost effective.

    Lesson learned: Make at least two copies of each program, or make a regular backup of your hard disk. Save early, save often!
  • matt_burrowsmatt_burrows Posts: 6
    edited 2005-09-06 20:16
    Thanks. Under what conditions could the chip lose its program, and how likely are said conditions to arise? I'm going to get to work on the program again, but I don't plan on uploading the new one untill I have to.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-06 20:47
    None except an extreme failure (if you have WRITE in a loop that goes out of control you could, theoretically, overwrite your program) or downloading a new program.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-09-06 21:04
    We did have a customer's stamp lose it's data- it was struck by lightening.

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke

    Parallax Tech Support
    rclarke@parallax.com
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-09-06 21:18
    The EEPROM that the BS2 uses to save its data is quite reliable. Limitations: Apparently it fails if struck by lightening (but so will most of the rest of the chips on the module. You can only write to it about a million times before memory locations stop accepting data -- but that's usually not a problem with 'normal' programming.

    The "load" cycle for the eeprom is a slightly involved hand-shake on the serial lines between the BS2 and the PC's Parallax IDE -- VERY unlikely to be triggered at random, so that should be OK too.

    So the only time it changes is when the IDE erases it in preparation for downloading a the tokens of a new program.
  • matt_burrowsmatt_burrows Posts: 6
    edited 2005-09-09 16:35
    Thanks guys. I have one more question though. Allanlane5 mentioned that the EEPROM can only be written to aprox. 1 million times before going bad. Does this only apply to the actual WRITE command, or does using variables count as writing to memory? The program I wrote doesn't use the write command, but writes to and reads from a number of variables in loops non stop. Could this be bad?
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-09-09 16:53
    Nope, only programming, and the "WRITE" keyword, actually modify the EEPROM, and affect the "number of writes" issue. "Normal" variables are actually kept in registers on the PIC chip, and thus can be read and written to forever.

    Post Edited (allanlane5) : 9/9/2005 5:02:49 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-09 16:53
    Downloading a program and using the WRITE keyword are the only things that affect the EEPROM. Normal variables are stored in RAM, so there is no problem there.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • matt_burrowsmatt_burrows Posts: 6
    edited 2005-09-09 21:31
    Thanks so much for all your help!
Sign In or Register to comment.