I got xRingbufferReceiveUpToFromISR assert failed!

WayneJia
Posts: 17
Joined: Thu Aug 03, 2017 7:28 am

I got xRingbufferReceiveUpToFromISR assert failed!

Postby WayneJia » Fri Aug 04, 2017 1:29 am

I have two problems with I2C.
I read data per 20ms from BMX055(9 axis sensor) who work with I2C .

1.xRingbufferReceiveUpToFromISR assert failed.My wifi storage is WIFI_STORAGE_RAM ,I save wifi ssid and password in NV by nvs_set_str().
This is log:

Code: Select all

C:/esp32-idf/esp-idf/components/freertos/ringbuf.c:600 (xRingbufferReceiveUpToFromISR)- assert failed!
abort() was called at PC 0x400879d5 on core 0
Guru Meditation Error: Core  0 panic'ed (abort)

Backtrace: 0x400d1408:0x3ffc0590 0x4008542c:0x3ffc05b0 0x40118908:0x3ffc05d0 0x40081f41:0x3ffc0600

Rebooting...
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
2.Another problem is that i2c not work totally.(I2C work normally at most of the time)
Sometimes,device reboot whith i2c not work totally.This situation most commonly happened when I turn on device after make erase_flash flash or mak flash.I2C will not respond,all read or write operations failed,so the code of I2C part will run very slowly and the device will not work.In this situation ,I must unplug battery to make I2C work again.Even I make erase_flash flash again,the device not working, either!-------------In this situation that SCL is high with SDA is low all the time!

This is part of my code:
1.I init I2C at main_app().
2.I read data from sensor per 20ms in other task.

Code: Select all

#define I2C_MASTER_FREQ_HZ         400000     /*!< I2C master clock frequency */
#define I2C_PIN_SCL 13
#define I2C_PIN_SDA 14

void i2c_master_App_init(void)
{
	esp_err_t err;
	
    int i2c_master_port = I2C_NUM_0;
    i2c_config_t conf;
    conf.mode = I2C_MODE_MASTER;
    conf.sda_io_num = I2C_PIN_SDA;
    conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
    conf.scl_io_num = I2C_PIN_SCL;
    conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
    conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
    err = i2c_param_config(i2c_master_port, &conf);
    err = i2c_driver_install(i2c_master_port, conf.mode,
                       I2C_MASTER_RX_BUF_DISABLE,
                       I2C_MASTER_TX_BUF_DISABLE, 0);
}

esp_err_t i2c_master_read_slave(uint8_t slaveAddr,uint8_t* data_rd, size_t size)
{
    esp_err_t err;
	
    if (size == 0) {
        return ESP_OK;
    }
    i2c_cmd_handle_t cmd = i2c_cmd_link_create();
    err = i2c_master_start(cmd);
    err = i2c_master_write_byte(cmd, ( slaveAddr << 1 ) | READ_BIT, ACK_CHECK_EN);
    if (size > 1) {
        err = i2c_master_read(cmd, data_rd, size - 1, ACK_VAL);
    }
    err = i2c_master_read_byte(cmd, data_rd + size - 1, NACK_VAL);
    err = i2c_master_stop(cmd);
    esp_err_t ret = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_RATE_MS);
    i2c_cmd_link_delete(cmd);
    return ret;
}

esp_err_t i2c_master_write_slave(uint8_t slaveAddr,uint8_t* data_wr, size_t size)
{
   esp_err_t err;
	
    i2c_cmd_handle_t cmd = i2c_cmd_link_create();
    err = i2c_master_start(cmd);
    err = i2c_master_write_byte(cmd, ( slaveAddr << 1 ) | WRITE_BIT, ACK_CHECK_EN);
    err = i2c_master_write(cmd, data_wr, size, ACK_CHECK_EN);
    err = i2c_master_stop(cmd);
    esp_err_t ret = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_RATE_MS);
    i2c_cmd_link_delete(cmd);
    return ret;
}

esp_err_t BMX055_IIC_Write_Bytes(uint8_t Sensor_Slave_Addr,uint8_t addr,uint8_t* data_wr, size_t size)
{

        uint8_t data[16];
	data[0]=addr;
	MEMCPY(data+1,data_wr,size);
	esp_err_t err = i2c_master_write_slave(Sensor_Slave_Addr,data,size+1);//write addr+data
	return err;
}

esp_err_t BMX055_IIC_Read_Bytes(uint8_t Sensor_Slave_Addr,uint8_t addr,uint8_t* data_re, size_t size)
{
        uint8_t data[1];
	data[0]=addr;
	esp_err_t err = i2c_master_write_slave(Sensor_Slave_Addr,data,1);//write addr
	if(err!=ESP_OK)return err;
	err = i2c_master_read_slave(Sensor_Slave_Addr,data_re,size);//read data
	return err;
}
thanks
best wishes ;)

WayneJia
Posts: 17
Joined: Thu Aug 03, 2017 7:28 am

Re: I got xRingbufferReceiveUpToFromISR assert failed!

Postby WayneJia » Sat Aug 05, 2017 8:51 am

It is very strange.
When I add ble code to my project and call ble ,it will not appear assert faild!
And when I add other code to my project with ble closed(the ble code is in project,but I do not call ble interface),the assert failed appear in different way.It may be that device reboot infinite loop with assert failed,I must unplug battery or short ciruit to recover.

WayneJia
Posts: 17
Joined: Thu Aug 03, 2017 7:28 am

Re: I got xRingbufferReceiveUpToFromISR assert failed!

Postby WayneJia » Sat Aug 05, 2017 8:54 am

If I keep ble and wifi on,the device will be very hot. :(

WayneJia
Posts: 17
Joined: Thu Aug 03, 2017 7:28 am

Re: I got xRingbufferReceiveUpToFromISR assert failed!

Postby WayneJia » Mon Aug 07, 2017 3:02 am

I find what cause assert failed!
When I connet wifi to AP,I2C assert failed will heppen.
If I do not connect wifi to AP,It will not happen.
If I connect wifi to AP and turn on ble,it will not happen.
It is very strange!

Wifi can break I2C?

sushenghua@msn.com
Posts: 3
Joined: Fri Oct 13, 2017 9:58 am

Re: I got xRingbufferReceiveUpToFromISR assert failed!

Postby sushenghua@msn.com » Sun Nov 05, 2017 5:07 am

I got the same issue, the assertion failed at line 600 of esp-idf/components/freertos/ringbuf.c, the param 'ringbuf' expected non-null. That means 'uint8_t *data = (uint8_t*) xRingbufferReceiveUpToFromISR(p_i2c->tx_ring_buf, &size, tx_fifo_rem);' at line 380 of i2c.c
got param 'p_i2c->tx_ring_buf' null

The i2c used as the master mode in my project, the p_i2c->tx_ring_buf is initialized as NULL in function 'i2c_driver_install' that's the cause of the problem. What triggers the I2C_TXFIFO_EMPTY_INT_ST_M?

Who is online

Users browsing this forum: No registered users and 50 guests