Shop OBEX P1 Docs P2 Docs Learn Events
P2-ROM: Booter, Serial, Flash, SD card, Monitor and TAQOZ features and operation - Page 4 — Parallax Forums

P2-ROM: Booter, Serial, Flash, SD card, Monitor and TAQOZ features and operation

124»

Comments

  • evanhevanh Posts: 15,915
    edited 2018-06-03 03:51
    jmg wrote: »
    Can you summarize the rules around long files names and formatting steps ?
    They aren't as bad as I was thinking there for a while, but best not to use them at all. They aren't recognised by the boot process and because they take up three filename entries each when deleting they leave a lot of odd gaps when mixed with 8.3 naming.

    jmg wrote: »
    Does this mean the FPGA loading side is not 100% reliable, but gets more reliable with a longer power-off ?
    Probably. I'm leaving this one in the don't do it bin.

    Thanks Tubular, for the push button reset help. It works. I remember that used to be an input that could be read so I gather Chip changed the FPGA function for it.

  • Here's the updated monitor register definitions used for SD functions.
    ''============[ COG VARIABLES - SD BOOT]========================================
                    org     $1C0              ' place the variables in cog $1C0-$1DF
    
    cmdout          res     1                       ' The 8b CMDxx | $40
    cmdpar          res     1                       ' The 32b parameters
    cmdcrc          res     1                       ' The 8b CRC (must be valid for CMD0 & CMD8)
    cmdpar2         res     1                       ' SDV1=$0, SDV2=$40000000
    cmdtype         res     1                       ' reply is R1=1, R3=3, R7=7, else 0
    reply           res     1                       ' R1 reply (moved to replyR1 when R3/R7 32b reply here)
    replyR1         res     1                       ' R1 reply (8b saved when R3/R7 32b reply follows)
    dataout         res     1                       ' 8/32 bit data being shifted out
    bytescnt        res     1                       ' #bytes to send/recv
    bitscnt         res     1                       ' #bits to be shifted in/out
    ctr1            res     1
    timeout         res     1                       ' = starttime + delay
    spare           res     1
    skiprun         res     1                       ' 1= skip load/run mbr/vol & load/no-run fname
                                                    '\ 1=SDV1, 2=SDV2(byte address), 3=SDHC/SDV2(block address)
    blocksh         res     1                       '/ block shift 0/9 bits
    clustersh       res     1                       ' sectors/cluster SHL 'n' bits
    
    vol_begin       res     1 '$0000_2000           ' Ptn0: first sector of PTN
    fsi_begin       res     1 '$0000_2001           ' Ptn0:       sector of file system info
    fat_begin       res     1 '$0000_3122           ' Ptn0: first sector of FAT table
    dir_begin       res     1' $0000_4000           ' Ptn0: first sector of DATA is DIR table
    dat_begin       res     1 '$0000_4580 $0000_54C0' Ptn0: first sector of file's DATA
    ptn_size        res     1 '$0008_0000           '       file-size 32KB = 64<<9 sectors
    
    _bufad          res     1
    _blocknr        res     1
    _sectors        res     1
    _entries        res     1
    bufad           res     1                       ' ptr sector buffer
    blocknr         res     1                       ' sector#
    fname           res     3                       ' 8+3+1
    _hubdata        res     1
                    fit     $1E0
    
  • Cluso99Cluso99 Posts: 18,069
    Bump thread for reference now we have first P2 silicon
  • thejthej Posts: 232
    edited 2018-09-29 03:07
    Is there a separate doc for this or does it only exist in this thread so far?
    Found it.
    j
  • Cluso99Cluso99 Posts: 18,069
    edited 2018-09-29 07:01
    Here are the MONITOR commands in the final ROM
    ROM_Booter_v32i.spin2    29/09/2018 4:19PM (downloaded from P2 forum)
    =====================
    
    ''-----------------------------------------------------------------------------------------------
    ''  MONITOR                        LMM DEBUGGER - SUPPORTED COMMANDS
    ''-----------------------------------------------------------------------------------------------
    ''  xxxxxx : xx xx xx xx ... <cr>  DOWNLOAD:  to   cog/lut/hub {addr1} following {byte(s)}
    ''  xxxxxx - [xxxxxx] [L] <cr>     MEM LIST:  from cog/lut/hub {addr1} to < {addr2}  L=longs
    ''  xxxxxx G <cr>                  GOTO:      to   cog/lut/hub {addr1}
    ''                                                FC000 G <cr> will perform a reboot
    ''  Q <cr>                         QUIT:      Quit Rom Monitor and return to the User Program
    ''                                               {addr} is on the stack
    ''  Lfilename.xxx<cr>              LOAD:      Load file from SD   (8.3 filename)
    ''                                               returns "=" on success, "!" on failure
    ''  Rfilename.xxx<cr>              RUN:       Run  file from SD   (8.3 filename)
    ''                                               returns "!" on failure
    ''  <esc><cr>                      TAQOZ:     goto TAQOZ
    ''  <cr>                                      will repeat last MEM LIST command
    ''-----------------------------------------------------------------------------------------------
    
    Note the changes to the download command to use ":", the memory list command to "-" and optional trailing "L" parameter (L=longs, else bytes).
    Filenames are in the format 8.3 (short filenames) with SD formatted as FAT32.
  • Cluso99Cluso99 Posts: 18,069
    edited 2018-12-26 01:20
    ROM MONITOR

    Updated 25Oct2018 15:56 (GMT+11:00)

    Here are the Monitor subroutine entry points...
    '' +--------------------------------------------------------------------------+
    '' | Cluso's LMM_SerialDebugger for P2    (c)2013-2018 "Cluso99" (Ray Rodrick)|
    '' +--------------------------------------------------------------------------+
    ''  xxxxxx : xx xx xx xx ... <cr>  DOWNLOAD:  to   cog/lut/hub {addr1} following {byte(s)}
    ''  xxxxxx - [xxxxxx] [L] <cr>     MEM LIST:  from cog/lut/hub {addr1} to < {addr2}  L=longs
    ''  xxxxxx G <cr>                  GOTO:      to   cog/lut/hub {addr1}
    ''                                                FC000 G <cr> will perform a reboot
    ''  Q <cr>                         QUIT:      Quit Rom Monitor and return to the User Program
    ''                                               {addr} is on the stack
    ''  Lfilename.xxx<cr>              LOAD:      Load file from SD   (8.3 filename)
    ''                                               returns "=" on success, "!" on failure
    ''  Rfilename.xxx<cr>              RUN:       Run  file from SD   (8.3 filename)
    ''                                               returns "!" on failure
    ''  <esc><cr>                      TAQOZ:     goto TAQOZ
    ''  <cr>                                      will repeat last MEM LIST command
    '' +--------------------------------------------------------------------------+
    ''              LMM DEBUGGER - lmm_f CALL Modes...(not all modes supported in ROM)
    '' +--------------------------------------------------------------------------+
      _MODE         = $F << 5                       ' mode bits defining the call b8..b5 (b4..b0 are modifier options)
      _SHIFT        = 5                             ' shr # to extract mode bits
      _HEX_         = 2 << 5                        ' hex...
        _REV_               = 1 << 4                '   - reverse byte order
        _SP                 = 1 << 3                '   - space between hex output pairs
       '_DIGITS             = 7..0 where 8->0       '   - no. of digits to display
      _LIST         = 3 << 5                        ' LIST memory line (1/4 longs) from cog/hub
        _ADDR2              = 1 << 4                ' 1= use lmm_p2 as to-address
        _LONG_              = 1 << 1                ' 1=display longs xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
      _TXSTRING     = 4 << 5                        ' tx string (nul terminated) from hub
      _RXSTRING     = 5 << 5                        ' rx string
        _ECHO_              = 1 << 4                '    - echo char
        _PROMPT             = 1 << 3                '    - prompt (lmm_x)
        _ADDR               = 1 << 2                '    - addr of string buffer supplied
        _NOLF               = 1 << 1                '    - strip <lf>
      _MONITOR      = 7 << 5                        ' goto rom monitor
    '' +--------------------------------------------------------------------------+
    _SerialInit        = $fcab8     ' Serial Initialise     (lmm_x & lmm_bufad must be set first)
    _HubTxCR           = $fcae4     ' Sends <cr><lf>        (overwrites lmm_x)
    _HubTxRev          = $fcaec     ' Sends lmm_x with bytes reversed
    _HubTx             = $fcaf0     ' Sends lmm_x           (can be up to 4 bytes)
    _HubHexRev         = $fcb24     ' Sends lmm_x with bytes reversed as Hex char(s) as defined in lmm_f
    _HubHex8           = $fcb28     ' Sends lmm_x as Hex char(s) after setting lmm_f as 8 hex chars
    _HubHex            = $fcb2c     ' Sends lmm_x as Hex char(s) as defined in lmm_f
    _HubTxStrVer       = $fcb9c     ' Sends $0 terminated string at lmm_p address after setting lmm_p=##_str_vers
    _HubTxString       = $fcba4     ' Sends $0 terminated string at lmm_p address
    _HubListA2H        = $fcbc4     ' List/Dump line(s) from lmm_p address to lmm_p2 address after setting lmm_f=#_LIST+_ADDR2 
    _HubList           = $fcbc8     ' List/Dump line(s) from lmm_p address to lmm_p2 address according to lmm_f
    _HubRx             = $fcb10     ' Recv char into lmm_x
    _HubRxStrMon       = $fccc4     ' Recv string into lmm_bufad address after setting prompt=lmm_x=#"*" & params=lmm_f=#_RXSTRING+_ECHO_+_PROMPT
    _HubRxString       = $fcccc     ' Recv string into lmm_p/lmm_bufad address according to params in lmm_f
    _HubMonitor        = $fcd78     ' Calls the Monitor; uses lmm_bufad as the input buffer address
    _RdLongCogHub      = $fcf34     ' read cog/lut/hub long from lmm_p address into lmm_x, then lmm_p++
    _str_vers          = $fd014     ' locn of hub string, $0 terminated
    '' +--------------------------------------------------------------------------+
      _HUBROM          = $FC000     ' ROM $FC000
      _HUBBUF          = $FC000     ' use as RxString buffer    (overwrites Booter)
      _HUBBUFSIZE      = 80         ' default size for _HUBBUF  (can be 128)
    '' +--------------------------------------------------------------------------+
    

    In addition to this, you need to have these COG registers available. You can define by CON or reserved as registers in your code (both types given)
    CON                ''============[ COG VARIABLES $1E0-$1EF - MONITOR]==============================
                       ''-------[ LMM parameters, etc ]------------------------------------------------
    lmm_x              = $1e0          ' parameter passed to/from LMM routine (typically a value)
    lmm_f              = $1e1          ' parameter passed to      LMM routine (function options; returns unchanged)
    lmm_p              = $1e2          ' parameter passed to/from LMM routine (typically a hub/cog ptr/addr)
    lmm_p2             = $1e3          ' parameter passed to/from LMM routine (typically a 2nd hub/cog address)
    lmm_c              = $1e4          ' parameter passed to/from LMM routine (typically a count)
                       ''-------[ LMM additional workareas ]-------------------------------------------
    lmm_w              = $1e5          ' workarea (never saved - short term use between calls, except _HubTx)
    lmm_tx             = $1e6          ' _HubTx
    lmm_hx             = $1e7          ' _HubHex/_HubString
    lmm_hx2            = $1e8          ' _HubHex
    lmm_hc             = $1e9          '   "
    lmm_lx             = $1ea          ' _HubList
    lmm_lf             = $1eb          '   "
    lmm_lp             = $1ec          '   "
    lmm_lp2            = $1ed          '   "
    lmm_lc             = $1ee          '   "
    lmm_bufad          = $1ef          ' _HubRxString
    
    ''============[ COG VARIABLES - MONITOR]========================================                                    
                    res     $1E0-$            ' reserve (if any)                   
                    org     $1E0              ' place the variables in cog $1E0-$1EF                                    
    ''-------[ LMM parameters, etc ]------------------------------------------------                                    
    lmm_x           res     1       '$1e0  parameter passed to/from LMM routine (typically a value)                           
    lmm_f           res     1       '$1e1  parameter passed to      LMM routine (function options; returns unchanged)         
    lmm_p           res     1       '$1e2  parameter passed to/from LMM routine (typically a hub/cog ptr/addr)                
    lmm_p2          res     1       '$1e3  parameter passed to/from LMM routine (typically a 2nd hub/cog address)             
    lmm_c           res     1       '$1e4  parameter passed to/from LMM routine (typically a count)                           
    ''-------[ LMM additional workareas ]-------------------------------------------                                   
    lmm_w           res     1       '$1e5  workarea (never saved - short term use between calls, except _HubTx)               
    lmm_tx          res     1       '$1e6  _HubTx                                                                             
    lmm_hx          res     1       '$1e7  _HubHex/_HubString                                                                 
    lmm_hx2         res     1       '$1e8  _HubHex                                                                            
    lmm_hc          res     1       '$1e9    "                                                                                
    lmm_lx          res     1       '$1ea  _HubList                                                                           
    lmm_lf          res     1       '$1eb    "                                                                                
    lmm_lp          res     1       '$1ec    "                                                                                
    lmm_lp2         res     1       '$1ed    "                                                                                
    lmm_lc          res     1       '$1ee    "                                                                                
    lmm_bufad       res     1       '$1ef  _HubRxString                                                                       
                    fit     $1F0                                                                                            
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2018-10-25 05:38
    Here is a very simple example of using the ROM Monitor with...
    * Setting the crystal oscillator (we have a 12MHz oscillator)
    * Setting clock to 96MHz
    * Setting Serial to 115,200 baud, 8 bits
    * Sending serially a $0 terminated string in a 1s loop

    This is the user code to do this...
    DAT             orgh    0
                    org     0
    ''-------[ Set Xtal ]---------------------------------------------------------- 
    entry           hubset  #0                                      ' set 20MHz+ mode
                    hubset  ##%1_001011_0001011111_1111_01_00       ' ena-xtal+PLL,div=12,mul=96,p=15,0pF,20MHz+
                    waitx   ##20_000_000/100                        ' ~10ms at 20MHz (rc osc)
                    hubset  ##%1_001011_0001011111_1111_01_11       ' 96MHz
    ''-----------------------------------------------------------------------------
                    waitx   ##delay5s                       ' just a delay to get pc terminal running
    ''-------[ Start Serial ]------------------------------------------------------ 
                    mov     lmm_bufad,        ##_HUBBUF     ' locn of hub buffer for serial routine 
                    mov     lmm_x,            ##_bitper     ' sets serial baud
                    call    #_SerialInit                    ' initialise serial
    ''-----------------------------------------------------------------------------
    .loop           mov     lmm_p,            ##_str_vers   ' must be in hub!
                    call    #_HubTxString                   ' display the $0 terminated string
                    waitx   ##delay1s                       ' just a delay before repeating
                    jmp     #.loop
    ''-----------------------------------------------------------------------------
    

    This is the full code with equates...
    '' +--------------------------------------------------------------------------+
    '' | Cluso's ROM_Monitor_Demo_001 for P2 v32i Silicon                   v0.xx |
    '' +--------------------------------------------------------------------------+
    '' |  Author :       (c)2013-2018 "Cluso99" (Ray Rodrick)                     |
    '' |  License:       MIT License - See end of file for terms of use           |
    '' +--------------------------------------------------------------------------+
    '' RR20181025   001     initial demo
    
    ''============================[ CON ]============================================================
    CON
    '------------------------------------------------------------------------------------------------
      _clockfreq    =  96_000_000
      _cpufreq      = _clockfreq
      delay5s       = _cpufreq * 5                            ' 5s
      delay1s       = _cpufreq                                ' 1s  
      _baud         = 115_200                                 ' 115,200 baud
      _bitper       = (_cpufreq / _baud) << 16 + 7            ' xxxxxxx baud, 8 bits
      _txmode       = %0000_0000_000_0000000000000_01_11110_0 'async tx mode, output enabled for smart output
      _rxmode       = %0000_0000_000_0000000000000_00_11111_0 'async rx mode, input  enabled for smart input
    '------------------------------------------------------------------------------------------------
       rx_pin       =       63                   ' pin serial receiver
       tx_pin       =       62                   ' pin serial transmitter
    '------------------------------------------------------------------------------------------------
                       
    CON
    '' +--------------------------------------------------------------------------+
    '' | Cluso's LMM_SerialDebugger for P2    (c)2013-2018 "Cluso99" (Ray Rodrick)|
    '' +--------------------------------------------------------------------------+
    ''  xxxxxx - xx xx xx xx ... <cr>  DOWNLOAD:  to cog/lut/hub {addr1} following {byte(s)}
    ''  xxxxxx [.xxxxxx] L <cr>        LIST:      from cog/lut/hub {addr1} to < {addr2}
    ''  xxxxxx G <cr>                  GOTO:      to cog/lut/hub {addr1}
    ''  Q <cr>                         QUIT:      Quit Rom Monitor and return to the User Program
    ''  Rffffffffxxx<cr>               RUN:       Run file from SD
    ''  <esc><cr>                      TAQOZ:     goto TAQOZ
    '' +--------------------------------------------------------------------------+
    ''              LMM DEBUGGER - lmm_f CALL Modes...(not all modes supported)
    '' +--------------------------------------------------------------------------+
      _HEX_         = 2 << 5                        ' hex...
        _REV_               = 1 << 4                '   - reverse byte order
        _SP                 = 1 << 3                '   - space between hex output pairs
       '_DIGITS             = 7..0 where 8->0       '   - no. of digits to display
      _LIST         = 3 << 5                        ' LIST memory line (1/4 longs) from cog/hub
        _ADDR2              = 1 << 4                ' 1= use lmm_p2 as to-address
        _LONG_              = 1 << 1                ' 1=display longs xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
      _TXSTRING     = 4 << 5                        ' tx string (nul terminated) from hub
      _RXSTRING     = 5 << 5                        ' rx string
        _ECHO_              = 1 << 4                '    - echo char
        _PROMPT             = 1 << 3                '    - prompt (lmm_x)
        _ADDR               = 1 << 2                '    - addr of string buffer supplied
        _NOLF               = 1 << 1                '    - strip <lf>
    '' +--------------------------------------------------------------------------+
    _SerialInit        = $fcab8     ' Serial Initialise     (lmm_x & lmm_bufad must be set first)
    _HubTxCR           = $fcae4     ' Sends <cr><lf>        (overwrites lmm_x)
    _HubTxRev          = $fcaec     ' Sends lmm_x with bytes reversed
    _HubTx             = $fcaf0     ' Sends lmm_x           (can be up to 4 bytes)
    _HubHexRev         = $fcb24     ' Sends lmm_x with bytes reversed as Hex char(s) as defined in lmm_f
    _HubHex8           = $fcb28     ' Sends lmm_x as Hex char(s) after setting lmm_f as 8 hex chars
    _HubHex            = $fcb2c     ' Sends lmm_x as Hex char(s) as defined in lmm_f
    _HubTxStrVer       = $fcb9c     ' Sends $0 terminated string at lmm_p address after setting lmm_p=##_str_vers
    _HubTxString       = $fcba4     ' Sends $0 terminated string at lmm_p address
    _HubListA2H        = $fcbc4     ' List/Dump line(s) from lmm_p address to lmm_p2 address after setting lmm_f=#_LIST+_ADDR2 
    _HubList           = $fcbc8     ' List/Dump line(s) from lmm_p address to lmm_p2 address according to lmm_f
    _HubRx             = $fcb10     ' Recv char into lmm_x
    _HubRxStrMon       = $fccc4     ' Recv string into lmm_bufad address after setting prompt=lmm_x=#"*" & params=lmm_f=#_RXSTRING+_ECHO_+_PROMPT
    _HubRxString       = $fcccc     ' Recv string into lmm_p/lmm_bufad address according to params in lmm_f
    _HubMonitor        = $fcd78     ' Calls the Monitor; uses lmm_bufad as the input buffer address
    _RdLongCogHub      = $fcf34     ' read cog/lut/hub long from lmm_p address into lmm_x, then lmm_p++
    _str_vers          = $fd014     ' locn of hub string, $0 terminated
    '' +--------------------------------------------------------------------------+
      _HUBROM          = $FC000     ' ROM $FC000
      _HUBBUF          = $FC000     ' use as RxString buffer    (overwrites Booter)
      _HUBBUFSIZE      = 80         ' default size for _HUBBUF  (can be 128)
    '' +--------------------------------------------------------------------------+
    
    DAT
                    orgh    0
                    org     0
    entry
    
    ''-------[ Set Xtal ]---------------------------------------------------------- 
                    hubset  #0                                      ' set 20MHz+ mode
                    hubset  ##%1_001011_0001011111_1111_01_00       ' ena-xtal+PLL,div=12,mul=96,p=15,0pF,20MHz+
                    waitx   ##20_000_000/100                        ' ~10ms at 20MHz (rc osc)
                    hubset  ##%1_001011_0001011111_1111_01_11       ' 96MHz
    ''-----------------------------------------------------------------------------
    
                    waitx   ##delay5s                       ' just a delay to get pc terminal running
    
    ''-------[ Start Serial ]------------------------------------------------------ 
                    mov     lmm_bufad,        ##_HUBBUF     ' locn of hub buffer for serial routine 
                    mov     lmm_x,            ##_bitper     ' sets serial baud
                    call    #_SerialInit                    ' initialise serial
    ''-----------------------------------------------------------------------------
    
    ' this code displays a version string (it's not required)
    .loop           mov     lmm_p,            ##_str_vers   ' must be in hub!
                    call    #_HubTxString
                    waitx   ##delay1s                       ' just a delay before repeating
                    jmp     #.loop
    
    ''---------------------------------------------------------------------------------------------------
    
    
    ''============[ COG VARIABLES - MONITOR]========================================                                    
                    res     $1E0-$            ' reserve (if any)                   
                    org     $1E0              ' place the variables in cog $1E0-$1EF                                    
    ''-------[ LMM parameters, etc ]------------------------------------------------                                    
    lmm_x           res     1       '$1e0  parameter passed to/from LMM routine (typically a value)                           
    lmm_f           res     1       '$1e1  parameter passed to      LMM routine (function options; returns unchanged)         
    lmm_p           res     1       '$1e2  parameter passed to/from LMM routine (typically a hub/cog ptr/addr)                
    lmm_p2          res     1       '$1e3  parameter passed to/from LMM routine (typically a 2nd hub/cog address)             
    lmm_c           res     1       '$1e4  parameter passed to/from LMM routine (typically a count)                           
    ''-------[ LMM additional workareas ]-------------------------------------------                                   
    lmm_w           res     1       '$1e5  workarea (never saved - short term use between calls, except _HubTx)               
    lmm_tx          res     1       '$1e6  _HubTx                                                                             
    lmm_hx          res     1       '$1e7  _HubHex/_HubString                                                                 
    lmm_hx2         res     1       '$1e8  _HubHex                                                                            
    lmm_hc          res     1       '$1e9    "                                                                                
    lmm_lx          res     1       '$1ea  _HubList                                                                           
    lmm_lf          res     1       '$1eb    "                                                                                
    lmm_lp          res     1       '$1ec    "                                                                                
    lmm_lp2         res     1       '$1ed    "                                                                                
    lmm_lc          res     1       '$1ee    "                                                                                
    lmm_bufad       res     1       '$1ef  _HubRxString                                                                       
                    fit     $1F0                                                                                            
    ''=======[ ^^^^^ End of COG Variables ^^^^^ ]===================================                                                   
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2018-10-25 04:58
    ROM SD Code/Routines

    Here are the Monitor subroutine entry points (not all are callable directly)
    CON                '' +--------------------------------------------------------------------------+
                       '' | Cluso's Minimal SD Boot Test for P2  (c)2012-2018 "Cluso99" (Ray Rodrick)|
                       '' +--------------------------------------------------------------------------+
                         _csum    = ("P" + "r"<<8 + "o"<<16 + "p"<<24)  ' "Prop" checksum (reversed)
                         _csum2   = ("P" + "r"<<8 + "o"<<16 + "P"<<24)  ' "ProP" checksum (reversed)
                         _fname1a = ("_" + "B"<<8 + "O"<<16 + "O"<<24)  '\\ filename...
                         _fname1b = ("T" + "_"<<8 + "P"<<16 + "2"<<24)  '||   8.3 +$00
                         _fname1c = ("B" + "I"<<8 + "X"<<16 + $00<<24)  '//
                         _fname2c = ("B" + "I"<<8 + "Y"<<16 + $00<<24)  '//
                         mbr_begin  = 0                 ' first sector of disk $0000_0000
                       '+-----------------------------------------------------------------------------+
                       '       COG & LUT & HUB ADDRESSES
                       '+-----------------------------------------------------------------------------+
                         hubdata       = $0_0000        ' expands up   (512byte sectors)
                         max_size      = (512-16)*1024  ' max file_size(bytes) that can be loaded
                         cog_start0    = $000           ' cog code start
                         cog_len       = 512-16         ' cog code length
                         cog_len80     = 512/4          ' 512 bytes (sector)
                       '+-----------------------------------------------------------------------------+
    _Start_SDcard      = $fc560     ' initialise & read CSD/CID
    _Run_SDfile        = $fc578     ' initialise & read CSD/CID
    _Load_SDfile       = $fc590     ' initialise & read CSD/CID
    _SDcard_Init       = $fc5a4     ' init hub data ptr=$0
    _readMBR1          = $fc6dc     ' do not load/run MBR/VOL code
    _readMBR           = $fc6e0     ' VBR/MBR = SECTOR 0
    _readDIR           = $fc810     ' copy _fname1 -> fname
    _searchDIR         = $fc840     ' 12th char must be $00
    _validateCSUM      = $fc8d0     ' check long at $17C
    _readFILE          = $fc900     ' DAT SECTOR#
    _readnxtSECTOR     = $fc944     ' next sector#
    _readnxtSLOT       = $fc948     ' next data slot
    _readSECTOR        = $fc950     ' sector#
    _readREG           = $fc974     ' CMD9,10: CSD,CID register
    _readBLOCK         = $fc97c     ' CMD17: PAR=sector, 512 bytes
    _cmdRZA41          = $fc9bc     ' CMD55:       R1 response
    _cmdRZtoken        = $fc9bc     ' CMD9,10,17,24: R1+$FE response
    _cmdR1R3           = $fc9c4     ' CMD58:    R1+R3 response
    _cmdR1R7           = $fc9c4     ' CMD8:     R1+R7 response
    _cmdR1             = $fc9c4     ' CMD0,A41,16: R1 response
    _cmdxx             = $fc9c8     '
    _getreply          = $fc9f8     ' recv R1 byte
    _recvlong          = $fca30     ' call here to Recv a Long (+send 1's)
    _sendlong          = $fca34     ' call here to Send a Long (long=32bits)
    _sendFF            = $fca3c     ' call here to Send $FF Byte
    _recvbyte          = $fca3c     ' call here to Recv a Byte (+send 1's)
    _sendbyte          = $fca40     ' call here to Send a Byte (msbit first)
    _sendrecv          = $fca48     ' clear reply
    _fail              = $fca74     ' C & NZ = fail
                       '+-----------------------------------------------------------------------------+
    
    In addition to this, you need to have these COG registers available. You can define by CON or reserved as registers in your code (both methods given)
                       ''============[ COG VARIABLES $1C0-$1DF - SD BOOT]==============================
    cmdout             = $1c0          ' The 8b CMDxx | $40
    cmdpar             = $1c1          ' The 32b parameters
    cmdcrc             = $1c2          ' The 8b CRC (must be valid for CMD0 & CMD8)
    cmdpar2            = $1c3          ' SDV1=$0, SDV2=$40000000
    cmdtype            = $1c4          ' reply is R1=1, R3=3, R7=7, else 0
    reply              = $1c5          ' R1 reply (moved to replyR1 when R3/R7 32b reply here)
    replyR1            = $1c6          ' R1 reply (8b saved when R3/R7 32b reply follows)
    dataout            = $1c7          ' 8/32 bit data being shifted out
    bytescnt           = $1c8          ' #bytes to send/recv
    bitscnt            = $1c9          ' #bits to be shifted in/out
    ctr1               = $1ca          
    timeout            = $1cb          ' = starttime + delay
    spare              = $1cc          
    skiprun            = $1cd          ' 1= skip load/run mbr/vol & load/no-run fname
                                       '\ 1=SDV1, 2=SDV2(byte address), 3=SDHC/SDV2(block address)
    blocksh            = $1ce          '/ block shift 0/9 bits
    clustersh          = $1cf          ' sectors/cluster SHL 'n' bits
                                       
    vol_begin          = $1d0          ' Ptn0: first sector of PTN
    fsi_begin          = $1d1          ' Ptn0:       sector of file system info
    fat_begin          = $1d2          ' Ptn0: first sector of FAT table
    dir_begin          = $1d3          ' Ptn0: first sector of DATA is DIR table
    dat_begin          = $1d4          ' Ptn0: first sector of file's DATA
    ptn_size           = $1d5          '       file-size 32KB = 64<<9 sectors
                                       
    _bufad             = $1d6          
    _blocknr           = $1d7          
    _sectors           = $1d8          
    _entries           = $1d9          
    bufad              = $1da          ' ptr sector buffer
    blocknr            = $1db          ' sector#
    fname              = $1dc          ' 8+3+1
    _hubdata           = $1df          
    
    ''============[ COG VARIABLES - SD BOOT]========================================
                    long    $0[$1C0-$]        ' fill with zeros (if any)                   
                    org     $1C0              ' place the variables in cog $1C0-$1DF
    
    cmdout          res     1                       ' The 8b CMDxx | $40
    cmdpar          res     1                       ' The 32b parameters
    cmdcrc          res     1                       ' The 8b CRC (must be valid for CMD0 & CMD8)
    cmdpar2         res     1                       ' SDV1=$0, SDV2=$40000000
    cmdtype         res     1                       ' reply is R1=1, R3=3, R7=7, else 0
    reply           res     1                       ' R1 reply (moved to replyR1 when R3/R7 32b reply here)
    replyR1         res     1                       ' R1 reply (8b saved when R3/R7 32b reply follows)
    dataout         res     1                       ' 8/32 bit data being shifted out
    bytescnt        res     1                       ' #bytes to send/recv
    bitscnt         res     1                       ' #bits to be shifted in/out
    ctr1            res     1
    timeout         res     1                       ' = starttime + delay
    spare           res     1
    skiprun         res     1                       ' 1= skip load/run mbr/vol & load/no-run fname
                                                    '\ 1=SDV1, 2=SDV2(byte address), 3=SDHC/SDV2(block address)
    blocksh         res     1                       '/ block shift 0/9 bits
    clustersh       res     1                       ' sectors/cluster SHL 'n' bits
    
    vol_begin       res     1 '$0000_2000           ' Ptn0: first sector of PTN
    fsi_begin       res     1 '$0000_2001           ' Ptn0:       sector of file system info
    fat_begin       res     1 '$0000_3122           ' Ptn0: first sector of FAT table
    dir_begin       res     1' $0000_4000           ' Ptn0: first sector of DATA is DIR table
    dat_begin       res     1 '$0000_4580 $0000_54C0' Ptn0: first sector of file's DATA
    ptn_size        res     1 '$0008_0000           '       file-size 32KB = 64<<9 sectors
    
    _bufad          res     1
    _blocknr        res     1
    _sectors        res     1
    _entries        res     1
    bufad           res     1                       ' ptr sector buffer
    blocknr         res     1                       ' sector#
    fname           res     3                       ' 8+3+1
    _hubdata        res     1
                    fit     $1E0
    
  • Cluso99Cluso99 Posts: 18,069
    Reserved for sample code using the ROM SD code
  • Cluso99Cluso99 Posts: 18,069
    Reserved for sample SD Boot sectors and files
  • Does SD boot work? Or will it require the re-spin?
  • ke4pjw wrote: »
    Does SD boot work? Or will it require the re-spin?

    Yes, it works. From TAQOZ you can even write directly to a file or the mbr. I will post up some samples soon.
  • Cluso99Cluso99 Posts: 18,069
    Peter has SD working. I'm in the process of getting P1 spin code working so I can port my Prop OS to P2 simply.
Sign In or Register to comment.