>PS: I've also seen procedure _sd_read_512(), filling an array, index by index ([0], [1], ...), resulting in 512 lines in the body. There sure must be a reason, but I have to ask: why not using a loop ?
While loops are handled very efficient by the compiler, access to arrays with a variable index is not as much so. For the PATA lib, it definitely increases speed a lot to read one sector not using a loop. For SD I'm not so sure about this, as data transfer over SPI takes its time, so the difference may be less here.
But that's surely the reason for the existence of this "bad style" part: Speed.
Greets,
Kiste
Please use spi_master instead of spi_carrier. When SPI is defined inthe sample, there can be aliases.
Matt.
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
Here are some sample includes for samples that I use. Alias takes few
extra lines and is quite effective for generic libs.
PS: I have many of these snippets made up if you need them for Jaluino
IDE.
PS#2: Let me know when you get more Jaluino boards :)
I prefer to take the spi init procedure and split it into two.
Sure, and also check if pragma inline is a good idea.
From my lib:
address = address * 512 -- make sd card sector addressable, sd cards
are normally byte addressable.
My comment is not completely true. SD Cards ARE normally byte
addressable, but for fat32 and PC's, there is never a need to start in
the middle of a 512 byte chunk and end in the middle of the next.
For example, you could start a read at byte 256 of the sd card, and
end at byte 512 + 256 (which is 512 bytes read total)
FAT32 and PC's assume the first sector starts at byte 0 and the next
sector is at byte 512
My conclusion:
You can start reading or writing a block from anywhere, but have to
read/write an entire block, default block size is 512 (one sector).
I'm not sure if there's another way to read/write other then block
mode. We could improve the library by looking into this or to set a
block size of 1 byte and add a constant for the user.
512 should stay default, byte reads/writes may not work at all on high
capacity SD memory cards. I don't think I tried any high capacity
cards yet with this lib.
Filesystems usually assume sectors are 512 bytes. From what I
understand, hard disks always use 512 byte sectors. Hard disks have a
read/write buffer that is 512 bytes.
I would have to ask the user: why not just use 23k256 instead of sd
card for byte reads/writes?
I would have to ask the user: why not just use 23k256 instead of sd
card for byte reads/writes?
I've used 24LC256, 32kByte EEPROM, 8 chips totalling to 0.25MByte on one PCB. It's connected via I2C. Works fine. If more memory was required, I wanted to use SD card, for it is far cheaper per byte...
Page size of 64 byte has only to be observed while writing, reading consecutive or adressed bytes is easily possible, one chip at a time.
Greets,
Kiste
> But you can actually read byte-by-byte, using sd_data_byte pseudo-var ? YouYes, you can maybe read byte-by-byte, but you can't write byte-by-
> don't necessarily have to deal with a 512-bytes buffer.
byte. You have to write the entire block.
If you want, we can add some user constants and improve the lib.
> ... this means sd_card is "infected" (no offense :)) with FAT32 concerns.
> Not a big deal in this case (start at 0, assume next is at 512), because
> filesystems blocks are mutiple of 512. But if there's something more
> FAT32-specific, it should be removed to be as generic as possible, so other
> can build on top of it without finding weird workaround. AFAIK there's
> currently no such case !
Maybe this:
address = address * 512
can be changed to this:
address = address * SD_BLOCK_SIZE
Is there a need for block size to be variable? Is there a need for
blocks to not start at byte 0?
Adding this feature may be desirable (with warning about HC cards). Do
you also wish that fat32 could use smaller blocks?
For $0.03 per MByte, including card holder? Yes, I would, bien sure. (oops, that was french :-)
Especially if I stored raw data without any file system, I would make a SD-card non-replaceable. At least noone would ask me then how to read that card on his windows machine. Discrete memory chips are harder to come by, more expensive and often take more board space, so why shouldn't I solder on a SD-card?
Greets,
Kiste
Great, so I may just add that optional constant SD_BLOCK_SIZE
You should also be careful about stopping your reads in the middle of
a block. I think the working (but not proper) way to stop in the
middle of a block is to de-activate the chip select line. If the chip
select line stays active, the sd card will assume the next thing you
try to do is a read. Even if you are trying to send a command.
The proper way of course is to just dummy read the rest of the block.
I do wish to improve the lib and I very much appreciate your input!
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
I was about to write that... But then I realized that both chips were pin compatible, so the PCB would work with ram or flash ;-)
Greets,
Kiste
Greets,
Kiste
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
I'll perform more tests, and try to close SD card sector every 512 bytes (it is required, right ?)
2011/4/28 mattschinkel <mattsc...@hotmail.com>Why did you decide to read 4 bytes (0x3253FEFF) instead of two
(0x3253)?
What are the next bytes if you read after 0x3253FEFF?
Matt.
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
Matt.
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
Le 30 avr. 2011 à 18:36, mattschinkel <mattsc...@hotmail.com> a
écrit :
> Maybe try large files on FAT32 to see if you have the same issue.
>
> Matt.
>
Thanks Seb, hopefully this will fix some issues. It's funny how I

tia
cheers
seb
--
Sébastien Lelong
Le 3 mai 2011 à 15:10, mattschinkel <mattsc...@hotmail.com> a
écrit :
> is there a way to read and write at the same time, IYou will have to stop_read/start_write. I don't know of any other way.
> mean, do I have to stop_read/start_write and stop_write/start_read to
> switch between 2 modes, or is there something easier ?
Same thing for hard disks.
Keep hard disks in mind. This makes me ask, Will your lib support hard
disks? You may want to copy the aliases and method from the FAT32 lib.
Just do stop read (inactive chip select). I don't think there is any
> also, is it possible to partial partial sector ? (though I think I
> know the answer...)
harm, but I didn't see any official doc on this. There may be
something in sd card specification. Maybe we can test on a few cards
to see if the result is the same.
|
CompactFlash cards are connected with an electrically PATA-compatible interface, so it is not strictly useable for hard disks only. Greets, Kiste |
I'm not so sure - the speed is greatly increased because each field in the array is adressed by a _constant_ subscript. The loop version is not slow because of it's a loop. Loops are quite efficient in JAL. What takes quite some time is storing the values to the array using a _variable_ subscript.
Greets,
Kiste
Good point :-)
I had been thinking about that part of the fat lib with PATA in mind, where data is transferred in parallel and two bytes are read within six or seven processor cycles. When SPI is used, things could be significantly sped up by not using a generic "read and write" procedure, but a read-only-procedure. The read-and-write-procedure is called, transfers the "write" data, and waits until the "read" data is ready. As it is only dummy data that is transfered while reading from the SD card, there would be no need to wait for the data transfer. About eight processor cycles per byte are to be saved like that, and those cycles could make up for the variable indexing.
If the read-only-procedure would be inlined, even more cycles would be saved, and that read-only-procedure would be very small, so that should not cost much program data.
The real problem IMO is, that the fat lib would have to make a difference on what storage backend it is run then.
Greets,
Kiste