DFU-OTA project main file to assembly language file transition.

Hi,

    I am working on the sample DFU OTA project as recommended below, 

https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/ncs-dfu?CommentId=3cb5df69-fd8f-4160-9171-74b6e8246c1a

I am getting the prints as below upon dfu on my nrf52833dk board. 

Upon reboot i can see the logs , "starting bootloader" which are being generated from mcuboot source file main.c (v1.8.0\bootloader\mcuboot\boot\zephyr).

after this the logs furthur like "Primary image", are being generated from the file 4452.zephyr.lst

Kindly help me in understanding how the execution is entering zephyr.lst from main.c . after printing "starting bootloader". Attached below is the main() code.

void main(void)
{
    struct boot_rsp rsp;
    int rc;
    fih_int fih_rc = FIH_FAILURE;

    MCUBOOT_WATCHDOG_FEED();

#if !defined(MCUBOOT_DIRECT_XIP)
    BOOT_LOG_INF("Starting bootloader");
#else
    BOOT_LOG_INF("Starting Direct-XIP bootloader");
#endif

#ifdef CONFIG_MCUBOOT_INDICATION_LED
    /* LED init */
    led_init();
#endif

    os_heap_init();

    ZEPHYR_BOOT_LOG_START();

    (void)rc;

#if (!defined(CONFIG_XTENSA) && defined(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL))
    if (!flash_device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL)) {
        BOOT_LOG_ERR("Flash device %s not found",
		     DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL);
        while (1)
            ;
    }
#elif (defined(CONFIG_XTENSA) && defined(JEDEC_SPI_NOR_0_LABEL))
    if (!flash_device_get_binding(JEDEC_SPI_NOR_0_LABEL)) {
        BOOT_LOG_ERR("Flash device %s not found", JEDEC_SPI_NOR_0_LABEL);
        while (1)
            ;
    }
#endif

#ifdef CONFIG_MCUBOOT_SERIAL
    if (detect_pin(CONFIG_BOOT_SERIAL_DETECT_PORT,
                   CONFIG_BOOT_SERIAL_DETECT_PIN,
                   CONFIG_BOOT_SERIAL_DETECT_PIN_VAL,
                   CONFIG_BOOT_SERIAL_DETECT_DELAY) &&
            !boot_skip_serial_recovery()) {
#ifdef CONFIG_MCUBOOT_INDICATION_LED
        gpio_pin_set(led, LED0_GPIO_PIN, 1);
#endif

        BOOT_LOG_INF("Enter the serial recovery mode");
        rc = boot_console_init();
        __ASSERT(rc == 0, "Error initializing boot console.\n");
        boot_serial_start(&boot_funcs);
        __ASSERT(0, "Bootloader serial process was terminated unexpectedly.\n");
    }
#endif

#if defined(CONFIG_BOOT_USB_DFU_GPIO)
    if (detect_pin(CONFIG_BOOT_USB_DFU_DETECT_PORT,
                   CONFIG_BOOT_USB_DFU_DETECT_PIN,
                   CONFIG_BOOT_USB_DFU_DETECT_PIN_VAL,
                   CONFIG_BOOT_USB_DFU_DETECT_DELAY)) {
#ifdef CONFIG_MCUBOOT_INDICATION_LED
        gpio_pin_set(led, LED0_GPIO_PIN, 1);
#endif
        rc = usb_enable(NULL);
        if (rc) {
            BOOT_LOG_ERR("Cannot enable USB");
        } else {
            BOOT_LOG_INF("Waiting for USB DFU");
            wait_for_usb_dfu(K_FOREVER);
            BOOT_LOG_INF("USB DFU wait time elapsed");
        }
    }
#elif defined(CONFIG_BOOT_USB_DFU_WAIT)
    rc = usb_enable(NULL);
    if (rc) {
        BOOT_LOG_ERR("Cannot enable USB");
    } else {
        BOOT_LOG_INF("Waiting for USB DFU");
        wait_for_usb_dfu(K_MSEC(CONFIG_BOOT_USB_DFU_WAIT_DELAY_MS));
        BOOT_LOG_INF("USB DFU wait time elapsed");
    }
#endif

    FIH_CALL(boot_go, fih_rc, &rsp);
    if (fih_not_eq(fih_rc, FIH_SUCCESS)) {
        BOOT_LOG_ERR("Unable to find bootable image");
        FIH_PANIC;
    }

    BOOT_LOG_INF("Bootloader chainload address offset: 0x%x",
                 rsp.br_image_off);

#if defined(MCUBOOT_DIRECT_XIP)
    BOOT_LOG_INF("Jumping to the image slot");
#else
    BOOT_LOG_INF("Jumping to the first image slot");
#endif

#if USE_PARTITION_MANAGER && CONFIG_FPROTECT

#ifdef PM_S1_ADDRESS
/* MCUBoot is stored in either S0 or S1, protect both */
#define PROTECT_SIZE (PM_MCUBOOT_PRIMARY_ADDRESS - PM_S0_ADDRESS)
#define PROTECT_ADDR PM_S0_ADDRESS
#else
/* There is only one instance of MCUBoot */
#define PROTECT_SIZE (PM_MCUBOOT_PRIMARY_ADDRESS - PM_MCUBOOT_ADDRESS)
#define PROTECT_ADDR PM_MCUBOOT_ADDRESS
#endif

    rc = fprotect_area(PROTECT_ADDR, PROTECT_SIZE);

    if (rc != 0) {
        BOOT_LOG_ERR("Protect mcuboot flash failed, cancel startup.");
        while (1)
            ;
    }
#endif /* USE_PARTITION_MANAGER && CONFIG_FPROTECT */
#if defined(CONFIG_SOC_NRF5340_CPUAPP) && defined(PM_CPUNET_B0N_ADDRESS)
    pcd_lock_ram();
#endif

    ZEPHYR_BOOT_LOG_STOP();

    do_boot(&rsp);

    BOOT_LOG_ERR("Never should get here");
    while (1)
        ;
}

Parents
  • Hi Vinay, 

    No I don't think it's printed by the zephyr.lst file. The file is the Assembly auto generation from the application code. 

    What you need to look for where it prints out "Primary image:" is in swap_status_source() function in swap_move.c in bootloader\mcuboot\boot\bootutil\src

    Another location where it may print "Primary image" is in swap_scratch.c but it depends on the activity you are doing with MCUBOOT. 

  • Thanks @Hung Bui.

                          some query related to the same example.

    1.While sending image from Bluetooth(mobile app) , "where it is downloading the image nd where it is storing the image" ?

    2. Once controller received the complete image , "DFU soft reset will run. from where it is getting reset"?

    3. from where "the key and image extraction is running"

Reply
  • Thanks @Hung Bui.

                          some query related to the same example.

    1.While sending image from Bluetooth(mobile app) , "where it is downloading the image nd where it is storing the image" ?

    2. Once controller received the complete image , "DFU soft reset will run. from where it is getting reset"?

    3. from where "the key and image extraction is running"

Children
Related