Again, the process works. The code in the objects (and the Basic interpreters) all works. I've used DongleBasic on all sorts of Propeller boards with extra EEPROM and standard / mini / micro SD cards and it all works, with or without pullups. Start with known good code like KyeDos or DongleBasic. Make sure you can read the SD card file and that it's the same as your compiled binary file. Use the existing routines (in DongleBasic) to load and run the binary file, then move on to your own program.
The pin directions are fine, but is it crucial to have pull-ups?
Well I guess we have to break the problem down into its components. Open a file on an SD card, write one byte, close the file. But I think you haven't even got it working to that point - it won't even initialise the SD card?
However, the mSD wouldn't boot even though the "booting...." message showed up on my LCD.
Not sure if that is booting or not.
I'm going to harp on about the pin directions because it is what I got wrong the first time I played with SD cards. The other thing is different brands of SD cards, but check those pin directions first. "DO" and "DI" can be a bit vague - data into what? There is another nomenclature, MOSI and MISO which mean master out, slave in, and master in, slave out which I've started adding to schematics. MOSI is DI.
Did you solder up the micro SD socket? I only ever got about a 50% success rate and ended up going back to standard sized SD cards.
Do i have to close the SD in order for it to work?
Second, i tried the second part of your question, and all i got were 0's.
That could be a serious problem. That means that there was no initialization code......
I will try to boot it directly from EEPROM.
I actually had another program made (ExecuteSD 3) that uses Ariba's example. However, the mSD wouldn't boot even though the "booting...." message showed up on my LCD.
.....
There is no "booting.." message in your attached Spin file.
Here is an extended version, which should give you (and us) more information about what works and what not:
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
long ioControl[2]
byte name[16]
OBJ
sd: "fsrwFemto"
lcd: "Debug_Lcd"
PUB Start | wdcog, mount
lcd.init(1, 19200, 4)
lcd.backlight(true)
lcd.cls
sd.start(@ioControl)
lcd.str(string("Try to mount.."))
mount := \sd.mount(2,3,4,5)
if mount < 0
lcd.str(string("Error:"))
lcd.dec(mount)
repeat
lcd.str(string("okay mounted"))
waitcnt(clkfreq*2+cnt)
lcd.str(string("1.file on SD:"))
\sd.opendir
if sd.nextfile(@name) => 0
lcd.str(@name)
waitcnt(clkfreq*2+cnt)
lcd.str(string("Try to boot.."))
ifnot sd.popen(string("Blink.bin"), "r")
lcd.str(string("file OK - booting"))
waitcnt(clkfreq+cnt)
sd.bootSDcard
else
lcd.str(string("file not found"))
repeat
This code works on my Propeller (with other SD pins, another file and another display object).
fsrwFemto works only with SD cards up to 2 GB (SD type 1 cards).
I'm hoping that Andy's comment with SD cards only going to 2Gb is not the problem. It may well be.
Meanwhile, not closing the SD card shouldn't affect the first time you use it but it might affect subsequent times and that won't help with the debugging process.
Can you create a tiny .txt file in notepad or something, with the text "Hello World" or whatever, save it as a .txt file, eg Hello.txt, double check it is 11 bytes long, copy to the SD card, then see if you can open that file and read the bytes.
That's odd. My LCD says that the file hasn't been found. Hmmmm.....
@Ariba - your LED blinked when you executed the file, right?
@Dr_Acula - i tried copying the first few bytes from the file, and i got only zeroes, which means that there was no initialization code for the Blink file. (Wha??)
If the file wasn't closed there is a small chance of file corruption. Probably only small given you are reading rather than writing, but if you can't find files now, maybe reformat the SD card. It would only need a quick format from windows so should only take 10 seconds.
Reading data off a small text file might be a little easier than a binary file as you can be certain what those bytes should be (or get a hex editor but lets keep things simple). Your first byte on Hello World should be ascii 72 hex 48 ("H").
That's odd. My LCD says that the file hasn't been found. Hmmmm.....
@Ariba - your LED blinked when you executed the file, right?
I've started another application, not your blink code. But now I have also tested this, and it blinks. I had to change the pin number, because my SD is connected at P23. The odd thing was that the binary had all $FFs instead of the compiled code, if I saved the binary direct from the Prop-Tool to SD. If I save the binary to harddisk first (with extension .binary), then rename it to .bin and then copy it to SD - the data is okay.
1) So do you get no Error message at mount? - then your SD card should work.
2) Do you get the name of the first file on the SD card (the only one in your case)?
If 1) and 2) is okay then you may just have used a wrong name at popen.
OK, my sd card gets the boot message, so it mounted fine.
Then it opens the dir, and the message there works fine.
The messages on my LCD are good EXCEPT at the crucial part - it then says "file not found"
I verified the file, and apparently i'm not getting any initialization code. I open the file from the sd, and i get the binary representation, but it opens a blank spin file.
I'll try your method of saving the binary to computer first.... then save it as .bin to the SD.
In theory this should work, but I have not looked closer at your copy code.
But why will you do it so?
The main error was that you have mounted the card with sd.initSDcard(pins...) instead of sd.mount(pins...). If you change that you should be able to open the file, read the content, and copy it to EEPROM.
A little while back Kye wrote an SD driver, and as Mike Green mentioned, it has some methods for loading files into memory off an SD card and then rebooting the propeller. I was drawn to Kye's driver as I had a pile of SD cards with many brands and his driver worked on all the cards I had. So I wrote a command line operating system based around his driver. It was built for a VGA screen and then Jeff Ledger added a TV driver. You can move around within directories, do a listing of files and run .bin files.
I've more recently coded a touchscreen version that has the files as icons on the screen and it is also based on Kye's driver.
The main program is KyeDos3_TV and the comments at the beginning show the steps needed to get this working. There are a number of objects commented out, like the driver for a 20x4 LCD screen, but they have been left in to show how this can work with a number of displays. I had it working sending data to the VGA display, to the 20x4 LCD screen and to the serial port as that was a flexible way of debugging. Comment out the things you don't need.
Maybe you can find something useful in this?
Hi Dr_Acula,
Is the file "KyeDos3_TV.zip" the version built for VGA screen and then Jeff Ledger added a TV driver? I am looking for that version.
In the post you said " There are a number of objects commented out...."
I am trying to add some features back into "KyeDos3_TV", but the zip does not contain all the objects.
I have looked everywhere I can think of and I can not find the 2 objects listed below:
Looks like you found the answer - good news! (Sorry I couldn't reply - post was at 3am time here).
Let us know if you have any problems - putting this together is a bit like a jigsaw with bits all over, but pretty much all the hard bits have been written somewhere so it is just a matter of finding them on the obex or in the forum.
Is the file "KyeDos3_TV.zip" the latest version available ?
I am trying to add some features back into "KyeDos3_TV".
I have gotten the Real Time Clock (RTC) working.
I am still trying to make it play wav files (but this is not a big problem as I can play them with other spin files).
I seem to have one problem with the features you left "working" in KyeDOS3_TV; the "Backspace" key function does not work correctly in the copy I have, do you know if it ever worked after you changed the TV driver to the 40x13 driver?
Thanks,
zappman
PS: Yes, I agree "putting this together is a bit like a jigsaw with bits all over, but pretty much all the hard bits have been written somewhere so it is just a matter of finding them on the obex or in the forum."
For the RTC maybe go back to Kye's SD driver code. I think that also includes the wav file player (those got removed as it all ran out of code space).
Once you have Kyedos working, you can chain one program to another and then the lack of code space becomes less of a problem. Load up a pretty touchscreen, touch an icon, then reload a brand new program to play a wav file. Takes about 1-2 seconds.
Comments
Well I guess we have to break the problem down into its components. Open a file on an SD card, write one byte, close the file. But I think you haven't even got it working to that point - it won't even initialise the SD card?
Not sure if that is booting or not.
I'm going to harp on about the pin directions because it is what I got wrong the first time I played with SD cards. The other thing is different brands of SD cards, but check those pin directions first. "DO" and "DI" can be a bit vague - data into what? There is another nomenclature, MOSI and MISO which mean master out, slave in, and master in, slave out which I've started adding to schematics. MOSI is DI.
Did you solder up the micro SD socket? I only ever got about a 50% success rate and ended up going back to standard sized SD cards.
Once again, i tired executing the bin file, and nothing blinking.
(This is getting a little frustrating)
Does anyone have any suggestions?
I am including all the objects and files below:
ExecuteSD.spin
ExecuteSD3.spin
FemtoBasic.spin
fsrwFemto.spin
sdspiFemto.spin
Blink.spin
I am now certain that my hardware for the SD is fine.
Something tells me that its the bin file...... but i'm not sure what to do.
First thing - where is the sd file closed?
Next thing
Somewhere between these two lines
add a debug message to print the first long of your binary file. Print it in hex. Is it what it should be?
compile your program with F8 and "show hex" and it is
00 B4 C4 04
It might be in reverse order but it should be those numbers.
Second, i tried the second part of your question, and all i got were 0's.
That could be a serious problem. That means that there was no initialization code......
There is no "booting.." message in your attached Spin file.
Here is an extended version, which should give you (and us) more information about what works and what not:
This code works on my Propeller (with other SD pins, another file and another display object).
fsrwFemto works only with SD cards up to 2 GB (SD type 1 cards).
Andy
Meanwhile, not closing the SD card shouldn't affect the first time you use it but it might affect subsequent times and that won't help with the debugging process.
Can you create a tiny .txt file in notepad or something, with the text "Hello World" or whatever, save it as a .txt file, eg Hello.txt, double check it is 11 bytes long, copy to the SD card, then see if you can open that file and read the bytes.
That's odd. My LCD says that the file hasn't been found. Hmmmm.....
@Ariba - your LED blinked when you executed the file, right?
@Dr_Acula - i tried copying the first few bytes from the file, and i got only zeroes, which means that there was no initialization code for the Blink file. (Wha??)
Reading data off a small text file might be a little easier than a binary file as you can be certain what those bytes should be (or get a hex editor but lets keep things simple). Your first byte on Hello World should be ascii 72 hex 48 ("H").
Should i download the bytes in a text file, then convert it to a bin file on the program??
I've started another application, not your blink code. But now I have also tested this, and it blinks. I had to change the pin number, because my SD is connected at P23. The odd thing was that the binary had all $FFs instead of the compiled code, if I saved the binary direct from the Prop-Tool to SD. If I save the binary to harddisk first (with extension .binary), then rename it to .bin and then copy it to SD - the data is okay.
1) So do you get no Error message at mount? - then your SD card should work.
2) Do you get the name of the first file on the SD card (the only one in your case)?
If 1) and 2) is okay then you may just have used a wrong name at popen.
Andy
Then it opens the dir, and the message there works fine.
The messages on my LCD are good EXCEPT at the crucial part - it then says "file not found"
I verified the file, and apparently i'm not getting any initialization code. I open the file from the sd, and i get the binary representation, but it opens a blank spin file.
I'll try your method of saving the binary to computer first.... then save it as .bin to the SD.
Nothing. :frown:
Thanks, Ariba, for your code!!!
I modified the popen filename from "Blink.bin" to @name, and it worked!!!
So, in theory, would my first ExecuteSD program work as well (loading the SD contents to EEPROM, then booting from the EEPROM)?
But why will you do it so?
The main error was that you have mounted the card with sd.initSDcard(pins...) instead of sd.mount(pins...). If you change that you should be able to open the file, read the content, and copy it to EEPROM.
Andy
@Ariba - the whole "copy to EEPROM and execute from EEPROM" is just something that i was interested in and wanted a proof of concept.
Thanks to the people who helped me with my code!!
I cannot express enough gratitude right now!
Hi Dr_Acula,
Is the file "KyeDos3_TV.zip" the version built for VGA screen and then Jeff Ledger added a TV driver? I am looking for that version.
In the post you said " There are a number of objects commented out...."
I am trying to add some features back into "KyeDos3_TV", but the zip does not contain all the objects.
I have looked everywhere I can think of and I can not find the 2 objects listed below:
'adc: "PCM2.1_ADCEngine.spin"
'dac: "PCM2.1_DACEngine.spin"
There my be some other objects missing from the removed features of KyeDos3_TV not in the zipped file.
Can you direct me to the missing objects?
Thanks,
zappman
I found the the objects in the zip file on this page http://forums.parallax.com/showthread.php?122991-SD2.0-Full-FAT32-16-File-Sytem-Driver-You-there!-Yes-you-viewing-this-forum.&highlight=adcengine
Let us know if you have any problems - putting this together is a bit like a jigsaw with bits all over, but pretty much all the hard bits have been written somewhere so it is just a matter of finding them on the obex or in the forum.
Is the file "KyeDos3_TV.zip" the latest version available ?
I am trying to add some features back into "KyeDos3_TV".
I have gotten the Real Time Clock (RTC) working.
I am still trying to make it play wav files (but this is not a big problem as I can play them with other spin files).
I seem to have one problem with the features you left "working" in KyeDOS3_TV; the "Backspace" key function does not work correctly in the copy I have, do you know if it ever worked after you changed the TV driver to the 40x13 driver?
Thanks,
zappman
PS: Yes, I agree "putting this together is a bit like a jigsaw with bits all over, but pretty much all the hard bits have been written somewhere so it is just a matter of finding them on the obex or in the forum."
Once you have Kyedos working, you can chain one program to another and then the lack of code space becomes less of a problem. Load up a pretty touchscreen, touch an icon, then reload a brand new program to play a wav file. Takes about 1-2 seconds.