mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-03 22:08:28 +00:00 
			
		
		
		
	fix(spi_flash): Fix spi_flash write fail on 26M C2(including OTA fail on this chip)
This commit is contained in:
		@@ -132,8 +132,9 @@ static inline void gpspi_flash_ll_set_buffer_data(spi_dev_t *dev, const void *bu
 | 
			
		||||
 * should be configured before this is called.
 | 
			
		||||
 *
 | 
			
		||||
 * @param dev Beginning address of the peripheral registers.
 | 
			
		||||
 * @param pe_ops Is page program/erase operation or not. (not used in gpspi)
 | 
			
		||||
 */
 | 
			
		||||
static inline void gpspi_flash_ll_user_start(spi_dev_t *dev)
 | 
			
		||||
static inline void gpspi_flash_ll_user_start(spi_dev_t *dev,  bool pe_ops)
 | 
			
		||||
{
 | 
			
		||||
    dev->cmd.update = 1;
 | 
			
		||||
    while (dev->cmd.update);
 | 
			
		||||
 
 | 
			
		||||
@@ -48,7 +48,7 @@ typedef union  {
 | 
			
		||||
#define spi_flash_ll_cmd_is_done(dev)                        gpspi_flash_ll_cmd_is_done((spi_dev_t*)dev)
 | 
			
		||||
#define spi_flash_ll_get_buffer_data(dev, buffer, read_len)  gpspi_flash_ll_get_buffer_data((spi_dev_t*)dev, buffer, read_len)
 | 
			
		||||
#define spi_flash_ll_set_buffer_data(dev, buffer, len)       gpspi_flash_ll_set_buffer_data((spi_dev_t*)dev, buffer, len)
 | 
			
		||||
#define spi_flash_ll_user_start(dev)                         gpspi_flash_ll_user_start((spi_dev_t*)dev)
 | 
			
		||||
#define spi_flash_ll_user_start(dev, pe_ops)                 gpspi_flash_ll_user_start((spi_dev_t*)dev, pe_ops)
 | 
			
		||||
#define spi_flash_ll_host_idle(dev)                          gpspi_flash_ll_host_idle((spi_dev_t*)dev)
 | 
			
		||||
#define spi_flash_ll_read_phase(dev)                         gpspi_flash_ll_read_phase((spi_dev_t*)dev)
 | 
			
		||||
#define spi_flash_ll_set_cs_pin(dev, pin)                    gpspi_flash_ll_set_cs_pin((spi_dev_t*)dev, pin)
 | 
			
		||||
@@ -65,7 +65,6 @@ typedef union  {
 | 
			
		||||
#define spi_flash_ll_set_hold(dev, hold_n)                   gpspi_flash_ll_set_hold((spi_dev_t*)dev, hold_n)
 | 
			
		||||
#define spi_flash_ll_set_cs_setup(dev, cs_setup_time)        gpspi_flash_ll_set_cs_setup((spi_dev_t*)dev, cs_setup_time)
 | 
			
		||||
#define spi_flash_ll_set_extra_address(dev, extra_addr)      { /* Not supported on gpspi on ESP32-C6*/ }
 | 
			
		||||
#define spi_flash_ll_set_pe_bit(dev)                         gpspi_flash_ll_set_pe_bit((spi_dev_t*)dev)
 | 
			
		||||
#else
 | 
			
		||||
#define spi_flash_ll_reset(dev)                              spimem_flash_ll_reset((spi_mem_dev_t*)dev)
 | 
			
		||||
#define spi_flash_ll_cmd_is_done(dev)                        spimem_flash_ll_cmd_is_done((spi_mem_dev_t*)dev)
 | 
			
		||||
@@ -76,7 +75,7 @@ typedef union  {
 | 
			
		||||
#define spi_flash_ll_get_buffer_data(dev, buffer, read_len)  spimem_flash_ll_get_buffer_data((spi_mem_dev_t*)dev, buffer, read_len)
 | 
			
		||||
#define spi_flash_ll_set_buffer_data(dev, buffer, len)       spimem_flash_ll_set_buffer_data((spi_mem_dev_t*)dev, buffer, len)
 | 
			
		||||
#define spi_flash_ll_program_page(dev, buffer, len)          spimem_flash_ll_program_page((spi_mem_dev_t*)dev, buffer, len)
 | 
			
		||||
#define spi_flash_ll_user_start(dev)                         spimem_flash_ll_user_start((spi_mem_dev_t*)dev)
 | 
			
		||||
#define spi_flash_ll_user_start(dev, pe_ops)                 spimem_flash_ll_user_start((spi_mem_dev_t*)dev, pe_ops)
 | 
			
		||||
#define spi_flash_ll_host_idle(dev)                          spimem_flash_ll_host_idle((spi_mem_dev_t*)dev)
 | 
			
		||||
#define spi_flash_ll_read_phase(dev)                         spimem_flash_ll_read_phase((spi_mem_dev_t*)dev)
 | 
			
		||||
#define spi_flash_ll_set_cs_pin(dev, pin)                    spimem_flash_ll_set_cs_pin((spi_mem_dev_t*)dev, pin)
 | 
			
		||||
@@ -93,7 +92,6 @@ typedef union  {
 | 
			
		||||
#define spi_flash_ll_set_hold(dev, hold_n)                   spimem_flash_ll_set_hold((spi_mem_dev_t*)dev, hold_n)
 | 
			
		||||
#define spi_flash_ll_set_cs_setup(dev, cs_setup_time)        spimem_flash_ll_set_cs_setup((spi_mem_dev_t*)dev, cs_setup_time)
 | 
			
		||||
#define spi_flash_ll_set_extra_address(dev, extra_addr)      spimem_flash_ll_set_extra_address((spi_mem_dev_t*)dev, extra_addr)
 | 
			
		||||
#define spi_flash_ll_set_pe_bit(dev)                         spimem_flash_ll_set_pe_bit((spi_mem_dev_t*)dev)
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -371,21 +371,12 @@ static inline void spimem_flash_ll_program_page(spi_mem_dev_t *dev, const void *
 | 
			
		||||
 * should be configured before this is called.
 | 
			
		||||
 *
 | 
			
		||||
 * @param dev Beginning address of the peripheral registers.
 | 
			
		||||
 * @param pe_ops Is page program/erase operation or not.
 | 
			
		||||
 */
 | 
			
		||||
static inline void spimem_flash_ll_user_start(spi_mem_dev_t *dev)
 | 
			
		||||
static inline void spimem_flash_ll_user_start(spi_mem_dev_t *dev, bool pe_ops)
 | 
			
		||||
{
 | 
			
		||||
    dev->cmd.usr = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * In user mode, it is set to indicate that program/erase operation will be triggered.
 | 
			
		||||
 * This function is combined with `spimem_flash_ll_user_start`. The pe_bit will be cleared automatically once the operation done.
 | 
			
		||||
 *
 | 
			
		||||
 * @param dev Beginning address of the peripheral registers.
 | 
			
		||||
 */
 | 
			
		||||
static inline void spimem_flash_ll_set_pe_bit(spi_mem_dev_t *dev)
 | 
			
		||||
{
 | 
			
		||||
    dev->cmd.flash_pe = 1;
 | 
			
		||||
    uint32_t usr_pe = (pe_ops ? 0x60000 : 0x40000);
 | 
			
		||||
    dev->cmd.val |= usr_pe;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user