Skip to content

Commit

Permalink
Merge pull request #327 from UnTraDe/spi_nand_flash/support_for_micro…
Browse files Browse the repository at this point in the history
…n_MT29F

added support for Micron MT29F nand flash ()
  • Loading branch information
igrr authored Jul 23, 2024
2 parents 47c8e7b + 2f4efeb commit 2da4e71
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ static spi_nand_flash_device_t *example_init_nand_flash(void)
.sclk_io_num = PIN_CLK,
.quadhd_io_num = PIN_HD,
.quadwp_io_num = PIN_WP,
.max_transfer_sz = 4096 * 2,
};

// Initialize the SPI bus
Expand Down
2 changes: 1 addition & 1 deletion spi_nand_flash/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "0.1.0"
version: "0.2.0"
description: Driver for accessing SPI NAND Flash
url: https://github.com/espressif/idf-extra-components/tree/master/spi_nand_flash
issues: https://github.com/espressif/idf-extra-components/issues
Expand Down
27 changes: 27 additions & 0 deletions spi_nand_flash/src/nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,31 @@ static esp_err_t spi_nand_gigadevice_init(spi_nand_flash_device_t *dev)
return ESP_OK;
}

static esp_err_t spi_nand_micron_init(spi_nand_flash_device_t *dev)
{
uint8_t device_id;
spi_nand_transaction_t t = {
.command = CMD_READ_ID,
.dummy_bits = 16,
.miso_len = 1,
.miso_data = &device_id
};
spi_nand_execute_transaction(dev->config.device_handle, &t);
dev->read_page_delay_us = 115;
dev->erase_block_delay_us = 2000;
dev->program_page_delay_us = 240;
switch (device_id) {
case MICRON_DI_34:
dev->dhara_nand.num_blocks = 2048;
dev->dhara_nand.log2_ppb = 6; // 64 pages per block
dev->dhara_nand.log2_page_size = 12; // 4096 bytes per page
break;
default:
return ESP_ERR_INVALID_RESPONSE;
}
return ESP_OK;
}

static esp_err_t detect_chip(spi_nand_flash_device_t *dev)
{
uint8_t manufacturer_id;
Expand All @@ -148,6 +173,8 @@ static esp_err_t detect_chip(spi_nand_flash_device_t *dev)
return spi_nand_winbond_init(dev);
case SPI_NAND_FLASH_GIGADEVICE_MI: // GigaDevice
return spi_nand_gigadevice_init(dev);
case SPI_NAND_FLASH_MICRON_MI: // Micron
return spi_nand_micron_init(dev);
default:
return ESP_ERR_INVALID_RESPONSE;
}
Expand Down
3 changes: 3 additions & 0 deletions spi_nand_flash/src/nand_flash_devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define SPI_NAND_FLASH_GIGADEVICE_MI 0xC8
#define SPI_NAND_FLASH_ALLIANCE_MI 0x52
#define SPI_NAND_FLASH_WINBOND_MI 0xEF
#define SPI_NAND_FLASH_MICRON_MI 0x2C

//Device ID (DI) for supported nand flash devices

Expand Down Expand Up @@ -39,3 +40,5 @@
#define WINBOND_DI_AA21 0xAA21
#define WINBOND_DI_BA21 0xBA21
#define WINBOND_DI_BC21 0xBC21

#define MICRON_DI_34 0x34
2 changes: 1 addition & 1 deletion spi_nand_flash/test_app/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dependencies:
espressif/spi_nand_flash:
version: '0.1.0'
version: '*'
override_path: '../../'

0 comments on commit 2da4e71

Please sign in to comment.