This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

* buffer overflow detected * . on zephyre icm20948

void main(void)
{	
  //Gpio_Initialise();
  I2C_Driver_Init();
  I2C_Scan_Address();

struct inv_icm20948_serif icm20948_serif;
  icm20948_serif.context   = 0; /* no need */
  icm20948_serif.read_reg  = idd_io_hal_read_reg;
  icm20948_serif.write_reg = idd_io_hal_write_reg;
  icm20948_serif.max_read  = 1024 * 16; /* maximum number of bytes allowed per serial read */
  icm20948_serif.max_write = 1024 * 16; /* maximum number of bytes allowed per serial write */

  icm20948_serif.is_spi = interface_is_SPI();
 icm20948_init(idd_io_hal_read_reg, idd_io_hal_write_reg,  inv_icm20948_sleep,  inv_icm20948_sleep);

  icm_device.base_state.serial_interface = SERIAL_INTERFACE_I2C;

  inv_icm20948_reset_states(&icm_device, &icm20948_serif);
  inv_icm20948_register_aux_compass(&icm_device, INV_ICM20948_COMPASS_ID_AK09916, AK0991x_DEFAULT_I2C_ADDR);

  rc = icm20948_sensor_setup();

  if (icm_device.selftest_done && !icm_device.offset_done)
  {
    // If we've run selftes and not already set the offset.
    inv_icm20948_set_offset(&icm_device, unscaled_bias);
    icm_device.offset_done = 1;
  }
  //enable sensors
  rc |= inv_icm20948_enable_sensor(&icm_device, idd_sensortype_conversion(INV_SENSOR_TYPE_RAW_GYROSCOPE), 1);
  //rc |= inv_icm20948_enable_sensor(&icm_device, idd_sensortype_conversion(INV_SENSOR_TYPE_RAW_ACCELEROMETER), 1);
  // rc |= inv_icm20948_enable_sensor(&icm_device, idd_sensortype_conversion(INV_SENSOR_TYPE_STEP_COUNTER), 1);
  
  //rc |= inv_icm20948_enable_sensor(&icm_device, idd_sensortype_conversion(INV_SENSOR_TYPE_MAGNETOMETER), 1);
 // rc |= inv_icm20948_enable_sensor(&icm_device, idd_sensortype_conversion(INV_SENSOR_TYPE_RAW_MAGNETOMETER), 1);
   //rc |= inv_icm20948_enable_sensor(&icm_device, idd_sensortype_conversion(INV_SENSOR_TYPE_GAME_ROTATION_VECTOR), 1);
 // rc |= inv_icm20948_enable_sensor(&icm_device, idd_sensortype_conversion(INV_SENSOR_TYPE_RAW_MAGNETOMETER), 1);
if(rc)
{
    printk("\r\nerror detected %d\r\n",rc );
    while(1);
}

while(1)
{
  int rv = inv_icm20948_poll_sensor(&icm_device, (void *)0, build_sensor_event_data);
}

I am using nrf5340 and icm20948 for our development. i had initialized things as shown in code attached.

this work fine for me. but when i am uncommenting rc |= inv_icm20948_enable_sensor(&icm_device, idd_sensortype_conversion(INV_SENSOR_TYPE_MAGNETOMETER), 1);  system is giving error * buffer overflow detected * .

i tried to increase HARDWARE_FIFO_SIZE to 4096 from 1024 but still issue is available. then i tried to increase stack size

 #define CONFIG_MAIN_STACK_SIZE 1024
#define CONFIG_PRIVILEGED_STACK_SIZE 1024 

to 2048 and 4096

with all combination.

but still issue is present kindly help me

  • If it was set to 0, that is probably not the issue, no. But can you try 32768, just to completely rule it out?

    Do you get the twim error if you do not comment in the magnetometer, but enable log?

    Can you use a debugger to find out exactly which function causes the twim error and the buffer overflow?

    I assume the image size is not something you can change, but if it is, can you try reducing it significantly?

    If none of that works, can you show me the code for the sensor_setup and enable_sensor functions?

Related