External NAND Flash with ESP32-C3
Posted: Fri Feb 21, 2025 10:27 am
Hello,
I am trying to interface external NAND flash with ESP32c3 board, I have gone through IDF example, but it turns out to be for NOR flash and from online references and going through datasheet the code needs modifications, can anyone help me with it, I am getting following output.
Here's my code for it
Thank you!
I am trying to interface external NAND flash with ESP32c3 board, I have gone through IDF example, but it turns out to be for NOR flash and from online references and going through datasheet the code needs modifications, can anyone help me with it, I am getting following output.
Code: Select all
I (262) example: Initializing external SPI Flash
I (272) example: Pin assignments:
I (272) example: MOSI: 7 MISO: 5 SCLK: 6 CS: 4
I (282) example: DMA CHANNEL: 3
Code: Select all
esp_err_t spi_nand_send_cmd(uint8_t *cmd, size_t cmd_len, uint8_t *rx_data, size_t rx_len) {
spi_transaction_t t = {
.length = cmd_len * 8,
.tx_buffer = cmd,
.rxlength = 0,
.rx_buffer = rx_data
};
return spi_device_transmit(handle, &t);
}
void read_nand_id() {
uint8_t cmd = CMD_READ_ID;
uint8_t id[3] = {0};
if (spi_nand_send_cmd(&cmd, 1, id, 3) == ESP_OK) {
ESP_LOGI(TAG, "Manufacturer ID: 0x%X, Device ID: 0x%X 0x%X", id[0], id[1], id[2]);
} else {
ESP_LOGE(TAG, "Failed to read NAND ID!");
}
}
void app_main(void)
{
/* Set up SPI bus and initialize the external SPI Flash chip */
example_init_ext_flash();
read_nand_id();
}