Shop OBEX P1 Docs P2 Docs Learn Events
Lost spin program - can I retrieve from EEPROM? — Parallax Forums

Lost spin program - can I retrieve from EEPROM?

softexsoftex Posts: 27
edited 2014-01-15 02:44 in Propeller 1
Just got caught in the propeller tool quirk of not saving when compiling, so I have a couple of days work in ya-ya land. My quirk is often compiling to EEPROM instead of just to RAM so I have a recent version now residing on EEPROM. I don't like my chances, but is there any way I can retrieve this back to spin code?

-Dave

Comments

  • RaymanRayman Posts: 14,662
    edited 2009-02-09 02:12
    You need Hippy!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-09 02:15
    No, not realistically.

    The original program does not exist in the Propeller. The Propeller Tool compiles the program into interpretive code which is quite compact. It's possible to read the EEPROM with another program in RAM and dump the contents of the EEPROM to a PC for example. There is a debugger that is available that can disassemble the information from the EEPROM into Spin interpretive code source, but this is not something that can be recompiled. It could painstakingly be hand translated into Spin, but there are no variable names or method names and the deconstruction is difficult at best. Practically speaking, you can't retrieve it as Spin source, certainly not meaningful Spin source code.
  • softexsoftex Posts: 27
    edited 2009-02-09 03:27
    Thanks anyway guys. I'm old enough to know better. But this IDE really SHOULD be saving on compiles - like most other editors. So the non-saving habit gets ingrained elsewhere, and jumps up an bites you in the *** here.

    -D
  • mctriviamctrivia Posts: 3,772
    edited 2009-02-09 03:33
    i don't know how often it does it but 1.2 does save periodically to a seperate file so you can recover if the program crashes. saving on each build is not necisarily a good thing. what if you make a change and it reques haviq? you can always not save and reload old code.
  • BradCBradC Posts: 2,601
    edited 2009-02-09 13:18
    mctrivia said...
    i don't know how often it does it but 1.2 does save periodically to a seperate file so you can recover if the program crashes. saving on each build is not necisarily a good thing. what if you make a change and it reques haviq? you can always not save and reload old code.

    That is where you want a nice deep undo buffer [noparse]:)[/noparse] You can save to your hearts content and as long as you have not close the editor you can always "ctrl+z" your way back to where you want to be.

    The Propeller tool appears to save a recovery of some sort prior to each compile..

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cardinal Fang! Fetch the comfy chair.
  • heaterheater Posts: 3,370
    edited 2009-02-09 14:38
    I don't know about that Brad. I've used many an editor that would allow you, after many hours of editing, to undo all the way back to an empty file. If that's where you started from. Trouble is after not very long it gets hard to tell how much undoing gets you to where you want to be. And it does not save you from an editor crash or computer outage.

    Personally I think an editor should snap shot frequently such that if it crashes or your computer goes down most of your work is intact somewhere.

    A save before compile usually suffices if you are in the habit of at least checking what you have done so far is at least syntactically correct.

    Then I think a save of what actually does compile without errors is more important than the intermediate junk and should be identifiable as such. But then whatever compiles and actually runs in some way is even more important and should be identifiable as such.

    But now we are in the world of backups and version control which probably don't belong in an editor and people should get into the habit of using anyway[noparse]:)[/noparse]

    By the way I seem to have a problem where the Parallax tool gets into a mode where it compiles what was last saved and not my recent, unsaved, edited version. Gets very confusing when I make a change and everything runs the same. Perhaps I have an old version now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.

    Post Edited (heater) : 2/9/2009 3:09:55 PM GMT
  • heaterheater Posts: 3,370
    edited 2009-02-09 14:59
    Softex, don't worry. Feels like a disaster when it happens but look on the bright side, you normally get a much better program the second time you write it[noparse]:)[/noparse]

    Seriously. I've heard that proposed as a software engineering practice.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • RiJoRiRiJoRi Posts: 157
    edited 2009-02-09 16:14
    I use a program that periodically backs up the files to a backup directory. It adds some Unix-like time stamp* to the file name to differentiate between saves.

    --Rich
    * Something like the number of seconds since the world began.
  • soshimososhimo Posts: 215
    edited 2009-02-09 16:53
    How about an option to allow lazy propeller programmers the ability to save on compile (I'm one of those lazy ones trust me). It can be off by default so the existing user base who doesn't care or who specifically does not want that setting to be on. I think that satisfies the needs of both camps. I have been using visual studio and it's many incarnations myself for over 10 years and the whole save on compile has become ingrained - in fact I use compile sometimes as a quick mechanism to save since I have the compile hot keys burned into my psyche.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-02-09 17:10
    Of course I am somewhat biased, but I wouldn’t want the IDE auto-saving on me…quite often I load a piece of code to test something and it often involves quickly changing a pin number. In that case auto-saving would be bad since I don’t want to affect my original demo files.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • RaymanRayman Posts: 14,662
    edited 2009-02-09 17:14
    I'm with soshimo...
  • hippyhippy Posts: 1,981
    edited 2009-02-09 18:01
    I hate auto-save on compile - found out the hard way when I deleted a whole load of code to try and resolve a syntax error in one line and lost everything else smile.gif As an option it would be acceptable.

    As to recreating Spin ( and any PASM ) from Eeprom; I estimate it is technically 98% doable, but not doable at present, and human readable stuff like variable, constant and object names etc would be lost. May be useful if desperate or determined to thieve someone else's code but I'd usually take a lost source as a golden opportunity for a rewrite in half the time and have a result twice as good.

    Spin is easier to decompile and reconstruct source from than most compiled languages because there's almost zero optimisation, it's all bytecode and the bytecode is predictable for each Spin language construct. It's all in a well defined order and format so it's relatively easy to take a bytecode sequence and deduce what it was created from. The biggest challenge I think is in determining array sizes.

    It should be possible to decompile Eeprom to source and be able to recompile that back to the exact same image but I haven't tried it because, while a fun challenge and worthy of a kudos badge, there didn't seem a lot of point to it when there are other things to do. But if someone has a couple of large suitcases full of dollar bills ...
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2009-02-09 18:28
    I do not appreciate the auto save on compile in other IDE's. I like to do my own style of version control, and the way the prop IDE is set up works fine for me.

    Are you certain that your code is lost softex?

    If so, bite the bullet, rewrite your code, and realize that the second time around you will probably do it better anyways.
  • heaterheater Posts: 3,370
    edited 2009-02-09 18:36
    Thing is there is a difference between that file on disk that you have just opened and the thing in the editor you are busy mangling.

    So I would argue that save on compile is a no no, a file should not be changed unless I say so. But the thing loaded in the editor should not be lost unless I say so either, like when the editor or computer bombs out. So there should be periodic snapshots somewhere other than the original file. Or perhaps I log of changes until those changes are committed. Editors like vi will do that.

    Or perhaps we should use VMS with its versioning file system. I do miss that some times.

    Still that brings us back to version management. Its very comforting to know every version of everything you ever did is safe in cvs or svn or something.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • softexsoftex Posts: 27
    edited 2009-02-09 23:27
    I lost the file by "cleverly" and intentionally closing the tab after cutting and pasting a bunch of junk that didn't work, and then figured that by just closing the tab and selecting "do not save" I could just re-load the previously "saved" version and not have to undo everthing. Sort of a poor-man's revert. The previous file was saved alright - about four days ago. When I realized what I did you could have heard me in the next area code. Anyway, I got off light - most of what I have been doing lately is messing with graphics.spin and trying to figure it out, so its not like I've been cranking voluminous code. I've already restored what I lost, and yeah, its probably a bit better. A tad frustrating and embarrassing is all. I'm sure none of you guys have ever done any such thing???

    -D
  • BradCBradC Posts: 2,601
    edited 2009-02-10 00:17
    soshimo said...
    I have been using visual studio and it's many incarnations myself for over 10 years and the whole save on compile has become ingrained - in fact I use compile sometimes as a quick mechanism to save since I have the compile hot keys burned into my psyche.

    Wherever you have an "editor" and a "compiler" rather than a properly integrated environment then save-on-compile is a must, as the compiler has no other way of getting the information out of the IDE.
    Some people like it, some people don't. Its not hard to make it an option unless you are using a poorly integrated "IDE" and have no choice, in which case you are stuck with it.

    Personally I don't like save-on-compile for precisely the reasons detailed by Chris and Hippy, but I would have no problem with the Propeller Tool having an option to do just that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cardinal Fang! Fetch the comfy chair.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2009-02-10 00:29
    softex, there is an autosave on compile built in whose restoration feature is automatically invoked on an IDE crash (you can invoke this manually by killing the process), but your actions circumvented it's operation because you were trying to be clever. You should never assume that an IDE has revision control built into it. There are products out on the market both free and for money that provide revsion control outside of the IDE, you should look into instaling one of these on your computer. To get this to work the way you want it to, you revsion control the autosave file the IDE creates, each time you compile the revision control software will save a copy allowing you to rever back to any compile.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker


    Post Edited (Paul Baker) : 2/10/2009 12:35:39 AM GMT
  • mctriviamctrivia Posts: 3,772
    edited 2009-02-10 00:55
    my sugestion get in the habit of saving periodically. zipping all asociated files and storing in an external array. Drobo is extremely slow but does provide a great large redundant backup.
  • mctriviamctrivia Posts: 3,772
    edited 2009-02-10 00:56
    oh and if really paranoid get this www.thinkgeek.com/gadgets/security/abd9/
  • RaymanRayman Posts: 14,662
    edited 2009-02-10 00:57
    Just use Vista... It has a "previous versions" volume shadow copy feature...
  • mctriviamctrivia Posts: 3,772
    edited 2009-02-10 00:58
    it also has crash your computer and not work with anything options also.
  • soshimososhimo Posts: 215
    edited 2009-02-10 01:36
    BradC said...
    Personally I don't like save-on-compile for precisely the reasons detailed by Chris and Hippy, but I would have no problem with the Propeller Tool having an option to do just that.

    Exactly why I said keep it as an option. I typically use source level control with the minimum being a self hosted SVN repository. I am very paranoid about losing code and if I need to make large changes in the trunk I will create a branch, otherwise I make sure I "post small and post often". Proper CM techniques and programmer discipline should prevent most "accidents". The only thing it doesn't prevent against is catastrophic failure or the lack of discipline in saving - which is something I've unfortunately acquired using a "poorly integrated IDE".
  • mctriviamctrivia Posts: 3,772
    edited 2009-02-10 01:40
    another option is do like eagle does and keep older versions as .spin1 .spin2 ... were higher numbers equal older files.
  • GiemmeGiemme Posts: 85
    edited 2009-02-10 10:35
    hello

    my advice is to attached the propeller IDE with a subversion repository and setup 3 environment:
    - Development
    - Test
    - Production

    Check-in/Check-out the files
    Backup regulary the subversion repository

    I promise you that no file are going to be lost

    Regards
    Gianni
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-02-10 16:39
    Best backup in the world... upload your work to the forum.. [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Check out: Protoboard Introduction , Propeller Cookbook 1.4 & Software Index
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • gio_romegio_rome Posts: 48
    edited 2014-01-15 02:30
    (I too lost a SPIN codee)

    With the program already in the EEPROM how is it possibile to _run_ another program into the RAM, since on boot time the chip will discard it in favour of the EEPROM program?

    Question anyway is: can the original (in EEPROM) program be retrieved at least in bytecode/compiled code, i.e. can be backed up at least in that form, so that I can do my things (rewrite it :/ ) without fear of losing it?

    Gio
  • Heater.Heater. Posts: 21,230
    edited 2014-01-15 02:44
    Wow, reviving a good old thread here.

    You can always program from the Prop Tool or BST or whatever into RAM without messing up the EEPROM. Be careful not to hit the program EEPROM buttons.

    So if you want to read the old programs binary from EEPROM you can write yourself a program which is run from RAM and:
    1) Reads the EEPROM bytes. There must be I2C drivers in OBEX that can do this.
    2) Sends them to the PC. Use the FullDuplexSerial object.

    Personally if the EEPROM content is valuable to you I would remove it from the Prop Programming pins and connect it to some others. Just to be sure you don't accidentally over write it with the Prop Tool or whatever.

    Also I'd probably want to do the programming into RAM of the recovery program from a command line loader. Then use hyperterminal or some Linux terminal program to capture the HEX bytes that come out.
Sign In or Register to comment.