Can't use a SD when booted from flash [solved in driver v. 2.71]
pik33
Posts: 2,366
I try to init a SD card using Cluso's driver v. 2.70
If a program boots from the serial port, it works
If it boots from the flash, it doesn't work ("I" command fails)
If I use "write flash" command in Propeller Tool, it writes the flash and then starts OK, and inits the SD (=works)
Do I have to do something after booting from the flash and before starting a SD driver (pin dirs, levels, tell the flash (how?) to switch off, etc?) to get the access to the SD card?
DIP switches on the board are set at 1100 (reset on, flash on, P59 up off, P59 down off)
Comments
In your flash program, add some more flash clock cycles, as per this info
https://forums.parallax.com/discussion/comment/1465384/#Comment_1465384
Various cards need 0, +1, +2 extra clock cycles in order to have the flash release its SO line, allowing subsequent card boot. One card I tested wouldn't release no matter how many extra clocks I gave it
Try this v271.
I don't expect any differences, but I've...
If this doesn't work I could try sending some clocks to the Flash chip with its' CS=1.
Or before you call the SD Driver you can do this yourself. Just use the Flash pins instead
FWIW The P2 boot protocol will (depending on pullup settings) try out the flash first (it reads the flash looking for an checksum equiv) and if it's not found the boot code then passes control to my ROM SD driver which will boot correctly.
Therefore, there is something being left incorrectly, or not cleared down correctly, as Flash and SD can co-exist on the shared pins. So this is solvable!
2.71 works.
Edit: Booting from flash always works - tested on 2 different cards.
A side effect occurs while booted from serial and using 32 GB Sandisk card: if, after mounting, I read something from the card, it mounts every second reboot (mounted at the first reboot after inserting the card, then not mounted-mounted-not mounted-mounted...
I don't know yet if it really doesn't mount or it mounts, and returns the error code: to be tested.
A cheaper 32 GB card mounts every time, so this behavior depends on the card,
Thanks.
OK we need to find out if the changes I did to v271 is fixing an SD problem, or as a consequence, fixing a flash problem.
I'm curious to know which of the two changes I did to 271 fixed the problem.
These are the two changes I did (both 1 liners)
I added a second line
call #_SDInit
And I added an extra line
flth #sdx_do
Perhaps you could try both by disabling each line?
Please note I have not verified the “X” command. It will cause a problem if the mailbox location gets overwritten with the loaded code/data because at the conclusion of the X it will clear parts of the mailbox which effectively overwrites the loaded code/data.
This is why I need to be able to place the mailbox at the top of hub ram.
Or, change my code to stop after an X. I can see that I’ll require two different commands, a “L” to load and “X” to load and execute. In P1 I prevented loading over the top of hub where the OS interface mailboxes were.
I used "I", "R" and "W" only so far.
2.70 never worked for me after booting from the flash, simply changing the file to 2.71 made it work.
I tried to comment out double init and flth, in 2.71 and it still works. Maybe I am too tired now and I am doing something wrong.