[yocto] Yocto procedure to write generated image to hdd

Iván Castell icastell at nayarsystems.com
Fri Mar 2 01:42:05 PST 2018


I have modified poky/meta/recipes-core/initrdscripts/initramfs-framework/init
to force a shell script when the "fatal" function is called:

# Prints a message and start a endless loop
fatal() {
    echo $1 >/dev/console
    echo >/dev/console
    sh

    #if [ -n "$bootparam_init_fatal_sh" ]; then
    #    sh
    #else
    #while [ "true" ]; do
    #   sleep 3600
    #done
    #fi
}

After regenerating the hddimage, adding "noapic" to bootargs and booting
the "install" option, I have a shell console available, but with a very
limited toolbox (cp, cat or even ls command are not available).

Some relevant error messages appear on the boot process. I copy theses
error messages by hand:

sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] 234441648 512-byte logical blocks: (120 GB/1112GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
support DPO or FUA
GPT: Primary header thinks Alt. header is not at the end of disk
GPT:1298455 != 234441647
GPT: Alternate GPT header not at the end of the disk
GPT: 1298455 != 234441647
GPT: Use GPU Parted to correct GPT errors.
 sda: sda1 sda2 sda3
sd 0:0:0:0: [sda] Attached SCSI disk

After that, some "command not found messages"

    /init: line78: touch: command not found
    /init: line81: mkdir: command not found
    /init: line82: mount: command not found
    /init: line86: cat: command not found
    /init: line98: grep: command not found
    /init: line112: sed: command not found

And after all, this error message appears:

    ERROR: Initramfs failed to initialize the system

Hope all this information can be helpful to fix this issue.

Thank you in advance! :-)



2018-03-02 9:52 GMT+01:00 Iván Castell <icastell at nayarsystems.com>:

>
> First of all, thank you for your support Mr. Anuj.
>
> I extracted "initrd" image contents:
>
> $ binwalk initrd
>
> DECIMAL       HEXADECIMAL     DESCRIPTION
> ------------------------------------------------------------
> --------------------
> 0             0x0             ASCII cpio archive (SVR4 with no CRC), file
> name: "kernel", file name length: "0x00000007", file size: "0x00000000"
> 120           0x78            ASCII cpio archive (SVR4 with no CRC), file
> name: "kernel/x86", file name length: "0x0000000B", file size: "0x00000000"
> 244           0xF4            ASCII cpio archive (SVR4 with no CRC), file
> name: "kernel/x86/microcode", file name length: "0x00000015", file size:
> "0x00000000"
> 376           0x178           ASCII cpio archive (SVR4 with no CRC), file
> name: "kernel/x86/microcode/.enuineIntel.align.0123456789abc", file name
> length: "0x00000036", file size: "0x00000000"
> 540           0x21C           ASCII cpio archive (SVR4 with no CRC), file
> name: "kernel/x86/microcode/GenuineIntel.bin", file name length:
> "0x00000026", file size: "0x00183400"
> 1586864       0x1836B0        ASCII cpio archive (SVR4 with no CRC), file
> name: "TRAILER!!!", file name length: "0x0000000B", file size: "0x00000000"
> 1587200       0x183800        gzip compressed data, maximum compression,
> from Unix, last modified: 2018-02-28 14:29:13
>
> $ dd if=initrd bs=1587200 skip=1 | gunzip | cpio -idm
>
> Now I have the initrd filesystem available. I can confirm there is a bug
> in that filesystem because the "init" script uses "sleep" but that tool is
> not installed on it.
>
> # Prints a message and start a endless loop
> fatal() {
>     echo $1 >/dev/console
>     echo >/dev/console
>
>     if [ -n "$bootparam_init_fatal_sh" ]; then
>         sh
>     else
>     while [ "true" ]; do
>         sleep 3600
>     done
>     fi
> }
>
> As you pointed, that "init" script is located into poky/meta/recipes-core/
> initrdscripts/initramfs-framework/init. In that init script there are two
> calls to "fatal" function. Maybe this information can be useful to discover
> what is happening.
>
> I have tested adding suggested "init_fatal_sh" bootarg but I don't get any
> shell to debug the problem.
>
>
>
> 2018-03-02 9:15 GMT+01:00 Anuj Mittal <anuj.mittal at intel.com>:
>
>> On 03/02/2018 03:41 PM, Iván Castell wrote:
>> >
>> > 2018-03-02 0:41 GMT+01:00 Anuj Mittal <anuj.mittal at intel.com
>> > <mailto:anuj.mittal at intel.com>>:
>> >
>> >     Hi,
>> >
>> >     On 03/01/2018 07:20 PM, Iván Castell wrote:
>> >     >
>> >     > Is this the proper way to install the generated image in the hard
>> >     disk?
>> >     > Maybe I am doing something wrong?
>> >
>> >     Does the image boot up if you select 'boot'?
>> >
>> >
>> > I tested selecting 'boot' option and it happens exactly the same: a
>> > black screen appears when booting with default options, and when adding
>> > "noapic", the screen is flooded of "sleep: command not found" messages.
>> >
>> >
>> >
>> >     Do you eventually get options to select storage media after all
>> >     these 'not found' messages if you select 'install'?
>> >
>> >
>> > After waiting more than 5 minutes, the "sleep: command not found"
>> > message continues flooding the screen.
>> >
>> >
>> >
>> >     Can you share the logs?
>> >
>> >
>> > If I could, I would do it, but I have no way to get those logs out of
>> > the box without a terminal available.
>>
>> The error is probably coming from
>> meta/recipes-core/initrdscripts/initramfs-framework/init.
>>
>> You can pass a boot parameter 'init_fatal_sh' and that should help you
>> drop to a shell and debug this problem further.
>>
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20180302/365e22d5/attachment.html>


More information about the yocto mailing list