This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5718: Setting breakpoint in U-boot

Part Number: AM5718


Hi,

I am using AM5718 IDK EVM,and ti-processor-sdk-linux-am57xx-evm-05.03.00.07.

I am using CCS Version: 8.3.0.00009 in host PC Ubuntu Version 18.04.3 LTS.

I have successfully debugged MLO using CCS (load memory->spl/u-boot-spl.bin, load symbols->spl/u-boot-spl). I could set hardware breakpoints and step through different points in MLO code.

Now I'm facing difficulty in running U-boot through JTAG in CCS. No prints are coming in the terminal. The procedure that I followed is given below:

1. Load MLO in JTAG and run. Following prints come in terminal:
----------------------
U-Boot SPL 2018.01 (Dec 19 2019 - 10:38:18)
DRA722-GP ES2.0
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
-----------------------------------


2. After running MLO, Run->Load Program->u-boot was loaded. PC was automatically updated to 0x80800000. After clicking Run, no print comes in terminal.

3. Before clicking Run, I could set hardware breakpoint in common/board_f.c inside function:

void board_init_f(ulong boot_flags)

{

gd->flags = boot_flags;

...
}

This breakpoint is not reached. Have I put breakpoint in the correct function? Can you give me some initial functions in U-Boot (not MLO) where I can put breakpoints and study the code flow?

3. I then loaded u-boot.bin. Changed PC to 0x80800000. Clicked Run. No print comes in terminal.

One month before, I had got U-Boot running prints in terminal while following steps 1-3. I don't know why I am not getting it now.


After following CCS debug tutorials and various links in E2E support forum, U-boot was build as given below:

---------------------------------------
1. Added debug flags in many different config.mk files in U-boot source as:

------------------
DBGFLAGS = -g2 -gdwarf-2
AFLAGS_DEBUG = -Wa,-gdwarf2
OPTFLAGS = -O1

----------------------------

2. Added CONFIG_ARMV7_LPAE=n in the configs/am57xx_evm_defconfig file.

3. Added CONFIG_OF_EMBED=y in the configs/am57xx_evm_defconfig file.

4. The option "Enable debug information for tools" under General setup → Configure standard U-boot features (expert users) was selected.

After adding this, am57xx_evm_defconfig was made and U-boot was rebuild. This was done outside CCS.

---------------------------------------

Please help on on how to run U-boot through JTAG in CCS and set breakpoint in U-Boot code?

regards,

Anupama

  • I did not use any sd-card while doing the above steps. No MLO/U-boot was flashed also.

    Anupama

  • Hi,

    I slightly modified my procedure after following the link:

     

    1. Load MLO in JTAG and run. Following prints come in terminal:
    ----------------------
    U-Boot SPL 2018.01 (Dec 19 2019 - 10:38:18)
    DRA722-GP ES2.0
    SPL: failed to boot from all boot devices
    ### ERROR ### Please RESET the board ###
    -----------------------------------

    2. After running MLO, Run->Load Program->u-boot was loaded. PC was automatically updated to 0x80800000. After clicking Run, no print comes in terminal.

    3. Again Run->Load Program->u-boot was loaded. PC was automatically updated to 0x80800000. After clicking Run, U-Boot prints come in terminal. It stops at
    "ERROR: can't get kernel image!" . 

    Now two issues are pending:

    1. Why do I have to Run->Load Program->u-boot twice?


    2. I am able to set hardware breakpoint but CCS is not stopping at the breakpoint. I tried to set breakpoint in common/board_f.c inside function:

    void board_init_f(ulong boot_flags)

    {

    gd->flags = boot_flags;

    ...
    }

    Please tell me a valid point in code where I can set breakpoint and study the u-Boot flow.

    regards,

    Anupama

  • Anupama Sreekumar said:
    I did not use any sd-card while doing the above steps. No MLO/U-boot was flashed also.

    Can you please do the following...

    • Insert a trap near the code you want to debug in SPL or U-Boot (like an endless loop polling a variable declared as 'volatile')
    • Program MLO/U-Boot onto an SD card and boot from that media (or, use another boot mode such as USB)
    • MLO/U-Boot will execute normally and get "trapped" by the code you added earlier
    • Now attach the JTAG debugger, and load the symbols (not code!) from the elf file, and halt execution. Also make sure to attach the debugger in a way that it doesn't "destroy" the device by executing scripts, GEL files (in case of CCS), etc.
    • From there on you can debug MLO/U-Boot with minimal side effects really

    The above is what I would recommend for 95% of all cases. If you try to side-load U-Boot entirely over JTAG you will introduce side effects (based on the fact that the execution environment will be different) and you will not be debugging your actual boot flow.

    Regards, Andreas

  • Hi Andreas,
    I have followed steps as per your direction.

    I have added an infinite loop in u-boot/common/board_f.c as below:

    volatile int ccs_debug_flag = 1;
    void wait_for_debugger()
    {
    ccs_debug_flag = 1;
    printf("Entering debugging infinite loop\n");
    while(ccs_debug_flag == 1)
    asm("NOP");
    return;

    }
    void board_init_f(ulong boot_flags)
    {
    wait_for_debugger();
    gd->flags = boot_flags;
    gd->have_console = 0;

    if (initcall_run_list(init_sequence_f))
    hang();


    After this, I have build U-boot and I have put MLO and U-Boot onto an SD card and booted EVM from SD card

    MLO/U-Boot executed normally and seems got "trapped" by the code. No prints were seen in console

    JTAG debugger was connected, and u-boot-source_folder/u-boot was loaded by Load Program-> u-boot. No GEL files were loaded.

    I could not understand about halting execution. It seemed to be in a halted condition. The only options available for me was Resume, Terminate, Step (F5, F6) etc. If I try stepping, code stops at vector.s given below:
    vector.s
    ---------

    _start:
    #ifdef CONFIG_SYS_DV_NOR_BOOT_CFG
    .word CONFIG_SYS_DV_NOR_BOOT_CFG
    #endif
    ARM_VECTORS
    #endif /* !defined(CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK) */

    ---------------
    I tried putting breakpoints just below wait_for_debugger(). It is not stopping there and remains in vector.s.

    Can you help me?

    regards,

    Andreas

     

  • Hi Anupama,

    Anupama Sreekumar said:
    I tried putting breakpoints just below wait_for_debugger(). It is not stopping there and remains in vector.s.

    You will either change the value your loop condition variable to make it exit the loop, or move the program counter (PC) past that loop using the register view in CCS (to edit the PC), otherwise it'll forever be stuck in that loop (I'm not sure how you would expect it to exit the loop without any further doing?).

    Also please review some basic U-Boot debugging tips documented here: http://software-dl.ti.com/processor-sdk-linux/esd/docs/06_02_00_81/linux/Foundational_Components_U-Boot.html#uboot-spl-debugging-tips

    Anupama Sreekumar said:
    MLO/U-Boot executed normally and seems got "trapped" by the code. No prints were seen in console

    Note that the console UART does not get initialized until further into the boot flow, so it is normal that printing very early on in board_init_f() will not yield anything visible.

    Regards, Andreas