[U-Boot] Debugging why my kernel won't start

Albert ARIBAUD
2010-08-17T10:10:19Z

Le 16/08/2010 22:15, Rogan Dawes a ?crit :
> On 2010/08/16 9:24 AM, Rogan Dawes wrote:
>> Hi folks,
>>
>> I'm trying to get mainline u-boot working on my DNS323 (Orion5x based).
>> Until I am confident in the config, I'm using a chainloaded approach,
>> wrapping my featureful u-boot in an image file:
>>
>> $ mkimage -A arm -O u-boot -T kernel -C none -a 0x3000000 -e 0x3000000
>> -n "UBoot dns323" -d u-boot.bin uImage.bin
>>
>> I am trying to boot the default kernel that is already flashed into the
>> device first. The first problem is that the DNS323 uses an incorrect
>> mach-type value of 526, while the registered value is 1542. See
>> <http://wiki.dns323.info/software:kernel>). I have modified
>> arch/arm/include/asm/mach-types.h to set MACH_TYPE_DNS323 to the
>> "correct" Dlink value, which should match what the default kernel is
>> expecting.
>>
>> Unfortunately, all I get is:
>>
>> DNS323B1> bootm FF820000
>> ## Booting kernel from Legacy Image at ff820000 ...
>> Image Name: Linux-2.6.12.6-arm1
>> Image Type: ARM Linux Kernel Image (uncompressed)
>> Data Size: 1490204 Bytes = 1.4 MiB
>> Load Address: 00008000
>> Entry Point: 00008000
>> Verifying Checksum ... OK
>> Loading Kernel Image ...
>>
>> and it hangs there.
>>
>> That appears to be this code from cmd_bootm:
>>
>> case IH_COMP_NONE:
>> if (load == blob_start) {
>> printf (" XIP %s ... ", type_name);
>> } else {
>> printf (" Loading %s ... ", type_name);
>> memmove_wd ((void *)load, (void *)image_start,
>> image_len, CHUNKSZ);
>> }
>> *load_end = load + image_len;
>> puts("OK\n");
>> break;
>>
>> So, the memmove_wd never completes, it seems.
>>
>> I added a debug statement at the top of memmove_wd, and got:
>>
>> Moving memory from ff820040 to 00008000
>>
>> Is that because the uImage header is 64 bytes?
>>
>> Also, the following suggests that there may be something wrong with the
>> addresses that I am using:
>>
>> DNS323B1> bootm FF820000 FF9A0000
>> ## Booting kernel from Legacy Image at ff820000 ...
>> Image Name: Linux-2.6.12.6-arm1
>> Image Type: ARM Linux Kernel Image (uncompressed)
>> Data Size: 1490204 Bytes = 1.4 MiB
>> Load Address: 00008000
>> Entry Point: 00008000
>> Verifying Checksum ... OK
>> ## Loading init Ramdisk from Legacy Image at ff9a0000 ...
>> Image Name: Ramdisk
>> Image Type: ARM Linux RAMDisk Image (gzip compressed)
>> Data Size: 5240600 Bytes = 5 MiB
>> Load Address: 00800000
>> Entry Point: 00800000
>> Verifying Checksum ... Bad Data CRC
>> Ramdisk image is corrupt or invalid
>> DNS323B1>
>>
>> My chainloaded u-boot is configured in an image to load at 0x3000000,
>> and stay there (no relocation), if I have understood these parameters
>> correctly:
>>
>> -a 0x3000000 -e 0x3000000
>>
>> Can anyone see what I am doing wrong?
>>
>> Many thanks!
>>
>> Rogan
>
> So I changed memmove_wd to use the watchdog style of memmove'ing, in
> small chunks to try to track down where the problem arises. I used 1kB
> chunks, and got:
>
> Moving 1024 of 611612 bytes from ff8f6840 to 000de800
> Moving 1024 of 610588 bytes from ff8f6c40 to 000dec00
> Moving 1024 of 609564 bytes from ff8f7040 to 000df000
>
> before it finally hung.
>
> So, I checked what was at that address:
>
> DNS323B1> md.b 000df000 400
> 000df000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df040: ff ff ff ff ff ff ff ff ff df ff ff ff ff ff ff
> ................
> 000df050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df070: ff ff ff ff bf ff ff ff ff ff ff ff ff f7 ff ff
> ................
> 000df080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df090: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df0a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df0b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df0c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df0d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df0e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df0f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df110: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df120: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df130: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df140: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df150: ff ff ff ff ff ff ff ff ff f7 ff ff ff ff ff ff
> ................
> 000df160: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df170: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df180: ff df ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df190: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df1a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df1b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df1c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df1d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df1e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df1f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df200: ff ff ff ff ff 7f ff ff ff ff ff ff ff ff ff ff
> ................
> 000df210: ff ff ff ff 03 00 00 00 17 f2 0d 00 f8 1f 11 00
> ................
> 000df220: 01 ea 11 00 02 00 00 00 00 00 00 00 00 00 00 00
> ................
> 000df230: 30 f2 0d 00 02 00 00 00 ff ff ff ff 30 f2 0d 00
> 0...........0...
> 000df240: 2e 2e 2e 2e 2e 2e 2e 2e 30 2e 2e 2e 00 ff ff ff
> ........0.......
> 000df250: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df260: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df270: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df280: 00 f0 0d 00 e4 fe 0d 00 01 00 00 00 00 04 00 00
> ................
> 000df290: 03 00 00 00 00 00 00 00 00 00 00 00 e0 bd 10 00
> ................
> 000df2a0: 10 00 00 00 d8 d0 10 00 ff ff ff ff 94 00 12 00
> ................
> 000df2b0: 03 00 00 00 ef 03 00 00 00 00 00 00 00 00 00 00
> ................
> 000df2c0: f5 f6 0d 00 b0 01 11 00 ff ff ff ff e4 f2 0d 00
> ................
> 000df2d0: e4 f6 0d 00 00 00 00 00 f5 fa 0d 00 01 00 00 00
> ................
> 000df2e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df2f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df300: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df310: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df320: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df330: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df340: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df350: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df360: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df370: ff df ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df380: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df390: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df3a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df3b0: ff ff ff ff ff ff ff ff ff ff ff ff ff fb ff ff
> ................
> 000df3c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df3d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df3e0: ff ff ff ff ff ff ef ff ff ff ff ff ff ff ff ff
> ................
> 000df3f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> DNS323B1>
> 000df400: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df410: ff ff ff ff ff ff ff ff ff ff ff bf ff ff ff ff
> ................
> 000df420: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df430: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df440: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df450: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df460: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df470: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df480: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df490: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df4a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df4b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df4c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df4d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df4e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df4f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df500: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df510: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df520: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df530: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df540: ff ff ff ff ff ff ff ff ff ff ff 7f ff ff ff ff
> ................
> 000df550: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df560: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df570: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df580: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df590: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df5a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df5b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df5c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df5d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff fd
> ................
> 000df5e0: ff ff ff ff ff fe ff ff ff ff ff ff ff ff ff ff
> ................
> 000df5f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df600: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df610: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df620: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df630: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df640: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df650: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df660: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df670: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df680: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df690: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df6a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df6b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df6c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df6d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df6e0: ff ff ff ff 6d 64 2e 62 00 30 30 30 64 66 30 30
> ....md.b.000df00
> 000df6f0: 30 00 34 30 30 00 ff ff ff ff ff ff ff ff ff ff
> 0.400...........
> 000df700: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df710: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df720: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df730: ff ff ff ff ff ff ff ff ff ff ff ff ff 7f ff ff
> ................
> 000df740: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df750: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df760: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df770: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df780: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df790: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df7a0: ff ff ff ff ff ff ff ff ff ff ff f7 ff ff ff ff
> ................
> 000df7b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df7c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df7d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df7e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> 000df7f0: ff ff ff fe ff ff ff ff ff ff ff ff ff ff ff ff
> ................
> DNS323B1>
>
> The first 1kB was not particularly interesting (to me). But the next
> chunk showed something interesting at 000df6e0:
>
> 000df6e0: ff ff ff ff 6d 64 2e 62 00 30 30 30 64 66 30 30
> ....md.b.000df00
> 000df6f0: 30 00 34 30 30 00 ff ff ff ff ff ff ff ff ff ff
> 0.400...........
>
> i.e. the command I had just executed.
>
> So, it seems that for some reason, even though I tried to place my chain
> loaded u-boot out of harms way at 0x3000000, for some reason, it was
> still allocating memory at a lower address, precisely where the kernel
> is supposed to be copied to for execution.
>
> Can anyone explain why this happens? Or what I can do to fix it?
>
> Many thanks!
>
> Rogan

(quick note to Wolfgang: yes, there is RAM at 0x00008000 on these
machines. All orion5x based machines have RAM start at 0, and u-boot
makes sure SDRAM is set up this way)

Rogan,

You cannot tell from your log output that memmove never completes. It
could as well be the kernel not outputting to the console, or failing to
start at all even though the move was ok.

The first thing you should do is make sure that you pass the right
machine-id, but also that you pass ATAGs correctly to the kernel -- it
seems that at least some LaCie custom u-boot implementations use an env
variable ('mainlineKernel', IIRC) to differenciate between mainline and
LaCie custom kernels. Maybe your HW was designed the same way. Best is
you look up the u-boot source code provided by the manufacturer of your
machine.

The second thing is to make sure your kernel uses the right console. Are
you using netconsole? Maybe the manufacturer's kernel does not have
netconsole. Do you use a serial (RS-232) console? Make sure the kernel
has command line arguments to use it too.

Amicalement,
--
Albert.