File
Blob: scripts/music_partition.py
| 1 | """Validate the music allocation before a music-only update.""" |
| 2 | import struct |
| 3 | |
| 4 | MUSIC_OFFSET = 0x410000 |
| 5 | MUSIC_BYTES = 16 * 1024 * 1024 |
| 6 | |
| 7 | |
| 8 | def require_music_partition(table): |
| 9 | found = [] |
| 10 | for offset in range(0, min(len(table), 0xC00), 32): |
| 11 | entry = table[offset:offset + 32] |
| 12 | if len(entry) != 32 or entry[:2] != b"\xaa\x50": |
| 13 | break |
| 14 | magic, kind, subtype, address, size, label, flags = struct.unpack('<HBBII16sI', entry) |
| 15 | if label.rstrip(b'\0') == b'music': |
| 16 | found.append((kind, subtype, address, size, flags)) |
| 17 | if found != [(1, 0x40, MUSIC_OFFSET, MUSIC_BYTES, 0)]: |
| 18 | raise ValueError("Install the 16 MiB partition layout with make flash before using make flash-music.") |