Linux explorations: flash memory (1) My current task is about flash memories, and certain operations about flash memory security. I'll have to build up some knowledge before being able to carry it on, and such knowledge involves implementation details of the Linux kernel. As I've done before, I'll track my progress here, marking useful (or seemingly useful) links along the way, maybe starting with some focus music. https://www.youtube.com/embed/eCs8LT290a4 1. User-space standpoint 2. A few Wikipedia pages 3. Linux docs: MTD, NOR and NAND == 1. User-space standpoint https://www.coresecurity.com/core-labs/articles/linux-flash-newbies-how-linux-works-flash It is possible to emulate flash in RAM to do testing: nandsim (kernel module) Besides using dd(1) on /dev/mtdX, there are many higher level tools available, to write flash, dump it, and then some (see mtd-utils). /dev/mtdblockX, crude abstraction to present flash as block device. Even small writes might erase a whole erase-block, which might wear the flash memory. * Using romfs: - genromfs(8) to generate read-only image from a directory - flash_erase to clean /dev/mtdX - nandwrite to write generated rom image to /dev/mtdX - mount(8) /dev/mtdblockX, specifying romfs as type. It is readonly. * Using jffs2: - mkfs.jffs2(1) can generate a filesystem image. The image is flash aware (e.g parametrised with the correct erase block size will behave better) Thoughts: - Using a plain dd(1) probably works on the regular 'read' callback of the driver as I imagine it. TODO: verify what's the difference with nanddump, for instance. == 2. A few Wikipedia pages https://en.wikipedia.org/wiki/Memory_Technology_Device https://en.wikipedia.org/wiki/JFFS2 https://en.wikipedia.org/wiki/YAFFS And more filesystem exist. Which ones are the most popular and why? == 3. Linux docs: MTD, NOR and NAND MTD = Memory Technology Device https://www.kernel.org/doc/html/latest/driver-api/mtd/ https://www.kernel.org/doc/html/latest/driver-api/mtd/spi-nor.html The kernel docs are not very structured, and quite hard to follow. I'm not sure what I'm reading about. Probably a better bet for tomorrow. http://www.linux-mtd.infradead.org/doc/general.html