@@ -8,8 +8,8 @@ which uses the Mobile Adapter to connect to
8
8
the web to download mini-games onto the local flash. Both ROM banks and
9
9
both RAM banks are views into the same ROM and RAM, but with separately
10
10
adjustable offsets. Since the banked regions are smaller the effective
11
- number of banks is twice what it usually would be; 8 kB ROM banks
12
- instead of 16 kB and 4 kB RAM banks instead of 8 kB .
11
+ number of banks is twice what it usually would be; 8 KiB ROM banks
12
+ instead of 16 KiB and 4 KiB RAM banks instead of 8 KiB .
13
13
14
14
## Memory
15
15
@@ -97,35 +97,68 @@ The commands and access sequences are as follows, were X refers to
97
97
either 4 or 6 and Y to 5 or 7, depending on the bank region:
98
98
99
99
```
100
- ------------- ------------- ------------- ------------- ------------- ------------- ------------------------------------------------
101
- 2:Y555=$AA 1:XAAA=$55 2:Y555=$80 2:Y555=$AA 1:XAAA=$55 ?:X000=$30 Erase sector\* (set 8 kB region to $FFs)
102
- 2:Y555=$AA 1:XAAA=$55 2:Y555=$80 2:Y555=$AA 1:XAAA=$55 ?:Y555=$10 Erase chip\* (set entire flash to $FFs)
103
- 2:Y555=$AA 1:XAAA=$55 2:Y555=$90 ID mode (reads out JEDEC ID (C2,81) at $X000)
104
- 2:Y555=$AA 1:XAAA=$55 2:Y555=$A0 Program mode\*
105
- 2:Y555=$AA 1:XAAA=$55 2:Y555=$F0 Exit ID/erase chip mode
106
- 2:Y555=$AA 1:XAAA=$55 ?:X000=$F0 Exit erase sector mode
107
- ?:????=$F0 Exit program mode
108
- ------------- ------------- ------------- ------------- ------------- ------------- ------------------------------------------------
100
+ ------------- ------------- ------------- ------------- ------------- ------------- ---------------------------------------------------
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)
103
+ 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
+ 2:Y555=$AA 1:XAAA=$55 2:Y555=$90 ID mode (reads out JEDEC ID (C2,81) at $XXX0,$XXX1)
105
+ 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*
107
+ 2:Y555=$AA 1:XAAA=$55 2:Y555=$60 2:Y555=$AA 1:XAAA=$55 2:Y555=$E0 Program mode for hidden region*
108
+ 2:Y555=$AA 1:XAAA=$55 2:Y555=$60 2:Y555=$AA 1:XAAA=$55 2:Y555=$40 Unprotect sector 0*
109
+ 2:Y555=$AA 1:XAAA=$55 2:Y555=$60 2:Y555=$AA 1:XAAA=$55 2:Y555=$20 Protect sector 0*
110
+ ?:????=$F0 Exit any of the commands above
111
+ ------------- ------------- ------------- ------------- ------------- ------------- ---------------------------------------------------
109
112
```
110
113
111
114
Commands marked with \* require the Write Enable bit to be 1. These will
112
115
make the flash read out status bytes instead of values. A status of $80
113
116
means the operation has finished and you should exit the mode using the
114
- appropriate command. A status of $10 indicates a timeout.
117
+ $F0 command. A status of $10 indicates a timeout.
115
118
116
- Programming must be done by first erasing a sector, activating write
117
- mode, writing out 128 bytes (aligned), then writing a 0 to the final
118
- address to commit the write, waiting for the status to indicate
119
- completion, and writing $F0 to the final address again to exit program
120
- mode. If a sector is not erased first programming will not work
119
+ Programming must be done by first erasing a sector, activating program
120
+ mode, writing out 128 bytes (aligned), then writing any value (except
121
+ $F0) to the final address again to commit the write, waiting for the
122
+ status to indicate completion, and writing $F0 to any address to exit
123
+ program mode. If a sector is not erased first, programming will not work
121
124
properly. In some cases it will only allow the stored bytes to be anded
122
125
instead of replaced; in others it just won't work at all. The only way
123
126
to set the bits back to 1 is to erase the sector entirely. It is
124
127
recommended to check the flash to make sure all bytes were written
125
128
properly and re-write (without erasing) the 128 byte block if some bits
126
- didn't get set to 0 properly. After writing all blocks in a sector
129
+ didn't get set to 0 properly. After writing all blocks in a sector,
127
130
Flash Write Enable should be set to 0.
128
131
132
+ In addition to the 1 MiB, the flash has a hidden 256 byte region that can
133
+ be made accessible by the read hidden region command.
134
+
135
+ Erasing and programming the hidden 256 byte region works the same as for
136
+ the "main" flash, just use the dedicated commands instead. It also needs
137
+ to be programmed in 128 byte chunks, so the program hidden region command
138
+ needs to be used twice to program the whole 256 bytes.
139
+
140
+ The last byte of the erase sector command needs to be written to an
141
+ address that lies within the sector that you want to erase. There are
142
+ eight sectors, 128 KiB each. E.g., to erase sector 2, the last
143
+ byte ($30) has to be written to address $40000. The bank number for
144
+ that address can be calculated like this: 2 \* 16, where 2 is the sector
145
+ number. Therefore, for erasing sector 2, before writing the last byte
146
+ ($30), write 32 to $2000 to select the bank, and then write $30 to
147
+ $4000 or any other address between $4000-$5FFF, the lower address bits
148
+ are not relevant.
149
+
150
+ The erase chip command erases the whole 1 MiB flash. The 256 byte hidden
151
+ region is ** not** erased by the erase chip command. If sector 0 is
152
+ protected, only sectors 1 to 7 are erased.
153
+
154
+ 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.
157
+
129
158
## External links
130
159
131
160
- Source: [ GBDev Forums thread by endrift] ( http://gbdev.gg8.se/forums/viewtopic.php?id=544 )
161
+ - Reference: [ Nintendo Power Game Boy Memory cartridge documentation] ( http://iceboy.a-singer.de/doc/np_gb_memory.html )
162
+ * The NP GB Memory cartridges use a nearly identical flash chip.
163
+ It seemingly only slightly differs in its part number. Therefore,
164
+ the part about the flash chip also applies to Net de Get.
0 commit comments