Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why does Fedora initframfs require fdt_high and initrd_high? #24

Open
pdp7 opened this issue Jun 17, 2021 · 4 comments
Open

why does Fedora initframfs require fdt_high and initrd_high? #24

pdp7 opened this issue Jun 17, 2021 · 4 comments

Comments

@pdp7
Copy link
Collaborator

pdp7 commented Jun 17, 2021

Regression

@atishp04 reported regression with https://github.com/starfive-tech/u-boot/tree/Fedora_VIC_7100_2021.04 branch after commit 985c9ef (in PR #20) which removed fdt_high=0xffffffffffffffff and initrd_high=0xffffffffffffffff

Note: PR #20 was the result of issue #19. That issue was trying to figure out why @tpetazzoni had to patch fdt_addr_r and kernel_comp_addr_r in buildroot commit buildroot/buildroot@839f00a#diff-b6f2579d76a7d36d1749682795632c0a37a5b73e1a1c78327cd2e32b3d119c61

extlinux.conf

@atishp04 has this in extlinux.conf on Fedora SD card:

kernel /Image.gz
fdt /jh7100-beaglev-starlight.dtb
append ro root=UUID=ae1e722a-d01b-4cdc-ab56-7b68abcdd0fe rhgb console=tty0 console=ttyS0,115200 earlycon=sbi rootwait stmmaceth=chain_mode:1 selinux=0 LANG=en_US.UTF-8
initrd /initramfs-5.10.6-210.0.riscv64.fc33.riscv64.img

I have this in extlinux.conf on my Fedora SD card:

label Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6+)
	kernel /vmlinuz-5.10.6+
	append ro root=UUID=f9449178-f968-425b-8676-1cf0616da884 rhgb console=tty0 console=ttyS0,115200 earlycon=sbi rootwait stmmaceth=chain_mode:1 selinux=0 LANG=en_US.UTF-8
	initrd /initramfs-5.10.6+.img
label Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6-202.0.riscv64.fc33.riscv64)
	kernel /vmlinuz-5.10.6-202.0.riscv64.fc33.riscv64
	append ro root=UUID=f9449178-f968-425b-8676-1cf0616da884 rhgb console=tty0 console=ttyS0,115200 earlycon=sbi rootwait stmmaceth=chain_mode:1 selinux=0 LANG=en_US.UTF-8
	initrd /initramfs-5.10.6-202.0.riscv64.fc33.riscv64.img
label emil-starlight
	kernel /Image
	fdt /jh7100-starlight.dtb
	append earlycon root=/dev/mmcblk0p2 rootwait stmmac.chain_mode=1

attempted fix with bootm_size

@trini suggested setting "bootm_size=0x10000000. However adding that to env did not help:

#define CONFIG_EXTRA_ENV_SETTINGS \
        "bootm_size=0x10000000\0" \
        "kernel_addr_r=0x84000000\0" \
        "fdt_addr_r=0x88000000\0" \
        "scriptaddr=0x88100000\0" \
        "script_offset_f=0x1fff000\0" \
        "script_size_f=0x1000\0" \
        "pxefile_addr_r=0x88200000\0" \
        "ramdisk_addr_r=0x88300000\0" \
        "kernel_comp_addr_r=0x90000000\0" \
        "kernel_comp_size=0x10000000\0" \
        "type_guid_gpt_loader1=" TYPE_GUID_LOADER1 "\0" \
        "type_guid_gpt_loader2=" TYPE_GUID_LOADER2 "\0" \
        "type_guid_gpt_system=" TYPE_GUID_SYSTEM "\0" \
        "partitions=" PARTS_DEFAULT "\0" \
        BOOTENV \
        BOOTENV_SF

still failed:

CPU:   rv64imafdc
DRAM:  8 GiB
MMC:   sdio0@10000000: 0, sdio1@10010000: 1
Net:   dwmac.10020000
Autoboot in 2 seconds
MMC CD is 0x1, force to True.
MMC CD is 0x1, force to True.
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
1163 bytes read in 8 ms (141.6 KiB/s)
Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 Boot Options.
1:      Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6+)
2:      Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6-202.0.riscv64.fc33.riscv64)
3:      emil-starlight
Enter choice: 1:        Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6+)
Retrieving file: /initramfs-5.10.6+.img
30042996 bytes read in 6220 ms (4.6 MiB/s)
Retrieving file: /vmlinuz-5.10.6+
8910804 bytes read in 1848 ms (4.6 MiB/s)
append: ro root=UUID=f9449178-f968-425b-8676-1cf0616da884 rhgb console=tty0 console=ttyS0,115200 earlycon=sbi rootwait stmmaceth=chain_mode8
  Uncompressing Kernel Image
