nwsp2 classic gpt support

Re: nwsp2 classic gpt support

Postby fvdw » Wed Jan 02, 2013 5:25 pm

some progress

I get now the right size mentioned by u-boot
Code: Select all
Reset IDE:
Marvell Serial ATA Adapter
Integrated Sata device found
[0 0 0]: Enable DMA mode
  Device 0 @ 0 0:
Model: WDC WD30EZRX-00DC0B0                     Firm: 80.00A80 Ser#:      WD-WMC1T0347553
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 2861588.4 MB = 2794.5 GB (6391452 x 1)


and no red flicker anymore, however no boot... :thinking
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: nwsp2 classic gpt support

Postby minibike12 » Wed Jan 02, 2013 5:33 pm

Nice work!
Do you have some more info where it goes wrong?
Maybe a start-up log or something else?
minibike12
 
Posts: 99
Joined: Sat Dec 22, 2012 9:23 pm
Location: The Netherlands

Re: nwsp2 classic gpt support

Postby fvdw » Wed Jan 02, 2013 5:47 pm

no, no error messages, the only thing which needs now to be accomplished is that it loads the kernel from the disk. I can load the kernel remote and then it works fine but at the end it must load the kernel from disk. So u-boot still has problems with reading a big GPT partition table
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: nwsp2 classic gpt support

Postby minibike12 » Wed Jan 02, 2013 7:04 pm

Ah okey.
minibike12
 
Posts: 99
Joined: Sat Dec 22, 2012 9:23 pm
Location: The Netherlands

Re: nwsp2 classic gpt support

Postby Mijzelf » Thu Jan 03, 2013 10:17 am

