[U-Boot-Users] Little endian

Ed Okerson eokerson at texasconnect.net
Thu Nov 27 19:34:30 CET 2003


Leon,

On Thu, 27 Nov 2003, Leon KUKOVEC wrote:

> Hey Ed,
>
> > table on a CF card without the bytes being swapped.  This led me to wonder
> > if anyone else was having these problems in little-endian mode or if it
> > was just me.
>
> I recently added PCMCIA support for PXA/WEPEP250 and have successfully used
> CompactFlash on it.

Congrats!

> I don't know AU1500 processor, but the comment in cmd_ide.c says that
> processor swaps something automaticaly.
>
> Paste:
> /* We only need to swap data if we are running on a big endian cpu. */
> /* But Au1x00 cpu:s already swaps data in big endian mode! */
> #if defined(__LITTLE_ENDIAN) || defined(CONFIG_AU1X00)
> #define input_swap_data(x,y,z) input_data(x,y,z)
> #else
> End of Paste

Yes, I saw that as well.

> You will prolly know what has to be swapped and what not for AU1500.

This is, or was, the problem.  I didn't know exactly what the problem was,
mostly because of my own cofusion, but I still think it is a bug in the
hardware, as Thomas pointed out earlier.

> Our PXA runs in little endian mode and all I had to tweak was the following:
>
> Convert PCMCIA Firmware Revision and Model Number into little endian because
> they are big endian strings and take care of lba_capacity which is little
> endian but has been swapped, which worked fine on big endian CPU's but on
> little endian, gave wrong number of sectors.

I have tweaked these as well for the Au1500, same problem as yours.

> Everything else seemed to work fine.

What partition types are you using?  I am trying to do a partition table
with some linux and at least one FAT16 partition, but even without the FAT
partition the system was showing a single partition as:

Partition Map for IDE device 0  --   Partition Type: DOS

Partition     Start Sector     Num Sectors     Type
    1                    0          501760      f8

I poked around alot in disk/part_dos.c and found that if I remarked out
the return after the check for PBR in print_partition_extended, then the
rest of the partitions would print out:

Partition Map for IDE device 0  --   Partition Type: DOS

Partition     Start Sector     Num Sectors     Type
    1                    0          501760      f8
    1                   32            4576      83
    2                 4608            4608      83
    3                 9216          492544      83

So this morning I started going through and figuring exactly what that
meant.  It appears that the first line shows up if the boot sector of the
compact flash card has a DOS boot signature that is what you get.  So
apparently some idiot (probably me) at some point in time formated that CF
card in a DOS machine with the /s option and it happily copied a DOS boot
record into the beginning of the card.  Boy do I feel stupid.  So I popped
the CF into a linux machine and typed "cat /dev/zero > /dev/hdg" re-ran
fdisk to create my partitions, and now u-boot happily reports:

DbAu1x00 # ide part

Partition Map for IDE device 0  --   Partition Type: DOS

Partition     Start Sector     Num Sectors     Type
    1                   32            4576      83
    2                 4608            4608      83
    3                 9216          492544      83
DbAu1x00 #

Which is what I wanted.  I have been using #if defined(CONFIG_AU1X00)
around my code mods, but it sounds like your changes and my changes are
about the same in the end, so perhaps we should come up with another
define for ENDIAN_CHALLENGED or something.

> PS: I have verified it by using the same CompactFlash card on a PC and it
>     works.
>
> Hope that helps.

It helped a lot.  Thanks.  I guess the moral of the story is when you are
having problems, make sure there isn't a short between the keyboard and
the chair first. :)

Ed Okerson





More information about the U-Boot mailing list