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

Parents
  • Hi,

    Can you show me the log when this error occurs? Were there any warnings when you compiled the project? 

  • whoami = ea
    dmp image size = 14304
    compass detected
    RAW gyro data 2 -5 16
    * buffer overflow detected *

    when i enable log 

    [00:00:02.279,266] [1;31m<err> i2c_nrfx_twim: Error 195952641 occurred for message 0[0m
    [00:00:02.279,449] [1;31m<err> i2c_nrfx_twim: Error 195952641 occurred for message 0[0m
    Scanning done
    whoami = ea
    dmp image size = 14304
    * buffer overflow detected *
    compass detected
    RAW gyro data -1 -13 22
    [00:00:07.068,511] [1;31m<err> os: r0/a1: 0x00000003 r1/a2: 0xe000ed00 r2/a3: 0x00000001[0m
    [00:00:07.068,511] [1;31m<err> os: r3/a4: 0x20000ebe r12/ip: 0x0000000a r14/lr: 0x00014a85[0m
    [00:00:07.068,542] [1;31m<err> os: xpsr: 0x69000000[0m
    [00:00:07.068,542] [1;31m<err> os: Faulting instruction address (r15/pc): 0x000082b8[0m
    [00:00:07.068,542] [1;31m<err> os: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0[0m
    [00:00:07.068,542] [1;31m<err> os: Current thread: 0x20000950 (unknown)[0m
    [00:00:07.278,228] [1;31m<err> os: Halting system[0m

  • If you are using our DK or our board files, can you try using different pins for i2c2? Not pin 32 or 33.

  • Can you try increasing CONFIG_HEAP_MEM_POOL_SIZE?

  • It was 0 i set it to 1024 but still same issue

  • 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?

Reply
  • 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?

Children
No Data
Related