6 .BI "bind -a #F" \fR[\fPn\fR]\fP " /dev"
10 .BI /dev/flash/ part ctl
13 The flash memory device serves a two-level directory,
14 giving access to files representing part or all of a bank of flash memory.
15 A platform might have more than one bank of flash, numbered starting from 0.
18 is a decimal integer that selects a particular bank of flash (default: 0).
19 Both NOR and NAND flash is supported.
20 For both types of flash,
21 the driver gives a read/write/erase interface to the raw flash device,
22 which can impose constraints on operations beyond those imposed by the driver.
24 The top level directory contains a single directory named
30 It contains two files for each partition:
33 and an associated control file
37 is the name of the partition.
38 Each partition represents a region of flash memory that starts and ends
39 on a flash segment (erase unit) boundary.
40 The system initially creates a single standard partition
42 representing the whole of flash memory, and the corresponding control file
44 Other partitions can be created by writing to
50 provides read and write access to the bytes on the system's flash memory.
51 Bytes can be read and written on any byte boundary:
52 the interface hides any alignment restrictions.
53 A read returns the value of the bytes at the current file offset,
54 where zero is the start of the partition.
55 A write reprograms the flash to the given byte values, at the current
56 file offset (relative to the start of the partition), using the physical
57 device's reprogramming algorithm.
58 An erased flash byte is logically
60 (regardless of the conventions of the physical flash device).
61 A write can change a bit with value 1 to a 0,
62 but cannot change a 0 bit to 1;
63 that can only be done by erasing one or more flash segments.
64 NAND flash typically has restrictions on the number of writes
65 allowed to a page before requiring a block erase.
67 .\" Reads and writes are unbuffered.
71 can be read and written.
72 A read returns several lines containing decimal and hexadecimal numbers
73 (separated by white space)
74 revealing the characteristics of memory within the partition.
76 the manufacturer ID, the flash device ID, the memory width in bytes,
77 and a string giving the flash type
82 Subsequent lines give characteristics of each group of erase units
84 where the erase units within a group have the same properties.
85 Each line gives the start and end (as byte addresses)
86 of the erase units in the region
87 that lie within the partition,
88 followed by the size in bytes of each erase unit, which is followed
89 for NAND flash by the size in bytes of a page.
90 The sizes for NAND flash include the extra bytes per page
91 typically used to hold an ECC and block status.
92 A write contains one of the following textual commands:
95 .BI add " name start end"
96 Create a new partition that ranges from
100 within the current partition.
101 Each value must be numeric (decimal, octal or hexadecimal)
102 and a multiple of the erase unit size.
104 must not be the name of an existing partition.
105 On success, new files
109 will appear in the parent
114 Erase the whole flash partition, setting all bytes to
116 except those that are hardware write-protected.
119 Erase the segment that begins at the given
121 within the partition,
124 except those that are hardware write-protected.
127 is given in bytes, but must be a multiple
128 of the segment (erase unit) size.
130 .BR protectboot " [ " off " ]"
131 By default the system prevents erase unit 0 of the flash from being
132 erased or written, assuming it
133 contains the primary bootstrap.
134 Writing this command with parameter
136 removes that protection.
139 with any other parameter (or none) restores the protection.
140 Note that a manufacturer might also have locked the flash in hardware,
141 and that protection must be removed in a device-dependent way.
144 If the underlying device must buffer or cache (current devices do not),
148 The syntax of all numbers is that of
152 the default base is 10.
154 .B /sys/src/9/*/devflash.c
159 A write will return an error if
160 an attempt is made to change a 0 bit to 1,
161 or if the flash memory fails to be programmed correctly.
163 The flash cannot be written if the kernel is executing directly from flash,
164 because the physical flash cannot be read during programming,
165 and the driver does not copy the programming code to DRAM.