PDA

View Full Version : SD2.0 Full FAT32/16 File Sytem Driver - You there! Yes you, viewing this forum.



Pages : [1] 2

Kye
06-04-2010, 12:42 PM
Hey everybody,
I’ve think I’ve finally got a working release of the file system driver that I’ve been coding for about a year now. So, meet the SD2.0· FATEngine, a fully functional FAT32 and FAT16 file system driver that supports SD cards and ·MMC cards (kinda). The driver supports accessing files and directories across a SD card. So, no longer will you be limited to the root directory. By using the FATEngine you can now read and write to files in any directory on the SD card. Included with this are also the abilities to change your working directory, rename files and folders, change file and folder attributes, and delete files and empty folders. Additionally file and folder creation is supported so that your application can build any directory structure it needs. Last but not least, the file system support full directory listing capabilities so that you can query information about all the files and directories on the SD card.
So, to keep this post short I recommend you read through the driver which is attached and try out the EXTENSIVE included demo which will function as a serial interface into your SD card. Simply open the SD2.0 FATDemo file up and configure the constants correctly. After doing so load the demo on your prop chip and type in “help”, followed by enter, to see the command list which gives all the allowed command names and arguments for those commands in the demo. If you have some wav files and audio hardware on your board please check out the “play” and “record” commands which can play and record wav files – they are especially nice. Also, remember to use the "mount" command first to mount the SD card so that you can acess the file system.
Anyway, I would like to ask that if you have a problem with the driver, please post online here about the problem so that I can work to fix it. I don’t know if the block driver supports every SD card out there but I’ve had no failures so far with any of my test cards. I would also like if you could post the results of the “test” command back on the forum if you do use the demo so that I can see what the average read and write speeds are for certain operations.
Thank you,
·(Going to bed now, will answer questions later at 10 or 11 am EST).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 6/4/2010 3:03:27 PM GMT

Cluso99
06-04-2010, 12:50 PM
Great work Kye. I look forward to having a play shortly.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade (http://forums.parallax.com/showthread.php?p=786418),·RamBlade (http://forums.parallax.com/showthread.php?p=849265),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) (http://forums.parallax.com/showthread.php?p=778427) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)·
· Prop OS: SphinxOS (http://forums.parallax.com/showthread.php?p=819353)·, PropDos (http://www.orrtech.us/propdos/) , PropCmd (http://obex.parallax.com/objects/440/)··· Search the Propeller forums (http://www.google.com/advanced_search?q=+site:forums.parallax.com&num=20&hl=en&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBlade Props: www.cluso.bluemagic.biz (http://www.cluso.bluemagic.biz)

Kye
06-04-2010, 01:14 PM
For anyone who does not have a DS1307 RTC attached use this code.

Just leave the clock pins in the constant section·unchanged. In this version I simply removed the abort statement for any clock I/O errors that happen. Invalid time stamps will be produced when this happens but·the driver will continue to work without a DS1307 RTC attached.

Thanks,


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 6/7/2010 2:23:04 AM GMT

heater
06-04-2010, 01:28 PM
Fantastic, just what Zog needs today:)

Amongst all those unix commands shouldn't "mkfil" be "touch"?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Dr_Acula
06-04-2010, 01:36 PM
Will be testing this very soon...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

pullmoll
06-04-2010, 04:13 PM
Here are my test results. DracBlade @ 80MHz. SD card is Kingston 2GB SD.



>_ Running command: test
Creating test file "testfile" ... Success

Wrote 131,072 bytes at 0000004297 bytes per second

Running byte stride write test...
Wrote 32,768 bytes at 0000002934 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 0000004402 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 0000005869 bytes per second

Running long stride read test...
Read 131,072 bytes at 0000016525 bytes per second

Running speed writing test (512 bytes at a time)...
Wrote 131,072 bytes at 0000000000 bytes per second

Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000223600 bytes per second

Running append test... Success

Running seek test... Success

Deleting test file "testfile" ... Success


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

heater
06-04-2010, 04:47 PM
Hmm... "Wrote 131,072 bytes at 0000000000 bytes per second". Excellent :)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

pullmoll
06-04-2010, 05:41 PM
heater said...
Hmm... "Wrote 131,072 bytes at 0000000000 bytes per second". Excellent :)

Excellent? That means not any byte was written!!!11!1

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

heater
06-04-2010, 05:46 PM
Seems to me you should still be waiting for that message to come out:)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

nicolad76
06-04-2010, 08:24 PM
Hi Kye, great job. I'll test it as soon as I get home.
Yesterday I was using the previous version and I noticed a problem with directory two chars long.
This is the sequence of instructions:

mount 0--> Ok
mkdir PO --> dir created
ls --> I can see the folder
cd PO --> Directory not found

From three chars up then there is no problem, everything works great!
I will test this driver for the same issue and I let you know.

Kye
06-04-2010, 10:06 PM
Mmm, the speed goes to zero when its not high enough...

The raw write speed for my driver isn't very high always, I've noticed that it can range from about 160KB a sec down to like 30KB depending on which card you use... I'm not sure why this happens.

The file system allocation write speed however is very slow when creating a new file. Because whenever you want a new cluster you have to read in a fat sector and then from there search for a free cluster. After finding one which could take multiple reads you then have to write out that cluster claiming that sector. Then you have to zero every byte in the·cluster over multiple sectors·and then read in the first·sector of that cluster... Finally after all that you can write to the file.

@nicolad76 - Just tested that and found no prolems. Just FYI, the previous version had a $&!^ ton of bugs...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 6/4/2010 2:14:17 PM GMT

Dr_Acula
06-04-2010, 10:41 PM
This is the 512mb card that will not work with fat16 on older sd card code. Working perfectly here, with fat32. Sweet!
1Gig ones are working too.





>help
Running command: help
Command Listing
<clear> - Clear the screen.
<echo> <string> - Echo the string argument.
<reboot> - Reboot the propeller chip.
<help> - Show the command listing.
<mount> <partition#> <check@> - Mount the file system. C=Check.
<unmount> - Unmount the file system.
<df> <fast> - Compute free sectors. F=Fast. 1 Sector = 512 Bytes.
<du> <fast> - Compute used sectors. F=Fast. 1 Sector = 512 Bytes.
<cd> <directory> - Change directory.
<attrib> <entry> <newAttributes> - Change attributes. R=ReadOnly, H=Hidden, S=System, A=Archive.
<rename> <oldName> <newName> - Rename a file or directory.
<rm> <entry> - Remove a file or directory.
<mkfil> <name> - Make a new file.
<mkdir> <name> - Make a new directory.
<boot> <file> - Reboot the propeller chip from a file.
<format> <partition> <newLabel> - Format the selected partition and give it a new label.
<ls> - List the contents of the working directory.
<pwd> - Print the working directory path.
<cat> <file> - Print the ASCII interpreted contents of a file.
<test> - Test file system functions and read and write speed.
<date> - Display the current date and time.
<time> - Change the current date and time.
<play> <file> - Play a wav file.
<record> <file> - Record a wav file.

>mount 0
Running command: mount 0
Disk 0x00000000 with volume ID 0xF8D75F5D a.k.a ready

>test
Running command: test
Creating test file "testfile" ... Success
Wrote 131,072 bytes at 0000022534 bytes per second
Running byte stride write test...
Wrote 32,768 bytes at 0000004332 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 0000008454 bytes per second
Running word stride read test...
Read 65,5536 bytes at 0000008489 bytes per second
Running long stride write test...
Wrote 131,072 bytes at 0000016141 bytes per second
Running long stride read test...
Read 131,072 bytes at 0000016839 bytes per second
Running speed writing test (512 bytes at a time)...
Wrote 131,072 bytes at 0000160992 bytes per second
Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000268320 bytes per second
Running append test... Success
Running seek test... Success
Deleting test file "testfile" ... Success


>


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 6/4/2010 2:46:17 PM GMT

Kye
06-04-2010, 10:59 PM
Mmm, that's a fast card you have there. Notice how the write speed does not suck.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Mike Green
06-04-2010, 11:21 PM
Kye,
Why do you have to zero a new cluster? It's going to be written over anyway.

Kye
06-05-2010, 12:31 AM
The FAT file system spec mandates that you do so when allocating a new cluster so that all remaining bytes are zeros. You must do this when making a new cluster for directories since a·zero byte at the start of a dir entry indicates the end of the directory.·For files it is not so neccesary... but I am using the same function for both. I could add in an option for the function·so that it does not·do that·for files. This would increase write·speed.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Microcontrolled
06-05-2010, 01:29 AM
Can this driver support bigger filenames then 7 letter and 3 letter extension??

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my new website!! (http://microcontrolled.propmodule.com/home.html)

Use the Propeller icon!! http://www.proptools.org/images/Propeller.gif

Follow me on Twitter! Search "Microcontrolled"

wjsteele
06-05-2010, 01:38 AM
Kye, this is fantastic work!!! Thanks!!!

Bill

trodoss
06-05-2010, 01:58 AM
@Kye,

I tried this with a 1 GB HP SD card, it works great.· Here are the results:



>_ mount 0
Running command: mount 0
Disk 0x00000000 with volume ID 0xFC303DA9 a.k.a ready
>_ test
Running command: test
Creating test file "testfile" ... Success
Wrote 131,072 bytes at 0000031688 bytes per second
Running byte stride write test...
Wrote 32,768 bytes at 0000004157 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 0000007721 bytes per second
Running word stride read test...
Read 65,5536 bytes at 0000008454 bytes per second
Running long stride write test...
Wrote 131,072 bytes at 0000013416 bytes per second
Running long stride read test...
Read 131,072 bytes at 0000016735 bytes per second
Running speed writing test (512 bytes at a time)...
Wrote 131,072 bytes at 0000053664 bytes per second
Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000241488 bytes per second
Running append test... Success
Running seek test... Success
Deleting test file "testfile" ... Success

>_

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit the Propeller Powered SIG (http://www.savagecircuits.com/forums/forumdisplay.php?29-Propeller-Powered)·fourm kindly hosted at Savage Circuits (http://www.savagecircuits.com/)


Game(s) Mythic Flight
(http://forums.parallax.com/showthread.php?p=766328)Utilities Font Editors (http://forums.parallax.com/showthread.php?p=833043) (AIGeneric, Potato_Text, etc.)

Kye
06-05-2010, 02:29 AM
@Microcontrolled - I support 8 letter names and 3 ccharacter extension. You can't support more than that without Microsoft's approval since they licensed LONG file names (255 character names). The driver could not be freeware if I were to support longer names.

Please keep the test results comming. I need to calculate an average. If no one has any problems I'll put the driver in the OBEX.

Thanks,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 6/4/2010 6:34:57 PM GMT

Ahle2
06-05-2010, 03:15 AM
Wrote 131,072 bytes at 0000030954 bytes per second

Running byte stride write test...
Wrote 32,768 bytes at 0000004087 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 0000007511 bytes per second

Running word stride read test...
Read 65,5536 bytes at 0000008489 bytes per second

Running long stride write test...
Wrote 131,072 bytes at 0000013031 bytes per second

Running long stride read test...
Read 131,072 bytes at 0000016944 bytes per second

Running speed writing test (512 bytes at a time)...
Wrote 131,072 bytes at 0000044720 bytes per second

Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000286208 bytes per second

Running append test... Success

Running seek test... Success



2 Gig Lexar
My 2Gig Zap glider doesn't work though. :(

hover1
06-05-2010, 03:27 AM
Any pullups required?
Anyone running @ 100 Mhz?

Jim

I'm running Base Pin 0 and getting mount failure.

Post Edited (hover1) : 6/4/2010 7:34:37 PM GMT

Wurlitzer
06-05-2010, 03:50 AM
Question Kye! As MS has licensed 255 character names could you create a structure to allow something greater than 255 thus getting around their road block? Even if this had a huge speed hit if you actually used something greater but worked well at something less than 255 it would be of great value.

That said, even with 8.3 file names this is great code and thanks for your efforts.

hover1
06-05-2010, 03:55 AM
Got it running. First EEPROM download didn't take. Running fine at 100Mhz. Can't get PropViewer to run so I can't get log file for test data. Will work on that.

Jim

HollyMinkowski
06-05-2010, 04:03 AM
Kye this is awesome!
U so smart http://forums.parallax.com/images/smilies/smile.gif

Will this work ok with big sd cards?
Like 8gb ones.....

Kye
06-05-2010, 04:13 AM
I've been running it with a 16GB RIdata flash card.

It gets great read and write speeds. I have about 40 WAV files on the card across different directories and I can play all of them.

@Wurlitzer (http://forums.parallax.com/member.php?u=45897)·- If I were to do that it really wouldn't be FAT16/32 compatible anymore. So, I really can't do that.

However, you could just make your files have their name stored as the first 256 bytes in the file.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 6/4/2010 8:18:46 PM GMT

hover1
06-05-2010, 05:17 AM
Well, I still couldn't get Propviewer to work. I'll have to look at RS232_COMEngine, didn't have the time right now. I took screen shots at 80Mhz and 100 Mhz.

Very nice Kye! Nice job on the entire suite! Can't wait to get a DS1307 now! (Should have been in my bins a long time ago).

Jim

Invent-O-Doc
06-05-2010, 08:12 AM
I've been looking through the code. This is a very nice set of features, though it looks like the demo will take a lot of resources. If I wanted to do a minimal set up that reads WAV files from an SD card, I assume that The FATEngine and the DACEngine would be the only two objects necessary, correct?

http://forums.parallax.com/images/smilies/freaked.gif I'm very impressed. Thanks for posting, I'll be looking for it on OBEX too.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
----------------------------------------
Tom Talbot
New Market, MD, USA

Timothy D. Swieter
06-05-2010, 09:10 AM
Later today I will download and test this set of SD routines out. This may be just the ticket to what I need for the Spinneret Web Server. How much resources does the core functions consume? Memory and cogs?

I'll be sure to post a couple different test cases with the SD cards I have on hand.

Good job Kye!!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, P.E.
www.brilldea.com (http://www.brilldea.com) - Prop Blade, LED Painter, RGB LEDs, 3.0" 16:9 LCD Composite video display, eProto for SunSPOT, PropNET, PolkaDOT-51
www.tdswieter.com (http://www.tdswieter.com)

Kye
06-05-2010, 09:59 AM
Yeah, you should comment out the code that you don't use. The driver is about 1900 longs. A fourth of the memory. Only one cog is used however.

The DAC Engine and the FAT Engine are all you need to play wav files. I also have the code necessary to do so in the function called "play".

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Dr_Acula
06-05-2010, 08:42 PM
Hi Kye,

I'm busy making your code jump through hoops. It works very well.

I just posted a long posting asking about bootloading.

I've just deleted that post. Because I found the "boot" command. And it works!!!!

This is awesome. Just what I needed.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 6/5/2010 12:50:19 PM GMT

Dr_Acula
06-05-2010, 09:54 PM
This is a complete mess of code, pulling in random keyboard drivers, the unoptimised VT100 VGA driver, removing the serial driver, removing the wav file audio driver, automatically mounting (but without checking for errors because I'm not sure how), and replacing all carriage returns with carriage return plus line feed...

but

what we have is an operating system that boots up using local VGA and keyboard. I compiled Femtobasic into a binary and renamed it FBAS.BIN and put that on the sd card, then run the command
BOOT FBAS.BIN

and it boots into Femtobasic.

It is a little slower than propdos to copy the bytes over but only a couple of seconds.

This is a standalone operating system! Life is very good. Thanks kye.

Next step might be to print out all the binary files on bootup. And add the option propdos has where you don't have to type "boot" - if you just type the name of the file and it is a .bin file then it runs.

addit: I can post code if you like but it is a real mess.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Oldbitcollector (Jeff)
06-05-2010, 10:55 PM
Please post it.

I'll port it over to Doug's NTSC video driver and replace my PropDOS with it. :)

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Feature Projects: PropellerPowered.com (http://www.propellerpowered.com)
Visit the: PROPELLERPOWERED SIG forum (http://www.savagecircuits.com/forums/forumdisplay.php?29-Propeller-Powered) kindly hosted by Savage Circuits (http://www.savagecircuits.com).

potatohead
06-05-2010, 11:16 PM
Awesome Kye. Thank you for this.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness! (http://propeller.wikispaces.com/)
8x8 color 80 Column NTSC Text Object (http://obex.parallax.com/objects/550/)
Wondering how to set tile colors in the graphics_demo.spin? (http://forums.parallax.com/attachment.php?attachmentid=70768)
Safety Tip: Life is as good as YOU think it is!

Kye
06-06-2010, 12:28 AM
Thank you people. But please keep the test results coming.

Right now it looks like:

4KBs Byte read, 4KBs Byte write
8KBs Word read, 8KBs Word write
16KBs Long read, 16KBs Long write
260KBs Sector read, 160KBs Sector write

@Dr_Acula - There's a function called "checkErrorNumber" which returns the error number of any abort error if one happened. At the top of the code all the abort numbers are listed. Also, the reason booting is slow is because the spin code has to read every byte of the boot file, this goes at 4KB a sec, the actual boot ram update in ASM completes in under a second at 250 KBs a sec.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

hover1
06-06-2010, 12:47 AM
Kye,



I see a little problem with writing 512. For example, pulmoll got 0 kps, I got about half of your quoted 160kbs, and Ahle2 only got a little over 44kbs. Dr A had the best result.

I think the average would bring your number down a bit. Don't get me wrong. It's still a great piece of code.

Jim

Edit: Just noted your post from yesterday about write speed not hitting 160kbs all the time..

Post Edited (hover1) : 6/5/2010 4:53:14 PM GMT

Kye
06-06-2010, 12:55 AM
Different cards get different speeds. 60KBs is more a reality but 160KBs is about the max.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Ahle2
06-06-2010, 07:19 AM
Do you have any idea why my "2GB ZAP GLIDER" doesn't mount ?

Kye
06-06-2010, 07:44 AM
Hmm, could be alot of things. Is the card an MMC card? If so I really don't fully support those.

Otherwise I have no clue. You would have to track what's going on in the mounting process through each step and see where it fails.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

RossH
06-06-2010, 08:08 AM
Hi Kye,

Great work.

I'm just putting the finishing touches on a release of Catalina/Catalina, so I'll probably proceed with the version I have, and wait till the next release to incorporate your latest and greatest version.

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Dr_Acula
06-06-2010, 08:32 AM
sandisk 1gig results



>test
Running command: test
Creating test file "testfile" ... Success
Wrote 131,072 bytes at 0000043881 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 0000008000 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 0000014324 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 0000071552 bytes per second
Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000223600 bytes per second
Running append test... Success
Running seek test... Success
Deleting test file "testfile" ... Success





* Added backspace support for the keyboard (keyboard returns ascii 200 so converted it to ascii 8, after finding kye's string handler already handles backspace)

* Added DIR command which is a short form of LS with just the filename

* Shortened the menu descriptions so they each fit on a single line on the vga display (80 characters)

* I am thinking about how CP/M works, where it goes through the list of commands, but the command is not present it goes through all the .COM files on the disk and looks to see if they exist and runs the appropriate one if it does. In our case, it would look for .BIN files

I just found this is already in propdos. Copied 'as is' with the original authors 'honest' comments



elseif command <> 0 '' AUTO-EXECUTE A .BIN FILE LIKE DOS
counter := 0
repeat until counter > 13
if command[counter] > 0
'' Convert Lowercase to UPPERCASE
if command[counter] > 96 and command[counter] < 123
command[counter] := command[counter]-=32
cline[counter] := command[counter]
counter++

counter:=strsize(@cline)
counter--
counter++ '' AAAAAARRRRRRGGG!!!
cline[counter]:=46 '' This paticular routine
counter++ '' proved to be a bit challenging.
cline[counter]:=66 '' To allow .BIN's to execute,
counter++ '' while ignoring everything else.
cline[counter]:=73 '' --works perfectly.. :)
counter++
cline[counter]:=78
rr:=strsize(@cline)
fsrw.opendir
repeat while fsrw.nextfile(@tbuf) == 0
tt:=(StrRight(@tbuf,3))
if textcomp(tt,string("BIN"),3) == true
if textComp(@cline,@tbuf,rr) == true
fsrw.popen(@cline,"r")
fsrw.bootSDCard


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Timothy D. Swieter
06-06-2010, 08:33 AM
Here are some test results. These two results are using uSD cards, the PropNET setup with a Parallax uSD card adapter. Sorry that I attached screen shots. It appears that Parallax Serial Terminal doesn't allow copy/paste. We should add that to the feature list.

Perhaps a Google Excel type of file should be started and then we as a community can insert our numbers as we get them and then compare easily across the columns or rows.

For testing I had uSD cards. One was labeled as a Sandisk 1GB and the the other a Rdata 1GB.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, P.E.
www.brilldea.com (http://www.brilldea.com) - Prop Blade, LED Painter, RGB LEDs, 3.0" 16:9 LCD Composite video display, eProto for SunSPOT, PropNET, PolkaDOT-51
www.tdswieter.com (http://www.tdswieter.com)

mpark
06-06-2010, 08:52 AM
Dr_Acula said...




counter--
counter++ '' AAAAAARRRRRRGGG!!!





OK, that's just too funny.

kuroneko
06-06-2010, 09:01 AM
Kye said...
Also, the reason booting is slow is because the spin code has to read every byte of the boot file, this goes at 4KB a sec ...

I'll bite, why? All you need are the first 64 512 bytes sector numbers. No problem here. Files are organised in clusters, sectors within a cluster are contiguous. So it boils down to getting the first few (if at all) cluster IDs and simply calculating the sector numbers. Also, these days a cluster size of 32K is not unusual so there isn't really any work to do :)

Edit: OK, I found the answer, but there must be a better way to achieve this. You can't really expect people to wait about 8 sec for checksum validation (EEPROM file and your figure of 4KB/s). What about an option to disable the check?

Post Edited (kuroneko) : 6/6/2010 1:41:22 AM GMT

Dr_Acula
06-06-2010, 10:44 AM
Modified program attached. This is for running on a standalone system with VGA and keyboard. Also a photo.

The listing on this particular sd card scrolls off the screen (so many games!!) so it would be very confusing to try to find the emulations in amongst all the other files. So on bootup it sorts only files with a .BIN extension and prints those.

Run one with the BOOT command.

I'm also trying to get a SPIN command working like in propdos - I had a simple idea you could leave the extension off and it would add the ".BIN" automatically but I can't find the command to do that in Kye's nifty string library.

If that works, maybe you could leave off the SPIN command as well, and just type FBAS and it goes through the list of files on the disk to see if FBAS.BIN exists.

Autorun is easy to add - there is a commented line near the beginning of the program



'fat.bootpartition(string("CPM.BIN")) ' uncomment this to autorun a binary spin file




Batch files might be possible. I'm not sure if they are needed. If you really wanted to run one particular binary, you would reprogram the eeprom with that binary.

For TV there is the AI_Generic_Driver_TV object. It has the same commands as the VGA object so just change it in the OBJ section

It is filling up the memory so some careful coding might be needed to put back the audio. However, the VT100 emulation has a huge number of VT100 codes that are not needed at all. So you could delete virtually all these (maybe leave 'clear screen')

For Cluso...

Cluso would like a program to fit in eeprom that loads this program.
1) Rename this program to something new
2) Comment out the vga and keyboard things at the beginning.
3) Compile with BST if you like and set BST to remove unused methods. That should make it a lot smaller.



PUB shell

VT100.start(16) ' start the vga driver VGA starts on pin 16
VT100.startcursor
VT100.color(%00001000_11111100) ' Blue_White blue =3/4 power 10, white =full
VT100.cursorset(5) ' cursor type 5
VT100.clearscreen
key.startx(26, 27, %100, 40) 'Start Keyboard Driver pin,pin,num,repeatrate
' ifnot(com.COMEngineStart(_receiverPin, _transmitterPin, _baudRateSpeed))
' reboot

ifnot(rtc.RTCEngineStart(_clockDataPin, _clockClockPin))
reboot

ifnot(fat.FATEngineStart(_cardDataOutPin, _cardClockPin, _cardDataInPin, _cardChipSelectPin, _clockDataPin, _clockClockPin))
reboot

' ifnot(dac.DACEngineStart(_leftChannelAudioPin, _rightChannelAudioPin, 0))
' reboot

' ifnot(adc.ADCEngineStart(_leftMicInputPin, _leftMicFeedBackPin, _rightMicInputPin, _rightMicFeedBackPin, 0))
' reboot

fat.mountPartition(0,0) ' mount the sd card
VT100.str(string("**** SD card operating system by Kwabena W. Agyeman ****"))
crlf
VT100.str(string("Type Help for command listing"))
crlf
DisplayBinaryFiles ' display all files ending in .BIN
'fat.bootpartition(string("CPM.BIN")) ' uncomment this to autorun a binary spin file
repeat

result := shellLine(string("SD>"))
crlf




comment out virtually everything above the fat.bootpartition line - except leave in place the two ifnot commands that start up the sd card and rtc.

Then it becomes a minimalist program in the eeprom and you can ship out boards with the eeprom preprogrammed and never need the proptool. Just put new files on the sd card.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 6/6/2010 3:00:01 AM GMT

potatohead
06-06-2010, 10:51 AM
Excellent!!!

I'm gonna have to go and rework potatotext for less HUB memory usage. Clusos use the init code as screen buffer bit should free a considerable amount, losing color would free a lot more. I have to say, this community is just damn cool. Every few days, something somewhere gets advanced a notch. Wish I had time to follow all of it! But, the upside is when I do look to do something new (to me), there is almost always something to build on now.

It really is impressive, and if that doesn't just highlight what kind of secret sauce is in this chip, I don't know what does.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness! (http://propeller.wikispaces.com/)
8x8 color 80 Column NTSC Text Object (http://obex.parallax.com/objects/550/)
Wondering how to set tile colors in the graphics_demo.spin? (http://forums.parallax.com/attachment.php?attachmentid=70768)
Safety Tip: Life is as good as YOU think it is!

KPR
06-06-2010, 12:12 PM
I agree with all the peeps saying they love this community.. I agree..

Kye, you have created the "Ultimate Bootloader / OS" .. Kudos..

I am just assembling my prop board from the wulfden.. and this will be whats going on it..

I'm gonna have to add a video out jack for the 3.5 inch lcd I have and a keyboard port as well..

All thats needed is networking..

KPR

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I always have someone watching my back.

HollyMinkowski
06-06-2010, 12:35 PM
Kye

This just makes so many projects so much easier to implement!

Lots of people are going to be using this code.
We will all be standing on the shoulders of a giant (You) http://forums.parallax.com/images/smilies/smile.gif

Ahle2
06-06-2010, 04:52 PM
I have played around with the modified version that Dr_Acula put together.
I just got the feeling of playing around in a REAL OS for the first time on the prop. ;) (Sorry OBC)

Dr_Acula
06-06-2010, 06:59 PM
What I posted is all very preliminary and a non perfect program is probably better than vapourware (or worse, teasing photos of something working but no code), but I'm wondering if Kye might be able to cast his eye over the code I posted and see if it can be improved.

Ideas:

1) Go back to a standard keyboard driver. (Did Kye write one?)
2) Remove all the VT100 codes. Maybe go back to a standard 80x40 vga driver. VT100 is overkill for this application, and it takes up valuable code space.
3) Add in TV (maybe as TV or VGA as probably not room for both, Unless you go to BST with #ifdefs. But ideally stick with the prop tool)
4) Hopefully with the code space saved, the serial port can be added back in. Then - send output to both the com port and to the vga. And merge input from the serial port and the keyboard. That will involve timeouts on both keyboard and the serial port (poll a buffer to see if anything is present). The zicog does this and it works works well as you don't have to keep changing code when you compile for different hardware.

I think with a combined vga and serial object you would have the best of both worlds. Serial port for those using the prop terminal. VGA for those using the demo board.

Probably also default to the demo board pins (vga and sd pins are different on the dracblade) as I can handle changing a couple of lines if I download the code.

Might need a few tweaks eg vga needs CRLF but the terminal seems happy with just CR. Though some other terminal programs prefer CRLF.

If it all fits, put the audio back in to my code (sorry Kye for breaking half your code!) Ideally merge into one common program, with a structure that is fairly easy to comment out things that are not needed.

I must say though that Kye's code is proving exceptionally useful. I have all these sd cards lying around that would not work with fat16 and they all work with fat32 and Kye's code. So suddenly I've got 10 extra sd cards for free. And the bootloader makes organising files so much easier.

I can see this growing too. I'm off to search for propeller text editors. I'd like to add that to the mix...

And (see photo), no evil error messages with Kye's code *grin*

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 6/6/2010 11:25:09 AM GMT

Toby Seckshund
06-06-2010, 07:09 PM
Dr_A

I am being incredably thick today (I'll put it downto the 7-day fortnight shift turning into a 7-day week) but I just tried to put a NASCOM.BIN onto my SD and Kye's code , modded by you sees it as a long filename NASCOM~1.BIN. I tried forcing the name to xxx.BIN but that just left me with xxx~2.BIN.

If it is so simple a problem, forgive me as I have been up in the night trying to stop the XXXXXXX flat roof from leaking. http://forums.parallax.com/images/smilies/cry.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Why did I think a new, more challenging, job was a good idea ??

Dr_Acula
06-06-2010, 07:25 PM
Toby, that sounds odd. I've changed a number filenames to 8.3 format so they fit and no problems. I'm using NASCOM.BIN as well. Only thing is that I did change the filename on the PC before transferring it over to the sd card.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Toby Seckshund
06-06-2010, 07:33 PM
I think that is what I tried. Hey Ho.

With Kye's code as a front end that second EEPROM I put into "Clunky" is very much redundant. I might just leave it, with Nas in it, for when I can't wait for a boot route. http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Why did I think a new, more challenging, job was a good idea ??

Dr_Acula
06-06-2010, 08:17 PM
Kye has done some amazing work. It all depends on how you look at things, but from my point of view, the eeprom now becomes a very tiny thing whose only purpose is to get the sd card working (and for debugging, though I mainly do that with F10 ram). The sd card becomes the main repository of data. I can see it loaded up with all sorts of programs - Catalina, Propbasic, games. All easily selectable with a menu that you can customise with some simple spin code.

Fat32 is so convenient. I know Kye has a format routine, but sd cards already come formatted as fat32 so you don't even need to do a format. I'm using these micro sd cards that come with a free micro-to-standard adaptor. There are these USB to micro-sd adaptors on ebay for only a couple of dollars. So easy to load up with many programs/emulations all at once.

If I ever were to consider flying to the US to one of these cool Propeller meetings, this is the application I would use as I could put everything on a SD card, then it would be easy to demonstrate many types of applications on the propeller and to switch between them without having to reprogram the eeprom. Just perfect for that 'how cool is this chip' demonstration where you want to be certain that it will all work on the day.

@Toby - does that mean you have it working now? If not, how can we help?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Toby Seckshund
06-06-2010, 08:56 PM
Lunch stopped play. I will have to get to grips with the Short/long name bit.

Although it is a slight inconvienence to have to add an EEPROM, at least you do not have to keep a track of how many times it has been written to before the main chip dies.



EDIT

I put the "Show extentions " bits on on the XP, ans it now renames ok. I had forgotten to do this after the last Format. Windows, Bless.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Why did I think a new, more challenging, job was a good idea ??

Post Edited (Toby Seckshund) : 6/6/2010 1:10:07 PM GMT

Dr_Acula
06-06-2010, 10:12 PM
Ah yes, with 'no extensions' shown you might have had it named as NASCOM.BIN.BIN

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Oldbitcollector (Jeff)
06-06-2010, 10:17 PM
Has anyone done the NTSC conversion yet? I didn't see it an attachments..

As for the block of .BIN execution code, I'd like to think I write better spin since then.. ;)

I did a release of PropDOS that I don't think I ever released, but the concept is EXTREMELY handy...
Version 1.8 of PropDOS doesn't halt if the keyboard isn't present. It accepts data from both a local
keyboard and RS232, as well as outputing data on both RS232 channels and video. The same way
Sun Microsystems SPARC machines used to work if a local keyboard wasn't detected.

Perhaps we could add this to KyeDOS?

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Feature Projects: PropellerPowered.com (http://www.propellerpowered.com)
Visit the: PROPELLERPOWERED SIG forum (http://www.savagecircuits.com/forums/forumdisplay.php?29-Propeller-Powered) kindly hosted by Savage Circuits (http://www.savagecircuits.com).

Kye
06-06-2010, 11:33 PM
Hey Dr_Acula,

I'll be releasing alot of other interesting stuff soon. I wrote a combo keyboard and mouse driver that adds alot of new and nice features not found in the current ones today.

Oh, and the format command is just a quick format rountine for FAT32 and FAT16. The file system already has to be in place, the format rountine just deletes everything on the selected partition. I made that for the data loging people who just want to write stuff to the SD card and not stop. Then when they need to start over its easy to wipe the card.

---

Anyway, I'll be putting this code on the obex soon if no one is finding any problems. I also would encourage you to use the directory features so that you don't have to put all the files in one folder. But I do support up to 65535 files and folders in one folder.

...And about booting being slow... There's not much I can do about that, you can disable the checksum test if you want, but then ANY file could be booted from... I won't change that in my code, but you can always MOD my code.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Ahle2
06-06-2010, 11:53 PM
Kye said...
Anyway, I'll be putting this code on the obex soon if no one is finding any problems.

Okey, so far two of my SD cards was unable to mount.
- SandDisk 1GB micro SD.
- ZAP GLIDER 2GB. (66x)

My other SD cards mounts perfectly.

Toby Seckshund
06-07-2010, 12:35 AM
I use a Sandisk 2GB and the system runs. Before on these emu's I have noticed that an old 16MB SD was incredibly slow, but worked. I have a 32MB MMC somewhere, I will see how that goes.


The only thing I have a quiry on is, When the first SD> prompt comes up, I always get a "Unknown command" message. The wanted cammand is happy on the second and all other times though.

I am using it on a copy of a DracBlade (with 512KB) but it is totally the same, as far as the core goes. I have a simular sort of thing on the Nascom emu, if I do not put a dummy ZZZ.NAS after the directories then it will not allow selection to be used via the up and down arrow keys.

Still if if all worked perfectly it would stop me having to think.

Thanks for this code, Kye.

Alan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Why did I think a new, more challenging, job was a good idea ??

Oldbitcollector (Jeff)
06-07-2010, 01:22 AM
Works with 2mb Kingston, and 4mb Sandisk SD cards, with the exception that I can't mkdir directories.
"Clock I/O Error"

Time chip a requirement?

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Feature Projects: PropellerPowered.com (http://www.propellerpowered.com)
Visit the: PROPELLERPOWERED SIG forum (http://www.savagecircuits.com/forums/forumdisplay.php?29-Propeller-Powered) kindly hosted by Savage Circuits (http://www.savagecircuits.com).

Rsadeika
06-07-2010, 01:36 AM
I am using a blank Kingston 2GB card, and when I tried to 'mkdir' I get a "Clock I/O error". I also get the same error when I try 'mkfil'. When I tried
'ls' command, it did not present an error. I tried the 'df fast', and 'du fast', and it did not complain.

My setup is a breadboard, with dip Prop wired up. I tried my ETT DS1307 Mini-board, but it did not respond, so I can assume that the board, or at
least the chip is dead.

KMyers
06-07-2010, 01:45 AM
Works good on my PPDB and a SanDisk 2 gb sd card. Can make directories and all but cant use clock.

Ken

Kye
06-07-2010, 07:02 AM
OBC, I posted a version which does not require the DS1307 clock. Its the second post on this thread. My regular driver requires the clock however.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Dr_Acula
06-07-2010, 07:12 AM
@Toby "The only thing I have a quiry on is, When the first SD> prompt comes up, I always get a "Unknown command" message. The wanted cammand is happy on the second and all other times though."

Is that using the serial driver or the local keyboard? I had the same problem on the serial driver, as the buffer has one or two bytes in it - I think from when it is connected or from the terminal program at the other end. The problem seemed to go away when I changed to local keyboard. It might be a matter of clearing the buffer.

@OBC, TV would be the next logical thing. Do you have some code?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

nicolad76
06-07-2010, 10:11 AM
This is my test.
Thanks for the great code you wrote!!!!!


>_ Running command: test
Creating test file "testfile" ... Success

Wrote 131,072 bytes at 0000056563 bytes per second

Running byte stride write test...
Wrote 32,768 bytes at 0000004227 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 0000008105 bytes per second

Running word stride read test...
Read 65,5536 bytes at 0000008454 bytes per second

Running long stride write test...
Wrote 131,072 bytes at 0000014883 bytes per second

Running long stride read test...
Read 131,072 bytes at 0000016804 bytes per second

Running speed writing test (512 bytes at a time)...
Wrote 131,072 bytes at 0000080496 bytes per second

Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000250432 bytes per second

Running append test... Success

Running seek test... Success

Deleting test file "testfile" ... Success


Micoro SD HC 4GB

Toby Seckshund
06-07-2010, 04:34 PM
Dr_A

The first prompt not working problem I have is from local kbd, I have not tried the remote way yet. Although the '232 was connected all the time to the PC. I will check that out when Clunky gets back on the bench (playing with AVRs, sorry, sorry, ... )

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Why did I think a new, more challenging, job was a good idea ??

Oldbitcollector (Jeff)
06-07-2010, 11:52 PM
@Dr_A

I can jump over from my current project to connecting Doug's 8x8 driver to this sometime this week.
(Unless you've already started.)

BTW, Your Dracoboards arrived today.. Not sure if I can get the parts quick enough before I go to UPEW, but I'm going to try.
(Nice Boards!!!!)

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Feature Projects: PropellerPowered.com (http://www.propellerpowered.com)
Visit the: PROPELLERPOWERED SIG forum (http://www.savagecircuits.com/forums/forumdisplay.php?29-Propeller-Powered) kindly hosted by Savage Circuits (http://www.savagecircuits.com).

jazzed
06-07-2010, 11:56 PM
Kye, Can you look into this for supporting long filenames? en.wikipedia.org/wiki/Rock_Ridge (http://en.wikipedia.org/wiki/Rock_Ridge)
@potatohead mentions it in another thread. Without long filenames your work is not useful for my next Java project.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM (http://www.brouhaha.com/~sdenson/PropellerJVM/index.html)

Kye
06-08-2010, 12:09 AM
Mmm, I sorry but I really can't be the one to add support for Rock_Ridge... I do not have time. This driver has already taken me a year to complete using most of my extra free time. I will not be changing the structure for a while.

But, you can just store the long name of the file inside the file as the first 256 bytes. Then make the actual names of the files on disk just hash codes that should match the long name of the file when asked for... or something like that.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

pullmoll
06-08-2010, 07:54 AM
Another test run with a 1GB SanDisk uSD card

>_ Running command: test
Creating test file "testfile" ... Success

Wrote 131,072 bytes at 0000042484 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 0000007895 bytes per second

Running word stride read test...
Read 65,5536 bytes at 0000008489 bytes per second

Running long stride write test...
Wrote 131,072 bytes at 0000014289 bytes per second

Running long stride read test...
Read 131,072 bytes at 0000016804 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 0000250432 bytes per second

Running append test... Success

Running seek test... Success

Deleting test file "testfile" ... Success




This time there is no "0" bytes per second read. I guess the one in my first post was due to some overrun?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects (http://pmbits.ath.cx/prop/)

Larry C.
06-08-2010, 08:09 AM
Here's the result of yet another test, memory chip was a PNY 2GB microSD:


>_ mount
Running command: mount
Disk 0x00000000 with volume ID 0xFC303DA9 a.k.a ready

>_ test
Running command: test
Creating test file "testfile" ... Success

Wrote 131,072 bytes at 0000056983 bytes per second

Running byte stride write test...
Wrote 32,768 bytes at 0000004262 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 0000008105 bytes per second

Running word stride read test...
Read 65,5536 bytes at 0000008489 bytes per second

Running long stride write test...
Wrote 131,072 bytes at 0000014988 bytes per second

Running long stride read test...
Read 131,072 bytes at 0000016874 bytes per second

Running speed writing test (512 bytes at a time)...
Wrote 131,072 bytes at 0000080496 bytes per second

Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000268320 bytes per second

Running append test... Success

Running seek test... Success

Deleting test file "testfile" ... Success

jazzed
06-08-2010, 11:36 AM
Kye said...
Mmm, I sorry but I really can't be the one to add support for Rock_Ridge... I do not have time. This driver has already taken me a year to complete using most of my extra free time. I will not be changing the structure for a while.

But, you can just store the long name of the file inside the file as the first 256 bytes. Then make the actual names of the files on disk just hash codes that should match the long name of the file when asked for... or something like that.

I believe I can make it work for what I need to do ... something like that. Thanks.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM (http://www.brouhaha.com/~sdenson/PropellerJVM/index.html)

potatohead
06-08-2010, 01:12 PM
http://en.wikipedia.org/wiki/TRANS.TBL

Perhaps that's a very easy answer Jazzed.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness! (http://propeller.wikispaces.com/)
8x8 color 80 Column NTSC Text Object (http://obex.parallax.com/objects/550/)
Wondering how to set tile colors in the graphics_demo.spin? (http://forums.parallax.com/attachment.php?attachmentid=70768)
Safety Tip: Life is as good as YOU think it is!

Rayman
06-09-2010, 09:22 PM
Kye: You've caught my attention with directory support, free space functions, and boot code.
I think I'll have to give it a try.

I'm a little worried though because some people have reported that some cards didn't work...
Do you think that is just because they are older cards?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

Kye
06-09-2010, 11:06 PM
Not every card works with FSRW as I've heard also. Mmm, I really have no clue. Apparently though there are differences in the card timing betwen thick and thin SD cards. It could be alot of things. I would need to have the said card in hand to debug with.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

lonesock
06-10-2010, 12:15 AM
Kye said...
Not every card works with FSRW as I've heard also...

Hmm. Do you know any specific cases? I was under the impression that the latest FSRW 2.6 version, using the default safe_spi block driver, hadn't had any issues. I do know that with some cards you can still get to a state that requires a power cycle if the prop was reset during a transfer, but that's because the MMC and SD specs don't specifically mandate how the cards handle a reset if they think they are in the middle of a multiblock read or write. And we use the multiblock mode because SDHC cards tend to suck, performance wise, using singleblock mode. Without the multiblock mode we wouldn't be able to get our current transfer rates of > 1MB/s.

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.

Kye
06-10-2010, 01:41 AM
Mmm, I really can't recall, but I'm not talking about your new block driver lonesock. I was talking about the old FSRW block drivers.

Mabye I'm wrong.

Also, How did you reach those speeds? Man I tried but I could not get the 20Mhz clock stuff to work. =)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

WBA Consulting
06-10-2010, 04:12 AM
They say the only dumb question is those that go un-asked, so to prevent this from staying a dumb question, here it is:

What are the capabilities of the WAV play and record functions in the SD2.0 object? What's the best "quality" I can record and what's the best "quality" that I can convert on my PC to have the propeller playback?

A friend of mine used my VMusic2 in a project for his autistic son that I believe could be easily done with this new object, but the audio needs to be clean on a 2" speaker. Obviously, with a 2" speaker I don't need CD quality, but telephone quality wouldn't be desirable as a finished project. The dis-advantages of the current design is that the audio files (mostly voice) have to be pre-recorded as MP3s which makes it less user friendly and requires a PC. It would be nice to be able to record the audio clips directly on the device.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andrew Williams
WBA Consulting
WBA-TH1M Sensirion SHT11 Module (http://www.aestheticacoustics.com/sht11_01.htm)
My Prop projects: Reverse Geo-Cache Box (http://forums.parallax.com/showthread.php?p=869153), Custom Metronome (http://forums.parallax.com/showthread.php?p=906277), Micro Plunge Logger (http://forums.parallax.com/showthread.php?p=875698)

Kye
06-10-2010, 06:13 AM
The WAV play function handles all wav files that comform to https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ that layout and can hit play back speeds of 44100 Khz. The DACEngine can go all the way up to 80Khz, but the block driver read speeds will only get you to about 60Khz max.

The record feature records wav files that also conform to the layout on the posted link. The only limiting factor with it is that some SD cards with my driver have very bad write speeds. So... I set the recording feature down to 8Khz with 8 bit sampling.
However, the ADCEngine can go up to 80Khz at 16 bits if the cards transfer speed can keep up with it.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Miner_with_a_PIC
06-10-2010, 10:22 PM
Kye said...
The FAT file system spec mandates that you do so when allocating a new cluster so that all remaining bytes are zeros. You must do this when making a new cluster for directories since a zero byte at the start of a dir entry indicates the end of the directory. For files it is not so neccesary... but I am using the same function for both. I could add in an option for the function so that it does not do that for files. This would increase write speed.


Kye could you please add this functionality as the write speed I am experiencing with this new snazzy release is considerably lower* than the fsrw predecessor. This lower write speed is forcing me to continue to use the fsrw version on my current project as SD write speed will become the system throughput bottleneck. Every bit helps but >= 2X speed increase would remove the bottleneck.

*Card being used...4GB Sandisk micro HD ....fsrw write speed ~250,000 bytes per second, SD2.0 27,000 bytes per second...both preallocation mode, same propeller system @ 40 Mhz (marginal increases in write speeds when bumping up to 80 Mhz). Similar results with other cards also...really a bummer as the new functionality in this library is outstanding.

Kye
06-10-2010, 11:26 PM
Yeah, I know, I wish I had lonesock to help me with the block driver.

Okay, I'll see what I can do.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

David B
06-11-2010, 12:33 AM
Kye, your FAT work is amazing, and is very well commented, which is really great.

Have you ever considered dividing the filesystem management code and the device sector access code into separate modules?

If you were to do that, then your FAT access code could be run on top of different devices, such as hard disks or even external RAM, as long as the device-driver modules provided initialization and shutdown routines and addressed-sector read and write routines.

Also, with a separate module, the low level SD card sector access module could be used directly by those who really need the fastest write speeds, such as for raw data loggers.

Or, lonesock's block driver could simply be plugged in to your FAT module, yielding the best of both worlds!

What do you think about that idea?

It's great how your SD device access code is so well commented, and it's also great that your code reads the SD size from the SD CSD register, which a raw data logger could find useful when it sets up its legal logging write addresses.

And a separate question in regards to attaining the fastest write speeds - I heard somewhere that if SD card raw sectors are explicitely pre-erased, then its data sector write operation will detect that condition and the actual data writes will go much faster, because they can then skip the internal erase step of the write process. I don't know if that's just a urban legend from the early days of SD development, or if it's still true.

Kye, during all your SD work, have you heard anything like that?

To test it, the raw SD erase command would have to be implemented, which neither your code nor the mb_raw_spi module currently does. Also, it looks like the erase command needs to be configured using some CSD register values, so it's not a trivial command to implement.

lonesock
06-11-2010, 12:53 AM
Kye said...
Yeah, I know, I wish I had lonesock to help me with the block driver.

Okay, I'll see what I can do.

Sorry for not responding earlier. In my safe driver (assuming 80MHz operation) I have the output at 20MHz, using one counter to drive a clock pin, and the second counter as a shift-out-register. You don't get to vary the clock pin speed, though, it must always be 1/4 the propeller's clock speed, that way each clock can line up to a single PASM instruction (usually a ROL on my shift register, PHSA). For safe input I'm using 10MHz (or, more correctly, prop frequency / 8). The fast version uses a 20MHz clock pin as well, but it doesn't work with all hardware at all times, so we default to the 10MHz for input. (btw, MMC init code can't happen at 20MHz, according to the spec, so I use a Spin version, which is plenty slow, and not too large.)

A second main trick for speed is the read-ahead and write-behind code. I have a single buffer (128 longs in the cog, = 512 bytes). When you transfer a block to be written, it get's copied into the cog buffer, then control returns to the caller, and the writing to the SD card actually happens in the background without tying up the calling cog. When you request a read block, the block is read, passed to the caller, then the next sequential block is read and stored in the buffer. At the next read call, the buffer is checked to see if the requested block actuall was the next one in the sequence...if so, it's already in the buffer, which is copied out, and the next sequential block is read. This takes advantage of the normal usage pattern of the reads and writes. You just have to be aware of the state of the driver, and you may have to block calls until the driver isn't busy.

Finally, I use the multiblock mode because most SDHC cards are terribly slow in single-block mode. YOur code may not be the bottleneck. Sometimes the wait for the card to signal ready after requesting a single block read or write is loooooong. You may want to add some profiling to see if this is the case.

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.

Kye
06-11-2010, 12:54 AM
Okay, so here's a version where I hooked in the FSRW block drivers...

The 512 bytes at a time read speed gain is about 150%. And the write speed gain is about 10%. So... I have no idea why I can't get faster write speeds. The cluster size for the test card was 128 sectors, so this is the most optimum senario for multiblock read and write.

Anyway, look through this version for clues on how to make it faster.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Kye
06-11-2010, 01:01 AM
@David B - Yes I have heard that pre erasing will increase speed. But I have no space for that in my code.

While everyone wants really fast read and write speeds... my goal is to have safe/compatible/ and reliable operation while providing alot of features. So, for now. use FSRW when you need massive speed. I don't think my file system will be able to offer it currently.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

MacTuxLin
06-11-2010, 04:51 PM
Hi Kye,

I've tested your code on a few uSD cards & they all worked without problems (attached are the results), fantastic. Just for fun, I've done a few formats on a single 4GB card in 2k, 4k, 8k & 16k allocated units. The speed seems to go up but at the expenses of many things like space & the life-span of the uSD. Appreciates your great work.

Kye
06-12-2010, 02:34 AM
@MacTuxLin - Thanks!

@All - Okay I think the reason I receive no speed gain using the FSRW drivers for write mode is because I read in every sector before I write it out. This makes multiblock mode write useless.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

BigFoot
06-12-2010, 07:47 AM
Nice work Kye,

If this works as advertised it could solve several problems that we have.

Russ

simonl
06-12-2010, 11:23 PM
Hmm, just been trying this - which seems excellent BTW - and got it working with a Kingston 1GB card, but not with a Canon 16M card. I tried FSRW2.6 to see if it's the card, but that fails when trying to write to the filesystem too.

I'm guessing that the card's not formatted correctly - although I formatted both in the same camera. Does anyone know what "format" command I should use (from Windows7) please?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
-------------------------------

www.norfolkhelicopterclub.com (http://www.norfolkhelicopterclub.com)

Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

MacTuxLin
06-12-2010, 11:39 PM
Hi Simon,

I used Win7 to format the card as well. Right-click on the card & select format (uncheck Quick Format). The default is 4k allocation unit, I think. I've did tried 2k, 4k, 8k & 16k and all worked but it is better to stick to win's default 4k.

Kye
06-12-2010, 11:54 PM
What part fails? Do you get a Disk I/O error? Or a file system unsupported error?

The Disk I/O error is not fixable if it keeps happening. The file system unsupported error means that the card is formated uncompatibly.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Bill Henning
06-13-2010, 02:10 AM
Hi Kye,

I tried to make a quick and dirty port to PropCade of the lonesock version you posted on this page.

Unfortunately it is not mounting my test uSD card, a 32MB SanDisk formatted for FAT16.

fsrw26 speed test works on it fine.

As long as I don't run VMCOG at the same time, the changes to your code are minimal - I just added two lines to shell to select the uSD, and changed the necessary pin definitions.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com (http://www.mikronauts.com) E-mail: mikronauts _at_ gmail _dot_ com
My products: Morpheus (http://mikronauts.com/products/morpheus/) / Mem+ (http://mikronauts.com/products/morpheus/memplus/) / PropCade (http://forums.parallax.com/showthread.php?p=894725) / FlexMem (http://forums.parallax.com/showthread.php?p=894853) / VMCOG (http://forums.parallax.com/showthread.php?p=878382) / Propteus (http://mikronauts.com/products/propteus/) / Proteus (http://mikronauts.com/products/proteus/) / SerPlug (http://mikronauts.com/products/serplug/)
and 6.250MHz Crystals to run Propellers at 100MHz (http://mikronauts.com/products/mikronauts-625mhz-crystal/) & 5.0" OEM TFT VGA LCD modules (http://forums.parallax.com/showthread.php?p=852195)
Las (http://mikronauts.com/software-products/largos/) - Large model assembler Largos (http://mikronauts.com/software-products/largos/) - upcoming nano operating system

Kye
06-13-2010, 04:00 AM
Yeah, the lonesock port failed to mount alot for me also... I probably don't know how to use it properly as it has "issues" with mounting...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Bill Henning
06-13-2010, 04:06 AM
Thanks, I will try your non-lonesock version :)


Kye said...
Yeah, the lonesock port failed to mount alot for me also... I probably don't know how to use it properly as it has "issues" with mounting...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com (http://www.mikronauts.com) E-mail: mikronauts _at_ gmail _dot_ com
My products: Morpheus (http://mikronauts.com/products/morpheus/) / Mem+ (http://mikronauts.com/products/morpheus/memplus/) / PropCade (http://forums.parallax.com/showthread.php?p=894725) / FlexMem (http://forums.parallax.com/showthread.php?p=894853) / VMCOG (http://forums.parallax.com/showthread.php?p=878382) / Propteus (http://mikronauts.com/products/propteus/) / Proteus (http://mikronauts.com/products/proteus/) / SerPlug (http://mikronauts.com/products/serplug/)
and 6.250MHz Crystals to run Propellers at 100MHz (http://mikronauts.com/products/mikronauts-625mhz-crystal/) & 5.0" OEM TFT VGA LCD modules (http://forums.parallax.com/showthread.php?p=852195)
Las (http://mikronauts.com/software-products/largos/) - Large model assembler Largos (http://mikronauts.com/software-products/largos/) - upcoming nano operating system

Kye
06-13-2010, 12:00 PM
Oh, how did you want me to mod it so that it will support tristating?

My driver supports polling of the SD card regularly however, so that feature won't be active if you tristate the lines.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Bill Henning
06-13-2010, 08:17 PM
I have to think a bit about how to share the SPI bus on PropCade. Probably I will have to use LOCKSET/LOCKCLEAR in VMCOG and the low level SD driver.

The way PropCade multiplexes SPI is:

3 bit SPI device address on P9/P10/P11 (LSB on P9, MSB on P11)

0-5 are SPI DIP/SOIC8 ram/flash devices
6 is the I/O expander
7 is the uSD socket

The reason I did it this way is that the four pin group from P0-P3 appears like a regular SPI group - /CS,CLK,MOSI,MISO

So I do need the SD card to totally release the SPI bus after a transaction, and as soon as I figure out the locking scheme, I need it to stuff 7 into P9-P11 after getting the lock, before asserting /CS.

I will probably use LOCK 1 for SPI multiplexing (I use LOCK 0 on Morpheus for memory contention control, and the new Morpheus+ also multiplexes one SPI channel)

Basically, on PropCade, I need to share the SPI bus between VMCOG, SD, and the I/O expander used for joysticks.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com (http://www.mikronauts.com) E-mail: mikronauts _at_ gmail _dot_ com
My products: Morpheus (http://mikronauts.com/products/morpheus/) / Mem+ (http://mikronauts.com/products/morpheus/memplus/) / PropCade (http://forums.parallax.com/showthread.php?p=894725) / FlexMem (http://forums.parallax.com/showthread.php?p=894853) / VMCOG (http://forums.parallax.com/showthread.php?p=878382) / Propteus (http://mikronauts.com/products/propteus/) / Proteus (http://mikronauts.com/products/proteus/) / SerPlug (http://mikronauts.com/products/serplug/)
and 6.250MHz Crystals to run Propellers at 100MHz (http://mikronauts.com/products/mikronauts-625mhz-crystal/) & 5.0" OEM TFT VGA LCD modules (http://forums.parallax.com/showthread.php?p=852195)
Las (http://mikronauts.com/software-products/largos/) - Large model assembler Largos (http://mikronauts.com/software-products/largos/) - upcoming nano operating system

Dr_Acula
06-13-2010, 10:44 PM
Hi Kye,

With a DOS it gets a bit tedious removing the sd card all the time, so I've been experimenting with xmodem. I started at 110 baud with lots of delays, then 1200 and have now pushed it up to 38k.

I have yet to add saving the file, but it worked as a seperate program so I think it should work (you can see the commented out test lines). There will be some debugging and I need to add timeouts, but this does download a 100k file with no problems.

In the code below, where I write out the bytes to the fat file I'm using this:



repeat i from 3 to 130
' fat.writebyte(XmodemIn[ i ]) ' save the 128 bytes




Is there a more elegant way, eg telling the fat driver I want to save 128 bytes with the pointer @xmodemin array, but start at address 3?





VAR
byte XModemIn[132]
byte validpacket
word PacketNumber
byte ErrorCounter
word i
byte OnesComplement
word Checksum
PRI programXmodem(stringPointer)

ifnot(str.stringCompareCI(string("xmodem"), stringPointer))
PrintString(string("creating file xmtest.txt"))
' fat.deleteEntry(string("xmtest.txt")) ' delete any files with this name
' fat.openFile(fat.newFile(string("xmtest.txt")), "W") 'create a new file
sio.rxflush(0) ' start with clear receive buffer
errorcounter:=0 ' reset error counter
sio.tx(0,21) ' send a NAK to start things off
packetnumber:=1 ' packet number 1
repeat
validpacket :=255 ' equals true
XModemIn[0]:=sio.rx(0) ' read in one byte
'vt100.hex(xmodemin[0],2)
'vt100.str(string(" "))
if XmodemIn[0] == 4 ' finish byte
errorcounter:=255 ' signifies finish with no errors
vt100.str(string("finish byte 4"))
else
if XmodemIn[0] <> 1 ' not 1
validpacket:=0 ' invalid packet
errorcounter++ ' add one to error counter
vt100.str(string("err1"))
else ' 1= a valid start byte for a packet
repeat i from 1 to 131
XmodemIn[ i ]:=sio.rx(0) ' read in rest of packet
'vt100.hex(xmodemin[ i ],2)
'vt100.str(string(" "))
repeat while packetnumber > 255 ' calculate the packet number always <256
packetnumber:=packetnumber-256
onescomplement:=255-packetnumber ' calculate the ones complement
if packetnumber <> XmodemIn
validpacket:=0
errorcounter++
vt100.str(string("err2"))

if XmodemIn <> onescomplement ' ones complement not correct
validpacket:=0
errorcounter++
vt100.str(string("err3"))

checksum:=0 ' calculate the checksum
repeat i from 3 to 130
checksum:=checksum+XmodemIn[ i ]
repeat while checksum>255 ' round to under 256
checksum:=checksum-256

if checksum <> XmodemIn[131] ' checksum not valid
validpacket:=0
errorcounter++
vt100.str(string("err4"))

if validpacket == 255 ' packet is valid so save it
repeat i from 3 to 130
' fat.writebyte(XmodemIn[ i ]) ' save the 128 bytes
packetnumber++ ' increment packet number
sio.tx(0,6) ' send a ACK and wait for the next packet
vt100.str(string("ACK"))
'vt100.dec(packetnumber)
vt100.out(13)
vt100.out(10)
else
sio.tx(0,21) ' send a NAK as the packet was corrupted
vt100.str(string("NAK"))
until errorcounter>10
' need to add the final bytes to finish up and close file
' looking at xmodem.asm I think it is supposed to send an ACK here, not a NAK, the text is wrong
sio.tx(0,6)

vt100.str(string("finished"))
' fat.CloseFile

abort 0


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 6/13/2010 2:50:12 PM GMT

Kye
06-13-2010, 10:53 PM
fat.writeData(address, count) ....

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

jazzed
06-13-2010, 11:17 PM
Dr_Acula said...

With a DOS it gets a bit tedious removing the sd card all the time, so I've been experimenting with xmodem.

@DR_A: Quick question. Sorry if it's too OT.

I did this xmodem thing too, but now I'm running Vista (involuntarily) and there is no hyperterm.
Can you recommend a link to a good xyzmodem client application download?

Thanks,
--Steve

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM (http://www.brouhaha.com/~sdenson/PropellerJVM/index.html)

StefanL38
06-14-2010, 01:31 AM
hi jazzed,

how about br@y's terminal ? (http://sites.google.com/site/braypp/terminal)

has even macros and a scripting language to interact with the other side conditionally

best regards

Stefan

DDS
06-14-2010, 04:08 AM
This is possibly in the wrong thread but...

I am new to the SD driver so excuse my ignorance...

I am using the FSRW 2.6 driver and it is working but I have to constantly remove the SD card and put it into a PC & read it there to get it to work again with the propeller. Is this what some refer to it getting "stuck"?
Is there a work-around? I have tried unmounting/remounting but it doesn't help.

I am using the "mb_rawb_spi" driver
Thanks in advance.

Don

Kye
06-14-2010, 04:21 AM
Mmm, I just know mine does not have that problem. I've had a similar issue when using the FSRW block driver sometimes. I think it has to do with multiblock mode.

I don't know a work arround. PM lonesock.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

jazzed
06-14-2010, 04:32 AM
StefanL38 said...
hi jazzed,
how about br@y's terminal ? (http://sites.google.com/site/braypp/terminal)


I don't think that supports xmodem for binary transfers. I already have code for xmodem.
It is a good protocol like y/z modem, kermit etc... for transfer to SD (barring IP or USB support).

Hopefully @DR_A will have a good xyz modem PC application download link.

Again, sorry if this is too OT.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM (http://www.brouhaha.com/~sdenson/PropellerJVM/index.html)

Dr_Acula
06-14-2010, 08:47 AM
Thanks kye, I figured it would be something simple.

I'm using a different serial driver as something is going wrong with the fat32 serial driver with a 132 byte packet, somewhere between bytes 15 and 31 it merges two bytes into one. Happens at all baud rates, even down to 110 baud. Just finding this took a serial sniffer program and printing every byte in hex on the vga screen and I'm still not sure why this happens as the buffer for both serial drivers is 256 bytes. Maybe it isn't between 15 and 31 - maybe the other bytes that go through at startup puts it there and that is where it cycles from 255 to 0. I figured I would get xmodem working first and go back to that.

Once I get it working with Rx, I'll do the Tx half. Then two propeller boards running KyeDOS can send files to each other. (just use a 3 wire null modem cable with wires 2 and 3 crossed over).

I also need to push the baud rate up to 115k.

As for downloading froma PC, I've been using Teraterm. But I am at work so I can't post the code, and I can't download the code to the work computer to see which version is the correct one. The newer versions cost money and don't work so well with xmodem. I *think* this is the correct version - about 2002 vintage, runs on xp (and so hopefully vista) and has xmodem www.tucows.com/preview/195282 (http://www.tucows.com/preview/195282) But if not, when I get home I'll post the code. I have some other terminal programs too, but the one I don't use much is hyperterminal. I've also got my own code in vb.net. Ultimately, if this works, maybe BST could include xmodem, but that is a long way down the track.

@DDS - I've not used fsrw much, but no problems like that with Kye's driver code. That is why I'm hooked!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 6/14/2010 12:54:26 AM GMT

Kye
06-14-2010, 09:15 AM
I should write a continuity tester program for my serial port driver... Mmm, I'm gonna do that tonight.

You keep finding errors in it Dr_Acula =).·Thanks however.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

jazzed
06-14-2010, 09:52 AM
Dr_Acula said...
I *think* this is the correct version - about 2002 vintage, runs on xp (and so hopefully vista) and has xmodem www.tucows.com/preview/195282 (http://www.tucows.com/preview/195282)


Looks like that one does not recognize the USB ports for me on Vista.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM (http://www.brouhaha.com/~sdenson/PropellerJVM/index.html)

Kye
06-14-2010, 10:31 AM
@Dr_Acula - Okay, I just wrote up a tester program and I had no problems at any baudrates. I'm not sure what's happening with you.

The program is atteched. It does a loop back test to make sure the data is being sent okay and stresses my driver as much as possible by transmiting 255 bytes back and forth in full duplex mode.

I think it is a pretty good test of functionality. It works fine in my hardware. Please test it on yours.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Dr_Acula
06-14-2010, 05:42 PM
Hi jazzed,

I'm home now and able to check the download on that program. It works ok on XP. See attached.

On my PC COM1 and COM2 are real physical serial ports. COM3 and COM4 are cheapie ebay $2 USB to D9 serial adaptors. So the list is 4 ports. That all works ok.

Can you describe the problem a bit more? If Teraterm (or other terminal programs) are not finding the serial ports, that might suggest more a Windows problem. What is Control Panel/System/Hardware/Device Manager/Ports reporting? for example I get USB-SERIAL CH340 (COM3) when I plug in the USB to serial adaptor. Unplug it and it automatically updates the new configuration. Does Vista work the same?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 6/14/2010 9:48:32 AM GMT

Dr_Acula
06-14-2010, 06:19 PM
Hi Kye,

Transferred the first .BIN file via xmodem (I'm testing with FEMTOBASIC which is renamed FBAS1.BIN)

Two minor errors:

1) If the file already exists, I would like to erase it. At the moment I am manually deleting it each time and using this code with the delete routine commented out.



'fat.deleteEntry(string("FBAS1.BIN")) ' delete any files with this name
fat.openFile(fat.newFile(string("FBAS1.BIN")), "W") 'create a new file




is there a way to see if a file exists, and only delete it if it is found?

2) XMODEM pads out the last packet with ascii hex 1A. See attached for a comparison of the original file and the downloaded file. This is upsetting your checksum routine in the SD2.0_FATEngine and it is aborting with the checksum error at the bottom of this piece of code. Is there a way around this?



PUB bootPartition(fileName) | bootSectors[64] '' 101 Stack Longs

'' ┌───────────────────────────────────────────────── ────────────────────────────────────────────────── ───────────────────────┐
'' │ Reboots the propeller chip to run the selected valid spin BIN or EEPROM file. │
'' │ │
'' │ If an error occurs this function will abort and return a pointer to a string describing that error. │
'' │ │
'' │ FileName - The name of the file to reboot from in the current directory. │
'' └───────────────────────────────────────────────── ────────────────────────────────────────────────── ───────────────────────┘

longfill(@bootSectors, 0, 64)
openFile(fileName~, "R")

repeat (listSize <# 32768)
result += readByte

ifnot($1FF & fileName++)
bootSectors[fileName >> 9] := (partitionStart + FATFirstSectorInCluster(currentCluster) + FATWorkingSectorInCluster)

result &= $FF
changeFilePosition(6)
fileName := readShort
closeFile

if((result and (result <> $14)) or (fileName <> $10))
errorNumberFlag := Checksum_Error
abort string("Checksum Error")




addit = this is a real kludge but I commented out these lines



' if((result and (result <> $14)) or (fileName <> $10))
' errorNumberFlag := Checksum_Error
' abort string("Checksum Error")




and it now does boot the .BIN file correctly. So - with this temporary fix, it is now possible to download and run new binary images without removing the sd card.

Ok - next job - get the 'SEND' half of xmodem working.

I've got a bit stuck reading the file size



VAR
long BinaryFileLength

PRI programXmodemSend(stringPointer)
ifnot(str.stringCompareCI(string("xms"), stringPointer))
PrintStringCR(string("sending file FBAS1.BIN"))
sio.rxflush(0) ' start with clear receive buffer
fat.openFile(string("FBAS1.BIN"), "R") 'open the file for reading
BinaryFileLength:=fat.ListSize




maybe the syntax isn't right but this always returns zero. Pub listsize says
'' │ If a file is currently open this function will retrieve that files information.

Help there would be most appreciated!

BTW, this sd card driver is a treasure trove of information. I need to know a file size. There is a routine for that. There is a routine for everything.

See pictures - KyeDOS is now working on a 20x4 LCD display, as well as VGA and via the serial port. Input from keyboard or serial port. Output to serial port, VGA and LCD.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 6/14/2010 12:07:08 PM GMT

Kye
06-14-2010, 11:33 PM
Mmm, as for packet padding, I would suggest removing the padding when xmodem is sending you the data. You know the file length right? So just zero out anything above that file length so that the padding is all zeros. Then the checksum rountine won't have a problem.

...

The list size rountine returns the file's size always. However, you may have not written out the size. You have to close the file after you finish writing it for the size to be written out.

Check what LS returns for the file size. That's what the file size will be when the file is opened.

...

And finally, for checking if a file exist. I used to have code that did that. And then I deleted it because it is worthless. Use the "checkErrorNumber"" function and abort traps to catch the error and then look to see if the file was not found. Otherwise continue passing the abort upwards.

So...

temp := \fat.openFile(string(name.bin"))
err := fat.checkErrorNumber

if(err <> fat#FILE_NOT_FOUND)
abort temp
elseif(err == fat#FILE_NOT_FOUND))
fat.newFile(...)
elseif(err == 0)
'Continue without error.

' Do stuff

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

heater
06-15-2010, 01:01 AM
Problem is in the CP/M world one does not know the file length. Files are always a multiple of the sector/cluster size of the CP/M operating system.
Text files has an EOF somewhere in there but that can't be used for binary files.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

lonesock
06-15-2010, 01:17 AM
DDS said...
This is possibly in the wrong thread but...

I am new to the SD driver so excuse my ignorance...

I am using the FSRW 2.6 driver and it is working but I have to constantly remove the SD card and put it into a PC & read it there to get it to work again with the propeller. Is this what some refer to it getting "stuck"?
Is there a work-around? I have tried unmounting/remounting but it doesn't help.

I am using the "mb_rawb_spi" driver
Thanks in advance.

Don

Hi, Don.

The recommended block driver is "safe_spi.spin", and is set up as the default block driver in the latest FSRW 2.6 distribution. Definitely start with that. Once that one is working, _then_ you can try using the faster read version (the "mb_rawb_spi.spin"). The faster read version is sensitive to tiny timing discrepancies, which can be caused by anything from hardware layout to cog-to-pin interaction timing.

Kye, same thing, please distribute the safe version...please please pretty please! [8^)

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.

Kye
06-15-2010, 09:30 AM
SafeSPI... Ah, okay. I will look at that code more closely.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Rayman
06-15-2010, 09:32 AM
jazzed said...

I did this xmodem thing too, but now I'm running Vista (involuntarily) and there is no hyperterm.
Can you recommend a link to a good xyzmodem client application download?

Thanks,
--Steve

jazzed:· If you still have a machine running XP, you can just copy over the hyperterminal program and run it under Vista.
There is one trick to it because one of the dll files is·in the·windows folder.
But, there's plenty of help out there on how to do it...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm

My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

jazzed
06-15-2010, 10:28 AM
You're right Rayman :) Thanks!

This page even has a zip package:
blog.taragana.com/index.php/archive/how-to-install-windows-xp-hyperterminal-client-on-windows-7-or-vista-for-free/ (http://blog.taragana.com/index.php/archive/how-to-install-windows-xp-hyperterminal-client-on-windows-7-or-vista-for-free/)


Rayman said...
[If you still have a machine running XP, you can just copy over the hyperterminal program and run it under Vista.
There is one trick to it because one of the dll files is in the windows folder.

But, there's plenty of help out there on how to do it...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM (http://www.brouhaha.com/~sdenson/PropellerJVM/index.html)

Dr_Acula
06-15-2010, 10:54 AM
Hi Kye,

I've made a lot more progress. xmodem is fairly easy to get working, but need to test lots of scenarios - eg unplugging a cable half way through - does it time out or hang?

1) File size is now reporting correctly. Yes, it hadn't written it out.
2) Packet padding - this is difficult as it is the sending program that does the padding and that might be hyperterminal or teraterm. So even if you write your own custom program with '0' padding, it still needs to be compatible with other download methods. I've left out your checksum and that does work. How is the checksum calculated for spin binary files?
3) I got the 'check for file' working. See code below.
4) I'm not sure about the best syntax for xmodem. CP/M used
XMODEM R MYFILE.TXT or
XMODEM S MYFILE.TXT

But I'm wondering about
XMR MYFILE.TXT
XMS MYFILE.TXT

I'm going to trap the file name in the xmr and xms pubs
(tested with vt100.str(str.tokenizeString(0)) which passes through a name)

And then I think I should be able to change the name of the file.


Code as it is up to now:




VAR
byte XmodemBuffer[132]
byte validpacket
word PacketNumber
byte ErrorCounter
word i
byte OnesComplement
word Checksum
byte Timeout
PRI programXmodemReceive(stringPointer)

ifnot(str.stringCompareCI(string("xmr"), stringPointer))
vt100.str(string("Send NAK and waiting for reply")) ' only print on local display, not to serial port
i:=0 ' set counter to 0
sio.rxflush(0) ' clear the receive buffer
repeat while (i < 10 and sio.rxavail(0)==0) ' send 10 NAKs don't make the delay too short
vt100.out(".") ' print a . on vga display
sio.tx(0,21) ' send a NAK to start things off
delay.pause1ms(1500) ' wait 1.5 seconds
i++ ' add 1 to i
if sio.rxavail(0) ' if any reply then do the file transfer
i:=\fat.openfile(string("FBAS1.BIN"),"R") ' does this file already exist?
i:=fat.checkerrornumber ' 0 if it does exist
if i==0 ' yes it does exist so delete it
fat.closefile ' close this file
fat.deleteEntry(string("FBAS1.BIN")) ' delete any files with this name
vt100.str(string(13,10,"Creating file FBAS1.BIN",13,10)) ' print creating new file message
fat.openFile(fat.newFile(string("FBAS1.BIN")), "W") 'create a new file
vt100.str(string("Starting file transfer",13,10))
errorcounter:=0 ' reset error counter
packetnumber:=1 ' packet number 1
repeat
validpacket :=255 ' equals true, set to 0 if any errors further down
timeout:=0
repeat while timeout <100 ' timeout if no byte arrives
if sio.rxavail(0) ' is there a byte?
XmodemBuffer[0]:=sio.rx(0) ' read in one byte
timeout:=255 ' finish the timeout
else
delay.pause1ms(1) ' wait 1 ms
timeout++ ' add 1 to timeout
if XmodemBuffer[0] == 4 ' finish byte
errorcounter:=255 ' signifies finish with no errors
else
if XmodemBuffer[0] <> 1 ' not 1
validpacket:=0 ' invalid packet
errorcounter++ ' add one to error counter
else ' 1= a valid start byte for a packet
i:=1
timeout:=0 ' if times out then packet will be corrupt
repeat while i<132 ' includes a timeout if half packet missing
if sio.rxavail(0) ' if a byte is available
XmodemBuffer[ i ] :=sio.rx(0) ' read it in
i++ ' and increment
else
delay.pause1ms(10) ' otherwise, pause a little
timeout++ ' and keep track of the pauses
if timeout>100 ' and give up after 1 second total
i:=133 ' force end if there is a timeout
errorcounter++ ' and add one to error counter
repeat while packetnumber > 255 ' calculate the packet number always <256
packetnumber:=packetnumber-256
onescomplement:=255-packetnumber ' calculate the ones complement
if packetnumber <> XmodemBuffer
validpacket:=0 ' not a valid packet
errorcounter++
if XmodemBuffer <> onescomplement ' ones complement not correct
validpacket:=0
errorcounter++
checksum:=0 ' calculate the checksum
repeat i from 3 to 130
checksum:=checksum+XmodemBuffer[ i ]
repeat while checksum>255 ' round to under 256
checksum:=checksum-256
if checksum <> XmodemBuffer[131] ' checksum not valid
validpacket:=0
errorcounter++
if validpacket == 255 ' packet is valid so save it
fat.writeData(@XmodemBuffer+3,128)
packetnumber++ ' increment packet number
sio.tx(0,6) ' send a ACK and wait for the next packet
vt100.out(".") ' print a . on the screen for each packet
else
sio.tx(0,21) ' send a NAK as the packet was corrupted
vt100.str(string("NAK"))
errorcounter++ ' increment the error counter
until errorcounter>10
sio.tx(0,6)
fat.CloseFile
abort 0


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 6/15/2010 3:03:34 AM GMT

heater
06-15-2010, 12:41 PM
Dr_A: Gosh XMODEM is getting long...

Suggest using:



packetnumber &= 255



instead pf:



repeat while packetnumber > 255 ' calculate the packet number always <256
packetnumber:=packetnumber-256




Same for checksum.

I have to try this out.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Dr_Acula
06-15-2010, 04:30 PM
Thanks heater, that works and saves some memory.

Tested with some big files , hundreds of kilobytes so the counter cycles many times. All working fine.

Yes, xmodem is long. I'm copying this from working vb.net code, which was in turn copied from Z80 .asm code. There are all sorts of tricks, for instance if you start up KyeDOS and then send a file from a terminal program, and serial buffer is not cleared, and the file happens to be a binary file, and the KyeDOS operating system is echoing back characters, and the file happens to be a binary file, and by chance, at least one byte of the first 132 byte packet happens to be a hex 21, then the KyeDOS will echo back that character in amongst all the other characters, and the sending program will interpret that as a NAK and will send the packet over and over. So you have to clear the buffer on bootup (and I clear it when the xmodem command is run as well, just to be sure).

The only way to find these things is exhaustive testing transferring files over and over. But in the process, I'm giving Kye's SD code a real workout and I haven't managed to break it.

And I have transferred many files to the sd card and haven't had to remove the card all day. This really is a time saver. It is so nifty to send a file like FemtoBasic and run it from the KyeDOS operating system.

Hey, and how cool is this for Kye's code.

Say you forget to insert the sd card, or you accidentally knock it out. I boot up with this



VT100.clearscreen ' clear the screen
vt100.str(string("Testing for SD card",13,10)) ' helpful message if card is out, better than just a blank screen




If there is no card, it leaves that message on the screen as a reminder, then hangs.

If there is a card, the next step is



fat.mountPartition(0,0) ' mount the sd card
VT100.clearscreen ' if the sd card is not inserted, will leave the message on the screen as a reminder. If it is inserted, start with a blank screen
PrintStringCR(string("**** SD card operating system by Kwabena W. Agyeman ****"))
PrintString(string("Type Help for command listing"))
crlf



etc

But here is something really nifty. If it is hanging at the "Testing for SD card" message, you can then insert the card and after a delay of a few seconds, it will keep going. Kye's code obviously keeps checking and rechecking for a card.

Warts and all, attached is a snapshot of the code. Works on dracblade boards. Other boards; - change pins and comment out the LCD driver code. Does NOT need external memory, so if you can attach an sd card to the demo board and change the pin settings this will work on any board with sd card attached.

This code is such fun to use!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 6/15/2010 8:44:44 AM GMT

Dr_Acula
06-15-2010, 09:49 PM
Xmodem now working both send and receive. See attached. Type Help for the syntax. Now KyeDOS can talk to a PC and also exchange files between two propeller boards.

The tx code ended up a bit neater than the rx code - less delays and timeouts.

A few minor bugs to work out - sometimes when I boot up KyeDOS and type a command it says "Command not found". Type it a second time and it works. Happens with all commands. I'm thinking a buffer somewhere isn't being cleared.

Another minor bug is that the CAT (TYPE to us CP/M people) is sending only carriage returns to the vt100 terminal, and it needs to send CRLF. At the moment it prints all the lines on top of each other. That might be a hangover from the propeller terminal that I think interprets CR as CRLF.

There was just one instance when I downloaded a file and the OS told me the file did not exist when I tried to send it back again. But it refreshed when I rebooted.

I guess YMODEM is next. It gets a little tedious typing the filename at both ends, and YMODEM is almost the same as xmodem except that it sends the filename in the first packet, so you only have to type it once.

I've certainly given Kye's code a good workout here!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Kye
06-15-2010, 10:47 PM
Thank you Dr_Acula!!! (Yes my file system driver actually retries up to 8 times to mount the SD card and for each of those eight tries it will attemp the first init command 128 times. So, if my driver cannot mount the card it is 100% incompatible. I also retry reading and writing up to 2 times if they fail to make sure the file system has the least amount of disk I/O errors as possible.)

Okay, so... its been about a two weeks. Has anyone found any outstanding problems that need to be fixed before releaseing to the obex?

Thanks,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

jazzed
06-16-2010, 12:35 AM
@DR_A,

The problem appears to be that teraterm sees COM1-4 which I have, but does not see COM8 where my Propeller is attached.

Hypertrm finds COM8 and COM21. It seems to work ok, so I'll stick with that for file transfers.

Thanks,
--Steve


Dr_Acula said...
Hi jazzed,

I'm home now and able to check the download on that program. It works ok on XP. See attached.

On my PC COM1 and COM2 are real physical serial ports. COM3 and COM4 are cheapie ebay $2 USB to D9 serial adaptors. So the list is 4 ports. That all works ok.

Can you describe the problem a bit more? If Teraterm (or other terminal programs) are not finding the serial ports, that might suggest more a Windows problem. What is Control Panel/System/Hardware/Device Manager/Ports reporting? for example I get USB-SERIAL CH340 (COM3) when I plug in the USB to serial adaptor. Unplug it and it automatically updates the new configuration. Does Vista work the same?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM (http://www.brouhaha.com/~sdenson/PropellerJVM/index.html)

Dr_Acula
06-16-2010, 11:17 AM
Yes Kye, I think if anything was going to break I would have found it, having spent several whole days testing this code. I think it is ready for the Obex. Fantastic work. Complicated coding behind the scenes but so easy to use.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

heater
06-16-2010, 01:59 PM
Kye: Great work, very nice looking code.

On the TriBlade board (blade 2) and RamBlade the SD card pins are shared with the external RAM "bus".

In order to use SD card and external RAM in an application it is necessary to tristate the RAM bus and the SD pins alternately, say when loading data from SD to RAM.

Is there a way to do that in FATE? On a quick scan through your code I did not see it. Is it possible to add such a feature?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Dr_Acula
06-16-2010, 07:36 PM
Hi Kye,

Now that xmodem is working in KyeDOS, I'm wondering about taking networking on the propeller a little further. I'm thinking of a very simplified bittorrent protocol, where boards might exchange pieces of files in a peer to peer network. This could be a very efficient way to broadcast a new file to a network, as a broadcast of 1 packet might go to n boards all at the same time.

I've been working on some packet descriptors - take a xmodem 132 byte packet, put in a 8.3 filename, source, destination, packet number, total packets and it still comes in well under 256 bytes.

I'm thinking of ways to integrate a random packet into a partially completed file using the FAT drivers.

Two ways seem possible:
1) store each packet as a seperate file, then build them all into a big file at the end.
2) Splice each packet as it arrives.

Option 1 is possibly the simplest to code as the buffer only needs to be 128 bytes so that can be an array in spin. Big files might end up with lots of pieces so lots of temporary files on the sd card. Is there a max number of files on the sd card? (a typical number might be 256 files of 128 bytes = a 32k binary file)

Option 2 I think needs the ability to have two files open at once. That is not possible, right? Unless you use an external ram chip as the temporary store for the big file.

I just noticed there is an "append" mode.



PUB openFile(fileName, mode) '' 33 Stack Longs
'' │ Mode - A character specifing the mode to use. R-Read, W-Write, A-Append. By default the file is opended for reading. │




This could be a very neat answer for boards without external memory. Save all the 128 byte packets as individual files. Then read them in one at a time to a spin array, then open the big file for append and add the array data at the end.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Kye
06-16-2010, 10:38 PM
You can have up to 65536 files in one directory.... well, more like ~60000 files but you can have alot. So if you keep track of names you could save each packet as a seperate file.

...

Okay, I'll add tristating features... but how do you want that to work? My driver polls the SD card regularly to make sure it it still there... and this is a nice safety feature that can prevent some nasty problems that can come from user error. So, I would like to leave it in place. However, when the card is unmounted my driver does nothing. So, I can make it tristate the pins when the card is unmounted. Or would that not be acceptable?

Please tell me how the tristating will be used.

Thanks,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Sapieha
06-16-2010, 11:07 PM
Hi Kye.

As I can see it - That polls feature needs only before READ/WRITE to be sure card is still mounted.

Rest of time it is unnecessary.


Regards

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


Sapieha

heater
06-17-2010, 08:20 PM
Kye: Here is an example of how tristating is done on the TriBladeProp using the slightly modified
fsrwfemto and sdspifemto that Cluso created for the TriBlade. All error checking removed.




err := sd.startSD(@ioControl) 'Start the SD routines
.
.
err := \sd.mount_explicit(spiDO,spiClk,spiDI,spiCS) 'Mount the SD
.
.
err := \sd.popen(string("fibo.bin"), "r")
'Read image file into external RAM
bytes := 1
repeat while bytes > 0
bytes := sd.pread(@diskbuff, 512)
err := sd.stopSDCard 'stop SD card, but do not stop SD cog (tristate)
repeat i from 0 to bytes - 1
vm.wrvbyte(ramaddr ^ %11, diskbuff[ i ]) 'To virtual memory. XOR here is an endianess fix.
ramaddr++
err := \sd.initSDCard(spiDO,spiClk,spiDI,spiCS) 'Init the SD (un-tristate)
err := sd.stopSDCard 'stop SD card, but do not stop cog




Note that the vm.wrvbyte also leaves the bus tristated when done.
Also sd.initSDCard method is just passed through to the SD driver by fsrwfemto.
Cluso's has a block read/write driver for ext RAM that include "idle" and "active" methods to do tristating.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Post Edited (heater) : 6/17/2010 12:26:08 PM GMT

Kye
06-17-2010, 10:11 PM
Okay, so there should be pull ups on the I/O lines in general in you want to go in and out of tristating mode because the lines will float otherwise and their default state needs to be high.

My driver works without pull ups so I will not make the default behaviour tristating when not in use. To make things simple I will add the ability for my driver to tristate its lines in the ASM code.

To expose the tristating feature you will have to make the "readWriteBlock" a public function and then pass it some letter to activate tristating and another letter to deactivate tristating. Also by exposing that function you will be able to have RAW read/write mounting and booting functionality.

Is that okay?

I'll post more information about what I have done when I finish.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

heater
06-17-2010, 10:27 PM
Kye, sounds great.

RAW sector/block access might keep some emulator guys happy. Is there a way to get the first sector of a a file to make that useful?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Kye
06-17-2010, 11:34 PM
That's illustrated in the boot function. So it can be easily added by anyone else.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Sapieha
06-17-2010, 11:39 PM
Hi Kye.


It is NOT at this lines need be HIGH -- Them need floating on SD as in other way this pin can't be used to other things that need change state.



Regards
Christoffer J

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


Sapieha

Cluso99
06-18-2010, 12:09 AM
Kye: The problem is that the SD card does not release driving the DO pin when -CS=1 (disabled). If this pin is used for other purposes as well, such as sharing with the SRAM which I do on the TriBlade and RamBlade boards, then the SD card must be forced to release the DO pin when -CS returns high. What needs to be done is to supply a number of clocks after -SD returns high. While my pcbs have pullups on all 4 SD pins, it certainly seems that only the -CS pullup is required. The spec calls for pullups to minimise current when the pin floats but it seems now a weak pullup may in fact be on newer SD cards nowadays.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade (http://forums.parallax.com/showthread.php?p=786418),·RamBlade (http://forums.parallax.com/showthread.php?p=849265),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) (http://forums.parallax.com/showthread.php?p=778427) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)·
· Prop OS: SphinxOS (http://forums.parallax.com/showthread.php?p=819353)·, PropDos (http://www.orrtech.us/propdos/) , PropCmd (http://obex.parallax.com/objects/440/)··· Search the Propeller forums (http://www.google.com/advanced_search?q=+site:forums.parallax.com&num=20&hl=en&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBlade Props: www.cluso.bluemagic.biz (http://www.cluso.bluemagic.biz)

heater
06-18-2010, 12:16 AM
Ah, sorry I was looking at this tristating from the the wrong wrong end of the line.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Kye
06-18-2010, 12:54 AM
You would need pullups because all the pins would be left floating otherwise... which is bad.

Anyway, here is the newest version with tristating added.

To acess the tristating you will need to make the readWriteBlock function public. Then just pass "T" (capital) as the command,
the rest of the fields are ignored.

Also note that if no other commands may be issued or the block driver will return an error until the card is untristated.

To untristate the card call the command again.

-- Okay that was 12 longs of code space to add that feature. So... please let that be the end of your requests.
·
Also, I do not know if the SD card will release the DO pin. I send it 8 clocks after setting the CS pin to high. I did not test any of the tristating stuff but it should work.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 6/17/2010 5:06:38 PM GMT

Sapieha
06-18-2010, 01:37 AM
Hi Kye.

That was GOOD news.
I don't think that Low level driver needs more REQUEST's.
And HI level before MS give permission to use long Names - I see no needs for more


Regards
Christoffer J

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


Sapieha

Dr_Acula
06-18-2010, 03:42 PM
Hi Kye,

I was wondering what you would think about adding another tiny function to the FATengine to see if a file exists?

Maybe this is already there, but if not, the general concept is to pass a filename and it returns true or false if the file exists.

Currently I'm trying to open the file, seeing what the error is, closing the file then passing back the error. You might be able to tweak that using 'result' and save creating a variable?

And just double check the true/false variable that comes back - I always get confused as to whether true is 0 or 1!

Hopefully this is only a few lines.




i:=\fat.openfile(Filename,"R") ' does this file already exist? The \ says to keep going even if there is an error
i:=fat.checkerrornumber ' 0 if it does exist
fat.closefile ' close this file


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Peter Jakacki
06-18-2010, 04:06 PM
Cluso99 said...
Kye: The problem is that the SD card does not release driving the DO pin when -CS=1 (disabled). If this pin is used for other purposes as well, such as sharing with the SRAM which I do on the TriBlade and RamBlade boards, then the SD card must be forced to release the DO pin when -CS returns high. What needs to be done is to supply a number of clocks after -SD returns high. While my pcbs have pullups on all 4 SD pins, it certainly seems that only the -CS pullup is required. The spec calls for pullups to minimise current when the pin floats but it seems now a weak pullup may in fact be on newer SD cards nowadays.


Even the CS pin should not have a pullup for the reason that card detect can be implemented in software by detecting whether the CS pin is pulled up by the SD card or not. The SD spec says that the CS pin on the card has a weak pullup and that this can be used for card detect. In my drivers I pulse this line low, change to input mode, wait a couple of microseconds and read the state of the CS pin. This proves very reliable and I make a point of detecting this in the low-level command loop and also during initialization. In the real world you need to react to and recover from card removals and insertions.



SD Card Spec V2.2
1.12.3 Card Acquisition and Identification
<snip>
An internal pull-up resistor on the DAT3 line may be used for card detection
(insertion/removal). The resistor can be disconnected during data transfer (using
ACMD42). Additional practical card detection methods can be found in SD Physical
Specification’s application notes given by the SDA.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

heater
06-18-2010, 04:13 PM
Peter Jakacki - "In the real world...."

I thought there was something odd about Propeller land:)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Peter Jakacki
06-18-2010, 06:17 PM
heater said...
Peter Jakacki - "In the real world...."

I thought there was something odd about Propeller land:)


aw mate, there is something absolutely odd about Prop land, it attracts all kinds of odd sorts http://forums.parallax.com/images/smilies/smile.gif

My comment about the "real world" though is probably more to do with the state of some objects that I find are lacking certain necessary features vs some other objects that are excessively didactic but still lack certain necessary features. When I am doing a commercial product I find that there is a big gulf between demos and what it takes to get them to be reliable and usable.

But that's not to say that I don't appreciate them, I certainly do, very much. I just don't have enough arms and hours in a day to do a fraction of the things I need to do, let alone what I want to do http://forums.parallax.com/images/smilies/cry.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

Rayman
06-18-2010, 08:35 PM
Peter Jakacki said...
In the real world you need to react to and recover from card removals and insertions.
I would go even further and suggest that one should monitor the write-protect status of the SD card in "real world"...

I usually add 4 resistors to the SD card circuit in order to monitor the card-detect and write-protect switches
on the SD card jack.· Here's the circuit:

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm

My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

Dr_Acula
06-18-2010, 10:07 PM
Dear Kye,

I'm debugging a rather strange fault where my LCD display is corrupted if running a program from the KyeDOS operating system, but reloading the eeprom with the program and directly booting it has no problems.

I was wondering if the reboot code explicitly stops all (or most) of the cogs before rebooting?





PUB bootPartition(fileName) | bootSectors[64] '' 101 Stack Longs

'' ┌───────────────────────────────────────────────── ────────────────────────────────────────────────── ───────────────────────┐
'' │ Reboots the propeller chip to run the selected valid spin BIN or EEPROM file. │
'' │ │
'' │ If an error occurs this function will abort and return a pointer to a string describing that error. │
'' │ │
'' │ FileName - The name of the file to reboot from in the current directory. │
'' └───────────────────────────────────────────────── ────────────────────────────────────────────────── ───────────────────────┘

longfill(@bootSectors, 0, 64)
openFile(fileName~, "R")

repeat (listSize <# 32768)
result += readByte

ifnot($1FF & fileName++)
bootSectors[fileName >> 9] := (partitionStart + FATFirstSectorInCluster(currentCluster) + FATWorkingSectorInCluster)

result &= $FF
changeFilePosition(6)
fileName := readShort
closeFile

' if((result and (result <> $14)) or (fileName <> $10))
' errorNumberFlag := Checksum_Error
' abort string("Checksum Error")

unmountPartition
readWriteBlock(@bootSectors, "B")

partitionMountedFlag := false
errorNumberFlag := Reboot_Error
abort string("Reboot Error")


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Kye
06-18-2010, 11:20 PM
@Dr_Aculam, Yes, in the ASM driver it stops all other processors before rebooting. This is has to be done however as I zero all memory.

Also, I'm thinking about making a if file exist function that also valids the listing information. I've also found several uses for somthing like that. Additionally I plan to make a function that just returns all the names in a file sequentially even through file open and close calls. This will be useful for examining all files in a directory.

However, I want to free up some space before making those.


Peter Jakacki said...

In the real world you need to react to and recover from card removals and insertions.


I think you'll really like my code then. It is ALOT more robust against card removals or insertions vs FSRW. Since I have all the mounting rountines in ASM, my driver can recover from card removals easily.

@Everyone

Using the Write Protect and Card Detect switches is pointless. You get the same functionality by just asking the card are you write protected or just by trying to communicate to it to see if its there.

I'll admit however, my block driver tries very hard to mount every SD card it uses... So, if the card does not mount then you may wait a while for it to give up. Can be in the seconds range or WAYYY... more sometimes. I like Peter's idea. But it will just take more code space. Ahhh! I'm already at 1920 Longs.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Rayman
06-19-2010, 01:39 AM
Kye said...
You get the same functionality by just asking the card are you write protected or just by trying to communicate to it to see if its there.

Sure about that?
I've heard the the write protect switch on SD cards is purely mechanical and not connected to internal electronics.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm

My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

Javalin
06-19-2010, 04:05 AM
>I've heard the the write protect switch on SD cards is purely mechanical and not connected to internal electronics.
both systems are in in use I believe. There are SPI commands to lock/unlock a range.

James

Kye
06-19-2010, 06:13 AM
Yes, the write protect switch is purely mechanical. However, you can also use software to lock portitions of an SD card. So why bother with the write protect switch since it really does nothin more than say please don't write to me.

SD cards have ALOTTTTTTTTTTTTT o security features at are not documented publicly.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

BradC
06-19-2010, 10:08 AM
Kye said...
Yes, the write protect switch is purely mechanical. However, you can also use software to lock portitions of an SD card. So why bother with the write protect switch since it really does nothin more than say please don't write to me.


Umm.. maybe because its the only way to tell if I've flipped the write protect on before I stick the card in the slot. Look at it another way, if I flip that switch and stick the card in your product, and your product writes to the card because it's too lazy to check the switch I'm going to be extremely irritated.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I mean, if I went around sayin' I was an emperor just because some moistened bint had lobbed a scimitar at me they'd put me away!"

Cluso99
06-19-2010, 11:14 AM
Kye: I use the open/find file in the fsrw driver to find the first sector address used. This is what ZiCog does. Wouldn't this do for what Drac is asking?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade (http://forums.parallax.com/showthread.php?p=786418),·RamBlade (http://forums.parallax.com/showthread.php?p=849265),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) (http://forums.parallax.com/showthread.php?p=778427) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)·
· Prop OS: SphinxOS (http://forums.parallax.com/showthread.php?p=819353)·, PropDos (http://www.orrtech.us/propdos/) , PropCmd (http://obex.parallax.com/objects/440/)··· Search the Propeller forums (http://www.google.com/advanced_search?q=+site:forums.parallax.com&num=20&hl=en&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBlade Props: www.cluso.bluemagic.biz (http://www.cluso.bluemagic.biz)

Dr_Acula
06-19-2010, 12:23 PM
Hi Cluso, yes the code below does work



i:=\fat.openfile(Filename,"R") ' does this file already exist? The \ says to keep going even if there is an error
i:=fat.checkerrornumber ' 0 if it does exist
fat.closefile ' close this file




If you open a file, presumably you have to close it too.

I was thinking more about asking Kye to include this as a new function - it would only take a tiny amout of space. And also whether it can be shrunk even further, eg by not having a variable 'i'

BTW Kye, if you are running out of space, compiling with BST and checking the box that excludes unused functions - this saved quite a bit of space for me.

Also - with KyeDOS - you can recompile code with lots of variations, eg compile a version with no audio, and it saves space and you can use that space for other things. It is easy to organise all these .bin files as different variants.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Kye
06-19-2010, 12:36 PM
@BradC - Yeah, you're right. Sorry I was being cheeky there =). I'll have to use more I/O pins however to support WP features.

Mmm, I have an idea. I can easily support the CardDetect feature and incorporate that into mounting. However, it really is not needed.

As for supporting the WriteProtect feature that would be a bit more complicated as my upper level code writes out last acess information on every file close. I could just make the lower level driver ignore writes when the write protect switch is low and then return to the upper level code as if it did the write to make everything seamless... but this could confuse a user of my code very easily.

Both these features could be optional... Maybe I'll add this feature in another release.

@Cluso99 - Oh... it won't end.... if you look how the bootParition function works you can see how to do this easily.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Cluso99
06-19-2010, 11:43 PM
Kye: Most SD card designs on the prop that I have seen do not support card select and write protect pins. They only use a 4 pin interface. Note also that the microSD socket that I use, and now some others also use, only supports the Card Select switch. I am fairly sure the Write Protect switch is not fitted in the socket, so it would be pointless trying to use it. The Card Detect switch is fitted, but I do not even wire it anywhere on either the TriBlade or RamBlade and do not intend to do so on the new RamBladeII or IOBlade. I fit pullups on all 4 pins (-CS, CLK, DI, DO) on TriBlade & RamBlade and intend to do likewise on the new pcbs too. The hardware method I use requires a pullup to be always present on the -CS pins.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade (http://forums.parallax.com/showthread.php?p=786418),·RamBlade (http://forums.parallax.com/showthread.php?p=849265),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) (http://forums.parallax.com/showthread.php?p=778427) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)·
· Prop OS: SphinxOS (http://forums.parallax.com/showthread.php?p=819353)·, PropDos (http://www.orrtech.us/propdos/) , PropCmd (http://obex.parallax.com/objects/440/)··· Search the Propeller forums (http://www.google.com/advanced_search?q=+site:forums.parallax.com&num=20&hl=en&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBlade Props: www.cluso.bluemagic.biz (http://www.cluso.bluemagic.biz)

Nargule
06-20-2010, 12:23 AM
Here's my test on a SanDisk microSD card:



>_ Running command: test
Creating test file "testfile" ... Success

Wrote 131,072 bytes at 0000046501 bytes per second

Running byte stride write test...
Wrote 32,768 bytes at 0000004297 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 0000008315 bytes per second

Running word stride read test...
Read 65,5536 bytes at 0000008454 bytes per second

Running long stride write test...
Wrote 131,072 bytes at 0000015547 bytes per second

Running long stride read test...
Read 131,072 bytes at 0000016804 bytes per second

Running speed writing test (512 bytes at a time)...
Wrote 131,072 bytes at 0000107328 bytes per second

Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000250432 bytes per second

Running append test... Success

Running seek test... Success

Deleting test file "testfile" ... Success


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Corwine

Rayman
06-20-2010, 03:41 AM
Kye said...
@BradC - Yeah, you're right. Sorry I was being cheeky there =). I'll have to use more I/O pins however to support WP features.
Kye:· That circuit I posted doesn't require any extra pins to monitor the WP and CP switches...

You just read the input state of two SD pins that are normally outputs...

This feature is not important at all for most hobby work, but essential for "real world" apps.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm

My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

Kye
06-20-2010, 04:49 AM
Okay, so this is what I will do. I'm going to post the current code in the obex. That will let people use my driver.

Next, I'll update the block driver to support card detect mode so that it can see if the card is inserted.

Card detect will work like this. When you start the driver you will need to pass it the card detect pin number. This pin number can overlap with another pin. The card detect feature will see no card is inserted when the pin is high and a card is inserted when the pin is low.

This allows Rayman's circuit to work but also allows you to have the CD and WR pins on seperate prop pins if you want.

I'll be doing the same thing for write protect but that has to be built into my driver more... I plan to implement a more generalized caching technique to make my code cleaner and faster.

Thanks,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Rayman
06-20-2010, 07:46 AM
I'd be very appreciative if you added support for my circuit. But, it's not totally necessary, because it's pretty trivial to just test those pins before starting up the SD card driver...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm

My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

Kye
06-20-2010, 10:30 AM
... I will have support for your circuit. See the post above...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Kye
06-23-2010, 07:00 AM
Okay its in the obex.

Thank you all.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

zappman
07-21-2010, 07:52 AM
This is so neat!

Here are the results for my 4GB PNY Card.



Running command: test
Creating test file "testfile" ... Success

Wrote 131,072 bytes at 0000005170 bytes per second

Running byte stride write test...
Wrote 32,768 bytes at 0000002969 bytes per second

Running byte stride read test...
Read 32,768 bytes at 0000004262 bytes per second

Running word stride write test...
Wrote 65,5536 bytes at 0000004472 bytes per second

Running word stride read test...
Read 65,5536 bytes at 0000008350 bytes per second

Running long stride write test...
Wrote 131,072 bytes at 0000006009 bytes per second

Running long stride read test...
Read 131,072 bytes at 0000016350 bytes per second

Running speed writing test (512 bytes at a time)...
Wrote 131,072 bytes at 0000008944 bytes per second

Running speed reading test (512 bytes at a time)...
Read 131,072 bytes at 0000250432 bytes per second

Running append test... Success

Running seek test... Success

Deleting test file "testfile" ... Success

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit Zappman's Blog at Savage Circuits (http://www.savagecircuits.com/forums/blog.php?120-zappman)

Kye
07-21-2010, 09:47 PM
Holy $%*& its alive! Its alive again!!!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Dr_Acula
07-21-2010, 10:08 PM
It lives every day on my Propeller boards!

The perfect system for rapidly switching between hardcore MPM network programming and games. (Not necessarily in that order *grin*).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

MacTuxLin
07-29-2010, 11:12 AM
Hi,
I'm hoping to use Kye's SD code in my project but I'm still a newbie on SPIN so I think I used the openFile wrongly. I think anyone could catch my mistake.




CON

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

_SD_DOPin = 0
_SD_DIPin = 2
_SD_CKPin = 1
_SD_CSPin = 3

OBJ

FAT : "SD2.0_FATEngine"
NUM : "Numbers"
STR : "C300M_STREngine"
COM : "RS232_COMEngine"

PUB Main

com.COMEngineStart(31, 30, 115_200)
waitcnt(clkfreq + cnt)

ifnot(fat.FATEngineStart(_SD_DOPin, _SD_CKPin, _SD_DIPin, _SD_CSPin, _clockDataPin, _clockClockPin))
reboot

com.transmitString(fat.mountPartition(str.decimalT oInteger(str.tokenizeString(0)), byte[str.tokenizeString(0)]))
com.transmitString(string("Disk 0x"))
com.transmitString(str.integerToHexadecimal(fat.ch eckDiskSignature, 8))
com.transmitString(string(" with volume ID 0x"))
com.transmitString(str.integerToHexadecimal(fat.ch eckVolumeIdentification, 8))
com.transmitString(string(" a.k.a "))
com.transmitString(str.trimString(fat.checkVolumeL abel))
com.transmitString(string(" ready", _newLineCharacter))
waitcnt(clkfreq + cnt)
'-----------------
'It Mounted OK.
'-----------------

'Trying to open file
com.transmitString(fat.openFile(str.tokenizeString (string("test001.txt")),"R"))
'-----------------
'com showed nothing. Seems to be wrong?
'-----------------





From the original program, the parameter for str.tokenizeString is always "0". Does this means it points to the first variable declared in VAR (which is charactersPointer)?

Thanks in advance.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ken

Post Edited (MacTuxLin) : 7/29/2010 3:18:50 AM GMT

Dr_Acula
07-29-2010, 11:31 AM
I'm not 100% sure of the tokenize bit, but this is my open file for a new file that does not yet exist

fat.openFile(fat.newFile(string("testfile")), "W")

and for a file that already exists

fat.openFile(string("testFile"), "R")

see if one of those helps?

also I don't think it is related as you say it mounts, but my mount code is shorter

fat.mountPartition(0,0) ' mount the sd card

though I think yours still has the same effect of producing zeros

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

MacTuxLin
07-29-2010, 11:46 AM
Thank you Dr_Acula! I did removed the tokenize but initially it didn't work. But re-looking at your example, I removed the ".txt" extension & now it worked! I don't know why so the openFile cannot work files with .3 extensions?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ken

Dr_Acula
07-29-2010, 12:08 PM
That is odd as my code does work with extensions. Anyway, if you can create a file and open it and close it then you can start testing things more thoroughly.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Kye
07-29-2010, 12:13 PM
The tokenize string function is a special version of the standard C strtok function that is used to break strings up into pieces. My tokenize string funtion looks for white space characters to break the string up on. Unless you have use input that needs to be toeknized don't use it.

http://www.cplusplus.com/reference/clibrary/cstring/strtok/

...

Open file should have no problems with the .txt extension. I've used this function all the time to play .wav files and read .txt files. Since opening "test001" worked and not "test001.txt" this means that your file was not named "test001.txt" but "test001". The exension matters and is part of the name of the file. "stuff' and stuff.txt" can be two completely different files in one directory.

Also note that my functions abort when they cannot process a request and return an error string. That said, you have no way to catch those failures in your code.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

MacTuxLin
07-29-2010, 12:38 PM
http://forums.parallax.com/images/smilies/blush.gif I'm so sorry!!! I named the extension wrongly on the SD card. My bad. After changing it, it worked!!! Thank you Kye & Dr_Acula. http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ken

Jorge P
07-29-2010, 05:10 PM
I am using the PPDB that has the DS1302, what do I need to change in order to use this RTC as opposed to the DS1307?

I checked the code and the DS1307 needs only two pins and the ds1302 needs 3.· Is it safe to leave out the extra pin o the 1302?

Thanks for the replies in advance.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
http://WhatsAvailable.org Software and Gadgets for Windows 7.

Kye
07-29-2010, 10:20 PM
I don't know what the DS1302 needs to operate. You will need to find a driver for that thing yourself. If you look through the FATEngine you'll find a function called "readClock". Just replace all the references to the DS1307 there.

Also, you'll need to remove the references to the DS1307 code in "FATEngineStart" and FATEngineStop" functions.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

jmspaggi
07-29-2010, 10:59 PM
Hi Nyamekye,

When I look at my card, it says VFAT. Is VFAT the same thing as FAT32? Or should I format it un FAT32 if I want to use it with your driver?

Thanks,

JM

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Linux? There is worst, but it's more expensive.

Kye
07-30-2010, 03:14 AM
Don't know what VFAT is. If its not FAT32 or FAT16 my driver will refuse to mount the SD card an throw and erorr about the file system not being supported.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Bob Lawrence (VE1RLL)
07-30-2010, 04:31 AM
re:Is VFAT the same thing as FAT32

From Q/A Wiki:
(Virtual File Allocation Table) The file system used in Windows for Workgroups and Windows 95/98. It provided 32-bit Protected Mode access for file manipulation. VFAT was faster than, but also compatible with, the DOS 16-bit File Allocation Table (FAT). In Windows for Workgroups, VFAT was called "32-bit file access." In Windows 95/98, it supported long file names up to 255 characters.

Bob Lawrence (VE1RLL)
07-30-2010, 04:36 AM
@Kye

Wow! what a fantastic job you did developing all of this. I look forward to using it in a project. I like the recording features you added as well. /forums/emoticons/cool.gif

Thanks!

Bob

Jorge P
07-30-2010, 04:40 AM
Thanks for the info Kye, I'll give it a try and post back later.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
http://WhatsAvailable.org Software and Gadgets for Windows 7.

jmspaggi
07-30-2010, 09:42 AM
@Kye and @Bob: I just found that VFAT and FAT32 are the same thing. So it should works ;)

@Kye:
Also, is it possible to open 2 files at the same time? Or do I have to close the first one before opening the second one?

I'm just waiting for the SD reader from Parallax ;) I really hope it will arrive soon. I want to test that?

Also, regarding performances, is that faster that an EEPROM? Or is an EEPROM faster than the SD?

Thanks,

JM

Kye
07-30-2010, 10:17 AM
The SD card is WAYYYYYYYYYYY faster than eeprom.

Right now opening two files is not supported seemlessly. Unless you understand what you are doing to have two files open at once you will corrupt your SD card file system if you try to have two files open at once.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

jmspaggi
07-30-2010, 10:23 AM
Way faster? Wow. I have some EEPROMs linked to my propeller to store Strings I want to display, so look like I'm beter to move them on the SD...

Regading the 2 files, will I corrupt the system even if everything is only on READ-ONLY mode? I just want to read an OGG file, and at the same time the catalogue to display the directory (or any other directory) content. Anyway, since you made the option to move in a file, I still can close one the time I look at the other, but I was just trying ;)

JM

jmspaggi
08-09-2010, 05:28 PM
Hi Kye,

I tried your driver and I have one small issu.

When I use it on my main loop, it's working perfectly. But when I'm trying to use it from a cog, listName call is never returning.

Here is my code:


CON
_cardDataOutPin = 7
_cardClockPin = 6
_cardDataInPin = 5
_cardChipSelectPin = 4

_clockDataPin = 25
_clockClockPin = 24

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

VAR
long sd_stack [64]
long volumeLabel
OBJ
fs : "SD2.0_FATEngine"
sx : "FullDuplexSingleton"
rtc: "DS1307_RTCEngine.spin"

PUB start (lf_number)
sx.start(31,30,0,115200)

ifnot(rtc.RTCEngineStart(_clockDataPin, _clockClockPin))
sx.str(string($d,"Not able to start the RTCEngine",$d))
reboot

ifnot(fs.FATEngineStart(_cardDataOutPin, _cardClockPin, _cardDataInPin, _cardChipSelectPin, _clockDataPin, _clockClockPin))
sx.str(string($d,"Not able to start the FATEngine",$d))
reboot

volumeLabel := fs.mountPartition (0, 0)
sx.str(string("Volume label: "))
sx.str(volumeLabel)
sx.str(string($d))

sx.str(string("Changing directory to : "))
sx.str(fs.changeDirectory(string("\")))
sx.str(string($d))

cognew (process, @sd_stack) ' Comment to run outside of the cof
'process ' Uncomment to run outside of the cog

PUB process | index, fileName
sx.str(string("Listing files...", $d))
index := 0
fs.listName("T")
repeat
fileName := fs.listName(0)
sx.str(string("Read "))
sx.str(fileName)
sx.str(string(" Index="))
sx.dec(index)
sx.str(string(" strsize="))
sx.dec(strsize(fileName))
sx.str(string($d))
until fileName == 0
repeat ' Comment to run outside of the cog


When I run that from a cog, I get a respons from fs.listName("T") then the next listName call never return. If I run that from the main, it's working fine.

So I think I'm doing something wrong, but I'm working on that for 3 hours now with no result :(

Any clue?

Thanks,

JM

jmspaggi
08-09-2010, 05:43 PM
I'm replying to myself ;)

I found a way to have it working.

I moved all my code into the cog instead of initializing the objects outside of the cog.

Don't ask me why it's working that way, and not the other way, because I don't understaing anything here ;)

Do I have a way to size the stack correctly?

JM



CON
_cardDataOutPin = 7
_cardClockPin = 6
_cardDataInPin = 5
_cardChipSelectPin = 4

_clockDataPin = 25
_clockClockPin = 24

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

VAR
long sd_stack [256]
long volumeLabel
OBJ
fs : "SD2.0_FATEngine"
sx : "FullDuplexSingleton"
rtc: "DS1307_RTCEngine.spin"

PUB start (lf_number)
cognew (process, @sd_stack) ' Comment to run outside of the cog
'process ' Uncomment to run outside of the cog

PUB process | index, fileName
sx.start(31,30,0,115200)

ifnot(rtc.RTCEngineStart(_clockDataPin, _clockClockPin))
sx.str(string($d,"Not able to start the RTCEngine",$d))
reboot

ifnot(fs.FATEngineStart(_cardDataOutPin, _cardClockPin, _cardDataInPin, _cardChipSelectPin, _clockDataPin, _clockClockPin))
sx.str(string($d,"Not able to start the FATEngine",$d))
reboot

volumeLabel := fs.mountPartition (0, 0)
sx.str(string("Volume label: "))
sx.str(volumeLabel)
sx.str(string($d))

sx.str(string("Changing directory to : "))
sx.str(fs.changeDirectory(string("\")))
sx.str(string($d))

sx.str(string("Listing files...", $d))
index := 0
sx.str(string("Moving to the first entry.", $d))
fs.listName("T")
repeat
sx.str(string("Reading next entry.", $d))
fileName := fs.listName(0)
sx.str(string("Read "))
sx.str(fileName)
sx.str(string(" Index="))
sx.dec(index)
sx.str(string(" strsize="))
sx.dec(strsize(fileName))
sx.str(string($d))
until fileName == 0
repeat ' Comment to run outside of the cog

Kye
08-10-2010, 01:29 AM
Its probably working now because you made the stack larger.

My stack size estimates included in my code are only estimates on about how many longs each function call takes. I base these estimates off a question I asked Chip back in a video fourm chat thingy last year.

With the file system driver the stack needed gets very large for all the function calls.

Oh, and are you usign the code from the OBEX? Its slightly better in handling wierd stuff like this.

jmspaggi
08-10-2010, 01:39 AM
Hi Kye,

I'm not sure it's coming from the stack. Because it was not working, then I move the engine start into the cog and it was working. I just retried and figured that the issue is coming from the serial output I'm using. If I put it on the start method, it's not working. If I put it on the cog, it's working. All you Engine can be put in the start or in the cog and easy working fine in both cases ;)

Also, I will only use read functions from your object. Do you think it's easy for someone quite new in SPIN to do some clean-up to remove all what is write related to save some space?

BTW, did I already thanked you for this object? ;)

JM

Kye
08-10-2010, 01:48 AM
Thanks,

You can comment out any function that doesn't cause the object to complain about compiling. If you get a compile error after commenting out a function then put that function back in.

So, I included locking in the lowest level detail of the driver so that two or more cores won't have problems reading and writing sectors off the SD card. However, this doesn't protect the file system.

So... if all your doing is reading... Then just avoid closing two files in the same directory at the same time or calling the disk free and used space functions.

A freak accident can happen where if you close two files at the same time that are in the same directory... one of the files will have its last access time stamp corrupted.

So, reading isn't really that bad. But if you were writing... oh boy. Stuff can go really wrong.

I'm working on a new release that will solve this problem.

jmspaggi
08-10-2010, 02:11 AM
Ok, thanks.

I will try to make a "lite" version of it ;)

Also, I don't need to time stamp for the file. I'm doing an OGG reader so this information is not required for me. I will probably comment that too.

So if I remove the last access time stamp, and all the write methodes, does it mean I can keep 2 files opened at the same time?

Because I need to open 2 files in the same directory. The catalogue where I have the translation ShortName <=> LongName, and the musique file itself... I will try, and see if it's working, else, I will wait for the V2 of the driver ;) anyway, I took me the whole day just to find how to send the list of files from one cog to another one, you will be at the V99 when I will be ready to open the musique file ;)

JM

Kye
08-10-2010, 03:01 AM
To get rid of the time stamp mismatch problem just go into the close file function and comment out the "readWriteSector("W")" functions. Don't comment out the ones with "R" only the ones with "W". This will get rid of that problem.

Even better. Just go to the last PRI function called readWriteBlock and change it to this.




if(strcomp(@cardUniqueID, @cardUniqueIDCopy) or (command == "M") or (command == "T"))
repeat while(lockset(cardLockID - 1))
cardSectorAddress := ((address + (partitionStart & (command <> "B"))) & (command <> "T"))
cardBlockAddress := (@dataBlock & (command <> "B") & (command <> "T"))

if(command <> "W")

cardCommandFlag := command
repeat while(cardCommandFlag)

command := cardErrorFlag~
lockclr(cardLockID - 1)
if(command)
partitionMountedFlag := false
errorNumberFlag := Disk_IO_Error
abort string("Disk I/O Error")



Basically just put the

cardCommandFlag := command
repeat while(cardCommandFlag)

lines inside of an in statement. The if statement being " if(command <> "W") "

This will basically turn off writing everywhere.

jmspaggi
08-10-2010, 03:55 AM
Hi Kye,

Should I also put


command := cardErrorFlag~
lockclr(cardLockID - 1)


Into the same if statement?

I just commented all the write functions I will not used and I saved only 6 longs ;) So probably I will just de-activate the write feature they way you are pointing above, and keep the original file...

Is there any write variable/buffer I can remove too? Or is the compiler removing it automatically if it's not used anymore?

Thanks,

JM

Kye
08-10-2010, 04:26 AM
Don't put that stuff into the if statement. That will cause stuff not to work at all.

If you're looking to save space just comment out all the public functions that you don't plan to use that don't cause compilier errors when commented out.

jmspaggi
08-10-2010, 06:04 PM
Oups. I putted it in the statement and it was still working ;)

So I removed that from the statement, and still working too.

I will now try to play with it and see if I'm able to do what I'm trying to do.

Thanks,

JM

jmspaggi
08-10-2010, 07:05 PM
Hi Kye,

One more question.

If I know the path of "something" and I want to know if it's a file or a directory. Is there something like getType(path)?

There is listIsDirectory, but is it working only when you call listName first?

Thanks,

JM


UPDATE: RTFM... So I have my respons. Thanks.


'' ┌───────────────────────────────────────────────── ────────────────────────────────────────────────── ───────────────────────┐
'' │ Returns whether or not the current file or directory pointed to by "listName" is a directory. │
'' │ │
'' │ If a file is currently open this function will retrieve that file's information. │
'' │ │
'' │ If "listName" did not succed or was not previously called the value returned is invalid. │
'' │ │
'' │ Returns true or false. │
'' └───────────────────────────────────────────────── ────────────────────────────────────────────────── ───────────────────────┘

w4fej
08-14-2010, 09:20 PM
Kye:

I'm quite interested in your file system for the SD cards however the attachment appears to be corrupted. (Never mind, I found the file in the Obex.)

What hardware do you recommend for this??

An amazing piece of work..

Mike B.

Kye
08-14-2010, 11:37 PM
The hardware needed is shown in the code at the top in the "FATEngine" file.

Just buy an SD card adapter from parallax and you'll be ready to go.

isleder
08-23-2010, 05:26 PM
Hi Kye,

Thanks for making this driver available. I am working on a telemetry project that logs data to an SD card. While logging about 200 byte data every 100ms, I want to play back wav files from the same SD card every few seconds. Would the driver able to do this of having two files open? or do I need to close the data file and store them in a buffer while playing back the wave file? What is the best way to go about this?

Thanks
Istvan

Kye
08-23-2010, 08:46 PM
Just include two copies of the driver in your code.

As in


OBJ

fat1: "SD2.0_Fatengine.spin"
fat2: "SD2.0_Fatengine.spin"


Then put locks arround every call to the driver. Each copy can have one file open.

Brian Riley
08-26-2010, 06:21 AM
Where can I find the latest copy of KyeDOS? I tried downloading DR Acula's versions from a few pages back, but the zip files kept asking for password to unzip them. TNX .. cheers BBR.

Kye
08-26-2010, 01:03 PM
My standard copy in the Obex. I dunno about what has been put in this thread. Ask Dr_Acula.

jmspaggi
08-31-2010, 10:38 PM
Hi Kye,

I found something strange on the SD driver.

First "issue"...

I'm reading a file by 128 byte chunks.

When I read from the beginning to the end, it always return 128 bytes per read using this code except the last call.



index := fs.readData (@sd_buffer, c#sdBufferSize)


sdBufferSize = 128.

If I read until index != 128, I read more than the file size. I don't know why, but readData is returning more than the file. So I read the file based on listSize like you did on the demo and it's working fine.

Seems that the value returned by readData is not always correct and is sometime trying to get more than what is available.

File size is 3511, but I can read 28 times 128 and 54. Total is 3638. Everything is "0" after the real end of the file. There is 127 extra bytes.
Same kind of results with a 512 bytes buffer, but this time I have 7x512+68=3652 instead of 3511.

Second "issue", maybe related...

Reading the same file, if I move in the middle before reading it, I get strange readData results.
When I do a fs.changeFilePosition (840), and then read 3 chunks, I get 128, 72, 128. The 2nd chunk is not complet. When I display it on the screen, it's really missing pieces

I'm using version 1.3. I did one modification to have it read-only but removed my update and restored the original file, with no result.

Do you have any updated version I can try? Any clue why it's doing that?

Thanks,

JM

Kye
09-01-2010, 02:24 AM
jmspaggi -Read data is not made to return the number of valid bytes read. It just happens to do so since I used the result variable for computation purposes. If you look at the documentation you will notice that I do not say it returns anything.

Please use the "listFileSize" function once the file is open to get the size of the file and then use that to figure how to read bytes from the file.

...

As for not returning data in proper chunk sizes... I don't quite understand what you mean. The FS code should work since it passes the read file backwards test in my demo.

This could be an error however, please give me the code you used and the output and I will add it to my list of things to fix. In the mean time please to to work arround this error.

I've been in the process of updating the code to make it better and much faster. I don't know when I will be done but I will be able to address the problem while changing my code.

Thanks,

jmspaggi
09-01-2010, 03:02 AM
Don't ask me why...

I read the comments on your file. Pretty all of them. And I was sure it was returning the quantity! I remember well the error message pointer, and thought it was the size when it's working!

And this is the source of all the issues I saw today.

Because I saw 128 then 57 then 128, I read only 57 bytes on the 2nd paquet. Then I jumped to the 3rd, and lost all what was between the 2...

So I remove all my references to the readData returned value, and now everything is working fine!

2nd time I did not read the manual correctly :( I have to apologize...

Thanks for you prompt feedback!

JM

Kye
09-01-2010, 01:03 PM
At least you're using what I wrote. That makes me happy.

w4fej
09-03-2010, 01:50 AM
Kye:

This may be a lame question but I am going to ask it anyway!.. A good teacher is not one that simply states facts about a subject but rather makes the student use his imagination and THAT causes learning..

Having said that Teacher, could you prime my imagination and plant some ideas for the SD card file system for me? It looks to me as though the main attraction of the SD and FAT system are more useful for taking data FROM the Prop and storing it on the SD for later use by a PC. Is this mostly correct?

What about getting "something" FROM the SD card for use BY the Prop? What sort of things would the FAT system be used for? Obviously you can't load and execute a program from the SD. What about creating a .JPEG on the PC and some how displaying it on my 7" LCD color monitor? Possible? My display has two video inputs that I can select with a slick little remote. One is connected to the Propeller Backpack and works fine for text. The display is for my R/C submarine project and I would love to be able to display at least pictures when not using the control function.

Well teacher, fire up my imagination!! :idea:

Mike B.

jmspaggi
09-03-2010, 03:21 AM
Hi Mike,

On Kye's object, there is a method to load a program in the EEPROM and start it. (Look at bootPartition(fileName) details)

That way, you can have like an unlimited memory as long as you are able to split your application in multiple parts.

I'm using the FAT object to only read files from the SD. I don't write anything on it and disable the write methods.

My application is a OGG reader for my car. I stored about 20GO of music files on my SD (All my CDs I ripped), and build a application to navigate through them and play them.

I will also probably store my application menu in a file to safe some memory on the prop.

If I'm able to complete everything, I will add playlist management, an FM receiver, and all what I can found ;) I will also probably add few EEPROMs images on the SD with some games (nibbles, etc.) just for fun.

JM

jmspaggi
09-03-2010, 03:28 AM
Hi Kye,

Can you add that to your driver?

' Store current directory on the top of heap
PUB pushD

' Go pack to the first directory on the heap
PUB pop

Or maybe without any heap, like store it, restore it.

Also, is there a way to know if we are at the root? And we have to count how many directory we opened to know how many ".." we can do?

Just some ideas ;)

Thanks,

JM

Heater.
09-03-2010, 05:15 AM
w4fej,


Obviously you can't load and execute a program from the SD.

Sure you can. The Zog byte code interpreter loads it's runnable program binaries from SD card all the time. It can also load "blobs" of compiled PASM code from SD into COG and start them running there.

The ZiCog and jaZ80 Z80 emulators load entire CP/M operating systems from SD card and run them which in turn load their executable Z80 binaries from CP/M files on th SD.

I'm sure there are BASIC and other systems for the Prop that load executable code from SD.

Dr_Acula
09-03-2010, 05:39 AM
heater is right - it is easy to load and run programs off an sd card. qZ80 can do it for C/Basic/Fortran/Forth etc.

But - qZ80 can't do jpeg picture graphics, as the emulation fills up the propeller memory so there isn't enough room for hi-res graphics (Though it is good enough for '80s games). http://smarthome.viviti.com/propeller are some of the programs you can load and run off an sd card.

Also - there is KyeDOS - which gives you a menu of propeller eeprom images, and you can select the one you want and it loads it. So you can boot into KyeDOS, then select which emulation you want to run (complete with its own custom disk image format) then run that emulation and it then loads the correct disk image off the sd card and then runs individual programs off the disk.

KyeDOS also can do other clever things - eg you can load up a disk image, say, PropBasic, run a program, write some data back to the sd card, write a .ini file as well, reboot the card from software control, it then runs the program in the .ini file (eg a Catalina C program) which can pass control etc. The only catch is that there is a bit of a delay (a few seconds) between each reload of 32k of data from the sd card into the propeller - though I think Kye might have sped this up a bit recently.

So it could be possible to have a very simple propeller program that displays a background jpeg on a screen, and a button or keypress or something that selects a program to run.

I don't think all the possibilities have been explored yet. What we have now is a simple text menu of programs you can run on an sd card, but there probably is no reason that menu could not be overlaid on a jpeg picture.

w4fej
09-03-2010, 10:24 AM
Wow, thanks for all the great insight into the SD card and FAT system. The mind reals!! lol..

Dr Acula, what a wild man!! I cut my teeth on CP/M and MP/M. I was in partnership with a gent back in the day and started with the IMSAI 8080 which I had serial number 000013! Eventually the 8080 computer was fully populated with 64K (8 boards) and made a DANDY room heater!

We built a 6 user MP/M system for a company in California that they used for years doing their invoices, inventory control, payroll etc. At one time it was the largest MP/M installation outside of Digital Reasearch itself. We built the whole system in solid Oak wood, 6 individual computers and a single server computer. We paid at the time $3300.00 for a 40 MEGABYTE (not gig) 8" hard drive and it was just fine for the system.

We ran a really great data base manager called "ODBS, Ohanlon Data Base Soultions" (I STILL have a copy of that system on a 5" floppy! lol). The whole system was parked in a room with a CNC wire cutting machine and was air conditioned MOST of the time. That last sentenance was the key to it's demise!. The system ran 24/7 and the A/C happened to die one weekend and it got to well over 100 degrees in the room and alas the boot floopy and all the backups died and the system was never to be reborn. :confused:

Ah yes, those were the "good" ole days.

Mike B.

Heater.
09-03-2010, 11:20 AM
w4fej:

Great story re: CP/M and MP/M.

And now you can run all your favorite CP/M programs on the Prop under ZiCog or yZ80 emulators and put it all in a matchbox:

http://hackaday.com/2009/12/27/zilog-in-a-matchbox/

Or yZ80 will run M/PM on Prop on a DracBlade board.

This all started for me years ago when I wanted to emulate an Intel 8080 on a Prop, just as a way to learn Prop assembler. That was the PropAltair project with the aim of making an Altair computer form a Prop. http://forums.parallax.com/showthread.php?t=101495

That grew into a full blown Zilog Z80 emulation with the ZiCog project, which ended up in the matchbox. http://forums.parallax.com/showthread.php?t=110804

Since then PullMoll has pushed things along even further with his qZ80 emulator for the Prop which now runs MP/M http://forums.parallax.com/showthread.php?t=121579

Now, what about scraping that Ohanlon Data Base Soultions software off of the floppy disk so that the Propeller can have a database :)

blittled
09-03-2010, 12:17 PM
Dr. Acula: Can you post KyeDOS again? For some reason it was a corrupted zip on 2 different computers I downloaded it to. Thanks!

Kye
09-03-2010, 02:59 PM
I decreased booting time down to 2 seconds now in the new version I am working on. But, school has started so the release date may be in December after the semester is over.

@w4fej - I don't think I can give you ideas on what to do with the code. I can only just enable you to use an SD card freely.

Dr_Acula
09-03-2010, 03:03 PM
Kyedos attached. It is Kye's code with a some changes so it creates a boot menu. Stripped out a bit of code and replaced it with a VT100 driver. It might need some minor tweaks to run on the propeller demo board. The core of the program is this


PrintStringCR(string("**** SD card operating system by Kwabena W. Agyeman ****"))
PrintString(string("Type Help for command listing"))
crlf
DisplayBinaryFiles ' display all files ending in .BIN
'fat.bootpartition(string("CPM.BIN")) ' uncomment this to autorun a binary spin file
sio.rxflush(0) ' in case try to send an xmodem transfer


@w4fej, are you interested in running MP/M on the propeller? I have this working with 8 users but I'm having a few problems with random crashes after running for 20 minutes with lots of hard drive activity, so something isn't quite stable. http://smarthome.viviti.com/mp-m I'd appreciate some input from an expert! Swap hardware for your expertise??

w4fej
09-04-2010, 03:29 AM
"Now, what about scraping that Ohanlon Data Base Soultions software off of the floppy disk so that the Propeller can have a database "

You interested in that?? I miss spoke, it's on a 3" floppy, not a 5". It's small enough I could probably email the whole development system to you. Let me see if I can lay my hands on it..

Mike B.

jmspaggi
09-04-2010, 03:34 AM
Hi Kye,

I tried to implement pushd and popd, but it's not working. pushd seems to be working fine, but popd send me back to the root.

Might be missing something on popd. Any idea?





byte workingDirectorPathIndexBackup
byte workingDirectoryPathBackup[66]

PUB pushd
workingDirectorPathIndexBackup := workingDirectoryPathIndex
wordmove (@workingDirectoryPathBackup, @workingDirectoryPath, 33)
return listWorkingDirectory

PUB popd
workingDirectoryPathIndex := workingDirectorPathIndexBackup
wordmove (@workingDirectoryPath, @workingDirectoryPathBackup, 33)
currentDirectory := listCluster
listReset
return listWorkingDirectory


I'm also trying to build a changePath method which accept "/repA/repB/repC" as parameter, but it's not workign too ;) First draft here. Will still work on that a bit.



PUB changePath(path) | i
changeDirectory("/")
result := 1
i := 1
repeat until result == strsize(path)
if (byte[@path+result] == "/") or (byte[@path+result] == "\")
bytemove (@changePathNameBuffer, @path+i, result-i)
byte[@changePathNameBuffer+result-i] := 0
changeDirectory(changePathNameBuffer)
i := result+1
result++


JM

Kye
09-04-2010, 02:32 PM
Yeah, the pop and push method won't do what you want. The string I use has nothing to do with where you are on the file system.

What you want to backup are the (currentDirectory, currentCluster, currentSector, and currentByte) variables. They control where you are in the directory.

Mainly just backup the currentDirectory variable. Then when you want to go back into the directory you backed up assign to the current directory the backed up variable and then call listReset.

...

You should just wait until I get pathing working before trying to use pathing like features. However, I will not be able to tackle that anytime soon.

Otherwise, you can impltment pathing your self by evaluating the path through CDing until you are in the proper folder.

jmspaggi
09-04-2010, 04:51 PM
Cool!

It's working A1!

Thanks a lot!

Here is the code if you want to integrate it in your next version. I also did changePath. It's working fine for me. So should be correct. I'm quite sure it can be optimized, but I'm new in Spin, so it's already a big success for me ;)

JM



PUB pushd
currentDirectoryBackup := currentDirectory
return listWorkingDirectory

PUB popd
currentDirectory := currentDirectoryBackup
listReset
return listWorkingDirectory

PUB changePath(path) | i, j
result := 0
if byte[path] == "/" or byte[path] == "\"
result := 1
i := result
changeDirectory(string("/"))
repeat until result == strsize(path)
if ((byte[path+result] == "/") or (byte[path+result] == "\"))
bytemove (@changePathNameBuffer, path+i, result-i)
byte[@changePathNameBuffer+result-i] := 0
changeDirectory(@changePathNameBuffer)
i := result+1
result++
return listWorkingDirectory

blittled
09-06-2010, 02:28 AM
I seem to have a problem. In the code listed below it works well the first time but when I reset my Propeller I never get to text.str(string("SD Mounted")). It will work on reset if I have ejected the SD Card and reinserted it. The hardware I'm using is Spin Studio with the Game Stacker and a generic 64 MB SD Card. Thanks.



ifnot(fat.FATEngineStart(SPI_DO, SPI_CLK, SPI_DI, SPI_CS, DATA, DATA_CLK))
reboot
fat.mountPartition(0,0) ' mount the sd card
text.str(string("SD Mounted"))
Delay(2500)
text.cls
ptr := fat.listWorkingDirectory
ptr := fat.listName(ptr)
repeat 21
if ptr <> 0
'text.str(ptr)
'PutName(ptr)
ext := GetExt(ptr)

case ext
0:
text.color(White)
1:
text.color(Blue)
2:
text.color(Green)
3:
text.color(Yellow)
text.str(ptr)
text.TxCrLf
ptr := fat.listName(ptr)

fat.unmountPartition

blittled
09-06-2010, 03:48 AM
Nevermind! I tried a 2GB PNY and have no problem with resetting. The 64MB "ancient" SD card probably can't handle mounting correctly.

Kye
09-06-2010, 03:48 AM
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?)

Thanks,

jmspaggi
09-07-2010, 03:03 AM
Hi Kye,

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

Kye
09-07-2010, 03:49 AM
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.

jmspaggi
09-07-2010, 12:43 PM
Which mean there is still some stuffs I don't understand with Spin ;)

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

Heater.
09-07-2010, 12:50 PM
jmspaggi


is the DAT section shared by all the object instances? Which is why cardLockID can be used for that?

Yes.


And the VAR section, we have one per instance?

Yes.

jmspaggi
09-07-2010, 01:55 PM
Super, thanks Heater!

One more think I will know about spin ;)

JM

Dr_Acula
10-04-2010, 12:03 PM
Hi Kye,

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)

Kye
10-04-2010, 01:56 PM
In the new version of my string driver library online I added the string concatenation.

So... just allocate some space on the stack for a string and then concatenate the string token with the sufix.

Dr_Acula
10-05-2010, 01:15 AM
Thanks++. I'll check it out.

David Betz
10-05-2010, 10:39 PM
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?

Thanks,
David

jmspaggi
10-05-2010, 10:53 PM
Hi David,

Just use 2 instances to keep 2 files open at the same time...


fs : "SD2.0_FATEngine"
fs2: "SD2.0_FATEngine"


I'm using it read only. Have not tried the write mode.

JM

David Betz
10-05-2010, 11:05 PM
Hi David,

Just use 2 instances to keep 2 files open at the same time...


fs : "SD2.0_FATEngine"
fs2: "SD2.0_FATEngine"


I'm using it read only. Have not tried the write mode.

JM
That sounds kind of dangerous although I suppose it might work if only one of the instances is writing. Thanks for the suggestion.

Kye
10-05-2010, 11:35 PM
It works fine as long as everything is in a single thread.

David Betz
10-05-2010, 11:45 PM
It works fine as long as everything is in a single thread.
Would it work if both files were being written?

Kye
10-06-2010, 03:17 AM
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.

David Betz
10-06-2010, 03:26 AM
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?

Kye
10-06-2010, 01:31 PM
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.

MacTuxLin
10-09-2010, 04:25 PM
Hi,

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.

Jean-Marie
10-31-2010, 06:34 PM
Hello Kye,

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 :


>_ 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

For those using VGA display and keyboard, try the modified version called KyeDos and proposed by Dr_Acula.

Kye
10-31-2010, 10:55 PM
Thanks, I'm working on a new much faster version.

jmspaggi
10-31-2010, 11:00 PM
Good news ;)

Let me know if you need someone to test it ;)

JM

Dr_Acula
11-04-2010, 04:58 AM
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.

Kye
11-04-2010, 05:32 AM
I think I may support KyeDos as a seperate piece of code later on when I finish my driver.

Dr_Acula
11-04-2010, 11:33 AM
That sounds a good idea. My code was a bit of a hack - eg I was removing bits of code until it all fit.

MacTuxLin
11-12-2010, 06:07 AM
Hi Kye,

May I know if a larger capacity uSD card would consume more mA?

Kye
11-12-2010, 01:56 PM
You could assume so, but those details are card specific. All SD cards just have to operate in a certaint mA range.

MacTuxLin
11-13-2010, 09:10 AM
Thanks Kye. I've added a cap to the uSD socket.

MacTuxLin
11-13-2010, 09:36 AM
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.

I'm sticking to SanDisk brands from now onwards.

Kye
11-13-2010, 03:39 PM
What I don't understand is why they all use different tech. Everything should just use the dame design. Then there would never be any problems.

Dr_Acula
12-11-2010, 03:41 AM
Attached is the latest version of KyeDOS. Fixed a few bugs in the xmodem file transfer as it was not recovering from a corrupted packet. For files > about 100k, there seem to always be the odd corrupted packet, and now it can recover and resend the packet.

The default baud rate has been changed to 115200. Some terminal programs cannot handle this speed, eg Teraterm. Shamcom (Shamrock Software) works fine. 115k is limited more by the speed of Spin than by the download rate.

Re sd cards, I have a 22uF tantalum and a 0.1uF bypass cap right at the sd card power pins. Also I've found the sd card needs to be physically close to the propeller. Max 2cm track length.

So far, every brand I have tried works with Kye's driver code.

MacTuxLin
12-11-2010, 08:38 AM
Hi Dr_Acula,
May I know the extra 22uF tantalum cap is needed due to your application or its a better general practice? I only place a 0.1uF bypass cap & don't have any problem with trace more than 2cm.

Kye
12-11-2010, 03:13 PM
Oh, hey all I should be done with the SD3.0 FatEngine by January.

Pathing works now! Plus its twice as fast without read ahead and write behind implemented. It might be 4 times faster than the SD2.0 fatengine when I am done.

(Pathing allows you to do stuff like "bin\stuff\code.spin" or stuff like "hello\..\hello\.\subHello\target.txt"

MacTuxLin
12-11-2010, 04:30 PM
Wow, super!

Dan E
12-11-2010, 05:35 PM
I would like to use this object to play a WAV file from the SD card, from what I've gathered so far I think the parts I need to call and/or modify pin selection are:

- formatPartition and mountPartition, to access SD card

- FATEngineStart, to assign pin selection for SD adapter

-programPlayWavFile, to play Wav file

I would appreciate some help in making this work properly, so that I can include audio in my school project Tuesday. I have a 16 Ohm, 200mW audio amplifer unit with speaker, for the output.

Thank you,
Dan E

Kye
12-11-2010, 07:38 PM
If you have my DACEngine and FATEngine... then here is the code you need.



PRI playWAV(fileName)

if(playerID)
cogstop(-1 + playerID~)

playerDoneFlag := false
playerID := (cognew(WAVPlayer(fileName), @WAVStack) + 1)

PRI WAVPlayer(fileName)

fat.mountPartition(0, 0)
fat.openFile(fileName, 0)

fat.changeFilePosition(22)
dac.numberOfChannelsSetup(fat.readShort)

dac.sampleRateSetup(playerSpeed := fat.readLong)

fat.changeFilePosition(34)
result := fat.readShort

dac.bitsPerSampleSetup(result)
dac.sampleSignSetup(result == 16)

fat.changeFilePosition(40)

dac.startPlayer
repeat (fat.readLong >> 9)
fat.readData(dac.transferData, 512)

dac.clearData
dac.stopPlayer

fat.unmountPartition
playerDoneFlag := true
cogstop(cogid)

DAT WAVDat

playerSpeed long 0
playerID byte 0
playerDoneFlag byte 0
WAVStack long 0[100]

Dan E
12-11-2010, 08:05 PM
Thank you very much, this is extremly helpful, and exactly what I need.

Is this how I would change LeftPinNumber and RightPinNumber in the DACengine object to work for my audio output?

Example:

Change
result := ((leftPinNumber <# 31) #> 0)

To
result := ((6 <# 31) #> 0) ?

In my case, pin 6 is my audio output, and I have one speaker, so I see I would make the inactive speaker in the code assigned -1.

Thanks again,
Dan E

Cluso99
12-11-2010, 08:12 PM
Dan E: Somewhere in the code LeftPinNumber will have been defined. It is best to change it there rather than what we call hard coding it in an instruction. It should be near the top of one of the files.

Dr_Acula
12-11-2010, 10:17 PM
Hi Dr_Acula,
May I know the extra 22uF tantalum cap is needed due to your application or its a better general practice? I only place a 0.1uF bypass cap & don't have any problem with trace more than 2cm.

Maybe it isn't totally necessary, but I had a board that was unstable without it. It was also before Kye's code was written, so possibly it was the sd card brand, not the board. In any case, I tend to buy 0.1uF caps and 22uF tantalums in bulk, so they are very cheap.

Another general reason is that any part that is using a lot of current and where that current is changing rapidly ought to have its own capacitor. This reduces noise on the supply lines. Things like the keyboard, mouse, LCD display and VGA display do use current but it is fairly constant. But the SD card uses a lot more when it is in use compared with idling.

If money is tight, I might suggest that you could try leaving it out, but if you are designing a board, at least put the pads in.


Oh, hey all I should be done with the SD3.0 FatEngine by January.

That sounds great! As a general idea, how quick is a reboot of a binary file (ie the command that loads a binary file into ram and then runs it)?