Well, you're using the code right so its a problem in my driver. That said, IDK what the problem is.
I would try to find a way around the problem for right now. Maybe use a different card as I have not heard of cards having problems remounting before.
(Note however, that mountParition can fail and you are not using an abort trap. So... maybe you should make the code try repeatedly to mount the card until it succeeds?)
In order to open 2 files at the same time, I'm using 2 instances of your object.
Can you please confirm that it's consuming 2 cogs? Because if it's the case, I will try to find a way to redesign my application to read one file at a time.
No, only one cog is used for the block driver which is a common resource shared by each included version of the file system. Think of the file system OBJ file as a FILE struct... you need multiple version of it to open multiple files.
I've set up Kyedos so it is my default position and they I can run various versions of CP/M. Would you be able to help me with a simple addition to the program?
To load a program in Kyedos I type
BOOT MYFILE.BIN
I was wondering if I can leave out the .BIN so you just type BOOT MYFILE
I tried writing some new code and added the command SPIN so that you would type
BOOT MYFILE.BIN
or
SPIN MYFILE
However, I'm not sure how to take MYFILE and add ".BIN" on the end. Any help would be most appreciated.
PRI programBoot(stringPointer)
ifnot(str.stringCompareCI(string("boot"), stringPointer))
PrintString(string("Loading..."))
stringPointer := str.tokenizeString(0)
fat.bootPartition(stringPointer)
PRI programSpin(stringPointer)
ifnot(str.stringCompareCI(string("spin"), stringPointer))
PrintString(string("Loading..."))
stringPointer := str.tokenizeString(0) ' not able to add .BIN to the string yet...
'PrintString(stringpointer) ' print the new string
'abort 0 ' for debugging
fat.bootPartition(stringPointer)
Can this driver handle more than one file open at a time? It doesn't look like it from my scan of the code. Is there a FAT16/FAT32 driver that can handle multiple open files? I have an application that needs to read from one file and write to another simultaneously. Is there a way to do that short of opening and closing the files constantly?
As long as only one processor is even accessing any of the instances of the driver there will be no problems.
However, this functionality has not been tested... But I wrote it to be functional if you use it in the above case. So I'm 99% sure the above method is fine.
Never use more than one processor however with this driver. There are definately race condtions you can get into that will corrupt data every so often.
Never use more than one processor however with this driver. There are definately race condtions you can get into that will corrupt data every so often.
It looks like you use locks so I would think it would work with multiple processors. Is that functionality just not debugged?
So, my use of locks in there does nothing except prevent block read and write conflicts.
However, at the file system level... weird stuff can happen. Lets say two processors are editing the FAT Table on the SD card. If they both happen to be writting to the FAT at the same place at the same time then corruption can occur. This is because each of the two threads could have old copies of the FAT and then when they went to write the data out neither core would account for the other ones update to the FAT.
I had the same requirement (opening more than 1 file at a time). However, in my case, I don't need to open 2 or more files exactly the same time. So, I wrote another object to act as a SD controller which can provide up to 7 file requests at any one time.
Different obj/cogs -> (requests) -> SD controller (cog) -> SD2.0
That way, multiple running cogs could send read and write requests.
Since all the requesting objects don't require > 115.2kbps, its worked out fine for me. Not sure if it is of help to anyone but this solved my need of opening multiple files using Kye's SD2.0.
I am sorry to be at the wrong moment, but, after your keyboard/mouse driver, I succeeded to run your SD2 driver on my homemade board and I am really grateful for sharing all your work.
I don't know if you are still interested in statistics but here are mine with a 2 Gb Kingmax Card :
[PHP]>_ mount 0
Running command: mount 0
Disk 0x00000000 with volume ID 0xD4DFE592 a.k.a JMCOL ready
>_ test
Running command: test
Creating test file "testfile" ... Success
Wrote 131,072 bytes at 0000035321 bytes per second
Running byte stride write test...
Wrote 32,768 bytes at 0000004192 bytes per second
Running byte stride read test...
Read 32,768 bytes at 0000004297 bytes per second
Running word stride write test...
Wrote 65,5536 bytes at 0000007860 bytes per second
Running word stride read test...
Read 65,5536 bytes at 0000008419 bytes per second
Running long stride write test...
Wrote 131,072 bytes at 0000013905 bytes per second
Running long stride read test...
Read 131,072 bytes at 0000016665 bytes per second
Running speed writing test (512 bytes at a time)...
Wrote 131,072 bytes at 0000062608 bytes per second
Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000214656 bytes per second
Running append test... Success
Running seek test... Success
Deleting test file "testfile" ... Success[/PHP]
For those using VGA display and keyboard, try the modified version called KyeDos and proposed by Dr_Acula.
I've had a few requests for copies of KyeDOS and I think the version a few pages back is out of date, so this is the July 2010 version.
I think Kye did make the code a bit faster after this was written, but it is more than fast enough for me.
I like this demo as it is a more sophisticated 'hello world' than flashing a led. A number of times I've started a new propeller project, and rather than start from scratch, there are some basic building blocks that I find are essential, namely keyboard, display and mass storage.
Not sure if anyone encountered this or if it help save some of your pain as it created mine. I found out that this Kingston-brand of uSD card are very inferior in its quality. I've tested many hours (>100) reading (only) & it would fail to read a block periodically. They must be using a poor quality SD controller inside.
Comments
I would try to find a way around the problem for right now. Maybe use a different card as I have not heard of cards having problems remounting before.
(Note however, that mountParition can fail and you are not using an abort trap. So... maybe you should make the code try repeatedly to mount the card until it succeeds?)
Thanks,
In order to open 2 files at the same time, I'm using 2 instances of your object.
Can you please confirm that it's consuming 2 cogs? Because if it's the case, I will try to find a way to redesign my application to read one file at a time.
Thanks,
JM
Is the DAT section shared by all the object instances? Which is why cardLockID can be used for that?
And the VAR section, we have one per instance?
If so, I was not aware of that
Thanks,
JM
Yes.
Yes.
One more think I will know about spin
JM
I've set up Kyedos so it is my default position and they I can run various versions of CP/M. Would you be able to help me with a simple addition to the program?
To load a program in Kyedos I type
BOOT MYFILE.BIN
I was wondering if I can leave out the .BIN so you just type BOOT MYFILE
I tried writing some new code and added the command SPIN so that you would type
BOOT MYFILE.BIN
or
SPIN MYFILE
However, I'm not sure how to take MYFILE and add ".BIN" on the end. Any help would be most appreciated.
So... just allocate some space on the stack for a string and then concatenate the string token with the sufix.
Thanks,
David
Just use 2 instances to keep 2 files open at the same time...
I'm using it read only. Have not tried the write mode.
JM
However, this functionality has not been tested... But I wrote it to be functional if you use it in the above case. So I'm 99% sure the above method is fine.
Never use more than one processor however with this driver. There are definately race condtions you can get into that will corrupt data every so often.
However, at the file system level... weird stuff can happen. Lets say two processors are editing the FAT Table on the SD card. If they both happen to be writting to the FAT at the same place at the same time then corruption can occur. This is because each of the two threads could have old copies of the FAT and then when they went to write the data out neither core would account for the other ones update to the FAT.
I had the same requirement (opening more than 1 file at a time). However, in my case, I don't need to open 2 or more files exactly the same time. So, I wrote another object to act as a SD controller which can provide up to 7 file requests at any one time.
Different obj/cogs -> (requests) -> SD controller (cog) -> SD2.0
That way, multiple running cogs could send read and write requests.
Since all the requesting objects don't require > 115.2kbps, its worked out fine for me. Not sure if it is of help to anyone but this solved my need of opening multiple files using Kye's SD2.0.
I am sorry to be at the wrong moment, but, after your keyboard/mouse driver, I succeeded to run your SD2 driver on my homemade board and I am really grateful for sharing all your work.
I don't know if you are still interested in statistics but here are mine with a 2 Gb Kingmax Card :
[PHP]>_ mount 0
Running command: mount 0
Disk 0x00000000 with volume ID 0xD4DFE592 a.k.a JMCOL ready
>_ test
Running command: test
Creating test file "testfile" ... Success
Wrote 131,072 bytes at 0000035321 bytes per second
Running byte stride write test...
Wrote 32,768 bytes at 0000004192 bytes per second
Running byte stride read test...
Read 32,768 bytes at 0000004297 bytes per second
Running word stride write test...
Wrote 65,5536 bytes at 0000007860 bytes per second
Running word stride read test...
Read 65,5536 bytes at 0000008419 bytes per second
Running long stride write test...
Wrote 131,072 bytes at 0000013905 bytes per second
Running long stride read test...
Read 131,072 bytes at 0000016665 bytes per second
Running speed writing test (512 bytes at a time)...
Wrote 131,072 bytes at 0000062608 bytes per second
Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000214656 bytes per second
Running append test... Success
Running seek test... Success
Deleting test file "testfile" ... Success[/PHP]
For those using VGA display and keyboard, try the modified version called KyeDos and proposed by Dr_Acula.
Let me know if you need someone to test it
JM
I think Kye did make the code a bit faster after this was written, but it is more than fast enough for me.
I like this demo as it is a more sophisticated 'hello world' than flashing a led. A number of times I've started a new propeller project, and rather than start from scratch, there are some basic building blocks that I find are essential, namely keyboard, display and mass storage.
May I know if a larger capacity uSD card would consume more mA?
I'm sticking to SanDisk brands from now onwards.