Welcome to the Parallax Discussion Forums, sign-up to participate.
P2 BOOT PROCESS After power-up or hardware reset, the P2 loads 16KB of P2 Boot Code from an internal serial ROM into the top 16KB of HUB RAM ($FC000-$FFFFF) ?? or maybe slightly less ?? COG #0 then executes this “booter program code”. This code has been published, and contains the following code sections: • Boot code (ROM_Booter.spin2): This code sets RC FAST ??? clock mode and then tests for external pullup and/or pulldown resistors on Pins P59, P60 & P61 (see table). This code uses the resistor settings to determine which section of code will execute next. • Serial code with autobaud: This section waits for the two character sequence “> “ on the serial input pin P63, and utilised this sequence to determine the current baud, and sets the SmartPins for Asynchronous Serial mode (P63 input & P62 output). Timeouts to try FLASH or SD ??? • FLASH Boot Code: This code uses P61=#CS, P60=CLK, P59=DI(out), P58=DO(in). Note: these pins are shared with the SD Card if present. ?? Description of checksum/load/run sequence ?? • SD Card Boot Code: This code uses P61=CLK, P60=#CS, P59=DI(out), P58=DO(in). Note: these pins are shared with the FLASH if present. The conditions for SD booting are described in more detail below. • Monitor/Debug Code: This code provides a Monitor and a number of support routines for debugging COG/LUT/HUB memory. This code can be called in a number of ways… o From the Boot code with the sequence ?? “ >Ctl-D” o From TAQOZ with “Ctl-D” ?? Does this still work ?? o From the user’s program. These routines execute in HUBEXEC mode using COG register space $1E0-$1EF for parameters and variables. The Monitor and its’ routines can be called as subroutines from the user’s program. The Monitor/Debug operation is described in more detail below. • TAQOZ: This code provides a standalone Forth test environment for the P2. This code can be called in a number of ways… o From the Boot code with the sequence o From the Monitor/Debugger prompt by the 2 character sequence “Ctl-D<cr>”. TAQOZ is described in more detail below. SD Boot Code Provided a pull-up is sensed on P61=#CS (provided by the SD Card itself) and the other conditions are met, then the Booter code will pass control to the SD Boot Code. The SD code performs the following steps… • Initialise the SD Card (in SPI mode). This is often referred to as “Mounting” the card. • If successful, read the MBR Sector $0000_0000 (512 bytes) into HUB RAM starting at HUB $00000. • Check if the 4 signature bytes at MBR offset $17C (now in HUB) contain “Prop” ($706F7250). If valid, then the MBR sector now residing at HUB $00000-$001FF (128 longs) is copied into COG RAM $000 and then a JMP $020 is executed. This has the effect of COG #0 executing the code loaded from the MBR starting at byte offset $080. Note the whole 512 byte (128 longs) sector is loaded into COG, so while the code starts at $080 (COG $020), this code can use code below this address if that code is valid and executable. Note that certain parts of the MBR are required by FAT32, etc. Any P2 code written into the MBR must maintain any required fields that the SD card format requires. • If the MBR does not contain “Prop” at $17C, then this location is checked for the signature “ProP” ($506F7250). If this is found, then $174 (4 bytes) is used as the raw SD Sector to start loading from, and $178 (4 bytes) is used as the length (in bytes). The program then reads code from the card beginning at the start sector for the length into HUB RAM beginning at HUB $00000. Upon completion of the load, 496 longs from HUB $00000 are copied into COG $0 and a JMP #$000 is executed to run the loaded code in COG. • If the MBR does not contain either signature, then the MBR is validated as follows: o $1BE is the Ptn0 Table o $1BE+0 AND $7F must equal $00 o $1BE+4 must be $0C or $0B o $1BE+8 is used as the Vol_Begin sector o $1BE+C is used at the Ptn Size o $1FE must be $55AA If these checks are met, then continue, else go back to Serial boot code. • The VOL sector is now read into HUB $00000, and it is checked for the signature “Prop” or “ProP” at offset $17C. If either is found, then the operation will continue the same as described above for the signature found in the MBR sector. • If the VOL does not contain either signature, then the VOL is validated as follows: o $00B must be 512 o $00D is used at the clustershift o $00E used to calculate FAT begin o $010 must be 2 (number of FAT tables) o $020 used to calculate PTN size (not checked) o $024 used to calculate DIR begin o $030 used to calculate FSI begin o $1FE must be $55AA If these checks are met, then continue, else go back to Serial boot code. • The FSI sector is read and validated as follows: o $000 must be $RRaA o $1E4 must be $rrAa o $1FE must be $55AA If these checks are met, then continue, else go back to Serial boot code. • The FAT DIRectory is now searched for the file “BOOT_P2.BIX”. If it is found, it is read into HUB $00000 for a maximum length of (512-16)*1024 which is 512-16KB such that it will not overwrite the top 16KB of HUB RAM. Then the first 496 longs will be copied into COG $000 and a JMP #$000 will execute. WARNING: This file must be contiguous on the SD Card! This is not checked!! • If the above file is not found, then the FAT DIRectory is searched for the file “BOOT_P2.BIY”. If it is found, then it will be read and executed in the same process as the previous step. • If neither file is found, the code returns to the Serial boot code. Cluso99