Forum Linux.embarqué uboot : inclure initrd dans le fichier fit

Posté par . Licence CC By‐SA.
Étiquettes :
2
29
sept.
2022

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 :

 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 :

 /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 :

 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.

  • # ramdisk compressé

    Posté par . Évalué à 3.

    Uboot a tendance à se prendre les pieds dans le tapis en décompressant un ramdisk depuis un itb et à écraser d'autres morceaux de ton image (d’où le fdt overwritten).

    Vaut mieux mettre compression = "none" pour ton ramdisk et laisser le noyau faire la décompression. Pour ça il faut le compiler avec l'option CONFIG_RD_GZIP=y.

    • [^] # Re: ramdisk compressé

      Posté par . Évalué à 1.

      Hello :)

      Merci de m'avoir répondu.

      J'ai testé ta suggestion mais toujours le même problème :'(

      Compression none pour le ramdisk dans le fit et rd_gzip dans le kernel.

Suivre le flux des commentaires

Note : les commentaires appartiennent à celles et ceux qui les ont postés. Nous n’en sommes pas responsables.