cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
nunu
Contributor
Contributor
7,753 Views
Registered: ‎06-08-2017

How using U-boot to start a bare metal application?

Hi, 

 

My aim is to start a bare metal application from a tftp-server.after after startting from SD-Card a u-boot.

I have also some general questions.

 

What I had done till now:

Create FSLB (with SDK), u-boot.elf, hello_world.elf (with SDK).

 

This files wrapped together to a bin-file with

Xilinx SDK
  Xilinx Tools -> Create Image:
  FSBL              (bootloader)
  u-boot.elf        (datafile)

 

The lscript.ld looks like:

  lscript.ld (FSBL)                       Base Address    Size
  ps7_ram_0_S_AXI_BASEADDR                0x00000000      0x00030000
  ps7_ram_1_S_AXI_BASEADDR                0xFFFF0000      0x0000FE00
  
  lscript.ld (Hello_World.elf)            Base Address    Size
  ps7_ddr_0_S_AXI_BASEADDR                0x100000        0x3FF00000                    
  ps7_qspi_linear_0_S_AXI_BASEADDR        0xFC000000      0x2000000
  ps7_ram_0_S_AXI_BASEADDR                0x0             0x30000
  ps7_ram_1_S_AXI_BASEADDR                0xFFFF0000      0x0000FE00

 

I have read the the u-boot has a specific memory start-addresses: In file sturctur of the u-boot i find this file

u-boot-xlnx/arch/arm/config.mk

 which contains: 

#ifndef CONFIG_STANDALONE_LOAD_ADDR
#ifneq ($(CONFIG_ARCH_OMAP2),)
CONFIG_STANDALONE_LOAD_ADDR = 0x80300000
#else
CONFIG_STANDALONE_LOAD_ADDR = 0xc100000
#endif
#endif

 How this addresses are involved to the addresse of the lscripts.ld?

 

Now to the behavior of the system til now.

After the u-boot starts the network environment variables are set and the connection to the tftp-server could be established.

 

 

Zynq> setenv ipaddr 192.168.xxx.101 
Zynq> setenv netmask 255.255.255.0
Zynq> setenv gatewayip 192.168.xxx.1
Zynq> serverip=192.168.xxx.100
Zynq> tftpboot 0x8000 FreeRTOS_HelloWorld.elf
Using ethernet@e000b000 device
TFTP from server 192.168.xxx.100; our IP address is 192.168.xxx.101
Filename 'FreeRTOS_HelloWorld.elf'.
Load address: 0x8000
Loading: ###############
         3 MiB/s
done
Bytes transferred = 205675 (3236b hex)

 

After using different addresses for the "go" command, the system comes to two different situations:

Zynq> go 0x8000
## Starting application at 0x00008000 ...
data abort
pc : [<000085ec>]          lr : [<3ff443c4>]
reloc pc : [<c40c65ec>]    lr : [<040023c4>]
sp : 3eb21d78  ip : c004cf82     fp : 3ff4437c
r10: 00000002  r9 : 3eb21ee8     r8 : 3ffaef30
r7 : 3eb2f820  r6 : 00008000     r5 : 00000002  r4 : c0054f82
r3 : 00008000  r2 : 3eb2f824     r1 : 3eb2f824  r0 : 00001004
Flags: nzCv  IRQs off  FIQs off  Mode SVC_32
Resetting CPU ...

in the second situation the Loading stucks

Zynq> tftpboot 0x80008000 FreeRTOS_HelloWorld.elf
Using ethernet@e000b000 device
TFTP from server 192.168.xxx.100; our IP address is 192.168.xxx.101
Filename 'FreeRTOS_HelloWorld.elf'.
Load address: 0x80008000
Loading: #

 

 

What i also had tried is to convert the  FreeRTOS_ZC706_HelloWorld.elf to a bin-file with:

arm-xilinx-linux-gnueabi-objcopy -O binary FreeRTOS_ZC706_HelloWorld.elf FreeRTOS_ZC706_HelloWorld.bin

mkimage -A arm -O u-boot -T standalone -C none -a 0x00108000 -e 0x00108000 -n "FreeRTOS_ZC706_HelloWorld" -d FreeRTOS_ZC706_HelloWorld.bin uFreeRTOS_ZC706_HelloWorld.bin
mkimage: Can't map uFreeRTOS_ZC706_HelloWorld.bin: Invalid argument


 

It seem to me that the memory mapping is not consistent:

