mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* raspberry pi mmc issue
@ 2013-10-15 11:51 Alexander Aring
  2013-10-15 12:23 ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Aring @ 2013-10-15 11:51 UTC (permalink / raw)
  To: barebox

Hi all,

I using a not mainlined raspberry pi qemu implementation [1] and tried to
run barebox on it. All seems to working but if I probe the mmc with
mci0.probe=1 qemu will crash on a assert on 4 byte assert [2].

I dig a little bit into the Datasheet of bcm2835 [3] which says:

"Contrary to Arasan™’s documentation the EMMC module registers can only
be accessed as 32 bit registers, i.e. the two LSBs of the address are
always zero."

Then I dig into the barebox bcm2835_mci implementation and found
something [4]. We use there a readb on SDHCI_RESPONSE_0 which is not a
32 bit access. I just commented the if branch and it works.

Maybe this can make some errors on a real raspberry, too.

Maybe somebody knows a little bit more about mci and can help me to find
a proper solution? Perhaps just make a 32 bit access and do some bit
magic with masks and shifts?

- Alex

[1] https://github.com/Torlus/qemu-rpi
[2] https://github.com/Torlus/qemu/blob/rpi/hw/arm/bcm2835_emmc.c#L405
[3] http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf page 66
[4] http://git.pengutronix.de/?p=barebox.git;a=blob;f=drivers/mci/mci-bcm2835.c;h=abd38a35c9bfadcb2e3013eb4b220f74acf7464b;hb=HEAD#l264

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: raspberry pi mmc issue
  2013-10-15 11:51 raspberry pi mmc issue Alexander Aring
@ 2013-10-15 12:23 ` Sascha Hauer
  2013-10-15 18:31   ` Alexander Aring
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2013-10-15 12:23 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

On Tue, Oct 15, 2013 at 01:51:17PM +0200, Alexander Aring wrote:
> Hi all,
> 
> I using a not mainlined raspberry pi qemu implementation [1] and tried to
> run barebox on it. All seems to working but if I probe the mmc with
> mci0.probe=1 qemu will crash on a assert on 4 byte assert [2].
> 
> I dig a little bit into the Datasheet of bcm2835 [3] which says:
> 
> "Contrary to Arasan™’s documentation the EMMC module registers can only
> be accessed as 32 bit registers, i.e. the two LSBs of the address are
> always zero."
> 
> Then I dig into the barebox bcm2835_mci implementation and found
> something [4]. We use there a readb on SDHCI_RESPONSE_0 which is not a
> 32 bit access. I just commented the if branch and it works.
> 
> Maybe this can make some errors on a real raspberry, too.
> 
> Maybe somebody knows a little bit more about mci and can help me to find
> a proper solution? Perhaps just make a 32 bit access and do some bit
> magic with masks and shifts?

Here the SD card works (both read and write). I can surely test a patch
converting this access into a 32bit access.

The only thing I realize here is that my 3.6.4 kernel fails to access
the SD card when barebox has accessed it before:

[    3.623861] mmc0: SD Status: Invalid Allocation Unit size.
[    3.635586] mmc0: error -110 whilst initialising SD card
[    3.724743] mmc0: SD Status: Invalid Allocation Unit size.
[    3.739073] mmc0: error -110 whilst initialising SD card
[    3.836341] mmc0: SD Status: Invalid Allocation Unit size.
[    3.847708] mmc0: error -110 whilst initialising SD card
[    3.965447] mmc0: read SD Status register (SSR) after 3 attempts
[    3.971483] mmc0: SD Status: Invalid Allocation Unit size.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: raspberry pi mmc issue
  2013-10-15 12:23 ` Sascha Hauer
@ 2013-10-15 18:31   ` Alexander Aring
  2013-10-15 18:39     ` Andre Heider
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Aring @ 2013-10-15 18:31 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi Sascha,

On Tue, Oct 15, 2013 at 02:23:32PM +0200, Sascha Hauer wrote:
> On Tue, Oct 15, 2013 at 01:51:17PM +0200, Alexander Aring wrote:
> > Hi all,
> > 
> > I using a not mainlined raspberry pi qemu implementation [1] and tried to
> > run barebox on it. All seems to working but if I probe the mmc with
> > mci0.probe=1 qemu will crash on a assert on 4 byte assert [2].
> > 
> > I dig a little bit into the Datasheet of bcm2835 [3] which says:
> > 
> > "Contrary to Arasan™’s documentation the EMMC module registers can only
> > be accessed as 32 bit registers, i.e. the two LSBs of the address are
> > always zero."
> > 
> > Then I dig into the barebox bcm2835_mci implementation and found
> > something [4]. We use there a readb on SDHCI_RESPONSE_0 which is not a
> > 32 bit access. I just commented the if branch and it works.
> > 
> > Maybe this can make some errors on a real raspberry, too.
> > 
> > Maybe somebody knows a little bit more about mci and can help me to find
> > a proper solution? Perhaps just make a 32 bit access and do some bit
> > magic with masks and shifts?
> 
> Here the SD card works (both read and write). I can surely test a patch
> converting this access into a 32bit access.
> 
ok I will send a patch which do:

cmd->response[i] |=
	bcm2835_mci_read(
	host,
	SDHCI_RESPONSE_0 +
	(3 - i) * 4 - 1) & 0xFF;

which works for qemu. My workaround (just comment the i != 3 branch) had
some trouble to read partition table. But with this solution all works fine.

But I wonder myself why this works now. We readed a byte from this postion
but now we read 4 bytes from this position and use the lastest bytes. The
correct way should be to make a 24 shift to right. Something like:

cmd->response[i] |=
	bcm2835_mci_read(
	host,
	SDHCI_RESPONSE_0 +
	(3 - i) * 4 - 1) >> 24;

To make a 32 bit access to byte access..

I don't really understand what the code is doing here right now, need
some more time to dig into this. Maybe the read overlaps more than one
register now which isn't well, too.

Another point is that the for loop (with i != 3) and error handling (every
check on ret != -1) looks a little bit crazy for me. Nevertheless I will send
a patch soon.

> The only thing I realize here is that my 3.6.4 kernel fails to access
> the SD card when barebox has accessed it before:
> 
> [    3.623861] mmc0: SD Status: Invalid Allocation Unit size.
> [    3.635586] mmc0: error -110 whilst initialising SD card
> [    3.724743] mmc0: SD Status: Invalid Allocation Unit size.
> [    3.739073] mmc0: error -110 whilst initialising SD card
> [    3.836341] mmc0: SD Status: Invalid Allocation Unit size.
> [    3.847708] mmc0: error -110 whilst initialising SD card
> [    3.965447] mmc0: read SD Status register (SSR) after 3 attempts
> [    3.971483] mmc0: SD Status: Invalid Allocation Unit size.

Mhh, I think my patch would not fix your problem. I successful access
the sdcard after booting linux, but this was on qemu...

- Alex

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: raspberry pi mmc issue
  2013-10-15 18:31   ` Alexander Aring
