How to store a program in flash for booting on the P2?
Mike Green
Posts: 23,101
in Propeller 2
What's the current 'best' way to store a binary image (xxx.binary) in the flash memory on the Eval Board? I can copy a program to an SD card as _BOOT_P2.BIX on my Mac, but I want to do something similar using the flash for booting (and storing other stuff). It would be easy if you could use both flash and an SD card at the same time, but they share all the same I/O pins.
Comments
(1) Select the Commands > Choose P2 Flash Program... menu item
(2) Pick either the P2ES_flashloader.bin or P2ES_sdcard.bin binary (use flashloader for the flash)
(3) Then pick Commands > Flash binary file...
You'll have to set the P2 ES switches appropriately; I can never remember what the settings are for programming the flash, but they're documented in the P2-ES docs.
I gave the directions for flexgui earlier in this thread. Did that not work for you?
loadp2 can do the flashing, but it needs a helper program to do it. It also is limited to flashing something no bigger than HUB RAM (actually a little smaller). To use loadp2 to flash ROM do: This loads the P2ES_flashloader.bin program at location 0 in HUB memory (that's the @0= part), and PROGRAM_TO_FLASH.bin at $8004, with its length at $8000 (that's the @8000+ part), then boots from 0 (where we loaded P2ES_flashloader.bin). The flash loader looks in memory at $8000 for its data and flashes that.
EEPROM (Flash) has priority over SD and there is no boot order, it's either/or. After that, it's up to the booted software to manage accessing both if desired.
A pullup on P61 will boot from Flash
A pullup on P60 (provided by the SD Card itself) and no pullup on P61 will boot from SD
A pulldown on P59 will prevent the Serial boot.
Trying SD boot will return to the Serial boot if neither boot prop identifier "Prop" nor "ProP" is found in the MBR (sector 0), not found in the VOL sector, and either the SD card is not formatted as FAT32 or the SD card is formatted as FAT32 and neither files _BOOT_P2.BIX and _BOOT_P2.BIY (case matters) are found.
I believe that the FLASH will return to Serial (not sure about SD) if the checksum is incorrect in the FLASH.
If you use my SD Driver, then after each SD transaction (initialise, readCSDCID, readSector, writeSector) the SPI pins should be returned to floating and the SD card is forced to release DO. Therefore, providing you do the same with each FLASH transaction, both FLASH and SD can be shared.
FWIW I have shared the SD with the SRAM pins successfully on P1 in my RamBlade for many years without problems even on commercial products.