At which adress the u-boot should load and start the application?

 

Thanks in advance

AN

Tags (2)
0 Kudos
Reply
20 Replies
nunu
Contributor
Contributor
7,723 Views
Registered: ‎06-08-2017

After start the u-boot and send the bdinfo cmd it appears thits output:

 

Zynq> bdinfo
arch_number = 0x00000000
boot_params = 0x00000000
DRAM bank   = 0x00000000
-> start    = 0x00000000
-> size     = 0x40000000
baudrate    = 115200 bps
TLB addr    = 0x3FFF0000
relocaddr   = 0x3FF42000
reloc off   = 0x3BF42000
irq_sp      = 0x3EB21ED0
sp start    = 0x3EB21EC0
ARM frequency = 666 MHz
DSP frequency = 0 MHz
DDR frequency = 533 MHz
Early malloc usage: 49c / 600
0 Kudos
Reply
nunu
Contributor
Contributor
7,696 Views
Registered: ‎06-08-2017

The solution is: The Xilinx SDK supply as an output an Elf-File, which the u-boot understands:

tftpboot 0x000000 FreeRTOS_ZC706_HelloWorld.elf
bootelf 0x0

Thanks 

0 Kudos
Reply
anicotra
Visitor
Visitor
4,037 Views
Registered: ‎08-16-2018

Hello,

I hope someone is still reading this thread.  I'm having an issue running a standalone program.  The program runs fine within the SDK (2018.3).  I produce an elf image and tftp the image to the zcu102..  

I've tried a number of different commands.  I get two results:  

1. Synchronous Abort, or

2. Starting App, and hang...

I'm using the following commands:

tftpboot 0 app.elf

bootelf 0

this, or any other adress gives me the synchronous abort message.

any help would be appreciated.

 

0 Kudos
Reply
stephenm
Moderator
Moderator
4,017 Views
Registered: ‎09-12-2007

You need to set the exception level of the app you are running on u-boot. You can do this in SDK. Right click on the BSP and select Board Support Package Settings. Enable the supervisor.

 

 

0 Kudos
Reply
anicotra
Visitor
Visitor
4,013 Views
Registered: ‎08-16-2018

i don't see a setting for supervisor in the BSPs settings.  I do see one for Hypervisor.  I tried that, but no success.

0 Kudos
Reply
stephenm
Moderator
Moderator
4,005 Views
Registered: ‎09-12-2007

Yes, I meant hypervisor (autocorrected)

I Tested this a while back. I thought I created a wiki for it. Let me check

0 Kudos
Reply
shabbirk
Moderator
Moderator
3,977 Views
Registered: ‎12-04-2016

Hi

 

I have tried on zc702 and able to run hello world application, as can be seen below:

Load elf file instead of binary file, as bootelf expects the application to be in elf format

fatload mmc 0 0x0 hello.elf

bootelf 0x0

Note: please ignore the misaligned operation messages on console

0 Kudos
Reply
anicotra
Visitor
Visitor
3,966 Views
Registered: ‎08-16-2018

yes, I've tried both elf and binary executables, however, both give me the synchronous abort..

0 Kudos
Reply
stephenm
Moderator
Moderator
3,959 Views
Registered: ‎09-12-2007

0 Kudos
Reply
anicotra
Visitor
Visitor
3,955 Views
Registered: ‎08-16-2018

thanks,  i did all this but still get the abort...  only difference is the load address..  also tried loading the elf image at ZERO.  same result...

ZynqMP> tftpboot helloworld.bin
Using ethernet@ff0e0000 device
TFTP from server 192.168.111.200; our IP address is 192.168.111.254
Filename 'helloworld.bin'.
Load address: 0x10000000
Loading: *
TFTP error: 'File not found' (1)
Not retrying...
ZynqMP> tftpboot /zcu102/helloworld.bin
Using ethernet@ff0e0000 device
TFTP from server 192.168.111.200; our IP address is 192.168.111.254
Filename '/zcu102/helloworld.bin'.
Load address: 0x10000000
Loading: ########
5.9 MiB/s
done

