A second SD/MMC (and slowing down it)

Started by marcolazzaroni, September 17, 2012, 10:47:54 AM

Previous topic - Next topic

marcolazzaroni

Hello all,
thanks in advance to anyone who will read this long post.

I have to interface the Olinuxino Maxi with a second SD card. I have three chances:

1) My first idea is to use some pins on GPIO, since they are connected to the second SD Card interface of the iMX233 uP. Does the kernel support it?

2) If it is not possible, I could search for a way to boot from something else than SD Card 1, and use this plug to get a place for my SD card.

3) I could connect an USB card reader.

I already successfully got in chance (3), but I have a problem.
I also need to place the SD Card not directly into the SD Card plug; I have it about half meter away. By means of some wires and a PCB shaped like an SD Card, the SD Card is half meters away.
It could sound a little crazy but this is made this way to match some geometry constraints.

Obviously this leads to some errors while reading/writing to the sd card.
With chance (3) the base clock is about 15 MHz; everything works for some seconds, then I get some communication errors, so a reset of the sd card is needed. Looking at the signals I see that they are little too much rounded up.

So my idea is that since it works for some seconds, by slowing to about 8 MHz or less I would get a reliable communication.

Chance (3) is not an option, I think, since I don't have idea about how to communicate with the USB Card Reader's chip and choose a slower SD clock.

Have you got any suggestions of any kind on about how to achieve my goal?

Thanks a lot.

Best regards,
  Marco

Fadil Berisha

Hi Marco,
>I could search for a way to boot from something else than SD Card 1, and use this plug to get a place for my SD card.

Have look at OLINUXINO-MAXI_revision_G.pdf for boot options on olinuxino-maxi. I think simplest way is to boot from SPI flash. In that case boot select pins are 0010 and you need to connect spi flash on UEXT connecor. I was asked to implement nor flash on olinuxino http://tech.groups.yahoo.com/group/olinuxino/message/1927. I have finished spi and i2c implementation and waiting for chip to do hardware verification. For now, I am hapy with dmesg:

[    0.910000] m25p80 spi32766.0: unrecognized JEDEC id ffffff

If you are going in this experiment, I will share with you code.

Regards
Fadil Berisha

ngcoders

Imx233 supports two ssp interfaces so two microsd are supported . We had designed a board which uses two micro sd cards ( google locux ).
Lookup the second interface on Maxi and use it , You may also use SPI to interface to micro sd , set the clock for SPI low so that errors do not happen.

marcolazzaroni

Hello Fadil and ngcoders,

thank you both for your replies. Since in my final project I'll need to boot from SD Card, I think that the best way is to get the second SD Card to work.

Also, I need a good data rate; I think that the ideal SD Card clock would be around 4 or 8 MHz (with the USB Card reader - chance (3) -, it works most of the time at 15MHz -> 5.6 MBytes/s; every 20 or 30 seconds I get an error).
By using SPI mode can I get such a speed? I think I need a 4 bit data transfer mode. Locux sounds interesting. Does locux support 4 wires data transfer mode?
Thanks again!
Cheers,
  Marco


marcolazzaroni

ngcoders,

Is the locux project (http://www.ngcoders.com/) still active?
Is there some code about the second SD card you could give me?
Is possible to get a board?
Cheers
  Marco

marcolazzaroni

I found out that SSP2 is not fully connected to GPIO port.
SSP2_CMD, SSP2_SCK, SSP2_DETECT are not connected.
So it is not possible to use SSP2 on the Olinuxino Maxi unless you do some hw modification to the board.


marcolazzaroni

I think I'll solder the lacking pins and give it a try.

I think that I have to look into device tree source thingies in order to enable mmc2, am I right?

marcolazzaroni

are /arch/arm/boot/dts/imx23-olinuxino.dts and arch/arm/boot/dts/imx23.dtsi the files I have to look at?
cheers
  Marco

dpwhittaker

Those are the ones... the dtsi declares the "prototypes" and the dts the implementation.  So leave the dtsi alone, but use it as a reference... things in the dts that match the dtsi override the parameters they define while keeping the rest of the parameters from the dtsi.  Look at the stuff that is already defined and you will see what I mean.

marcolazzaroni

I'm doing some progress.
I've modified imx23.dtsi adding these lines:

    mmc1_4bit_pins_a: mmc1-4bit@0 {
reg = <0>;
fsl,pinmux-ids = <
0x0002 /* MX23_PAD_GPMI_D00__SSP1_DATA0 */
0x0012 /* MX23_PAD_GPMI_D01__SSP1_DATA1 */
0x0022 /* MX23_PAD_GPMI_D02__SSP1_DATA2 */
0x0032 /* MX23_PAD_GPMI_D03__SSP1_DATA3 */
0x0142 /* MX23_PAD_GPMI_RDY1__SSP2_CMD */
0x0132 /* MX23_PAD_GPMI_RDY0__SSP2_DETECT */
0x0182 /* MX23_PAD_GPMI_WRN__SSP2_SCK */
>;
fsl,drive-strength = <1>;
fsl,voltage = <1>;
fsl,pull-up = <1>;
};

mmc1_8bit_pins_a: mmc1-8bit@0 {
reg = <0>;
fsl,pinmux-ids = <
0x0002 /* MX23_PAD_GPMI_D00__SSP1_DATA0 */
0x0012 /* MX23_PAD_GPMI_D01__SSP1_DATA1 */
0x0022 /* MX23_PAD_GPMI_D02__SSP1_DATA2 */
0x0032 /* MX23_PAD_GPMI_D03__SSP1_DATA3 */
0x0042 /* MX23_PAD_GPMI_D04__SSP1_DATA4 */
0x0052 /* MX23_PAD_GPMI_D05__SSP1_DATA5 */
0x0062 /* MX23_PAD_GPMI_D06__SSP1_DATA6 */
0x0072 /* MX23_PAD_GPMI_D07__SSP1_DATA7 */
0x0142 /* MX23_PAD_GPMI_RDY1__SSP2_CMD */
0x0132 /* MX23_PAD_GPMI_RDY0__SSP2_DETECT */
0x0182 /* MX23_PAD_GPMI_WRN__SSP2_SCK */
>;
fsl,drive-strength = <1>;
fsl,voltage = <1>;
fsl,pull-up = <1>;
};

mmc1_pins_fixup: mmc1-pins-fixup {
fsl,pinmux-ids = <
0x0132 /* MX23_PAD_GPMI_RDY0__SSP2_DETECT */
0x0182 /* MX23_PAD_GPMI_WRN__SSP2_SCK */
>;
fsl,pull-up = <0>;
};


I don't know why but I need to insert this in the .dts file (or I don't get anything):

            ssp1: ssp@80034000 {
                compatible = "fsl,imx23-mmc";
                pinctrl-names = "default";
                pinctrl-0 = <&mmc1_4bit_pins_a &mmc1_pins_fixup>;
                bus-width = <4>;
                status = "okay";
            };