@ 2013-10-15 18:39     ` Andre Heider
  2013-10-16  7:23       ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Andre Heider @ 2013-10-15 18:39 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

Hi,

On Tue, Oct 15, 2013 at 08:31:11PM +0200, Alexander Aring wrote:
> Hi Sascha,
> 
> On Tue, Oct 15, 2013 at 02:23:32PM +0200, Sascha Hauer wrote:
> > The only thing I realize here is that my 3.6.4 kernel fails to access
> > the SD card when barebox has accessed it before:
> > 
> > [    3.623861] mmc0: SD Status: Invalid Allocation Unit size.
> > [    3.635586] mmc0: error -110 whilst initialising SD card
> > [    3.724743] mmc0: SD Status: Invalid Allocation Unit size.
> > [    3.739073] mmc0: error -110 whilst initialising SD card
> > [    3.836341] mmc0: SD Status: Invalid Allocation Unit size.
> > [    3.847708] mmc0: error -110 whilst initialising SD card
> > [    3.965447] mmc0: read SD Status register (SSR) after 3 attempts
> > [    3.971483] mmc0: SD Status: Invalid Allocation Unit size.
> 
> Mhh, I think my patch would not fix your problem. I successful access
> the sdcard after booting linux, but this was on qemu...

I'm not seeing the issue here either (using Linus' master).

Regards,
Andre

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: raspberry pi mmc issue
  2013-10-15 18:39     ` Andre Heider
@ 2013-10-16  7:23       ` Sascha Hauer
  0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2013-10-16  7:23 UTC (permalink / raw)
  To: Andre Heider; +Cc: barebox

On Tue, Oct 15, 2013 at 08:39:27PM +0200, Andre Heider wrote:
> Hi,
> 
> On Tue, Oct 15, 2013 at 08:31:11PM +0200, Alexander Aring wrote:
> > Hi Sascha,
> > 
> > On Tue, Oct 15, 2013 at 02:23:32PM +0200, Sascha Hauer wrote:
> > > The only thing I realize here is that my 3.6.4 kernel fails to access
> > > the SD card when barebox has accessed it before:
> > > 
> > > [    3.623861] mmc0: SD Status: Invalid Allocation Unit size.
> > > [    3.635586] mmc0: error -110 whilst initialising SD card
> > > [    3.724743] mmc0: SD Status: Invalid Allocation Unit size.
> > > [    3.739073] mmc0: error -110 whilst initialising SD card
> > > [    3.836341] mmc0: SD Status: Invalid Allocation Unit size.
> > > [    3.847708] mmc0: error -110 whilst initialising SD card
> > > [    3.965447] mmc0: read SD Status register (SSR) after 3 attempts
> > > [    3.971483] mmc0: SD Status: Invalid Allocation Unit size.
> > 
> > Mhh, I think my patch would not fix your problem. I successful access
> > the sdcard after booting linux, but this was on qemu...
> 
> I'm not seeing the issue here either (using Linus' master).

Oh, great. Then I'll probably just have to update my kernel.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-10-16  7:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-15 11:51 raspberry pi mmc issue Alexander Aring
2013-10-15 12:23 ` Sascha Hauer
2013-10-15 18:31   ` Alexander Aring
2013-10-15 18:39     ` Andre Heider
2013-10-16  7:23       ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox