Implement use_global_block_protection_lock for write-enabling flash.
Fix mis-placed conditional in circuitpy_mpconfig.h.
This commit is contained in:
parent
361e0eb51c
commit
7012deb3e7
6 changed files with 14 additions and 4 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 6b678f15e378edce820f2ffdef3286b3e55449e7
|
||||
Subproject commit 134051e3337df1f4cfaea8665bbfaa93c5dc4dbb
|
||||
|
|
@ -344,6 +344,7 @@ typedef long mp_off_t;
|
|||
#define CIRCUITPY_CONSOLE_UART (1)
|
||||
#ifndef CIRCUITPY_CONSOLE_UART_BAUDRATE
|
||||
#define CIRCUITPY_CONSOLE_UART_BAUDRATE (115200)
|
||||
#endif
|
||||
#if !defined(CIRCUITPY_CONSOLE_UART_PRINTF)
|
||||
#define CIRCUITPY_CONSOLE_UART_PRINTF(...) mp_printf(&console_uart_print, __VA_ARGS__)
|
||||
#endif
|
||||
|
|
@ -353,7 +354,6 @@ typedef long mp_off_t;
|
|||
#if !defined(CIRCUITPY_CONSOLE_UART_TIMESTAMP)
|
||||
#define CIRCUITPY_CONSOLE_UART_TIMESTAMP (0)
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define CIRCUITPY_CONSOLE_UART (0)
|
||||
#define CIRCUITPY_CONSOLE_UART_PRINTF(...) (void)0
|
||||
|
|
|
|||
|
|
@ -23,3 +23,4 @@
|
|||
#define CMD_ENABLE_RESET 0x66
|
||||
#define CMD_RESET 0x99
|
||||
#define CMD_WAKE 0xab
|
||||
#define CMD_GLOBAL_BLOCK_PROTECTION_UNLOCK 0x98
|
||||
|
|
|
|||
|
|
@ -24,8 +24,12 @@ typedef struct {
|
|||
// status register.
|
||||
uint8_t quad_enable_bit_mask;
|
||||
|
||||
// Device has sector-level write protection
|
||||
bool has_sector_protection : 1;
|
||||
|
||||
// Device uses global block protection lock instead of status register bits to enable sector writes
|
||||
bool use_global_block_protection_lock : 1;
|
||||
|
||||
// Supports the 0x0b fast read command with 8 dummy cycles.
|
||||
bool supports_fast_read : 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
.max_clock_speed_mhz = {{ device.max_clock_speed_mhz }}, \
|
||||
.quad_enable_bit_mask = {{ device.quad_enable_bit_mask }}, \
|
||||
.has_sector_protection = {{ device.has_sector_protection | lower() }}, \
|
||||
.use_global_block_protection_lock = {{ device.use_global_block_protection_lock | lower() }}, \
|
||||
.supports_fast_read = {{ device.supports_fast_read | lower() }}, \
|
||||
.supports_qspi = {{ device["6b_quad_read"] | lower() }}, \
|
||||
.supports_qspi_writes = {{ device["32_qspi_write"] | lower() }}, \
|
||||
|
|
|
|||
|
|
@ -268,9 +268,13 @@ void supervisor_flash_init(void) {
|
|||
write_enable();
|
||||
|
||||
// Turn off sector protection
|
||||
if (flash_device->use_global_block_protection_lock) {
|
||||
spi_flash_command(CMD_GLOBAL_BLOCK_PROTECTION_UNLOCK);
|
||||
} else {
|
||||
uint8_t data[1] = {0x00};
|
||||
spi_flash_write_command(CMD_WRITE_STATUS_BYTE1, data, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Turn off writes in case this is a microcontroller only reset.
|
||||
spi_flash_command(CMD_DISABLE_WRITE);
|
||||
|
|
|
|||
Loading…
Reference in a new issue