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

Autoload from SD

VonSzarvasVonSzarvas Posts: 3,450
edited 2020-07-05 17:04 in Propeller 2
Hi!

Looking for advice on auto-load from SD card after Propeller 2 reset / power-up

Based on advice from @Cluso99 and @"Peter Jakacki" in this thread: https://forums.parallax.com/discussion/comment/1499474/#Comment_1499474

I have this Spin2 code:
con

  CLK_FREQ = 200_000_000        ' system freq as a constant
  
  _clkfreq = CLK_FREQ           ' set P2 clock

  

pub main()
        
  repeat 4

      PINHIGH(56)            
      waitms(500)
      PINLOW(56)
      waitms(500)


Using PropellerTool Alpha I saved that code in binary format, then renamed the file to the uppercase format XXXXXXXX.BIX
(Interesting the PropellerTool crashed when changing the file suffix in the SaveAs dialog.. Will report that)

Then copied the binary file BLINKY56.BIX to FAT32 SD card, and was hoping it would autorun. But nada.

I tried Peter's TAQOZ _P2_BOOT.BIX file, and that does autorun. So I know the SD format, Eval board and dip settings are good.

I'm wondering if there's a missing directive or some such needed in the spin2 code ?
Or special clock settings which Propeller Tool doesn't include in the binary image ?

Any tips?
Thanks !


ps. Cluso's sample P56.BIX didn't autorun either, but I could run it using SerialMonitor R command. Whereas I couldn't even R my BLINKY56.BIX (let alone autorun) :) Feels like something is missing!

Comments

  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-07-05 17:52
    [deleted]
  • Hmm i wonder whether its running on rcfast, then the leds might take 10x as long, and light when driven low, so could be ~10 seconds before you see a light

    Also are you renaming the file to _BOOT_P2.BIX ?
  • I have tried tried the same code saved as _BOOT_P2.BIX. Did not boot after 1 minute. Strange..
  • Cluso99Cluso99 Posts: 18,069
    PropTool has always required the binary to be saved as .binary (or .eeprom IIRC).

    You must rename the file before copying it to the SD card. Remember that FAT32 allows for long filenames but the loader only uses the short file names.
    Only files named _BOOT_P2.BIX then _BOOT_P2.BIY will autorun. BLINKY56.BIX will not autorun.

    Have you checked what files are on the SD card? You shouldn't run into having more than 1024 files in the root directory - the SD boot code only looks in the first cluster (usually 32KB) for directory entries.
  • Cluso99Cluso99 Posts: 18,069
    My P56 file was pasm
    DAT
            org     0  
    start   drvnot  #56                             ' P2EVAL Blue LED 0=ON
            waitx   ##20_000_000
            jmp     #start
    

    You may want to check PINHIGH and PINLOW as I am not sure if they make the pin an output. I thought Chip might have used DRIVEHIGH and DRIVELOW to be the same as pasm. I haven't had time to check.
  • What size is the .binary file?
    My guess is It may not include the Spin2 interpreter.
  • Cluso99 wrote: »
    You may want to check PINHIGH and PINLOW as I am not sure if they make the pin an output. I thought Chip might have used DRIVEHIGH and DRIVELOW to be the same as pasm. I haven't had time to check.

    Thanks for sharing the source. Looks like you are not setting a specific clock, so maybe using RCFAST?
    Perhaps that's an issue with my code... that I'm trying to use external XTAL, and perhaps that needs some extra handling at the top of the spin2 file.

    The code sample I posted works fine when loading over USB (Propeller Tool F10), which suggests to me that PINHIGH/LOW do set the pins to outputs.


    This morning I tried the TAQOZ DIR command, and there were lot's more files showing in the DIR list than on the SD card. It's like the MBR had many stale entries.
    (on the attached screengrab, only the files up to the first BOOT_P2.BIX file existed on the SD card when viewed from win10)

    So I reformatted the SD card with the slow format option, copied back Clusos P56.BIX demo code, renamed it to _BOOT_P2.BIX, and it worked as an autoboot.

    Hooray! Progress!

    Now I tried my pure spin example, and it still fails to Run or Autoload/run. (Although it does work when downloaded from Propeller Tool).

    Maybe ozpropdev is onto something about the spin interpreter. Is there a way to include that ?

    I'll try a simpler spin code example, that doesn't change clkfreq. See if that potential issue can be removed from the unknowns list.


    Also attached is a zip of the SD card. The file extensions indicate the code... .CLU is the P56 demo, .TAQ is the latest image I could find (and boots fine), and the file that's currently renamed with .BIX is the spin code that won't boot. This one should light all 8 LEDs every couple seconds, and does some 115k baud serial out on P0.
  • VonSzarvasVonSzarvas Posts: 3,450
    edited 2020-07-06 07:03
    Update...

    Removing the clock settings in Propeller Tool didn't help, so then tried compiling with PNut and BINGO, it works (the compiled binary when saved to SD as _BOOT_P2.BIX does autorun)

    Also immediately obvious was the larger file size of the compiled PNut binary (maybe that SPIN interpreter @ozpropdev mentioned is missing in the Propeller tool binary image)

    Sadly, PNut 34s chokes when trying to compile the code I really want to use (whereas Propeller Tool compiles/loads/runs fine), but at least I understand some of the problem now.


    Seems I need to figure a way to get Propeller Tool to include SPIN interpreter, or manually add that to the source code.

    Anyone know how to do that (or if that is even the right thing to do?)




  • evanhevanh Posts: 15,916
    Oh, yeah, I hit something similar when deleting long filenames. There was something about them that confused the simple directory scan of the prop2 SD boot.

  • evanh wrote: »
    Oh, yeah, I hit something similar when deleting long filenames. There was something about them that confused the simple directory scan of the prop2 SD boot.

    Ah ha ! That would fit the case here too. In addition to the windows generated (and generously long-named) "System Volume Information" folder, I also had some long filenames at some point in the past on that SD card.
  • As for TAQOZ coming up with those ghosts on the directory, I'd say that I need to make sure that it always does a fresh mount of the file system on startup. I thought I had but something's changed so I will make sure of it this time.
  • As for TAQOZ coming up with those ghosts on the directory, I'd say that I need to make sure that it always does a fresh mount of the file system on startup. I thought I had but something's changed so I will make sure of it this time.

    I cannot be certain I have your latest TAQOZ extended image- it was in a recent thread you posted but just mentioning in-case you did already update the code, and this leads you on a tail chase.

    That said... the DIR command here was with the RevB ROM builtin TAQOZ... so all bets on the ext.img version are off :)

  • Cluso99Cluso99 Posts: 18,069
    Those filenames with spaces between seem strange. Perhaps its just taqoz.
    I’m not sure about deleting long filename files. It should work correctly but i cannot be sure. I do have some long filenames on some of my SD cards but I don’t think I’ve ever deleted them.
  • Cluso99Cluso99 Posts: 18,069
    Seems PropTool may not be adding the spin2 interpreter. Pnut adds it automatically if spin2 code is detected.
    My P56 just uses rcfast.
  • Cluso99Cluso99 Posts: 18,069
    You could try the OS2 code i posted - use pnut to download. You can then do a DIR or LS command at the SD:> prompt.
  • VonSzarvasVonSzarvas Posts: 3,450
    edited 2020-07-06 10:13
    Cluso99 wrote: »
    You could try the OS2 code i posted - use pnut to download. You can then do a DIR or LS command at the SD:> prompt.

    I did try that-- yes, with OS2 I could DIR the SD card correctly, prior to reformatting it and unhelpfully losing the sample forever!

Sign In or Register to comment.