Now I see some activity in the logs:

[    1.110000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 30, clock_rate 239, ssp_clk 288000000, rate_actual 40000, rate_requested 40000
[    1.140000] mxs-mmc 80034000.ssp: initialized

Anyway, while ssp0 has other lines in the logs, nothing happens for ssp1 after this.

On the hardware side, all the SSP2 related pins are available on GPIO or UEXT; the only lacking one is SSP2_DETECT.
If I short this pin to GND (Correct?) I trigger something and I get activity on SCK and CMD pins (once every 1.1 s).
In the logs I see messages like this one

[   40.010000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 30, clock_rate 239, ssp_clk 288000000, rate_actual 40000, rate_requested 40000

Looking to get beyond it.
Any suggestions are much appreciated.
Cheers

marcolazzaroni

Some news.

I have something strange on DATA3 pin: it is at a constant voltage of 1,8V, while CLK and CMD signals range from 0 to 3 V.
DATA0, DATA1 and DATA2 are at a constant 3V.

So, either I have a hardware problem, or I have a configuration error on DATA3 pin, I think!

marcolazzaroni

shame on me!!!
I re-checked the pinout and I've discovered that the wiring was wrong!
I still have some problems:

Oct  3 16:10:12 debian kernel: [  847.880000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 30, clock_rate 239, ssp_clk 288000000, rate_actual 40000, rate_requested 40000
Oct  3 16:10:12 debian kernel: [  847.910000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 30, clock_rate 239, ssp_clk 288000000, rate_actual 40000, rate_requested 40000
Oct  3 16:10:12 debian kernel: [  847.930000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 30, clock_rate 239, ssp_clk 288000000, rate_actual 40000, rate_requested 40000
Oct  3 16:10:12 debian kernel: [  847.970000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 30, clock_rate 239, ssp_clk 288000000, rate_actual 40000, rate_requested 40000
Oct  3 16:10:12 debian kernel: [  847.990000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 30, clock_rate 239, ssp_clk 288000000, rate_actual 40000, rate_requested 40000
Oct  3 16:10:12 debian kernel: [  848.010000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 30, clock_rate 239, ssp_clk 288000000, rate_actual 40000, rate_requested 40000
Oct  3 16:10:12 debian kernel: [  848.140000] mmc1: host does not support reading read-only switch. assuming write-enable.
Oct  3 16:10:12 debian kernel: [  848.170000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 30, clock_rate 239, ssp_clk 288000000, rate_actual 40000, rate_requested 40000
Oct  3 16:10:12 debian kernel: [  848.190000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 2, clock_rate 28, ssp_clk 288000000, rate_actual 4965517, rate_requested 5000000
Oct  3 16:10:12 debian kernel: [  848.210000] mmc1: error -5 whilst initialising SD card
Oct  3 16:10:12 debian kernel: [  848.220000] mxs-mmc 80034000.ssp: mxs_mmc_set_clk_rate: clock_divide 2, clock_rate 28, ssp_clk 288000000, rate_actual 4965517, rate_requested 5000000

...they repeat every second.

5000000 is the freqency I've chosen; now I go and look for the meaning of error -5.

marcolazzaroni

Well! It works! It was related to some missing pullups on data and cmd pins!
If someone will need to do the same thing, he can use the modifications I pasted!