Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BHI260AP Shuttle Board 3.0 Kernel Version is 0

    BHI260AP Shuttle Board 3.0 Kernel Version is 0

    harry49511
    Occasional Visitor

    Hi,

    I am trying to bring up the BHI260AP Shuttle Board 3.0 at 1.8V using I2C with nrf52840DK.

    I had issue that I got kernel version value 0 from the call bhy2_get_kernel_version(&version, &bhy2), so basically I didnt get "printf("Boot successful. Kernel version %u.\r\n", version);".  But I thought I had successfully uploaded the firmware to the ram since the boot_status is 0x31 from the call bhy2_boot_from_ram(&bhy2). 

    What could be the problem?

    My BHI260AP Shuttle Board 3.0 setup:

    VDD -> 1.8V

    VDDIO -> 1.8V

    APP_SPI_CS -> 1.8V

    APP_SCL -> nrf52840DK SCL with external pull up resistor 4.7k

    APP_SPI_MISO -> GND

    APP_SDA -> nrf52840DK SDA with external pull up resistor 4.7k

    GND -> GND

    My sensor init part of code learnt from https://github.com/BoschSensortec/BHY2-Sensor-API :

    #include "bhi260ap/BHI260AP.fw.h"

    int sensor_BHI260AP_init()
    {
    uint8_t chip_id = 0;
    uint8_t product_id = 0;
    uint16_t version = 0;
    int8_t rslt;
    struct bhy2_dev bhy2;

    uint8_t hintr_ctrl, hif_ctrl, boot_status;

    #ifdef BHY2_USE_I2C
    intf = BHY2_I2C_INTERFACE;
    #else
    intf = BHY2_SPI_INTERFACE;
    #endif

    //setup_interfaces(true, intf); /* Perform a power on reset */

    #ifdef BHY2_USE_I2C
    rslt = bhy2_init(BHY2_I2C_INTERFACE, (bhy2_read_fptr_t) platform_twi_read, (bhy2_write_fptr_t) platform_twi_write, (bhy2_delay_us_fptr_t) platform_delay_us2, BHY2_RD_WR_LEN, NULL, &bhy2);
    #else
    rslt = bhy2_init(BHY2_SPI_INTERFACE, (bhy2_read_fptr_t) platform_spi_read, (bhy2_write_fptr_t) platform_spi_write, (bhy2_delay_us_fptr_t) platform_delay_us2, BHY2_RD_WR_LEN, NULL, &bhy2);
    #endif
    print_api_error(rslt, &bhy2);

    rslt = bhy2_soft_reset(&bhy2);
    print_api_error(rslt, &bhy2);

    rslt = bhy2_get_chip_id(&chip_id, &bhy2);
    print_api_error(rslt, &bhy2);

    /* Check for a valid chip ID */
    if ((chip_id != 0x70) && (chip_id != 0xF0))
    {
    printf("CHIP ID read %X. Expected %X\r\n", chip_id, BHY2_PRODUCT_ID);
    }
    else
    {
    printf("BHI260/BHA260 found. CHIP ID read %X\r\n", chip_id);
    }

    rslt = bhy2_get_product_id(&product_id, &bhy2);
    print_api_error(rslt, &bhy2);

    /* Check for a valid product ID */
    if (product_id != BHY2_PRODUCT_ID)
    {
    printf("Product ID read %X. Expected %X\r\n", product_id, BHY2_PRODUCT_ID);
    }
    else
    {
    printf("BHI260/BHA260 found. Product ID read %X\r\n", product_id);
    }

    /* Check the interrupt pin and FIFO configurations. Disable status and debug */
    hintr_ctrl = BHY2_ICTL_DISABLE_STATUS_FIFO | BHY2_ICTL_DISABLE_DEBUG;

    rslt = bhy2_set_host_interrupt_ctrl(hintr_ctrl, &bhy2);
    print_api_error(rslt, &bhy2);

    /* Configure the host interface */
    hif_ctrl = 0;
    rslt = bhy2_set_host_intf_ctrl(hif_ctrl, &bhy2);
    print_api_error(rslt, &bhy2);

    /* Check if the sensor is ready to load firmware */
    rslt = bhy2_get_boot_status(&boot_status, &bhy2);
    print_api_error(rslt, &bhy2);

    if (boot_status & BHY2_BST_HOST_INTERFACE_READY)
    {
    uint8_t sensor_error;
    int8_t temp_rslt;
    printf("Loading firmware.\r\n");

    /* If loading firmware to flash, erase the relevant section */
    #ifdef UPLOAD_FIRMWARE_TO_FLASH
    if (boot_status & BHY2_BST_FLASH_DETECTED)
    {
    uint32_t start_addr = BHY2_FLASH_SECTOR_START_ADDR;
    uint32_t end_addr = start_addr + sizeof(bhy2_firmware_image);
    printf("Flash detected. Erasing flash to upload firmware\r\n");

    rslt = bhy2_erase_flash(start_addr, end_addr, &bhy2);
    print_api_error(rslt, &bhy2);
    }
    else
    {
    printf("Flash not detected\r\n");

    return 0;
    }

    #endif

    rslt = bhy2_upload_firmware_to_ram(bhy2_firmware_image, sizeof(bhy2_firmware_image), &bhy2);
    temp_rslt = bhy2_get_error_value(&sensor_error, &bhy2);
    if (sensor_error)
    {
    printf("%s\r\n", get_sensor_error_text(sensor_error));
    }

    print_api_error(rslt, &bhy2);
    print_api_error(temp_rslt, &bhy2);

    #ifdef UPLOAD_FIRMWARE_TO_FLASH
    printf("Booting from Flash.\r\n");
    rslt = bhy2_boot_from_flash(&bhy2);
    #else
    printf("Booting from RAM.\r\n");
    rslt = bhy2_boot_from_ram(&bhy2);
    #endif

    temp_rslt = bhy2_get_error_value(&sensor_error, &bhy2);
    if (sensor_error)
    {
    printf("%s\r\n", get_sensor_error_text(sensor_error));
    }

    print_api_error(rslt, &bhy2);
    print_api_error(temp_rslt, &bhy2);

    rslt = bhy2_get_kernel_version(&version, &bhy2);
    print_api_error(rslt, &bhy2);
    if ((rslt == BHY2_OK) && (version != 0))
    {
    printf("Boot successful. Kernel version %u.\r\n", version);
    }
    }
    else
    {
    printf("Host interface not ready. Exiting\r\n");

    //close_interfaces(BHY2_SPI_INTERFACE);

    return 0;
    }

    return rslt;
    }

    3 REPLIES 3

    BSTRobin
    Community Moderator
    Community Moderator

    Hi harry49511,

    Attached example code run with latest BHI260AP sensor API v1.4.1(https://github.com/BoschSensortec/BHY2-Sensor-API/tree/master/firmware/bhi260ap) on STM32 for your reference.

    run result.png

    You could attack your print log and see whether there is some invalid return.

    Hi BSTRobin,

    Thanks for the STM32 example code. I almost duplicated the code and I  re-imported the BHI260AP code again just in case. But still the problem exsits. I even tried BHI260AP breakout board with Bosch application 3.0 board again and the BHI260AP worked on this board which meant the sensor hardware was not broken. 

    The only difference on nrf52840+breakout board is the hardware connection, I dont have interrupt pin connected, but I dont think that matters. What do you think?

    Here is the output from my device:
    nrf52840 output version 0.PNG

    BSTRobin
    Community Moderator
    Community Moderator

    Hi harry49511,

    The reference code supports interrupt mode and polling mode, and you must use one of them.
    1.Did you enable UPLOAD_FIRMWARE_TO_FLASH mocro definition?
    2.You need to use burst write to download firmware file. You can check the I2C waveform.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist