Shop OBEX P1 Docs P2 Docs Learn Events
Boot code from SD — Parallax Forums

Boot code from SD

BTXBTX Posts: 674
edited 2012-12-01 14:55 in Propeller 1
Hi all.
I would like to boot some different propeller code using "fsrw with safe_spi" like Kye did it in his "SD-MMC_FATEngine" code.
The point of why I can't use the Kye code is, that is so slow reading blocks of data from SD for my application, instead fsrw let me enough speed, but it has not bootpartition rutine...
Anybody has some code of what I ask for ?
All obex bootloaders I saw, use another slow code/methods.. :( unless I miss some...

Thinking in modify the safe_spi (which could be a nightmare for me), where should I read about to load propeller RAM for launch code ?
Thx in advance.

Comments

  • SapiehaSapieha Posts: 2,964
    edited 2012-12-01 14:50
    Look on thread we discussed -- Booting Propeller II from SD

    BTX wrote: »
    Hi all.
    I would like to boot some different propeller code using "fsrw with safe_spi" like Kye did it in his "SD-MMC_FATEngine" code.
    The point of why I can't use the Kye code is, that is so slow reading blocks of data from SD for my application, instead fsrw let me enough speed, but it has not bootpartition rutine...
    Anybody has some code of what I ask for ?
    All obex bootloaders I saw, use another slow code/methods.. :( unless I miss some...

    Thinking in modify the safe_spi (which could be a nightmare for me), where should I read about to load propeller RAM for launch code ?
    Thx in advance.
  • MagIO2MagIO2 Posts: 2,243
    edited 2012-12-01 14:55
    There is a fsrwFemto which implements a bootsd as well. But I guess it is also lots slower than the later versions of FSRW.
    As far as I remember the later versions of SDSPI really need all of the COG-RAM, so you can't add the boot-code to that directly. I'd simply write some own PASM code which uses SDSPI to load an EEPROM-file.

    1. A little change is needed in popen which needs to return the first sector of the file:
             if (mode == "r")
                frem := (clustersize) <# (filesize)
                return datablock
    
    Just search for the if (mode =="r") and I think the return has been changed from 0 to datablock.
    2. The PASM code has to stop all COGs that are running except the sdspi-COG and itself of course
    3. the PASM code needs to reimplement this simple piece of code from the sdspi-driver
      SPI_block_index := block_index
      SPI_buffer_address := buffer_address
      SPI_command := "r"
      repeat while SPI_command == "r"
    
    So, you need to add some simple getter functions to fsrw and the spi-driver, which return the base address of those SPI-variables.
    4. Having a loop which calls this function 64 times with incrementing sector (the one you got from popen) and an incrementing HUB-RAM-address will load the whole file into HUB-RAM
    5. Then it has to stop the SDSPI COG and start a COG with the SPIN interpreter running the loaded code
    Example can be found in SDSPIFemto
    :justStartUp            mov     i2cOther,i2cCmd         ' Use the COG supplied as the caller's
                            and     i2cOther,#%111          '  to start up the SPIN interpreter
                            test    Options,#ioStopLdr  wz  ' If ioStopLdr is set and ioNoStore is
                    if_nz   cogid   i2cOther                '  clear, then use this cog for SPIN
                            or      i2cOther,interpreter
                    if_nc   coginit i2cOther
    
    interpreter             long    ($0004 << 16) | ($F004 << 2) | %0000
    
Sign In or Register to comment.