Commit 4a36be9bdb42157401618681c9ac28e3824c120e

Authored by Darwin Dingel
Committed by Tom Rini
1 parent 15c939f970

disk: part_dos.c: Add a PBR check when MBR checking fails

Bug: SDCard with a messed up partition but still has a FAT signature
intact is readable in Linux but unreadable in uboot with 'fatls'.

Fix: When partition info checking fails, there is no checking for a
FAT signature (DOS_PBR) which will fail 'fatls'. FAT signature checking
is done when no valid partition is found in partition table. If FAT
signature is found, the disk will be read as PBR and continue
processing.

Signed-off-by: Darwin Dingel <darwin.dingel@alliedtelesis.co.nz>

Showing 1 changed file with 20 additions and 1 deletions Side-by-side Diff

... ... @@ -21,6 +21,8 @@
21 21  
22 22 #ifdef HAVE_BLOCK_DEVICE
23 23  
  24 +#define DOS_PART_DEFAULT_SECTOR 512
  25 +
24 26 /* Convert char[4] in little endian format to the host format integer
25 27 */
26 28 static inline int le32_to_int(unsigned char *le32)
... ... @@ -168,6 +170,7 @@
168 170 ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
169 171 dos_partition_t *pt;
170 172 int i;
  173 + int dos_type;
171 174  
172 175 if (dev_desc->block_read (dev_desc->dev, ext_part_sector, 1, (ulong *) buffer) != 1) {
173 176 printf ("** Can't read partition table on %d:%d **\n",
... ... @@ -198,7 +201,7 @@
198 201 (pt->sys_ind != 0) &&
199 202 (part_num == which_part) &&
200 203 (is_extended(pt->sys_ind) == 0)) {
201   - info->blksz = 512;
  204 + info->blksz = DOS_PART_DEFAULT_SECTOR;
202 205 info->start = (lbaint_t)(ext_part_sector +
203 206 le32_to_int(pt->start4));
204 207 info->size = (lbaint_t)le32_to_int(pt->size4);
... ... @@ -253,6 +256,22 @@
253 256 part_num, which_part, info, disksig);
254 257 }
255 258 }
  259 +
  260 + /* Check for DOS PBR if no partition is found */
  261 + dos_type = test_block_type(buffer);
  262 +
  263 + if (dos_type == DOS_PBR) {
  264 + info->start = 0;
  265 + info->size = dev_desc->lba;
  266 + info->blksz = DOS_PART_DEFAULT_SECTOR;
  267 + info->bootable = 0;
  268 + sprintf ((char *)info->type, "U-Boot");
  269 +#ifdef CONFIG_PARTITION_UUIDS
  270 + info->uuid[0] = 0;
  271 +#endif
  272 + return 0;
  273 + }
  274 +
256 275 return -1;
257 276 }
258 277