diff --git a/README.md b/README.md index d780cb1..85bc122 100644 --- a/README.md +++ b/README.md @@ -364,12 +364,18 @@ BOOTBOOT-PANIC: Unable to initialize SDHC card The loader was unable to initialize EMMC for SDHC card access, probably hardware error or old card. +``` +BOOTBOOT-PANIC: No GPT found +``` + +The loader was unable to load the GUID Partitioning Table. + ``` BOOTBOOT-PANIC: No boot partition ``` -Either the disk does not have a GPT, or there's no EFI System Partition nor any other bootable -partition on it. Or the FAT file system is found but inconsistent, or doesn't have a BOOTBOOT directory. +There's no EFI System Partition nor any other bootable partition in the GPT. Or the FAT file system is found but corrupt +(contains inconsistent BPB data), or doesn't have a BOOTBOOT directory (with 8+3 MSDOS entry, not LFN). ``` BOOTBOOT-PANIC: Not 2048 sector aligned diff --git a/aarch64-rpi/bootboot.c b/aarch64-rpi/bootboot.c index 59da7ab..5470b22 100644 --- a/aarch64-rpi/bootboot.c +++ b/aarch64-rpi/bootboot.c @@ -1218,8 +1218,8 @@ int bootboot_main(uint64_t hcl) /* read and parse GPT table */ r=sd_readblock(1,(unsigned char*)&__diskbuf,1); if(r==0 || memcmp((void*)&__diskbuf, "EFI PART", 8)) { -diskerr: - puts("BOOTBOOT-PANIC: No boot partition\n"); +gpterr: + puts("BOOTBOOT-PANIC: No GPT found\n"); goto error; } // get number of partitions and size of partition entry @@ -1227,7 +1227,7 @@ diskerr: if(np>127) np=127; // read GPT entries r=sd_readblock(*((uint32_t*)((char*)&__diskbuf+72)),(unsigned char*)&__diskbuf,(np*sp+511)/512); - if(r==0) goto diskerr; + if(r==0) goto gpterr; part=NULL; // first, look for a partition with bootable flag for(r=0;r=np) goto diskerr; + if(part==NULL || r>=np) { +diskerr: + puts("BOOTBOOT-PANIC: No boot partition\n"); + goto error; + } r=sd_readblock(part->start,(unsigned char*)&_end,1); if(r==0) goto diskerr; initrd.ptr=NULL; initrd.size=0; diff --git a/bootboot.bin b/bootboot.bin index bd0bd4c..91aa6a8 100644 Binary files a/bootboot.bin and b/bootboot.bin differ diff --git a/bootboot.efi b/bootboot.efi index fd8f328..cbc20c4 100755 Binary files a/bootboot.efi and b/bootboot.efi differ diff --git a/bootboot.img b/bootboot.img index 21a50e7..93c040a 100755 Binary files a/bootboot.img and b/bootboot.img differ diff --git a/bootboot.rom b/bootboot.rom index c86d2c1..fad245d 100644 Binary files a/bootboot.rom and b/bootboot.rom differ diff --git a/x86_64-bios/bootboot.asm b/x86_64-bios/bootboot.asm index 3742309..f28805c 100644 --- a/x86_64-bios/bootboot.asm +++ b/x86_64-bios/bootboot.asm @@ -1040,7 +1040,7 @@ end if mov esi, 0A000h+512 cmp dword [esi], 'EFI ' je @f -.nogpt: mov si, nogpt +.nogpt: mov esi, nogpt jmp prot_diefunc @@: mov edi, 0B000h mov ebx, edi @@ -1084,8 +1084,8 @@ end if .noto: add esi, ebx dec ecx jnz @b -.noinitrd: mov esi, nord - jz prot_diefunc +.nopart: mov esi, nopar + jmp prot_diefunc ; load ESP at free memory hole found .loadesp: mov dword [gpt_ptr], esi @@ -1112,9 +1112,9 @@ end if je .isfat ;no, then it's an initrd on the entire partition or eax, eax - jz .noinitrd + jz .nopart or ecx, ecx - jz .noinitrd + jz .nopart sub ecx, eax shl ecx, 9 mov dword [bootboot.initrd_size], ecx @@ -1325,6 +1325,8 @@ end if jz .loadinitrd dec ecx jnz .nextdir +.noinitrd: mov esi, nord + jmp prot_diefunc ;load cluster chain, eax=cluster, ecx=size .loadinitrd: @@ -2571,7 +2573,8 @@ memerr: db "E820 memory map not found",0 nogzmem: db "Inflating: " noenmem: db "Not enough memory",0 noacpi: db "ACPI not found",0 -nogpt: db "No boot partition",0 +nogpt: db "No GPT found",0 +nopar: db "No boot partition",0 nord: db "Initrd not found",0 nolib: db "/sys not found in initrd",0 nocore: db "Kernel not found in initrd",0 diff --git a/x86_64-efi/bootboot.c b/x86_64-efi/bootboot.c index 717abc3..1af243b 100644 --- a/x86_64-efi/bootboot.c +++ b/x86_64-efi/bootboot.c @@ -1256,7 +1256,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) EFI_PROCESSOR_INFORMATION *pibuf=(EFI_PROCESSOR_INFORMATION*)pibuffer; UINTN bsp_num=0, i, j=0, handle_size=0,memory_map_size=0, map_key=0, desc_size=0; UINT32 desc_version=0; - UINT64 lba_s=0,lba_e=0; + UINT64 lba_s=0,lba_e=0,sysptr; MMapEnt *mmapent, *last=NULL; file_t ret={NULL,0}; CHAR16 **argv, *initrdfile, *configfile, *help= @@ -1550,9 +1550,9 @@ gzerr: return report(EFI_COMPROMISED_DATA,L"Unable to uncompress"); // System tables and structures DBG(L" * System tables%s\n",L""); - LibGetSystemConfigurationTable(&AcpiTableGuid,(void *)&(bootboot->arch.x86_64.acpi_ptr)); - LibGetSystemConfigurationTable(&SMBIOSTableGuid,(void *)&(bootboot->arch.x86_64.smbi_ptr)); - LibGetSystemConfigurationTable(&MpsTableGuid,(void *)&(bootboot->arch.x86_64.mp_ptr)); + sysptr = 0; LibGetSystemConfigurationTable(&AcpiTableGuid,(void *)&sysptr); bootboot->arch.x86_64.acpi_ptr = sysptr; + sysptr = 0; LibGetSystemConfigurationTable(&SMBIOSTableGuid,(void *)&sysptr); bootboot->arch.x86_64.smbi_ptr = sysptr; + sysptr = 0; LibGetSystemConfigurationTable(&MpsTableGuid,(void *)&sysptr); bootboot->arch.x86_64.mp_ptr = sysptr; // FIX ACPI table pointer on TianoCore... ret.ptr = (UINT8*)(bootboot->arch.x86_64.acpi_ptr);