partition create writes the wrong extra family count when a partition has two custom family IDs

Aperta Adatta ai principianti
#368 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

@sebxt ci sta già lavorando.

Dal 20/10/2026.

  • #369 di @sebxt — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
cli

Direzione di ricerca

Inizia da partition_create_command::execute e segui il punto in cui viene popolato new_p.extra_families e aggiornato new_p.flags. Riproduci il problema con il JSON fornito usando picotool partition create, poi esamina il risultato con picotool info -a. Il lavoro è completato quando il numero di famiglie aggiuntive è 2 e gli ID di entrambe le famiglie sono elencati senza arresti anomali.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happens

When a partition in the JSON passed to picotool partition create lists exactly two family IDs that are not one of the built in families, the generated partition table says the partition has three extra families. Only two family words are written, so anything that parses the table reads the name length word (or the next partition) as a third family ID. picotool info -a on the generated file crashes with a segmentation fault, and the bootrom would see a malformed table.

One or three custom families are encoded correctly; two are not.

What should happen

The ACCEPTS_NUM_EXTRA_FAMILIES field should be 2 and picotool info should list both families.

Repro (develop at ba3df40, also master at 2041936)

cat > pt.json << 'EOF2'
{
  "version": [1, 0],
  "unpartitioned": {
    "families": ["absolute"],
    "permissions": {"secure": "rw", "nonsecure": "rw", "bootloader": "rw"}
  },
  "partitions": [
    {
      "name": "A",
      "size": "64K",
      "families": ["rp2350-arm-s", "0x12345678", "0x23456789"],
      "permissions": {"secure": "rw", "nonsecure": "rw", "bootloader": "rw"}
    }
  ]
}
EOF2
picotool partition create pt.json pt.bin
picotool info -a pt.bin

partition create exits 0, info -a exits with signal 11. The partition flags word in pt.bin is 0xfc021180; bits 7 and 8 (ACCEPTS_NUM_EXTRA_FAMILIES) are 3.

Root cause

In partition_create_command::execute the count is ORed into new_p.flags inside the loop over families:

new_p.flags |= new_p.extra_families.size() << PICOBIN_PARTITION_FLAGS_ACCEPTS_NUM_EXTRA_FAMILIES_LSB;

With two extra families the field gets 1 and then 2 ORed in, which gives 3. With three it gets 1, 2 and 3, which happens to give 3. The count should be set once, after the loop.

Lingua principale
C++
Stelle
1k
Fork
194
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di raspberrypi/picotool

Tutte le issue di raspberrypi/picotool

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.