Moving Image from 0x84000000 to 0x80200000, end=81b04000
## Flattened Device Tree blob at ff737920
  Booting using the fdt blob at 0xff737920
  Loading Ramdisk to 8e359000, end 8ffffb74 ... OK
ERROR: Failed to allocate 0x94ce bytes below 0x90000000.
device tree - allocation error
FDT creation failed! hanging...### ERROR ### Please RESET the board ###

setting bigger bootm_size=0x20000000 also failed:

Enter choice: 1:        Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6+)
Retrieving file: /initramfs-5.10.6+.img
30042996 bytes read in 6220 ms (4.6 MiB/s)
Retrieving file: /vmlinuz-5.10.6+
8910804 bytes read in 1848 ms (4.6 MiB/s)
append: ro root=UUID=f9449178-f968-425b-8676-1cf0616da884 rhgb console=tty0 console=ttyS0,115200 earlycon=sbi rootwait stmmaceth=chain_mode8
   Uncompressing Kernel Image
Moving Image from 0x84000000 to 0x80200000, end=81b04000
## Flattened Device Tree blob at ff737920
   Booting using the fdt blob at 0xff737920
   Loading Ramdisk to 9e359000, end 9ffffb74 ... OK
ERROR: Failed to allocate 0x94ce bytes below 0xa0000000.
device tree - allocation error
FDT creation failed! hanging...### ERROR ### Please RESET the board ###

no regression for 5.13 esmil_starlight

For comparison, the removal of fdt_high and initrd_high in 985c9ef is not a problem when using the 5.13 @esmil kernel on the same Fedora SD card:

U-Boot 2021.04 (Jun 17 2021 - 11:53:35 -0700)
CPU:   rv64imafdc
DRAM:  8 GiB
MMC:   sdio0@10000000: 0, sdio1@10010000: 1
Net:   dwmac.10020000
Autoboot in 2 seconds
MMC CD is 0x1, force to True.
MMC CD is 0x1, force to True.
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
1163 bytes read in 8 ms (141.6 KiB/s)
Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 Boot Options.
1:      Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6+)
2:      Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6-202.0.riscv64.fc33.riscv64)
3:      emil-starlight
Enter choice: 3
3:      emil-starlight
Retrieving file: /Image
17585664 bytes read in 2059 ms (8.1 MiB/s)
append: earlycon root=/dev/mmcblk0p2 rootwait stmmac.chain_mode=1
Retrieving file: /jh7100-starlight.dtb
17450 bytes read in 8 ms (2.1 MiB/s)
Moving Image from 0x84000000 to 0x80200000, end=81315000
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Loading Device Tree to 000000009fff8000, end 000000009ffff429 ... OK
Starting kernel ...
Linux version 5.13.0-rc1-starlight-drew-306874-ge6e90bd05d7e (pdp7@x1) (riscv64-linux-gnu-gcc (Ubuntu 10.2.0-8ubuntu1) 10.2.0, GNU ld (GNU 1
OF: fdt: Ignoring memory range 0x80000000 - 0x80200000

Commit 985c9ef is also not a problem for buildroot SD card:

U-Boot 2021.04 (Jun 17 2021 - 10:53:10 -0700)
CPU:   rv64imafdc
DRAM:  8 GiB
MMC:   sdio0@10000000: 0, sdio1@10010000: 1
Net:   dwmac.10020000
Autoboot in 2 seconds
MMC CD is 0x1, force to True.
MMC CD is 0x1, force to True.
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
183 bytes read in 7 ms (25.4 KiB/s)
1:      linux
Retrieving file: /boot/Image
19701248 bytes read in 4083 ms (4.6 MiB/s)
append: console=ttyS0,115200 earlyprintk root=PARTUUID=0fef845a-c6e1-45bc-82f7-002fa720f958 rootwait
Retrieving file: /boot/jh7100-beaglev-starlight.dtb
17366 bytes read in 10 ms (1.7 MiB/s)
Moving Image from 0x84000000 to 0x80200000, end=8151c000
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Loading Device Tree to 000000008fff8000, end 000000008ffff3d5 ... OK
Starting kernel ...

what controls fdt_blob?

Note that when boot fails for Fedora 5.10 kernel fdt blob is at ff737920:

## Flattened Device Tree blob at ff737920

instead of 88000000 which is the case for 5.13 esmil_starlight kernel on the Fedora SD card and the 5.13 kernel on the buildroot SD card:

## Flattened Device Tree blob at 88000000

The address ff737920 looks weird to me. @trini asked me to run bdi:

U-Boot 2021.04 (Jun 17 2021 - 11:53:35 -0700)
CPU:   rv64imafdc
DRAM:  8 GiB
MMC:   sdio0@10000000: 0, sdio1@10010000: 1
Net:   dwmac.10020000
Autoboot in 2 seconds
BeagleV # bdi     
boot_params = 0x0000000080000000
DRAM bank   = 0x0000000000000000
-> start    = 0x0000000080000000
-> size     = 0x0000000200000000
flashstart  = 0x0000000000000000
flashsize   = 0x0000000000000000
flashoffset = 0x0000000000000000
baudrate    = 115200 bps
relocaddr   = 0x00000000fff5d000
reloc off   = 0x000000007fd5d000
Build       = 64-bit
current eth = dwmac.10020000
ethaddr     = 2c:f7:f1:1b:e3:3f
IP addr     = 192.168.120.200
fdt_blob    = 0x00000000ff737920
new_fdt     = 0x00000000ff737920
fdt_size    = 0x00000000000064e0
lmb_dump_all:
    memory.cnt             = 0x1
    memory.size            = 0x0
    memory.reg[0x0].base   = 0x80000000
                   .size   = 0x200000000
    reserved.cnt           = 0x5
    reserved.size          = 0x0
    reserved.reg[0x0].base = 0x80000000
                     .size = 0x40000
    reserved.reg[0x1].base = 0xc9000000
                     .size = 0x4000000
    reserved.reg[0x2].base = 0xd0000000
                     .size = 0x28000000
    reserved.reg[0x3].base = 0xf9000000
                     .size = 0x1000000
    reserved.reg[0x4].base = 0xfb000000
                     .size = 0x2000000

issue with lmb_alloc_base on RISC-V?

@atishp04 notes that:

Both sifive & qemu config set these two 0xffffffffffffffff which disables relocations. Thus, lmb_alloc_base might not be tested well enough in this path for RISC-V

@trini commented:

If bringing that back fixes this issue, there's some deeper problem with the port going on, lmb_alloc_base should not be failing.

Results from reverting

I can confirm that reverting commit 985c9ef and restoring fdt_high=0xffffffffffffffff and initrd_high=0xffffffffffffffff does fix booting with the Fedora 5.10 initrd.

U-Boot 2021.04 (Jun 17 2021 - 12:58:12 -0700)

CPU:   rv64imafdc
DRAM:  8 GiB
MMC:   sdio0@10000000: 0, sdio1@10010000: 1
Net:   dwmac.10020000
Autoboot in 2 seconds
MMC CD is 0x1, force to True.
MMC CD is 0x1, force to True.
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
1163 bytes read in 8 ms (141.6 KiB/s)
Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 Boot Options.
1:      Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6+)
2:      Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6-202.0.riscv64.fc33.riscv64)
3:      emil-starlight
Enter choice: 1:        Fedora-riscv64-vic7100-dev-raw-image-Rawhide-20210415015319.n.0 (5.10.6+)
Retrieving file: /initramfs-5.10.6+.img
30042996 bytes read in 6220 ms (4.6 MiB/s)
Retrieving file: /vmlinuz-5.10.6+
8910804 bytes read in 1848 ms (4.6 MiB/s)
append: ro root=UUID=f9449178-f968-425b-8676-1cf0616da884 rhgb console=tty0 console=ttyS0,115200 earlycon=sbi rootwait stmmaceth=chain_mode8
   Uncompressing Kernel Image
Moving Image from 0x84000000 to 0x80200000, end=81b04000
## Flattened Device Tree blob at ff737920
   Booting using the fdt blob at 0xff737920
   Using Device Tree in place at 00000000ff737920, end 00000000ff740ded

Starting kernel ...

[    0.000000] Linux version 5.10.6+ (yanliu@Amethyst) (riscv64-linux-gnu-gcc (GCC) 10.2.1 20200826 (Red Hat Cross 10.2.1-3), GNU ld versio1
[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
@pdp7 pdp7 changed the title why does Fedora kernel require fdt_high and initrd_high? why does Fedora initframfs require fdt_high and initrd_high? Jun 17, 2021
@pdp7
Copy link
Collaborator Author

pdp7 commented Jun 17, 2021

@tekkamanninja @lbmeng @tpetazzoni @mcd500 @davidlt I would appreciate any feedback. @atishp04 and @trini seem to think there might be an issue with lmb_alloc_base on RISC-V.

@esmil
Copy link

esmil commented Jun 17, 2021

@pdp7 If the problem is finding space for relocating initrd and dtb then the reason the 5.13 kernel works may be simply because you don't use an initrd with that.

@tekkamanninja
Copy link
Collaborator

Since I have used GRUB to boot Fedora, we don't need fdt_high and initrd_high any more.
But I will go on investigate this issue

@trini
Copy link
Contributor

trini commented Aug 26, 2021

After some community investigation, this seems likely due to a lack of arch_lmb_reserve on riscv. A simple one like on arc or m68k (but with 4K stack, not 1K) should do it, but needs to be checked on hardware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants