eMMC driver (Can now read data in 8-bit mode!)
Rayman
Posts: 14,646
From the eMMC vs HyperFlash thread, I've bought some stuff to hook up a eMMC chip to the P2. (that thread is here: https://forums.parallax.com/discussion/169987/)
Fortunately, the thing came with a uSD adapter that I can use to get some code working (see pic).
I tried regular uSD code (FSRW) on it and it fails completely.
This is because this thing uses the MOSI pin (they call it CMD pin) in a bidirectional manner.
I skimmed through JEDEC Standard No. 84-A441 and found the details I needed to get started...
The first thing to do is send CMD0 with no parameters.
Then, do CMD1 to get the OCR (operation conditions register).
The attached code does this and the response looks legit. Yeh!
Update: "..test2f" can now read block #0 data from eMMC chip using uSD adapter.
Update2: "..test3b" can now read 8-bit bus data using homemade adapter.
Fortunately, the thing came with a uSD adapter that I can use to get some code working (see pic).
I tried regular uSD code (FSRW) on it and it fails completely.
This is because this thing uses the MOSI pin (they call it CMD pin) in a bidirectional manner.
I skimmed through JEDEC Standard No. 84-A441 and found the details I needed to get started...
The first thing to do is send CMD0 with no parameters.
Then, do CMD1 to get the OCR (operation conditions register).
The attached code does this and the response looks legit. Yeh!
Update: "..test2f" can now read block #0 data from eMMC chip using uSD adapter.
Update2: "..test3b" can now read 8-bit bus data using homemade adapter.
Comments
Should say "CMD0 then CMD1"
Issue a CMD0 and also a CMD8 with $1AA for operating conditions request etc.
Then read the OCR response as 32-bits (SPI Read Long) and print as a long (.L).
This is the precise reason that TAQOZ is in ROM. It's not just a language, it's a tool.
btw, I just revisited TAQOZ in ROM and while it doesn't have the bells and whistles since it is packed into 12k, you can still do a lot. If you need to change the pins that the SD interface uses, you can specify it as a long in dot decimal notation if you prefix with an ampersand like this &cs.miso.miso.sck -
For example suppose we connected the clock to P34, the data in of the SD to P33 and the data out of the SD to P32 and because we are higgerly-piggerly the card select to P37. We could specify the pinout with &37.32.33.34 and while there isn't a direct word to change it, we can overwrite the sdpins constant and check it like this:
Closer to i2c...
I’m supposed to have a 10k pull-up on the Cmd pin but seems to work without it.
A quick manual check of sending a $36 as an address and a command $10 and data byte $33. If I'm happy with that I might make that into a general purpose word for this: Then I can just type $33 $10 UB3CMD or supply any other parameters interactively.
I'm just making the suggestion as a reminder that this is built into the ROM and is always available, and only needs a terminal and it helps to have some kind of text editor. (I2C isn't in the ROM itself, but is easily added, or just use the full version)
I have C++ code that works, but my Spin2 code doesn't for some reason.
Also, there seems to be some other kind of CRC7 with the same polynomial that gives a different result... strange...
BTW: That response from the card isn't what I'm looking for, as I see it now. I need to give it a different parameter for CMD1 to proceed...
Which means figuring out the CRC...
Maybe I have to get through init first.
The P2 has hardware CRC instructions. Do these not work for this or did you forget about them?
The mmc version seems to be strange though
Seems you do 8 bits of crc for the 5 bytes of cmd+parameter, then do 7 bits of zero.
Finally, of course, you left shift and add 1.
Got it from the .zip file here: https://www.eetimes.com/heres-the-answer-to-crc-7-algorithm-for-the-sd-card/#
What's the advantage of these chips over the other solutions we've got so far? Sorry if I missed that. Read your progress report and was just wondering.
Ends in "55 AA", so I think it actually works!
Just looking at this: https://elinux.org/images/9/91/Clement-sd-mmc-high-speed-support-in-linux-kernel_0.pdf
The DDR50 mode looks like it should work. That'd give us 50 MB/s compared to the < 3 MB/s we get now with uSD.
That's quite a boost!
If it's true, could do things like switch between 1080p images in HyperRam faster than the blink of an eye.
And do 16bpp uncompressed video at 480p resolution.
(That might be such a good idea though because you'd burn through 16 GB in 5 minutes...)
(sidetrack: we need to get jpeg decompression working!)
Perhaps the P2 pins would recognize 1.8 V as logic high? Should I think...
Maybe can use the DAC to give 1.8 V output...
I'll just try 3.3 V for now.
Might have to move CMD to P8 and just tie RST to high and remove STRB.
That way, could use over on basepin #48 side of the board...
I see now that (unlike uSD cards) this thing really does need a pullup on the CMD (miso) line.
Does block read at 13 MHz here. But, think can get that up at least to 25 MHz.
There is a new RESn pin though... I’m not sure yet if this can just be tied high.
Sharing those data pins is an interesting idea for pin constrained setups but you'd really need a combined HyperRAM/Flash+eMMC driver to do that so there are no collisions. Unfortunately I've got no more room in my Hyper driver COG to add that, plus being slower to access it would mess up any real-time video transfers anyway