Day: December 3, 2012

When even DEBUG_LL fails, uncompressed kernel image help you

I was copying the kernel image (uImage) for H6837WI camera using YMODEM protocol over serial to address 0x50C07FC0 (default u-boot address for the command ‘loady’ on this device) and even enabling “Early printk” (DEBUG_LL) didn’t help me.

Then I noticed the uImage entry point was 0x51008000, but even copying the uImage file to there didn’t print anything. Then I decided to try the uncompressed image (arch/arm/boot/Image).

Then I got early printk working and explaining the error I was getting:

object$ loady 0x51008000
## Ready for binary (ymodem) download to 0x51008000 at 115200 bps...
CxyzModem - CRC mode, 23007(SOH)/0(STX)/0(CAN) packets, 9 retries
## Total Size = 0x002cede8 = 2944488 Bytes
object$ go 0x51008000
## Starting application at 0x51008000 ...

Error: unrecognized/unsupported machine ID (r1 = 0x52f2026c).

Available machine support:

ID (hex) NAME
0000078d Solomon Magus ADS

Please check your kernel config and/or bootloader.

Extraindo o Image descompactado do arquivo uImage

Estava procurando uma forma simples de extrair o cabeçalho do uImage. A forma mais simples é usar o dd e dar um skip nos primeiros 64 bytes do uImage (ou 64 + 8 no caso de uImage para ARM), mas encontrei o script simples que verifica o tipo do uImage e cria o zImage:

http://buffalo.nas-central.org/wiki/How_to_Extract_an_uImage

Outra alternativa é utilizar o uImage.py

Agora é só extrair o conteúdo do zImage para ter o Image do kernel:

$ arm-linux-objdump -EL -b binary -D -m armv5t zImage | grep 8b1f
    31e4:	00088b1f 	andeq	r8, r8, pc, lsl fp
   28404:	6c8b1f44 	stcvs	15, cr1, [fp], {68}

$ dd if=zImage of=myImage.gz bs=1 skip=12772
1454876+0 records in
1454876+0 records out
1454876 bytes (1.5 MB) copied, 2.4514 s, 593 kB/s

$ gunzip myImage.gz 
gzip: myImage.gz: decompression OK, trailing garbage ignored

Mais informações sobre o header do uImage, leia este post:
http://www.isysop.com/unpacking-and-repacking-u-boot-uimage-files/

Fonte da dica de como descompactar o zImage:
http://openinkpot.org/wiki/Documentation/ZImageFormat