Autoload from SD
VonSzarvas
Posts: 3,450
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:
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!
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
Also are you renaming the file to _BOOT_P2.BIX ?
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.
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.
My guess is It may not include the Spin2 interpreter.
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.
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?)
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.
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
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.
My P56 just uses rcfast.
I did try that-- yes, with OS2 I could DIR the SD card correctly, prior to reformatting it and unhelpfully losing the sample forever!