Cannot write to Micron NOR flash
I’m trying to write data to the [MT25QL512ABB NOR flash](https://media-www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/mt25q/die-rev-b/mt25q_qlkt_l_512_abb_0.pdf?rev=0ef0faa5f7b645d7bc11c30bfd27505b) using an STM32H7 chip, but the flash keeps returning a PROGRAM error and the write does not go through.
I am using the command 0x34, the 4-BYTE QUAD INPUT FAST PROGRAM command. I am then polling the flag status register after issuing the command, which returns a value of 0x91 on the flag status register. This means that the PROGRAM error bit is set, indicating the program command was not successful, and indeed this is verified by reading from the flash chip.
The specifics of the 0x34 command are as follows:
CMD: 0x34
ADDRESS: 0x00004400 (4-byte address mode)
DATA: 128 bytes, numbers 0x00 - 0x7F
Here’s a screenshot of the command as well as the first four data bytes. The command is issued in quad mode:

After the data bytes are sent, the status and flag status registers are then polled.
It takes about 4.2 milliseconds for the status register to go from 0x03 to 0x00 and for the flag status register to go from 0x01 to 0x91. Here’s a screenshot of that:

You’ll notice I read each of the registers twice, this is because the STM32 cannot go from writing to reading without 1 dummy cycle in between. So I read these registers twice and take the second reading as correct (in this case the two reads were identical, but this is not always the case). The datasheet indicates these registers can be read continuously. Though I only read them twice before re-issuing the command (so I can switch between reading the status and flag status registers).
Prior to this 0x34 command I have done the following:
Written (and verified) these values to the configuration registers:
- volatile configuration: 0xFB (default dummy cycles, no XIP, no wrap)
- enhanced volatile configuration: 0x2F (quad mode, STR, no RESET# on DQ3)
- status register: 0x02 (activated by calling the WRITE ENABLE COMMAND: 0x06)
- Cleared the flag status register of error bits (using 0x50 command)
I have also verified that all volatile lock bits are set to 0. The nonvolatile lock bits are set to 1 for every address, the global freeze bit is 1, and the sector protection register is 0xFFFF.
But the error bit for sector protection on the flag register (bit 1) is not set anyway, which I assume means this error is not caused by misconfigured sector protection.
I can’t figure out why this 0x34 command causes a PROGRAM error and refuses to write to the flash.
