Skip to content

Commit 0c85d44

Browse files
author
Cruz Monrreal
authored
Merge pull request #9408 from evva-sfw/feature/SPIF_ULBPR
SPIF - Fix command to unlock Global Block-Protection register
2 parents 5689b05 + f0ec813 commit 0c85d44

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ enum qspif_default_instructions {
9595
QSPIF_RSTEN = 0x66, // Reset Enable
9696
QSPIF_RST = 0x99, // Reset
9797
QSPIF_RDID = 0x9f, // Read Manufacturer and JDEC Device ID
98+
QSPIF_ULBPR = 0x98, // Clears all write-protection bits in the Block-Protection register
9899
};
99100

100101
// Local Function
@@ -204,9 +205,9 @@ int QSPIFBlockDevice::init()
204205
switch (vendor_device_ids[0]) {
205206
case 0xbf:
206207
// SST devices come preset with block protection
207-
// enabled for some regions, issue write disable instruction to clear
208+
// enabled for some regions, issue global protection unlock to clear
208209
_set_write_enable();
209-
_qspi_send_general_command(QSPIF_WRDI, QSPI_NO_ADDRESS_COMMAND, NULL, 0, NULL, 0);
210+
_qspi_send_general_command(QSPIF_ULBPR, QSPI_NO_ADDRESS_COMMAND, NULL, 0, NULL, 0);
210211
break;
211212
}
212213

components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ enum ops {
4040
SPIF_WRDI = 0x04, // Write Disable
4141
SPIF_RDSR = 0x05, // Read Status Register
4242
SPIF_RDID = 0x9f, // Read Manufacturer and JDEC Device ID
43+
SPIF_ULBPR = 0x98, // Clears all write-protection bits in the Block-Protection register
4344
};
4445

4546
// Status register from RDSR
@@ -66,9 +67,9 @@ int SPIFReducedBlockDevice::init()
6667
switch (id[0]) {
6768
case 0xbf:
6869
// SST devices come preset with block protection
69-
// enabled for some regions, issue gbpu instruction to clear
70+
// enabled for some regions, issue global protection unlock to clear
7071
_wren();
71-
_cmdwrite(0x98, 0, 0, 0x0, NULL);
72+
_cmdwrite(SPIF_ULBPR, 0, 0, 0x0, NULL);
7273
break;
7374
}
7475

components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ enum spif_default_instructions {
8888
SPIF_RSTEN = 0x66, // Reset Enable
8989
SPIF_RST = 0x99, // Reset
9090
SPIF_RDID = 0x9f, // Read Manufacturer and JDEC Device ID
91+
SPIF_ULBPR = 0x98, // Clears all write-protection bits in the Block-Protection register
9192
};
9293

9394
// Mutex is used for some SPI Driver commands that must be done sequentially with no other commands in between
@@ -167,9 +168,9 @@ int SPIFBlockDevice::init()
167168
switch (vendor_device_ids[0]) {
168169
case 0xbf:
169170
// SST devices come preset with block protection
170-
// enabled for some regions, issue write disable instruction to clear
171+
// enabled for some regions, issue global protection unlock to clear
171172
_set_write_enable();
172-
_spi_send_general_command(SPIF_WRDI, SPI_NO_ADDRESS_COMMAND, NULL, 0, NULL, 0);
173+
_spi_send_general_command(SPIF_ULBPR, SPI_NO_ADDRESS_COMMAND, NULL, 0, NULL, 0);
173174
break;
174175
}
175176

0 commit comments

Comments
 (0)