fvdw wrote:Capacity: 2861588.4 MB = 2794.5 GB (6391452 x 1)
What did you change to get this? What strikes is that the size looks good (although, shouldn't it be 3000GB?) but the substantiation is nuts. (6391452 x 1)

This one
Capacity: 764436.4 MB = 746.5 GB (1565565872 x 512)
has a sane substantiation. But if I substitute with 4k sectors, I get 6TB.

I'm surprised to see that u-boot seems to do some sanity checks on GPT.
Code: Select all
GPT: last_usable_lba incorrect: %lX > %lX
Can't you just pull this check? The only important matter here is that u-boot can find the startsector (logical) and maybe the size of partition 6. It shouldn't care that partition 8 seems to extend beyond the end of the disk.

BTW, have you any idea which values should have been printed here?
Mijzelf
 
Posts: 255
Joined: Wed Nov 21, 2012 9:12 am

Re: nwsp2 classic gpt support

Postby fvdw » Thu Jan 03, 2013 11:39 am

Mijzelf wrote:What did you change to get this?

Put all the three configs for 64LBA support in
Capacity: 2861588.4 MB = 2794.5 GB (6391452 x 1)
What strikes is that the size looks good (although, shouldn't it be 3000GB?) but the substantiation is nuts. (6391452 x 1)

The size correct. Just calculate it to Bytes and you get 3 TB in bytes and thats also the number mentioned in gdisk (2861588*1012481024), a 3TB disk gas 3TB in bytes

The number between the brackets are weird, that should the number of blocks and the blocksize.
This the part of the code were is generated. If you go through it I do not understand that it can print the total size right but not the number of blocks and blocksize as these are used to determine the total size :scratch
Code: Select all
   if ((dev_desc->lba * dev_desc->blksz)>0L) {
      ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem;
      lbaint_t lba;

      lba = dev_desc->lba;

      lba512 = (lba * (dev_desc->blksz/512));
      mb = (10 * lba512) / 2048;   /* 2048 = (1024 * 1024) / 512 MB */
      /* round to 1 digit */
      mb_quot   = mb / 10;
      mb_rem   = mb - (10 * mb_quot);

      gb = mb / 1024;
      gb_quot   = gb / 10;
      gb_rem   = gb - (10 * gb_quot);
#ifdef CONFIG_LBA48
      if (dev_desc->lba48)
         printf ("            Supports 48-bit addressing\n");
#endif
#if defined(CFG_64BIT_LBA) && defined(CFG_64BIT_VSPRINTF)
      printf ("            Capacity: %ld.%ld MB = %ld.%ld GB (%qd x %ld)\n",
         mb_quot, mb_rem,
         gb_quot, gb_rem,
         lba,
         dev_desc->blksz);
#else
      printf ("            Capacity: %ld.%ld MB = %ld.%ld GB (%ld x %ld)\n",
         mb_quot, mb_rem,
         gb_quot, gb_rem,
         (ulong)lba,
         dev_desc->blksz);
#endif
   } else {
      puts ("            Capacity: not available\n");
   }


ps for the 1 TB disk this the output when using the same u-boot
Code: Select all
Reset IDE:
Marvell Serial ATA Adapter
Integrated Sata device found
[0 0 0]: Enable DMA mode
  Device 0 @ 0 0:
Model: SAMSUNG HD103SI                          Firm: 1AG01118 Ser#: S1Y5JDWZ626309
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 953869.7 MB = 931.5 GB (6391452 x 0)

After asking this info U-boot doesn't respond anymore

With he first u-boot (without LBA64 only GPT)
Code: Select all
Reset IDE:
Marvell Serial ATA Adapter
Integrated Sata device found
[0 0 0]: Enable DMA mode
  Device 0 @ 0 0:
Model: SAMSUNG HD103SI                          Firm: 1AG01118 Ser#: S1Y5JDWZ626309
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 953869.7 MB = 931.5 GB (1953525168 x 512)

U-boot respond normally after asking this info.

The main difference between the two u-boots is this (in ide.h)
Code: Select all
#ifdef CFG_64BIT_LBA
typedef uint64_t lbaint_t;
#define IDE_BLOCK_NUMBER_MASK 0x0000fffff0000000
#define LBA_LOW_REG_SHIFT   24
#define LBA_MID_REG_SHIFT   32
#define LBA_HIGH_REG_SHIFT   40
#else
typedef ulong lbaint_t;
#define IDE_BLOCK_NUMBER_MASK 0xf0000000
#define LBA_LOW_REG_SHIFT   24
#define LBA_MID_REG_SHIFT   0
#define LBA_HIGH_REG_SHIFT   0
#endif



I'm surprised to see that u-boot seems to do some sanity checks on GPT.
Code: Select all
GPT: last_usable_lba incorrect: %lX > %lX
Can't you just pull this check? The only important matter here is that u-boot can find the startsector (logical) and maybe the size of partition 6. It shouldn't care that partition 8 seems to extend beyond the end of the disk.

BTW, have you any idea which values should have been printed here?

what should be printed is the number of the last usable block (sector) and the last sector of the disk.
I get this message when using the 3 TB disk with the first U-boot without LBA 64 support. It seems to take as last block the value for 2.2 TB and as last usable the value reported by the disk. Or something like that number.
The message disappears when adding all three configs for lba64, but then u-boot is still nt able to read the disk, although no longer the red/blue flashing of the leds is present. Its steady blue but it won't read the disk.
Yes I can take out this check and not include the LBA64 configs and see what happens, so using he first attempt but with this check disabled and see if that makes u-boot happy. As the only thing I need is that u-boot loads the kernel from sda6 and this check makes it refuse to do that because it thinks the GPT table is invalid. There is no writing required to the disk by u-boot so no real problem, only u-boot should not be used to write to the disk
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: nwsp2 classic gpt support

Postby fvdw » Thu Jan 03, 2013 1:23 pm

:punk victory, disabling the "last lba check" made it work, it just booted my 3 TB disk.

of course still weird information when talking to u-boot and letting it give information, but at least it is able to load the kernel from sda6 and fire up the box
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: nwsp2 classic gpt support

Postby Mijzelf » Thu Jan 03, 2013 1:32 pm

Something strange is going on. Consider this line:
Code: Select all
printf ("            Capacity: %ld.%ld MB = %ld.%ld GB (%qd x %ld)\n",
         mb_quot, mb_rem,
         gb_quot, gb_rem,
         lba,
         dev_desc->blksz);
mb_quot...gb_quot are all ulongs (unsigned 32 bits integers), while lba is a lbaint_t, which is a uint64_t, which is an unsigned 64 bits value. I don't know the size of dev_desc->blksz

This is C, which means all values are pushed on stack, before printf is invoked. It's 32 bits code, so all stack entries are 32 bit.
So the stack is:
[pointer to formatstring]
[mb_quot]
[mb_rem]
[gb_quot]
[gb_rem]
[lba low]
[lba high]
[dev_desc->blksz]

In the format string %ld means 'take a 32 bit value from stack, and print it decimal, signed'. %qd means 'take a 64 bit value from stack, and print it decimal, signed'.
Now I *think* %qd isn't handled correctly, and it takes just a 32 bits value from stack. This means the blocksize is printed using [lba high], which is 1 for disks 2TiB-4TiB, and 0 for disks <2TiB. That fits with your observations.
But it the %qd itself prints a constant, 6391452, which is definitely not the value of [lba low].
An other option is that [lba high] and [low] are swapped on stack, and %qd takes nothing from stack, but just prints a constant.

Something is seriously wrong with printf.
Also:
Code: Select all
printf("GPT: last_usable_lba incorrect: %llX > %llX\n",
         le64_to_int(pgpt_head->last_usable_lba), lastlba);
gives
Code: Select all
GPT: last_usable_lba incorrect: %lX > %lX
%llX is an equivalent of %qX, which means: take 64 bits from stack and print it hexadecimal. But it's just not evaluated.

But it's not only printf() which is wrong, the GPT is read wrong either. Did you do a 'make clean' after changing the CONFIG values?

/EDIT: Congratulations!
Mijzelf
 
Posts: 255
Joined: Wed Nov 21, 2012 9:12 am

Re: nwsp2 classic gpt support

Postby fvdw » Thu Jan 03, 2013 2:21 pm

Yes I did a make clean and also additional command needed to clean up the code (make mrproper)
I also noticed that printf doesn't like %llX format, could that be a compiler issue ?
I used gcc 4.2.3 to get it compiled, I have a more recent compiler but that is not able to compile the source code.
I think GPT is read correctly by u-boot but only not printed correctly with LBA64 disabled. Why it is not able to read when LBA64 is enabled I don't know yet. Below the output from the net console using u-boot 1.3.9 with GPT enabled but without the 64LBA configs and disabled last lba check (I added a message when it is skipping the test). You can see the total size is not printed correctly also the total number of sectors is wrong but sector size is correct.
Notice the same problem with %llx when printing partition table in u-boot, but it finds the 8 partitions
(I found these ide commands in the source code, there are more)


Code: Select all
interactive shell

Marvell>> version
version

U-Boot 1.1.4 (Jan  3 2013 - 14:00:56) Marvell version: 3.4.16  LaCie 1.3.9 256MB fvdw gpt vs4

Marvell>> ide reset
ide reset

Reset IDE:
Marvell Serial ATA Adapter
Integrated Sata device found
[0 0 0]: Enable DMA mode
  Device 0 @ 0 0:
Model: WDC WD30EZRX-00DC0B0                     Firm: 80.00A80 Ser#:      WD-WMC1T0347553
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 764436.4 MB = 746.5 GB (1565565872 x 512)

Marvell>> ide info
ide info

IDE device 0: Model: WDC WD30EZRX-00DC0B0                     Firm: 80.00A80 Ser#:      WD-WMC1T0347553
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 764436.4 MB = 746.5 GB (1565565872 x 512)
Marvell>> ide part
ide part
## Testing for valid EFI partition ##

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

GPT: skipping last lba check
Part  Start LBA  End LBA
gpt1  0x%lX    0x%lX
gpt2  0x%lX    0x%lX
gpt3  0x%lX    0x%lX
gpt4  0x%lX    0x%lX
gpt5  0x%lX    0x%lX
gpt6  0x%lX    0x%lX
gpt7  0x%lX    0x%lX
gpt8  0x%lX    0x%lX
Marvell>> disk 0x800000 0:6
disk 0x800000 0:6
GPT: skipping last lba check
## Valid EFI partition found ##

Loading from IDE device 0, partition 6: Name: gpt6  Type: U-Boot
   Image Name:   Linux-2.6.39.4
   Created:      2012-12-23  21:59:32 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3123456 Bytes =  3 MB
   Load Address: 00008000
   Entry Point:  00008000

Marvell>> printenv bootargs
printenv bootargs
bootargs=console=ttyS0,115200 root=/dev/sda7 ro reset=0 productType=ASTON_KW
Marvell>> bootm
bootm
## Booting image at 00800000 ...
   Image Name:   Linux-2.6.39.4
   Created:      2012-12-23  21:59:32 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3123456 Bytes =  3 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK

Starting kernel ...

fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: nwsp2 classic gpt support

Postby Mijzelf » Thu Jan 03, 2013 2:51 pm

could that be a compiler issue ?
Don't think so. This is about string parsing.
I think your Lacie sources are an 'in between' version, with half implemented 64 bit support. The mixed up 'll' and 'q' prefixes also suggest that.
I think GPT is read correctly by u-boot but only not printed correctly with LBA64 disabled.
Concur. But the end of partition 8 doesn't fit in an 32 bits value, so that cannot be read well.
also the total number of sectors is wrong
It's the lower significant 32 bits part of the 'real' value: 1565565872 decimal = 5D50A3B0 hex.
If I add the higher significant 32 bits, this becomes 000000015D50A3B0, which is 5860533168 decimal, which boils down to 3000592982016 bytes. Know that value?
Notice the same problem with %llx when printing partition table
I think the values are 32 bits values, when LBA64 disabled, so you could just change %llX in %lX, and get the right values. It is a lbaint_t type, I suppose (lba integer type)
Code: Select all
#ifdef CFG_64BIT_LBA
typedef uint64_t lbaint_t;
<snip>
#else
typedef ulong lbaint_t;
<snip>
#endif
Mijzelf
 
Posts: 255
Joined: Wed Nov 21, 2012 9:12 am

PreviousNext

Return to Development

Who is online

Users browsing this forum: No registered users and 10 guests