Créer sa propre image debian pour le Raspberry Pi 2 B

Tags: #<Tag:0x00007f63f1a884a8> #<Tag:0x00007f63f1a883b8> #<Tag:0x00007f63f1a88278>

Bonjour,

Est-ce quelqu’un a déjà réussi à préparer sa propre image pour le Raspberry Pi 2 B à partir uniquement des dépôts de debian ?

Je n’ai jamais réussi et me rabattais sur les images de Raspbian, puis de Raspberry Pi OS.
Mais ça commence à me courir sur le système de ne pas réussir à créer ma propre image par debootstrap, alors que j’ai aucun problème pour le Sheevaplug ou l’A20-OLinuXino-LIME2 (qui nécessite quand même une astuce particulière pour flasher le SPL au bon endroit).

J’utilise le paquet raspi-firmware qui est sensé installer le bootloader du Raspberry Pi dans /boot/firmware, mais ça ne fonctionne pas.

Voici les grandes étapes :
Le partitionnement de la carte SD :

$ sudo parted -s rpi.img unit s print 
Model:  (file)
Disk : [...]/rpi.img: 4194304s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 
 
Number  Start    End       Size      Type     File system  Flags
 1      8192s    524287s   516096s   primary  fat32        boot, lba
 2      524288s  4194303s  3670016s  primary  ext4

Et le contenu du répertoire /boot/firmware :

$ ls -la ~/mnt/boot/firmware/
total 81496
drwxr-xr-x 2 root root     4096  1 janv.  1970 .
drwxr-xr-x 3 root root     4096 20 sept. 21:40 ..
-rwxr-xr-x 1 root root    27406 20 sept. 21:40 bcm2711-rpi-400.dtb
-rwxr-xr-x 1 root root    27434 20 sept. 21:40 bcm2711-rpi-4-b.dtb
-rwxr-xr-x 1 root root    27323 20 sept. 21:40 bcm2711-rpi-cm4-io.dtb
-rwxr-xr-x 1 root root    12791 20 sept. 21:40 bcm2835-rpi-a.dtb
-rwxr-xr-x 1 root root    12927 20 sept. 21:40 bcm2835-rpi-a-plus.dtb
-rwxr-xr-x 1 root root    12909 20 sept. 21:40 bcm2835-rpi-b.dtb
-rwxr-xr-x 1 root root    13149 20 sept. 21:40 bcm2835-rpi-b-plus.dtb
-rwxr-xr-x 1 root root    12997 20 sept. 21:40 bcm2835-rpi-b-rev2.dtb
-rwxr-xr-x 1 root root    13021 20 sept. 21:40 bcm2835-rpi-cm1-io1.dtb
-rwxr-xr-x 1 root root    12835 20 sept. 21:40 bcm2835-rpi-zero.dtb
-rwxr-xr-x 1 root root    13361 20 sept. 21:40 bcm2835-rpi-zero-w.dtb
-rwxr-xr-x 1 root root    14374 20 sept. 21:40 bcm2836-rpi-2-b.dtb
-rwxr-xr-x 1 root root    14816 20 sept. 21:40 bcm2837-rpi-3-a-plus.dtb
-rwxr-xr-x 1 root root    14993 20 sept. 21:40 bcm2837-rpi-3-b.dtb
-rwxr-xr-x 1 root root    15349 20 sept. 21:40 bcm2837-rpi-3-b-plus.dtb
-rwxr-xr-x 1 root root    14355 20 sept. 21:40 bcm2837-rpi-cm3-io3.dtb
-rwxr-xr-x 1 root root    14667 20 sept. 21:40 bcm2837-rpi-zero-2-w.dtb
-rwxr-xr-x 1 root root    52460 20 sept. 21:34 bootcode.bin
-rwxr-xr-x 1 root root      105 20 sept. 21:40 cmdline.txt
-rwxr-xr-x 1 root root      520 20 sept. 21:40 config.txt
-rwxr-xr-x 1 root root     3170 20 sept. 21:34 fixup4cd.dat
-rwxr-xr-x 1 root root     5399 20 sept. 21:34 fixup4.dat
-rwxr-xr-x 1 root root     8379 20 sept. 21:34 fixup4db.dat
-rwxr-xr-x 1 root root     8379 20 sept. 21:34 fixup4x.dat
-rwxr-xr-x 1 root root     3170 20 sept. 21:34 fixup_cd.dat
-rwxr-xr-x 1 root root     7262 20 sept. 21:34 fixup.dat
-rwxr-xr-x 1 root root    10228 20 sept. 21:34 fixup_db.dat
-rwxr-xr-x 1 root root    10226 20 sept. 21:34 fixup_x.dat
-rwxr-xr-x 1 root root 25048780 22 sept. 11:35 initrd.img
-rwxr-xr-x 1 root root 25048780 20 sept. 21:40 initrd.img-6.1.0-10-armmp-lpae
-rwxr-xr-x 1 root root  5403136 22 sept. 11:35 kernel7.img
-rwxr-xr-x 1 root root   803964 20 sept. 21:34 start4cd.elf
-rwxr-xr-x 1 root root  3744808 20 sept. 21:34 start4db.elf
-rwxr-xr-x 1 root root  2249280 20 sept. 21:34 start4.elf
-rwxr-xr-x 1 root root  2996680 20 sept. 21:34 start4x.elf
-rwxr-xr-x 1 root root   803964 20 sept. 21:34 start_cd.elf
-rwxr-xr-x 1 root root  4816712 20 sept. 21:34 start_db.elf
-rwxr-xr-x 1 root root  2973536 20 sept. 21:34 start.elf
-rwxr-xr-x 1 root root  3720360 20 sept. 21:34 start_x.elf
-rwxr-xr-x 1 root root  5403136 20 sept. 21:40 vmlinuz-6.1.0-10-armmp-lpae

