qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deprecate the ppc405 boards in QEMU?


From: Cédric Le Goater
Subject: Re: Deprecate the ppc405 boards in QEMU?
Date: Tue, 19 Oct 2021 22:55:50 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0

On 10/19/21 18:12, Christophe Leroy wrote:


Le 19/10/2021 à 16:56, BALATON Zoltan a écrit :
On Tue, 19 Oct 2021, Christophe Leroy wrote:
Le 19/10/2021 à 15:44, Christophe Leroy a écrit :
There is something:

=> bootm 0
Wrong Image Format for bootm command
ERROR: can't get kernel image!

=> md 0
00000000: 00000000 b497aae1 616e9207 003227a4    '..V....an...2'.
00000010: 00000000 00000000 ee36255f 05070201    .........6%_....
00000020: 4c696e75 782d352e 31352e30 2d726335    Linux-5.15.0-rc5
00000030: 2d303232 32342d67 61336330 30376164    -02224-ga3c007ad
00000040: 1f8b0800 00000000 0203ec5c 0f7013e7    ...........\.p..

=> mw.l 0 0x27051956

=> bootm 0
## Booting kernel from Legacy Image at 00000000 ...
    Image Name:   Linux-5.15.0-rc5-02224-ga3c007ad
    Image Type:   PowerPC Linux Kernel Image (gzip compressed)
    Data Size:    3286948 Bytes = 3.1 MiB
    Load Address: 00000000
    Entry Point:  00000000
    Verifying Checksum ... Bad Data CRC
ERROR: can't get kernel image!


So we have something but it seems it gets overwritten by stuff.

Anyway loading a uImage at 0 is just bad because it is a gzipped image that 
should get gunzipped at address 0.

Or should we just copy the raw kernel at 0 and jump to the entry point ? But 
then we also need a device tree somewhere.


If I change KERNEL_LOAD_ADDR to 0x1000000, I can bootm at that address, and it 
seems it properly decompress the kernel:

=> bootm 0x1000000
## Booting kernel from Legacy Image at 01000000 ...
  Image Name:   Linux-5.15.0-rc5-02224-ga3c007ad
  Image Type:   PowerPC Linux Kernel Image (gzip compressed)
  Data Size:    3296789 Bytes = 3.1 MiB
  Load Address: 00000000
  Entry Point:  00000000
  Verifying Checksum ... OK
  Uncompressing Kernel Image ... OK


And it initialises the MMU properly.

Then it gets stuck because there is no devicetree.

(gdb) bt
#0  0xc00094cc in udelay ()
#1  0xc0025d34 in panic ()
#2  0xc06415a0 in early_init_devtree ()
#3  0xc0641da8 in machine_init ()
#4  0xc0002200 in start_here ()

Maybe you need to embed a dtb in your kernel if that's possible somehow? Or QEMU 
has a -dtb option that sets machine->dtb but you need board code to do 
something with it. See how it's done in other boards like virtex_ml507 and 
sam460ex. But maybe you'd be better off not using -kernel option as it seems to 
not really working for these 405 boards but load and start the kernel from u-boot. 
Not sure what device does u-boot support but QEMU can emulate usb-storage, 
network, different disks so something might work with u-boot if this board has any 
peripherals. If it doesn't emulate any peripherals what do you expect to do with 
the kernel once it boots?


I should be able to build a multi-FIT image that embeds the kernel and the 
device tree.

I don't know about the peripherals, what I need it a kernel that is able to 
boot and run some user exe. I'm working on low level functionnalities like 
VMAP_STACK, STRICT_KERNEL_RWX, Userspace protection, etc ... I want to be able 
to check that after some modifications the kernel can still boot on every CPU 
sub-family, and I need to run LKDTM tests.

For this a kernel + initrd is enough.

Thanks
Christophe

If we don't need a loader, we are better off simplifying the 405 boards with
a simple init sequence such as :

    if (machine->kernel_filename) {
        hwaddr kernel_base = 0;
        int kernel_size = 0;
        hwaddr initrd_base = 0;
        int initrd_size = 0;

        kernel_size = load_elf(machine->kernel_filename, NULL, NULL, NULL,
                               &boot_entry, &kernel_base, NULL, NULL,
                               0 /* LE */, PPC_ELF_MACHINE, 0, 0);
        if (kernel_size < 0) {
            error_report("Could not load kernel '%s' : %s",
                         machine->kernel_filename, 
load_elf_strerror(kernel_size));
            exit(1);
        }

        if (machine->initrd_filename) {
            initrd_base = QEMU_ALIGN_UP(kernel_base + kernel_size, 0x10000);
            initrd_size = load_image_targphys(machine->initrd_filename,
                                              initrd_base, 16 * MiB /* Some 
value */);
            if (initrd_size < 0) {
                error_report("Could not load initial ram disk '%s'",
                             machine->initrd_filename);
                exit(1);
            }
        }

        if (machine->dtb) {
            dt_base = mw_dtb_load(machine, kernel_base, kernel_size, 
initrd_base,
                                  initrd_size);
        }
    }

We need to set the nip to 'boot_entry' and gpr[3] to 'dt_base'.

unless some pre-initialization of hw is required before running Linux ?

Thanks,

C.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]