Shop OBEX P1 Docs P2 Docs Learn Events
Copy from SD to EEPROM — Parallax Forums

Copy from SD to EEPROM

MagIO2MagIO2 Posts: 2,243
edited 2009-05-12 06:42 in Propeller 1
Hi there.

Today I need some help from you. I have a little problem with my development environment. When I have big programs to write to the propeller, it says 'connection lost'. So, as I have the SD card running, my idea was to copy the EEPROM-file from SD to EEPROM using the·femot SD card driver and the basic I2C driver. I already fixed some little mistakes, but it still does not work. It seems to be copied, but when I do a reset nothing happens.
Could it be a problem to have two 32kB EEPROMs in parallel? But they have different adresses. Do you find something in the code?

      $00006BC0: ' eep
        i2c.Initialize(i2c#BootPin)
        fileName( par_list[noparse][[/noparse]0], @exts )
        ' search for the file on SD card
        found:=sdfat.popen( @fname, "r")
        ' if the cog-program can be found, use it
        if found<>-1
          sstart:=0
          i:=true
          repeat 64                            
            sdfat.pread(@load_buffer, 512)
            j:=@load_buffer
            repeat 8
              if i2c.WritePage(i2c#BootPin, i2c#EEPROM, sstart, j, 64)
                i:=false
                quit
              if (sstart//1024) == 0
                term.tx( "." )
                
              start_time := cnt ' prepare to check for a timeout
              repeat while i2c.WriteWait(i2c#BootPin, i2c#EEPROM, sstart)
                if cnt - start_time > clkfreq / 10
                  i:=false
                  quit
              sstart+=64
              j+=64
            sdfat.pclose
          if i==true
            term.tx(13)
            term.str(@fname)
            term.str(string(" written.",13))
          else
            term.str(string("Write error [noparse][[/noparse]"))
            term.dec(i)
            term.str(string("]!",13))  
        else
          fnf


It's part of a case statement of my CogOS which first makes a hash value out of the command input (·$00006BC0: ' eep )
The load_buffer has 512 longs, because I can load PASM code directly from SD card to COG RAM. I simply use it here again.

par_list is an array of command-line parameters. For strings it's an adress inside the keyboard string-buffer. Numbers are parsed from hex, bin, dec format into binary format and stored there directly.

In theory it should load the complete EEPROM-file in 512 byte pakets and store it in 64 byte pakets (which is the page-size of the EEPROM).

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-11 18:15
    It's hard to tell from your cut and paste, but it looks like the "sdfat.pclose" is indented improperly. The other code appears like it should work.
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-05-11 18:25
    Indeed ... that's it.

    Thank you Mike!

    But unfortunately burning the Turbulence demo did not help ... it's not running. Does it need some hardware to be present?
  • kuronekokuroneko Posts: 3,623
    edited 2009-05-12 02:50
    MagIO2 said...
    But unfortunately burning the Turbulence demo did not help ... it's not running. Does it need some hardware to be present?
    The demo expects ... a demoboard ... or something looking like it (wrt VGA, audio, P0..P8 not driven externally, 5MHz crystal). IIRC, Shazz had some trouble with SD card h/w in that it introduced some glitches but the demo itself did run. What exactly do you mean when you say "not running"?

    You mentioned 2 EEPROMs on different addresses. Where is the turbulence code located? Does your CogOS get in the way of normal program loading? Do simple programs work when burned to EEPROM (like flashing an LED)? The EEPROM check done by the demo consists of reading the first 2 longs from offset 0 of the boot EEPROM and check it against the RAM copy. But getting there implies that it got past the VGA and audio setup.

    Having said that, you could compile from source now and put in appropriate debug code [noparse]:)[/noparse]

    Post Edited (kuroneko) : 5/12/2009 4:06:28 AM GMT
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-05-12 06:32
    Thank you kuroneko!

    The first problem came into my mind last evening .. I'm running my breadboard system with a 10MHz crystal. Wonder if the demo will run if I patch the EEPROM-file to 10 MHz.

    The next problem is the VGA ... I thought it will run on a TV.

    Oh ... did he Linus post the code already ... cool
  • kuronekokuroneko Posts: 3,623
    edited 2009-05-12 06:42
    MagIO2 said...
    I'm running my breadboard system with a 10MHz crystal. Wonder if the demo will run if I patch the EEPROM-file to 10 MHz.
    Should work, at least the video system will cope. Can't remember the audio setup ATM but as it's usually all based on the system clock it should be fine if you run at 80MHz. I was thinking of patching it for the Hydra but using a demo-board was easier [noparse]:)[/noparse]
Sign In or Register to comment.