From 94dddcd420bff7b49b59e043259d1b13de7af8ea Mon Sep 17 00:00:00 2001 From: Peter van der Perk Date: Fri, 2 Oct 2026 11:25:47 +0200 Subject: [PATCH] fix(fmu-v6xrt): correct the MX25UM51345G read status dummy cycles The datasheet gives RDSR four dummy cycles in both STR and DTR OPI. FlexSPI counts DDR dummy cycles in half cycles, so the operand has to be 0x08; 0x04 programmed only two cycles. The ROM issues status reads at the low IP command clock, where two cycles still read back, so this was latent rather than a live failure. All three fmu-v6xrt boards carried the same value. Also describe the config: the part number it is for, the setup command the boot ROM runs, and the rules the part puts on the sequences. The command extension here is the inverted opcode, unlike the ISSI part which ignores it. Signed-off-by: Peter van der Perk --- .../fmu-v6xrt/src/imxrt_flexspi_nor_flash.c | 4 +-- .../fmu-v6xrt/src/imxrt_flexspi_nor_flash.c | 4 +-- .../fmu-v6xrt/src/imxrt_flexspi_nor_flash.c | 30 ++++++++++++++----- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/boards/agam/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c b/boards/agam/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c index 6f126257249..2c051acfbea 100644 --- a/boards/agam/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c +++ b/boards/agam/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c @@ -110,9 +110,9 @@ const struct flexspi_nor_config_s g_flash_fast_config = { [0 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, DUMMY_DDR, FLEXSPI_8PAD, 0x28),//0xb3288b20, [0 + 2] = FLEXSPI_LUT_SEQ(READ_DDR, FLEXSPI_8PAD, 0x04, STOP_EXE, FLEXSPI_1PAD, 0x00), //0xa704, - /* Read status */ + /* Read status, 4-byte address, 4 dummy cycles (2N in DDR mode) */ [4 * 2 + 0] = FLEXSPI_LUT_SEQ(CMD_DDR, FLEXSPI_8PAD, 0x05, CMD_DDR, FLEXSPI_8PAD, 0xfa), - [4 * 2 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, DUMMY_DDR, FLEXSPI_8PAD, 0x04), + [4 * 2 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, DUMMY_DDR, FLEXSPI_8PAD, 0x08), [4 * 2 + 2] = FLEXSPI_LUT_SEQ(READ_DDR, FLEXSPI_8PAD, 0x04, STOP_EXE, FLEXSPI_1PAD, 0x00), /* Write enable SPI *///06h diff --git a/boards/ark/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c b/boards/ark/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c index dc210966169..a21c4999df4 100644 --- a/boards/ark/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c +++ b/boards/ark/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c @@ -110,9 +110,9 @@ const struct flexspi_nor_config_s g_flash_fast_config = { [0 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, DUMMY_DDR, FLEXSPI_8PAD, 0x28),//0xb3288b20, [0 + 2] = FLEXSPI_LUT_SEQ(READ_DDR, FLEXSPI_8PAD, 0x04, STOP_EXE, FLEXSPI_1PAD, 0x00), //0xa704, - /* Read status */ + /* Read status, 4-byte address, 4 dummy cycles (2N in DDR mode) */ [4 * 2 + 0] = FLEXSPI_LUT_SEQ(CMD_DDR, FLEXSPI_8PAD, 0x05, CMD_DDR, FLEXSPI_8PAD, 0xfa), - [4 * 2 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, DUMMY_DDR, FLEXSPI_8PAD, 0x04), + [4 * 2 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, DUMMY_DDR, FLEXSPI_8PAD, 0x08), [4 * 2 + 2] = FLEXSPI_LUT_SEQ(READ_DDR, FLEXSPI_8PAD, 0x04, STOP_EXE, FLEXSPI_1PAD, 0x00), /* Write enable SPI *///06h diff --git a/boards/px4/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c b/boards/px4/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c index a137cc4d7d3..ac49d57b02d 100644 --- a/boards/px4/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c +++ b/boards/px4/fmu-v6xrt/src/imxrt_flexspi_nor_flash.c @@ -72,6 +72,22 @@ const struct flexspi_nor_config_s g_flash_config = { .reserve2[0] = 0x7008200, }; +/* Macronix MX25UM51345G, 512 Mb, run at 200 MHz in octal DTR (8D-8D-8D). + * + * The flash powers up in 1-pad SPI, so the boot ROM runs one setup command + * from this config: sequence 6 writes configuration register 2 at address 0 + * with value 2, which switches the flash to octal DTR. The dummy cycles need + * no command, the default of 20 already allows 200 MHz. + * + * Rules this part puts on the octal DTR sequences below: + * + * - a second command byte must follow the opcode (the command extension). + * This part wants the inverted opcode, so 0xEE sends 0x11. + * - an address is always 4 bytes. + * - FlexSPI counts dummy cycles in half cycles, so the operand is twice the + * number of cycles the datasheet asks for. + */ + const struct flexspi_nor_config_s g_flash_fast_config = { .memConfig = { @@ -110,27 +126,27 @@ const struct flexspi_nor_config_s g_flash_fast_config = { [0 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, DUMMY_DDR, FLEXSPI_8PAD, 0x28),//0xb3288b20, [0 + 2] = FLEXSPI_LUT_SEQ(READ_DDR, FLEXSPI_8PAD, 0x04, STOP_EXE, FLEXSPI_1PAD, 0x00), //0xa704, - /* Read status */ + /* Read status (0x05) in octal DTR, 4-byte address, 4 dummy cycles */ [4 * 2 + 0] = FLEXSPI_LUT_SEQ(CMD_DDR, FLEXSPI_8PAD, 0x05, CMD_DDR, FLEXSPI_8PAD, 0xfa), - [4 * 2 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, DUMMY_DDR, FLEXSPI_8PAD, 0x04), + [4 * 2 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, DUMMY_DDR, FLEXSPI_8PAD, 0x08), [4 * 2 + 2] = FLEXSPI_LUT_SEQ(READ_DDR, FLEXSPI_8PAD, 0x04, STOP_EXE, FLEXSPI_1PAD, 0x00), - /* Write enable SPI *///06h + /* Write enable (0x06) in SPI */ [4 * 3 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06, STOP_EXE, FLEXSPI_1PAD, 0x00),//0x00000406, - /* Write enable OPI SPI *///06h + /* Write enable (0x06) in octal DTR */ [4 * 4 + 0] = FLEXSPI_LUT_SEQ(CMD_DDR, FLEXSPI_8PAD, 0x06, CMD_DDR, FLEXSPI_8PAD, 0xF9), - /* Erase sector */ + /* Erase 4 KB sector (0x21) */ [4 * 5 + 0] = FLEXSPI_LUT_SEQ(CMD_DDR, FLEXSPI_8PAD, 0x21, CMD_DDR, FLEXSPI_8PAD, 0xDE), [4 * 5 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, STOP_EXE, FLEXSPI_1PAD, 0x00), - /*Write Configuration Register 2 =01, Enable OPI DDR mode*/ //72H +32bit address + CR20x00000000 = 0x01 + /* Write configuration register 2 (0x72) at address 0: switch SPI to octal DTR */ [4 * 6 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x72, CMD_SDR, FLEXSPI_1PAD, 0x00),//0x04000472, [4 * 6 + 1] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x00, CMD_SDR, FLEXSPI_1PAD, 0x00),//0x04000400, [4 * 6 + 2] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x00, WRITE_SDR, FLEXSPI_1PAD, 0x01),//0x20010400, - /*Page program*/ + /* Page program (0x12) */ [4 * 9 + 0] = FLEXSPI_LUT_SEQ(CMD_DDR, FLEXSPI_8PAD, 0x12, CMD_DDR, FLEXSPI_8PAD, 0xED),//0x87ed8712, [4 * 9 + 1] = FLEXSPI_LUT_SEQ(RADDR_DDR, FLEXSPI_8PAD, 0x20, WRITE_DDR, FLEXSPI_8PAD, 0x04),//0xa3048b20, },