spi_nor_otp_read_secr(9)
π spi_nor_otp_read_secr(9) β the Kernel API Manual, bestie edition π
okay so this is spi_nor_otp_read_secr from the Kernel API Manual and she is lowkey iconic β she reads a security register for you, no cap β¨
β¨ NAME β¨
spi_nor_otp_read_secr β read security register π¦
πΈ SYNOPSIS πΈ
int spi_nor_otp_read_secr (struct spi_nor *nor , loff_t addr , size_t
len , u8 *buf );
literally that's the whole signature, copy it exactly pls π
π ARGUMENTS π
norβ pointer tostruct spi_nor, the main character of this whole operation πaddrβ the offset to read from, i.e. where the tea is located πlenβ number of bytes to read, so like how much tea you're grabbing π«Άbufβ pointer to dst buffer, the lil basket where your bytes go π
π§ DESCRIPTION π§
So here's the vibe: this reads a security register by using the SPINOR_OP_RSECR commands. That's it, that's the job β¨
Now for the lore: in Winbond/GigaDevice datasheets the term "security register" stands for an one-time-programmable memory area, consisting of multiple bytes (usually 256). So one "security register" maps to one OTP region. iykyk π
This method is used on GigaDevice and Winbond flashes. Only those two, fr fr π₯
β οΈ Please note, the read must not span multiple registers. Like, do not do that. Respect the boundaries bestie π
π RETURN π
number of bytes read successfully, -errno otherwise π β so you either get your byte count or you get told off with an error code, there is no third option π
β SEE ALSO β
Kernel file ./drivers/mtd/spi-nor/otp.c β go read the source, she's right there π¦
spi_nor_otp_write_secr(9)spi_nor_otp_erase_secr(9)spi_nor_otp_lock_sr2(9)spi_nor_otp_is_locked_sr2(9)
the whole OTP friend group honestly, obsessed with them π
and that's the page!! brought to you by the fine folks over at ./drivers/mtd/spi-nor, dated October 2026 β mwah, love u, go read ur security registers responsibly π§ββοΈπ
πΈ
π¦ 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