ZynqMP> go 0x10000000
## Starting application at 0x10000000 ...
"Synchronous Abort" handler, esr 0x02000000
ELR: 940
LR: 7fef21e4
x0 : 0000000000000001 x1 : 000000007debcf18
x2 : 000000007debcf18 x3 : 0000000010000000
x4 : 0000000000000000 x5 : 0000000000000030
x6 : 000000007ff685d8 x7 : 000000000000000f
x8 : 000000007deae9e0 x9 : 0000000000000008
x10: 000000007deae26a x11: 0000000000000001
x12: 0000000000000008 x13: 00000000ffffffff
x14: 000000007ffdcb68 x15: 000000007deae027
x16: 0000000000000940 x17: 0000000000000000
x18: 000000007deaede8 x19: 000000007debcf18
x20: 0000000000000002 x21: 0000000010000000
x22: 000000007debcf10 x23: 000000007ff9db84
x24: 0000000000000002 x25: 000000007debcf70
x26: 0000000000000000 x27: 0000000000000000
x28: 0000000000000000 x29: 000000007deaeb20

Resetting CPU ...

 

0 Kudos
Reply
stephenm
Moderator
Moderator
3,943 Views
Registered: ‎09-12-2007

Yes, you will need to place the applciation at an offset. I have updated the wiki to reflect this:

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/147882060/Executing+application+from+u-boot+on+ZCU102

0 Kudos
Reply
stephenm
Moderator
Moderator
3,904 Views
Registered: ‎09-12-2007

Did you get this working?

0 Kudos
Reply
anicotra
Visitor
Visitor
3,896 Views
Registered: ‎08-16-2018

nope..  i tried a coupole different offsets 0x06000000 and 0x10000000.  Both yelded the same behavior.  I create two output files, one elf and one binary.  The binary, when go $offset, says starting application, and just hangs (no error messages), the elf when bootelf, emits the synchronous abort message.  

0 Kudos
Reply
stephenm
Moderator
Moderator
3,888 Views
Registered: ‎09-12-2007

Can you try with my Hello_World.bin

0 Kudos
Reply
anicotra
Visitor
Visitor
3,882 Views
Registered: ‎08-16-2018

same result, 

ZynqMP> go 0x6000000
## Starting application at 0x06000000 ...

 

Nothing else, just hangs...

There's no hardware issue here either, this same board boots and runs a large vxWorks image with no issues at all..

0 Kudos
Reply
stephenm
Moderator
Moderator
3,870 Views
Registered: ‎09-12-2007

Can you send oyur HDF file?

0 Kudos
Reply
anicotra
Visitor
Visitor
3,862 Views
Registered: ‎08-16-2018

see attached...

0 Kudos
Reply
stephenm
Moderator
Moderator
3,838 Views
Registered: ‎09-12-2007

How did you generate the uboot? What EL settings did you use. Can you check the BIF:

the_ROM_image:
{
[fsbl_config] a53_x64
[bootloader] embedded/lib/sw_apps/zynqmp_fsbl/src/fsbl.elf
[pmufw_image] embeddedsw/lib/sw_apps/zynqmp_pmufw/src/executable.elf
[destination_device=pl] design_1_wrapper.bit
[, destination_cpu=a53-0,exception_level=el-3,trustzone] arm-trusted-firmware/build/zynqmp/release/bl31/bl31.elf
[, destination_cpu=a53-0,exception_level=el-2] u-boot-xlnx/u-boot.elf
}

 

Try with attached, and make sure you follow the steps in the wiki

jkim1
Visitor
Visitor
3,034 Views
Registered: ‎04-02-2019

In addition to these steps, the /board/xilinx/zynqmp.c in my u-boot source originally had do_go_exec() function surrounded by #if 0, effectively disabling it. If you need to execute an EL-1 application from u-boot, which runs at EL-2 by default, you need to enable the do_go_exec() function in zynqmp.c and the exception level will be switched to EL-1 when you use the "go" command. You will see the function call armv8_switch_to_el1() in the do_go_exec() implementation. This call is required if you are launching an EL-1 application from u-boot.

0 Kudos
Reply
Prasanna_K
Explorer
Explorer
522 Views
Registered: ‎07-24-2020

Hi @stephenm ,

I tried your binary to execute the application in u-boot, however, the system hangs after the program execution, 

 

IWG35M> fatload mmc 1 0x6000000 Hello_World.bin
36936 bytes read in 15 ms (2.3 MiB/s)
IWG35M> go 0x6000000
## Starting application at 0x06000000 ...
Hello World

 

After the program execution, I want to get back into u-boot prompt, How can I achieve this?

How can I change the exception level to EL 0,1,2,3 ? Note: I do not want to include the application in the BOOT.bin, I want to load the application manually using fatload command.

Regards,

Prasanna

0 Kudos
Reply