muxed FSMC in STM32F407vet6 through HAL for NOR flash memory write operations issue HAL
I'm trying to set up FSMC in muxed mode to read_write external NOR flash devices. Muxed pins goes through 2 8-bit latches 74HC574D.
The problem is that currently i can barely read from external NOR and it's not accepting commands.
Firstly HAL_NOR_Init(&hnor1, &Timing, NULL) returns HALL_ERR since it fails to read CommandSet from NOR. It should read address 0x13 from CFI and get 0x02 or 0x01 as a result, but write commad makes no effect and as a result driver reads at 0x13 from memopry start.
After analyzing what's going on on the FSMC bus I still cand fing any clues. Here is an example how it performs ReadID sequence, using standard HAL_NOR_ReadID

Everything looks correct, 3 sequences 0x555 - >0xAA, 0x2AA -> 0x55 and 0x555 -> 0x90, but reading 0x00 and 0x01 right after returns data from NOR not the deviceID
I've also tried bitbang mode with same pins and code below successfully reads deviceID. So after all it's not a witing problem, but maby timings or some FSMC setting
HAL_StatusTypeDef NOR_ReadID_Manual(uint16_t* manufacturer, uint16_t* device) {
if (!manufacturer || !device) return HAL_ERROR;
NOR_Manual_Init();
write_nor(0x0000, 0xF0);
write_nor(0x555 * 2, 0x00AA);
write_nor(0x2AA * 2, 0x0055);
write_nor(0x555 * 2, 0x0090);
*manufacturer = read_nor(0x00 * 2);
*device = read_nor(0x01 * 2);
// Reset
write_nor(0x0000, 0xF0);
return HAL_OK;
}

I've tried different timings but it has no effect. Currently it runs on 21Mhz
With such init settings:
/** Perform the NOR1 memory initialization sequence
*/
hnor1.Instance = FSMC_NORSRAM_DEVICE;
hnor1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
/* hnor1.Init */
hnor1.Init.NSBank = FSMC_NORSRAM_BANK1;
hnor1.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_ENABLE;
hnor1.Init.MemoryType = FSMC_MEMORY_TYPE_NOR;
hnor1.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16;
hnor1.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE;
hnor1.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;
hnor1.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;
hnor1.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS;
hnor1.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE;
hnor1.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE;
hnor1.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE;
hnor1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
hnor1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
hnor1.Init.PageSize = FSMC_PAGE_SIZE_NONE;
/* Timing */
Timing.AddressSetupTime = 4;
Timing.AddressHoldTime = 3;
Timing.DataSetupTime = 6;
Timing.BusTurnAroundDuration = 2;
Timing.CLKDivision = 16;
Timing.DataLatency = 17;
Timing.AccessMode = FSMC_ACCESS_MODE_A;
/* ExtTiming */