diff --git a/src/main/drivers/flash_w25n.c b/src/main/drivers/flash_w25n.c index c23a1bddfbd..8d62537f005 100644 --- a/src/main/drivers/flash_w25n.c +++ b/src/main/drivers/flash_w25n.c @@ -160,7 +160,10 @@ static void w25n_performOneByteCommand(uint8_t command) static void w25n_performCommandWithPageAddress(uint8_t command, uint32_t pageAddress) { - uint8_t cmd[4] = { command, 0, (pageAddress >> 8) & 0xff, (pageAddress >> 0) & 0xff}; + // The 2Gbit devices have 2048 blocks of 64 pages, so their page address needs 17 bits. + // Its most significant bit is the lowest bit of the first address byte, which is a don't + // care on the 1Gbit W25N01GV where the page address never exceeds 16 bits. + uint8_t cmd[4] = { command, (pageAddress >> 16) & 0xff, (pageAddress >> 8) & 0xff, (pageAddress >> 0) & 0xff}; busTransfer(busDev, NULL, cmd, sizeof(cmd)); }