[PATCH] arm64: zynqmp: Support semhosting boot method

Michal Simek michal.simek at amd.com
Fri Feb 16 14:48:08 CET 2024



On 2/15/24 20:31, Sean Anderson wrote:
> On 2/15/24 14:08, Michal Simek wrote:
>>
>>
>> On 2/15/24 18:19, Sean Anderson wrote:
>>> Currently, when we boot from JTAG we try to boot U-Boot from RAM.
>>> However, this is a bit tricky to time, since the debugger has to wait
>>> for SPL to initialize RAM before it can load U-Boot. This can result in
>>> long waits, since occasionally initializing RAM (and other things in
>>> psu_init) takes a long time to complete and the debugger must wait for
>>> this worst case.
>>>
>>> Support semihosting if it is enabled, as it lets U-Boot tell the
>>> debugger when we are ready for the image. This means we don't have to
>>> wait any more than necessary. We don't change the default config to
>>> ensure we don't break compatibility with existing debuggers that don't
>>> expect us to hit semihosting breakpoints.
>>>
>>> Signed-off-by: Sean Anderson <sean.anderson at seco.com>
>>> ---
>>>
>>>    arch/arm/mach-zynqmp/spl.c | 10 ++++++++--
>>>    1 file changed, 8 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-zynqmp/spl.c b/arch/arm/mach-zynqmp/spl.c
>>> index a0f35f36faa..5af735aa5ce 100644
>>> --- a/arch/arm/mach-zynqmp/spl.c
>>> +++ b/arch/arm/mach-zynqmp/spl.c
>>> @@ -9,6 +9,7 @@
>>>    #include <image.h>
>>>    #include <init.h>
>>>    #include <log.h>
>>> +#include <semihosting.h>
>>>    #include <spl.h>
>>>    #include <linux/delay.h>
>>>
>>> @@ -66,6 +67,11 @@ void spl_board_init(void)
>>>    }
>>>    #endif
>>>
>>> +static u32 jtag_boot_device(void)
>>> +{
>>> +       return semihosting_enabled() ? BOOT_DEVICE_SMH : BOOT_DEVICE_RAM;
>>> +}
>>> +
>>>    void board_boot_order(u32 *spl_boot_list)
>>>    {
>>>           spl_boot_list[0] = spl_boot_device();
>>> @@ -75,7 +81,7 @@ void board_boot_order(u32 *spl_boot_list)
>>>           if (spl_boot_list[0] == BOOT_DEVICE_MMC2)
>>>                   spl_boot_list[1] = BOOT_DEVICE_MMC1;
>>>
>>> -       spl_boot_list[2] = BOOT_DEVICE_RAM;
>>> +       spl_boot_list[2] = jtag_boot_device();
>>>    }
>>>
>>>    u32 spl_boot_device(void)
>>> @@ -97,7 +103,7 @@ u32 spl_boot_device(void)
>>>
>>>           switch (bootmode) {
>>>           case JTAG_MODE:
>>> -               return BOOT_DEVICE_RAM;
>>> +               return jtag_boot_device();
>>>    #ifdef CONFIG_SPL_MMC
>>>           case SD_MODE1:
>>>           case SD1_LSHFT_MODE: /* not working on silicon v1 */
>>
>> Good timing. Can you please tell me how to test this? What's the setup?
>> Which debugger are you using?
> 
> I am using OpenOCD with the patches at https://review.openocd.org/c/openocd/+/8133
> 

I am trying it on the top of the latest git but getting issue with event block 
and no idea how to fix it.

# sudo openocd -f 
/usr/local/share/openocd/scripts/interface/ftdi/digilent_jtag_hs3.cfg -f 
/usr/local/share/openocd/scripts/target/xilinx_zynqmp.cfg
Open On-Chip Debugger 0.12.0+dev-01509-g6d288937cb2d (2024-02-16-12:22)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 
'transport select <transport>'.
wrong # args: should be "-event <event-name> <event-body>"


Do you know how to fix it?

Thanks,
Michal



More information about the U-Boot mailing list