URL: https://linuxfr.org/forums/linux-embarque/posts/uboot-inclure-initrd-dans-le-fichier-fit Title: uboot : inclure initrd dans le fichier fit Authors: doudootiana Date: 2022年09月29日T15:37:08+02:00 License: CC By-SA Tags: banana_pi et u-boot Score: 2 Hello à toutes et à tous. Je suis encore novice dans le domaine du Linux embarqué. J'essaie d'apprendre en cherchant les infos sur le web mais là ça fait une semaine que je bloque. Je travaille sur une Bananapi r3. J'ai fait le bootloader avec U-boot et ATF ( j'espère utiliser les bons termes ^^) . J'ai crée un fichier fit qui contient le noyau, le dtb et j'aimerais aussi y mettre l'initrd qui est au format cpio.gz Lors du boot, j'ai cette erreur : ```sh Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit ## Error: "initrd" not defined fit=diagbox.itb 75430704 bytes read in 7555 ms (9.5 MiB/s) ## Loading kernel from FIT Image at 46000000 ... Using 'conf-1' configuration Trying 'kernel' kernel subimage Description: Kernel Type: Kernel Image Compression: gzip compressed Data Start: 0x460000c0 Data Size: 9023926 Bytes = 8.6 MiB Architecture: AArch64 OS: Linux Load Address: 0x44000000 Entry Point: 0x44000000 Hash algo: sha1 Hash value: db19bf77644b49dd92e368d44d550ee7622c4975 Verifying Hash Integrity ... sha1+ OK ## Loading fdt from FIT Image at 46000000 ... Using 'conf-1' configuration Trying 'fdt' fdt subimage Description: Flattened Device Tree blob Type: Flat Device Tree Compression: uncompressed Data Start: 0x4689b36c Data Size: 19100 Bytes = 18.7 KiB Architecture: AArch64 Load Address: 0x47000000 Hash algo: sha1 Hash value: 2fba374f801b81c839aa55c2f3c7182b44d4a4f3 Verifying Hash Integrity ... sha1+ OK Error: fdt overwritten Could not find a valid device tree RescueOS> ``` Lorsque je retire le rootfs du fichier fit, et que je le charge séparément, la carte boot bien. J'ai remarqué qu'en enlevant la Load address du fdt, la carte boot aléatoirement. La Bananapi r3 nécessite une table de partition de type GPT. Voici la composition de ma table de partition : ``` { "bl2" : { "start": 1024, "end" : 8191, "attributes": 4, "uuid" : "{19a4763a-6b19-4a4b-a0c4-8cc34f4c2b8a}" }, "u-boot-env" : { "start": 8192, "end" : 9215, "uuid" : "{19a4763a-6b19-4a4b-a0c4-8cc34f4c2ab9}" }, "factory" : { "start": 9216, "end" : 13311, "uuid" : "{8142c1b2-1697-41d9-b1bf-a88d76c7213f}" }, "fip": { "start": 13312, "end" : 17407, "uuid" : "{18de6587-4f17-4e08-a6c9-d9d3d424f4c5}" }, "kernel" : { "start": 17408, "end" : 293888, "uuid" : "{971f7556-ef1a-44cd-8b28-0cf8100b9c7e}" }, "rootfs" : { "start": 293889, "end" : 1342465, "uuid" : "{309a3e76-270b-41b2-b5d5-ed8154e7542b}" }, "data" : { "start": 1342466, "end" : 6585346, "uuid" : "{309a3e76-270b-41b2-b5d5-ed8154e7542b}" } } ``` La configuration du fichier fit : ```sh /dts-v1/; / { description = "Kernel et dtb pour RescueOS"; #address-cells = <1>; images { kernel { description = "Kernel"; data = /incbin/("Image.gz"); type = "kernel"; arch = "arm64"; os = "linux"; compression = "gzip"; load = <0x44000000>; entry = <0x44000000>; hash-1 { algo = "sha1"; }; }; fdt { description = "Flattened Device Tree blob"; data = /incbin/("diagbox.dtb"); type = "flat_dt"; arch = "arm64"; load = <0x47000000>; compression = "none"; hash-1 { algo = "sha1"; }; }; fdt-nand{ data = /incbin/("diagbox-nand.dtbo"); type = "flat_dt"; arch = "arm64"; }; }; ramdisk { description = "ramdisk"; data = /incbin/("rootfs.cpio.gz"); type = "ramdisk"; arch = "arm64"; os = "linux"; compression = "gzip"; hash-1 { algo = "sha1"; }; }; configurations { default = "conf-1"; conf-1 { description = "Configuration"; kernel = "kernel"; fdt = "fdt", "fdt-nand"; ramdisk = "ramdisk"; hash-1 { algo = "sha1"; }; }; }; }; ``` Et le fichier uEnv.txt de uboot : ```sh board=bpi-r3 device=mmc partition=0:5 bootenv=uEnv.txt bootdevice=sd fit=bpi-r3.itb #bootconf="#conf-2" #initrd=rootfs.cpio.zst loadaddr=0x46000000 kaddr=0x46000000 rdaddr=0x48000000 root=/dev/mmcblk0p6 rootfstype=ext4 rootwait console=ttyS0,115200n1 earlycon=uart8250,mmio32,0x11002000 bootopts=debug=7 checkenv=test -e ${device} ${partition} ${bootenv} loadenvfile=if fatload ${device} ${partition} ${loadaddr} ${bootenv};then env import -t ${loadaddr} ${filesize};else echo "fatload (${bootenv}) failed";fi loadenv=if run checkenv;then run loadenvfile;fi resetenv=env default -a;printenv; loadkernel=fatload $device $partition $kaddr ${kernel} buildargs=setenv bootargs "board=${board} earlycon=uart8250,mmio32,0x11002000 ${bootopts} root=${root}" #console=${console} useusb=if usb info; then usb reset;else usb start;fi; setenv device usb;setenv partition 0:1;ls ${device} ${partition} useinitrd=setenv root "/dev/ram0 rw";setenv bootopts "${bootopts} initrd=${rdaddr},20M";fatload ${device} ${partition} ${rdaddr} ${initrd}; checkrd=if printenv initrd;then run useinitrd;fi newboot=run checkrd; run buildargs;if printenv fit;then setenv kernel ${fit};if run loadkernel; then bootm ${kaddr}${bootconf}; fi;fi; ``` Si quelqu'un a une idée :) En vous remerciant d'avance.