@@ -55,16 +55,20 @@ Select the active RAM Bank B (B000-BFFF)
55
55
### 0C00-0FFF — Flash Enable (Write Only)
56
56
57
57
Enable or disable access to the flash chip. Only the lowest bit (0 for
58
- disable, 1 for enable) is used. Flash Write Enable must be active to
59
- change this .
58
+ disable, 1 for enable) is used. If disabled, then the /CE (chip enable)
59
+ signal from the MBC6 chip to the flash will stay disabled .
60
60
61
61
### 1000 — Flash Write Enable (Write Only)
62
62
63
- Enable or disable write mode for the flash chip. Only the lowest bit (0
64
- for disable, 1 for enable) is used. Note that this maps to the /WE pin
65
- on the flash chip, not whether writing to the bus is enabled;
66
- some flash commands (e.g. JEDEC ID query) still work with this off so
67
- long as Flash Enable is on.
63
+ Enable or disable write mode for flash sector 0 and the hidden region.
64
+ Only the lowest bit (0 for disable, 1 for enable) is used. Note that
65
+ this maps to the /WP pin (write protect) on the flash chip, not whether
66
+ writing to the bus is enabled; most flash commands still work with this
67
+ off so long as Flash Enable is on (see table below). If this register
68
+ is set to 0 (disabled), which is the default value after power up, then
69
+ neither flash sector 0 nor the hidden flash region can be erased or
70
+ programmed. Flash sectors 1 to 7 are not affected by this and can
71
+ always be erased and programmed as long as Flash Enable is on.
68
72
69
73
### 2000-27FF — ROM/Flash Bank A Number (Write Only)
70
74
@@ -98,23 +102,26 @@ either 4 or 6 and Y to 5 or 7, depending on the bank region:
98
102
99
103
```
100
104
------------- ------------- ------------- ------------- ------------- ------------- ---------------------------------------------------
101
- 2:Y555=$AA 1:XAAA=$55 2:Y555=$80 2:Y555=$AA 1:XAAA=$55 ?:????=$30 Erase sector* (set 128 KiB region to $FFs)
102
- 2:Y555=$AA 1:XAAA=$55 2:Y555=$80 2:Y555=$AA 1:XAAA=$55 2:Y555=$10 Erase chip* (set entire 1 MiB to $FFs)
105
+ 2:Y555=$AA 1:XAAA=$55 2:Y555=$80 2:Y555=$AA 1:XAAA=$55 ?:????=$30 Erase sector (set 128 KiB region to $FFs)
106
+ 2:Y555=$AA 1:XAAA=$55 2:Y555=$80 2:Y555=$AA 1:XAAA=$55 2:Y555=$10 Erase chip (set entire 1 MiB to $FFs)
103
107
2:Y555=$AA 1:XAAA=$55 2:Y555=$60 2:Y555=$AA 1:XAAA=$55 2:Y555=$04 Erase hidden region* (set hidden 256 bytes to $FFs)
104
108
2:Y555=$AA 1:XAAA=$55 2:Y555=$90 ID mode (reads out JEDEC ID (C2,81) at $XXX0,$XXX1)
105
109
2:Y555=$AA 1:XAAA=$55 2:Y555=$77 2:Y555=$AA 1:XAAA=$55 2:Y555=$77 Read hidden region
106
- 2:Y555=$AA 1:XAAA=$55 2:Y555=$A0 Program mode*
110
+ 2:Y555=$AA 1:XAAA=$55 2:Y555=$A0 Program mode
107
111
2:Y555=$AA 1:XAAA=$55 2:Y555=$60 2:Y555=$AA 1:XAAA=$55 2:Y555=$E0 Program mode for hidden region*
108
112
2:Y555=$AA 1:XAAA=$55 2:Y555=$60 2:Y555=$AA 1:XAAA=$55 2:Y555=$40 Unprotect sector 0*
109
113
2:Y555=$AA 1:XAAA=$55 2:Y555=$60 2:Y555=$AA 1:XAAA=$55 2:Y555=$20 Protect sector 0*
110
114
?:????=$F0 Exit any of the commands above
111
115
------------- ------------- ------------- ------------- ------------- ------------- ---------------------------------------------------
112
116
```
113
117
114
- Commands marked with \* require the Write Enable bit to be 1. These will
115
- make the flash read out status bytes instead of values. A status of $80
116
- means the operation has finished and you should exit the mode using the
117
- $F0 command. A status of $10 indicates a timeout.
118
+ Commands marked with \* require the Flash Write Enable bit to be 1. The
119
+ erase, program and (un-)protect flash commands will make the flash read
120
+ out status bytes instead of values. If status bit 7 is set (mask $80) the
121
+ operation has finished and you should exit the mode using the $F0
122
+ command. Status bit 4 (mask $10) indicates a timeout. Status bit 1 (mask
123
+ $02) is set when the sector 0 protection was enabled by the Protect Sector
124
+ 0 command.
118
125
119
126
Programming must be done by first erasing a sector, activating program
120
127
mode, writing out 128 bytes (aligned), then writing any value (except
@@ -149,11 +156,18 @@ are not relevant.
149
156
150
157
The erase chip command erases the whole 1 MiB flash. The 256 byte hidden
151
158
region is ** not** erased by the erase chip command. If sector 0 is
152
- protected, only sectors 1 to 7 are erased.
159
+ protected, either by the Flash Write Enable bit in MBC6 register 0x1000
160
+ or by the Protect Sector 0 flash command (or both), only sectors 1 to 7
161
+ are erased.
153
162
154
163
Sector 0 (the first 128 KiB of the flash) can be protected from erasure
155
- and programming, using the protect/unprotect sector 0 commands. The state
156
- of the protection is stored non-volatile.
164
+ and programming, using the Protect/Unprotect Sector 0 flash commands.
165
+ The state of the protection is stored non-volatile. This acts as a second
166
+ layer of protection in addition to the Flash Write Enable bit. The Flash
167
+ Write Enable bit protects both, sector 0 and the hidden region. The
168
+ Protect Sector 0 command only protects sector 0. If you want to make sure
169
+ that you can erase and program sector 0, you first have to set the Flash
170
+ Write Enable bit to 1, then issue the Unprotect Sector 0 flash command.
157
171
158
172
## External links
159
173
0 commit comments