STRUCT UBI_EC_HDR(9)
π NAME π
struct ubi_ec_hdr β the UBI erase counter header, bestie. (Also hi, welcome to the Kernel API Manual β¨ this is your girl explaining kernel structs in the group chat, you're welcome.)
β¨ SYNOPSIS β¨
struct ubi_ec_hdr {
__be32 magic;
__u8 version;
__u8 padding1[3];
__be64 ec;
__be32 vid_hdr_offset;
__be32 data_offset;
__be32 image_seq;
__u8 padding2[32];
__be32 hdr_crc;
};
π Members π
magicβ the erase counter header magic number (UBI_EC_HDR_MAGIC). It's giving "hello, I am definitely a UBI erase counter header" β¨versionβ the version of the UBI implementation that's supposed to accept this UBI image, iykyk.padding1β reserved for future, zeroes. Just vibing there empty π«Άecβ the erase counter. Main character energy, honestly.vid_hdr_offsetβ where the VID header starts.data_offsetβ where the user data start.image_seqβ the image sequence number.padding2β reserved for future, zeroes. Again, just filling space πhdr_crcβ the erase counter header CRC checksum.
π Description π
Okay so the erase counter header takes 64 bytes and has a plenty of unused space for future usage. The unused fields are zeroed β no notes, just zeroes.
The version field is used to indicate the version of the UBI implementation which is supposed to be able to work with this UBI image. And here's the important bit: if version is greater than the current UBI version, the image is rejected. π« That may be useful in the future if something is changed radically. This field is duplicated in the volume identifier header too (yes, it said it twice, it means it).
The vid_hdr_offset and data_offset fields contain the offset of the volume identifier header and user data, relative to the beginning of the physical eraseblock. These values have to be the same for all physical eraseblocks β no cap, consistency is the vibe check.
The image_seq field is used to validate a UBI image that has been prepared for a UBI device. The image_seq value can be any value, but it must be the same on all eraseblocks. UBI will ensure that all new erase counter headers also contain this value, and will check the value when attaching the flash. One way to make use of image_seq is to increase its value by one every time an image is flashed over an existing image β then, if the flashing does not complete, UBI will detect the error when attaching the media. Honestly? Detective work. Obsessed. ππ
π¦ SEE ALSO π¦
Kernel file ./drivers/mtd/ubi/ubi-media.h, plus the whole friend group: struct ubi_vid_hdr(9), struct ubi_vtbl_record(9), struct ubi_fm_sb(9), struct ubi_fm_hdr(9), struct ubi_fm_scan_pool(9), struct ubi_fm_ec(9), struct ubi_fm_volhdr(9), struct ubi_fm_eba(9) π
okay that's the whole page, you ate that π this little number was served to you straight from ./drivers/mtd/ubi, and it's the October 2026 edition β mwah, go read the headers bestie, periodt πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms