[U-Boot] MMC and buffer alignment question

Wolfgang Denk wd at denx.de
Wed Mar 19 15:44:52 CET 2014


Dear Eric Nelson,

In message <5329A80B.9020908 at boundarydevices.com> you wrote:
> 
> > short question to the usage of the mmc command (and also the mmc
> > driver API): is it intended that mmc read / write may fail when the
> > supplied address in RAM is not aligned?
> 
> If not intended, it is known.

I consider this a known bug.

> > ARMV7 will give output like this:
> >
> > U-Boot > mmc read 12000002 44 44
> >
> Why would you want to do this?

For example, BMP images require loading on a +2 aligned address due to
their stupid header format.  I ran into this before myself: it is
impossible to match both the alignment reuqirements of the bmp command
and the mmc read command at the same time.  One must manually copy the
memory ragen again.  This is a plain, stupid bug.

> > Special commands inside the mmc drivers and in env_mmc implement the
> > alignment magic. Shouldn't the mmc do the magic (and if neccesarry
> > provide help using temp buffers if needed) so that all users outside can
> > read / write without caring for special cases?
> 
> Is there a use case here? There are plenty of memory addresses that
> won't work with commands like "mmc read".

"mmc read" and "mmc write" are operations that work on character
buffers, like all other file IO ops.  These should not require any
specific alignment.

> Is it worth **any** code to try and catch them?

Definitely yes.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Real computer scientists despise the idea of actual  hardware.  Hard-
ware has limitations, software doesn't. It's a real shame that Turing
machines are so poor at I/O.


More information about the U-Boot mailing list