ESP32/ESP32S3模组在使用Touchpad例子发生flash出错问题解决方式

目前楼主使用的是ESP32S3-WROOM-1

前天发现跑了一个致命问题:开发板跑examples\peripherals\touch_sensor\touch_sensor_v2\touch_pad_read这个demo,在读取线程里调用esp_light_sleep_start进入低功耗,这时候程序跑一会就出问题,该问题表现为模组启动失败,提示E (409) esp_image: Image hash failed - image is corrupt
该问题比较隐蔽且致命。查找原因发现跟低功耗有关,官方问题有相关记录:https://github.com/espressif/esp-idf/issues/8175
但是,该记录没有写解决方式,目前楼主已经通过一个方法解决出现该flash出错问题的方式。

因为我们程序运行一段时间需要进低功耗,昨天晚上试了一个好的模组跑一会进入低功耗就有问题了,于是我尝试在进入低功耗前,关闭touch的功能,在退出低功耗时,重新初始化touch功能,问题不再出现,附上代码~~~


```c
static void tp_read_init(void)
{
    /* Initialize touch pad peripheral. */
    touch_pad_init();
    for (int i = 0; i < TOUCH_BUTTON_NUM; i++) {
        touch_pad_config(button[i]);
    }
#if TOUCH_CHANGE_CONFIG
    /* If you want change the touch sensor default setting, please write here(after initialize). There are examples: */
    touch_pad_set_meas_time(TOUCH_PAD_SLEEP_CYCLE_DEFAULT, TOUCH_PAD_MEASURE_CYCLE_DEFAULT);
    touch_pad_set_voltage(TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD, TOUCH_PAD_LOW_VOLTAGE_THRESHOLD, TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD);
    touch_pad_set_idle_channel_connect(TOUCH_PAD_IDLE_CH_CONNECT_DEFAULT);
    for (int i = 0; i < TOUCH_BUTTON_NUM; i++) {
        touch_pad_set_cnt_mode(button[i], TOUCH_PAD_SLOPE_DEFAULT, TOUCH_PAD_TIE_OPT_DEFAULT);
    }
#endif
    /* Denoise setting at TouchSensor 0. */
    touch_pad_denoise_t denoise = {
        /* The bits to be cancelled are determined according to the noise level. */
        .grade = TOUCH_PAD_DENOISE_BIT4,
        .cap_level = TOUCH_PAD_DENOISE_CAP_L0,
    };
    touch_pad_denoise_set_config(&denoise);
    touch_pad_denoise_enable();
    ESP_LOGI(TAG, "Denoise function init");

    /* Enable touch sensor clock. Work mode is "timer trigger". */
    touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
    touch_pad_fsm_start();
}

static void tp_read_deinit(void)
{
	touch_pad_deinit();
	touch_pad_reset();
	touch_pad_denoise_disable();
	touch_pad_fsm_stop();
}

void low_power()
{
	//gpio唤醒,仅用于light sleep mode
	esp_sleep_enable_timer_wakeup(5000000);//us //SLEEP_TIME
	esp_sleep_enable_gpio_wakeup();
	esp_light_sleep_start();
	/* Determine wake up reason */
	const char* wakeup_reason;
	uint8_t ret = esp_sleep_get_wakeup_cause();
	printf("esp wakeup!! ret:%d\n", ret);
	switch(ret)
	{
		case ESP_SLEEP_WAKEUP_TIMER:
			wakeup_reason = "timer";
			
			break;
		case ESP_SLEEP_WAKEUP_GPIO:
			wakeup_reason = "pin";
			break;
		default:
			wakeup_reason = "other";
			break;
	}
}

tp_read_deinit();//这里不加容易导致flash出错
low_power();
tp_read_init();//与tp_read_deinit成对出现

全文完.....
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值