Ici, j’ai copié l’image du noyau vmlinuz-6.1.0-10-armmp-lpae en kernel7.img, qui est requis pour le démarrage du Raspberry Pi 2 B.

Mais l’affichage de la console de debuggage UART n’affiche rien lors de la mise sous tension du Raspberry Pi.

Est-ce que le paquet raspi-firmware fonctionne bien avec le Raspberry Pi 2 B ?

J’avance enfin un peu…

Le paquet raspi-firmware fonctionne finalement bien.
Le seul problème est la définition de la console série dans le fichier /boot/firmware/cmdline.txt.
À l’installation, on a :

console=tty0 console=ttyS1,115200 root=/dev/mmcblk0p2 rw fsck.repair=yes net.ifnames=0 cma=64M rootwait 

Je ne sais pas ce qu’est la console ttyS1, mais ce n’est pas la bonne pour utiliser l’UART.
Il faut rajouter console=serial0,115200 pour que ça fonctionne :

console=serial0,115200 console=tty0 console=ttyS1,115200 root=/dev/mmcblk0p2 rw fsck.repair=yes net.ifnames=0 cma=64M rootwait 

Maintenant, j’ai un autre problème, c’est que le noyau n’arrive pas à accéder à la partition racine :

[    0.000000] Booting Linux on physical CPU 0xf00
[    0.000000] Linux version 6.1.0-10-armmp-lpae (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP Debian 6.1.38-1 (2023-07-14)
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=30c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi 2 Model B Rev 1.1
[    0.000000] random: crng init done
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] efi: UEFI not found.
[    0.000000] Reserved memory: bypass linux,cma node, using cmdline CMA params instead
[    0.000000] OF: reserved mem: node linux,cma compatible matching fail
[    0.000000] cma: Reserved 64 MiB at 0x0000000037400000
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000000000-0x000000002fffffff]
[    0.000000]   Normal   empty
[    0.000000]   HighMem  [mem 0x0000000030000000-0x000000003b3fffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000003b3fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000003b3fffff]
[    0.000000] percpu: Embedded 18 pages/cpu s41684 r8192 d23852 u73728
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 240960
[    0.000000] Kernel command line: video=Composite-1:720x480@60i,margin_left=32,margin_right=32,margin_top=32,margin_bottom=32 dma.dmachans=0x7ff5 bcm2709.boardrev=0xa01041 bcm2709.serial=0x5c7e3350 bcm2709.uart_clock=48000000 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 smsc95xx.macaddr=B8:27:EB:7E:33:50 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  console=ttyAMA0,115200 console=tty0 console=ttyS1,115200 root=/dev/mmcblk0p2 rw fsck.repair=yes net.ifnames=0 cma=64M rootwait
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:all(zero), heap alloc:on, heap free:off
[    0.000000] Memory: 850484K/970752K available (12288K kernel code, 1709K rwdata, 3588K rodata, 2048K init, 384K bss, 54732K reserved, 65536K cma-reserved, 118784K highmem)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] ftrace: allocating 39699 entries in 117 pages
[    0.000000] ftrace: allocated 117 pages with 5 groups
[    0.000000] trace event string verifier disabled
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu: 	RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[    0.000000] 	Rude variant of Tasks RCU enabled.
[    0.000000] 	Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000004] sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns
[    0.000038] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
[    0.000124] bcm2835: system timer (irq = 60)
[    0.002211] arch_timer: cp15 timer(s) running at 19.20MHz (phys).
[    0.002238] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: 440795202767 ns
[    0.002264] sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398046511078ns
[    0.002284] Switching to timer-based delay loop, resolution 52ns
[    0.003027] Console: colour dummy device 80x30
[    0.003992] printk: console [tty0] enabled
[    0.004095] Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=76800)
[    0.004175] pid_max: default: 32768 minimum: 301
[    0.004476] LSM: Security Framework initializing
[    0.004611] landlock: Up and running.
[    0.004637] Yama: disabled by default; enable with sysctl kernel.yama.*
[    0.004990] AppArmor: AppArmor initialized
[    0.005032] TOMOYO Linux initialized
[    0.005100] LSM support for eBPF active
[    0.005359] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.005421] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.007299] CPU: Testing write buffer coherency: ok
[    0.008147] CPU0: update cpu_capacity 1024
[    0.008197] CPU0: thread -1, cpu 0, socket 15, mpidr 80000f00
[    0.009697] cblist_init_generic: Setting adjustable number of callback queues.
[    0.009757] cblist_init_generic: Setting shift to 2 and lim to 1.
[    0.009983] cblist_init_generic: Setting shift to 2 and lim to 1.
[    0.010372] Setting up static identity map for 0x400000 - 0x4000ac
[    0.011338] rcu: Hierarchical SRCU implementation.
[    0.011379] rcu: 	Max phase no-delay instances is 1000.
[    0.013802] EFI services will not be available.
[    0.014820] smp: Bringing up secondary CPUs ...
[    0.016473] CPU1: update cpu_capacity 1024
[    0.016496] CPU1: thread -1, cpu 1, socket 15, mpidr 80000f01
[    0.018193] CPU2: update cpu_capacity 1024
[    0.018214] CPU2: thread -1, cpu 2, socket 15, mpidr 80000f02
[    0.019837] CPU3: update cpu_capacity 1024
[    0.019857] CPU3: thread -1, cpu 3, socket 15, mpidr 80000f03
[    0.020091] smp: Brought up 1 node, 4 CPUs
[    0.020240] SMP: Total of 4 processors activated (153.60 BogoMIPS).
[    0.020273] CPU: All CPU(s) started in HYP mode.
[    0.020295] CPU: Virtualization extensions available.
[    0.021850] devtmpfs: initialized
[    0.033047] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.033612] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.033757] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
[    0.038653] pinctrl core: initialized pinctrl subsystem
[    0.040149] DMI not present or invalid.
[    0.040895] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.045165] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.049643] audit: initializing netlink subsys (disabled)
[    0.050148] audit: type=2000 audit(0.044:1): state=initialized audit_enabled=0 res=1
[    0.051934] thermal_sys: Registered thermal governor 'fair_share'
[    0.051954] thermal_sys: Registered thermal governor 'bang_bang'
[    0.051990] thermal_sys: Registered thermal governor 'step_wise'
[    0.052018] thermal_sys: Registered thermal governor 'user_space'
[    0.052045] thermal_sys: Registered thermal governor 'power_allocator'
[    0.052715] No ATAGs?
[    0.052998] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.053048] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.054456] Serial: AMBA PL011 UART driver
[    0.083285] kprobes: kprobe jump-optimization is enabled. All kprobes are optimized if possible.
[    0.085870] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages
[    0.085930] HugeTLB: 0 KiB vmemmap can be freed for a 2.00 MiB page
[    0.091828] iommu: Default domain type: Translated 
[    0.091887] iommu: DMA domain TLB invalidation policy: strict mode 
[    0.095631] NetLabel: Initializing
[    0.095688] NetLabel:  domain hash size = 128
[    0.095712] NetLabel:  protocols = UNLABELED CIPSOv4 CALIPSO
[    0.095877] NetLabel:  unlabeled traffic allowed by default
[    0.096291] vgaarb: loaded
[    0.127032] clocksource: Switched to clocksource arch_sys_counter
[    0.128299] VFS: Disk quotas dquot_6.6.0
[    0.128475] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.129876] AppArmor: AppArmor Filesystem Enabled
[    0.146944] NET: Registered PF_INET protocol family
[    0.147961] IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.152871] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.153256] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.153348] TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.153627] TCP bind hash table entries: 8192 (order: 5, 131072 bytes, linear)
[    0.154003] TCP: Hash tables configured (established 8192 bind 8192)
[    0.154564] MPTCP token hash table entries: 1024 (order: 2, 16384 bytes, linear)
[    0.154797] UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.154907] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.155437] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.155546] NET: Registered PF_XDP protocol family
[    0.155594] PCI: CLS 0 bytes, default 64
[    0.157407] hw perfevents: enabled with armv7_cortex_a7 PMU driver, 5 counters available
[    0.157444] Trying to unpack rootfs image as initramfs...
[    0.157551] Initramfs unpacking failed: invalid magic at start of compressed archive
[    0.210490] Freeing initrd memory: 24464K
[    0.235762] Initialise system trusted keyrings
[    0.235920] Key type blacklist registered
[    0.236458] workingset: timestamp_bits=14 max_order=18 bucket_order=4
[    0.249219] zbud: loaded
[    0.251345] integrity: Platform Keyring initialized
[    0.251434] integrity: Machine keyring initialized
[    0.251468] Key type asymmetric registered
[    0.251495] Asymmetric key parser 'x509' registered
[    0.262270] alg: self-tests for CTR-KDF (hmac(sha256)) passed
[    0.262982] bounce: pool size: 64 pages
[    0.263356] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[    0.263727] io scheduler mq-deadline registered
[    0.283391] simple-framebuffer 3eaf0000.framebuffer: framebuffer at 0x3eaf0000, 0x10a800 bytes
[    0.283472] simple-framebuffer 3eaf0000.framebuffer: format=a8r8g8b8, mode=656x416x32, linelength=2624
[    0.288121] Console: switching to colour frame buffer device 82x26
[    0.294898] simple-framebuffer 3eaf0000.framebuffer: fb0: simplefb registered!
[    0.311925] Serial: 8250/16550 driver, 5 ports, IRQ sharing enabled
[    0.318953] Serial: AMBA driver
[    0.323459] STM32 USART driver initialized
[    0.328984] bcm2835-power bcm2835-power: Broadcom BCM2835 power domains driver
[    0.334289] mousedev: PS/2 mouse device common for all mice
[    0.342913] ledtrig-cpu: registered to indicate activity on CPUs
[    0.347249] bcm2835-mbox 3f00b880.mailbox: mailbox enabled
[    0.353019] NET: Registered PF_INET6 protocol family
[    0.364084] Segment Routing with IPv6
[    0.367186] In-situ OAM (IOAM) with IPv6
[    0.370208] mip6: Mobile IPv6
[    0.373100] NET: Registered PF_PACKET protocol family
[    0.376284] mpls_gso: MPLS GSO support
[    0.379688] ThumbEE CPU extension supported.
[    0.382580] Registering SWP/SWPB emulation handler
[    0.386526] registered taskstats version 1
[    0.389453] Loading compiled-in X.509 certificates
[    1.812662] Loaded X.509 cert 'Debian Secure Boot CA: 6ccece7e4c6c0d1f6149f3dd27dfcc5cbb419ea1'
[    1.818468] Loaded X.509 cert 'Debian Secure Boot Signer 2022 - linux: 14011249c2675ea8e5148542202005810584b25f'
[    1.828651] zswap: loaded using pool lzo/zbud
[    1.832845] Key type .fscrypt registered
[    1.835646] Key type fscrypt-provisioning registered
[    1.843752] Key type encrypted registered
[    1.846419] AppArmor: AppArmor sha1 policy hashing enabled
[    1.849104] ima: No TPM chip found, activating TPM-bypass!
[    1.851763] ima: Allocated hash algorithm: sha256
[    1.854437] ima: No architecture policies found
[    1.857083] evm: Initialising EVM extended attributes:
[    1.859595] evm: security.selinux
[    1.862015] evm: security.SMACK64 (disabled)
[    1.864414] evm: security.SMACK64EXEC (disabled)
[    1.866750] evm: security.SMACK64TRANSMUTE (disabled)
[    1.869071] evm: security.SMACK64MMAP (disabled)
[    1.871375] evm: security.apparmor
[    1.873623] evm: security.ima
[    1.875816] evm: security.capability
[    1.877955] evm: HMAC attrs: 0x1
[    3.652817] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 114, base_baud = 0) is a PL011 rev2
[    4.741647] printk: console [ttyAMA0] enabled
[    4.750835] raspberrypi-firmware soc:firmware: Attached to firmware from 2022-08-26T14:04:36
[    4.774274] Waiting for root device /dev/mmcblk0p2...

Et je reste coincé là…

Si je remplace dans le fichier /boot/firmware/cmdline.txt :

root=/dev/mmcblk0p2

par

root=PARTUUID="3515804e-02"

j’ai le même problème :

[    4.792483] Waiting for root device PARTUUID="3515804e-02"...

Quelqu’un sait ce qui ne va pas ?

Dans les logs du noyau, j’ai ça :

[    0.254203] Trying to unpack rootfs image as initramfs...
[    0.254295] Initramfs unpacking failed: invalid magic at start of compressed archive

À priori, le noyau n’arrive pas à exploiter le initramfs

Après des heures à me prendre la tête sur le problème, j’ai décidé de tester mon installation non plus sous bookworm mais sous trixie et ÇA MARCHE !!! :smiley: :smiley: :smiley:

Il doit y avoir un bug quelque part avec bookworm

Donc la paquet raspi-firmware fonctionne correctement sous trixie.
Et il faut passer le paramètre

console=serial0,115200

dans /boot/firmware/cmdline.txt pour avoir la console UART.

Bonjour LS, le meilleur moyen de créer sa propre distri est de loin LFS