Shop OBEX P1 Docs P2 Docs Learn Events
How to store a program in flash for booting on the P2? — Parallax Forums

How to store a program in flash for booting on the P2?

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

  • RaymanRayman Posts: 14,646
    I think both flexgui and pnut do it for you
  • In flexgui you have the choice of programming to flash or to SD:

    (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 know flexgui won't. It uses loadp2 and the list of options doesn't mention either flash or SD cards. I use a Mac. I can run Windows 10 using Parallels Desktop, but it's awkward.
  • Mike Green wrote: »
    I know flexgui won't. It uses loadp2 and the list of options doesn't mention either flash or SD cards. I use a Mac. I can run Windows 10 using Parallels Desktop, but it's awkward.

    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:
    loadp2 -p /dev/tty/port -b230400 "@0=P2ES_flashloader.bin,@8000+PROGRAM_TO_FLASH.bin" -t -k
    
    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.
  • evanhevanh Posts: 15,916
    loadp2 has worked with the EEPROM chip on the Eval boards for a long time now. You do have to enable it with a dip switch.

    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.
  • Thanks, I guess I didn't understand about the helper program. I'll give it a try
  • evanhevanh Posts: 15,916
    Oh, yeah, good point, that gets tacked to the front of the binary to be burnt.
  • Cluso99Cluso99 Posts: 18,069
    A pullup on P59 will boot from Serial
    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.
Sign In or Register to comment.