UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer matzik
Observer
1,050 Views
Registered: ‎10-18-2017

How do I, with u-boot, start an r5-application that the linker put into TCM?

(using zynqmp on zcu102)

 

I have a u-boot that is configured with config_mp.

 

I have generated and built hello world in xsdk for the r5.

 

I have generated a binary with the objcopy command and found the main function with the readelf.

 

If I load the binary to address 0 with u-boot, I can successfully start it with:

 

cpu 4 release 0x1000fc split

 

I found the release address with help from readelf.

 

But if I try the same with a binary linked to be in tcm, I cannot make it work.

I changed the linker script according to the link below.

http://www.wiki.xilinx.com/ZU%EF%BC%8B+Example+-+PM+Hello+World#RPU%20to%20run%20from%20TCM

 

I can load it to address 0x00FFE00000. That would be the start of the TCM. But if I try with the release row below, I do not get any printouts:

 

cpu 4 release <address in tcm, cannot remeber right now> split

I got the address with a call to readelf, grepping for main.

 

Any ideas?

0 Kudos
4 Replies
Observer krassin6227
Observer
513 Views
Registered: ‎05-18-2018

Re: How do I, with u-boot, start an r5-application that the linker put into TCM?

Hi Matzik,

can you show clear steps of how you were able to start an R5-Application with u-boot?

0 Kudos
Visitor vincenttrinh
Visitor
356 Views
Registered: ‎10-02-2018

Re: How do I, with u-boot, start an r5-application that the linker put into TCM?

Hi,

I made the "hello_world" application run onthe R5 using uboot.  I am using SDK 2018.2.  I am running in lock-step mode.

I used the hsi tool, and my build environemtn is linux (ubuntu 16.04).

linux build environment setup:

export CROSS_COMPILE=aarch64-linux-gnu-
source /media/usb0/Xilinx/SDK/2018.2/settings64.sh
export PATH=$PATH:/media/usb0/dci/xilinx/dtc
export PATH=$PATH:/media/usb0/dci/xilinx/u-boot-xlnx/tools

hsi commands:

hsi% set appdir hello_world
hsi% set hw [hsi::open_hw_design /media/usb0/joveai-dci/fpga/fpga_wrapper_with_bitstream.hdf]
hsi% set cpu psu_cortexr5_0
hsi% set swdesign [hsi::create_sw_design system -proc $cpu -app hello_world]
hsi% hsi::generate_app -hw $hw -sw $swdesign -app hello_world -proc $cpu -dir $appdir
hsi% quit

Then I had to manually modfiy the hello_world Makefile and lscript.ld that were generated so that the program would compile and link correctly.

Makefile:

Add "-mfloat-abi=hard" to CFLAGS variable:

CFLAGS := -mfloat-abi=hard

(Optional) Add "-mcpu=cortex-r5" to compile commandline for .c files:

%.o:%.c
$(CC) $(CC_FLAGS) $(CFLAGS) -c -mcpu=cortex-r5 $< -o $@ $(INCLUDEPATH)

lscript.ld:

Modify Memory section so that the file is linked to the proper TCM address (example):

MEMORY
{
/* psu_ocm_ram_0_MEM_0 : ORIGIN = 0xFFFC0000, LENGTH = 0x40000 */
/* psu_qspi_linear_0_MEM_0 : ORIGIN = 0xC0000000, LENGTH = 0x20000000 */
/* psu_r5_0_atcm_MEM_0 : ORIGIN = 0x0, LENGTH = 0x10000 */
/* psu_r5_0_btcm_MEM_0 : ORIGIN = 0x20000, LENGTH = 0x10000 */
/* psu_r5_ddr_0_MEM_0 : ORIGIN = 0x100000, LENGTH = 0x7FE00000 */
/* psu_r5_tcm_ram_0_MEM_0 : ORIGIN = 0x0, LENGTH = 0x40000 */
psu_r5_0_atcm_MEM_0 : ORIGIN = 0x0, LENGTH = 0x10000 /* actyally LENGTH can be smaller */
psu_r5_ddr_0_MEM_0 : ORIGIN = 0x10000, LENGTH = 0x10000 /* you can change these values to use all of the TCM if you like */
}

Then just make, and executable.elf is produced.

Then use armr5-none-eabi-objcopy to make a binary file:

armr5-none-eabi-objcopy -O binary executable.elf executable.bin

In order to load executable.bin into the TCM, you need to have your FSBL initialize the TCM.  To do this change the "FSBL_A53_TCM_ECC_EXCLUDE_VAL" to 0 in your xfsbl_config.h file, and remake your FSBL.

xfsbl_config.h:

#define FSBL_A53_TCM_ECC_EXCLUDE_VAL (0U)

Now after using this new FSBL, and launching to UBOOT, you can load executable.bin into the TCM, and launch the R5 (example):

Uboot:

setenv autoload no;dhcp;setenv serverip 10.15.10.72;tftpb 0xffe00000 executable.bin
cpu 4 release 0x0 lockstep

Then it just prints "hello world" on the uart.

--

Vincent.

 

Observer jwoeber
Observer
227 Views
Registered: ‎04-04-2019

Re: How do I, with u-boot, start an r5-application that the linker put into TCM?

Hi,

thanks for your detailed description. I tried to replicate it but I failed while programming the executable.bin to address 0xffe00000. I get the error:

EDIT: https://forums.xilinx.com/t5/Embedded-Linux/Reading-MPSOC-OCM-from-UBoot/td-p/863789 solved my problem. I had to add CONFIG_DEFINE_TCM_OCM_MMAP to the uboot defines.

 

"Synchronous Abort" handler, esr 0x96000046
ELR:     8031ab8
LR:      8031a94
x0 : 0000000000000000 x1 : 00000000e59ff018
x2 : 00000000000f41f3 x3 : 00000000ffe00000
x4 : 0000000000000001 x5 : 000000000000000d
x6 : 0000000000000000 x7 : 000000007ded854e
x8 : 000000007dec28f0 x9 : 0000000000000008
x10: 000000000000000d x11: 00000000ffffffd0
x12: 000000000001869f x13: 0000000000008354
x14: 000000007dec2cdc x15: 0000000000000002
x16: 0000000000008110 x17: 0000000000000000
x18: 000000007dec2df8 x19: 000000007dec48e0
x20: 0000000000000020 x21: 0000000000000000
x22: 000000007dec2988 x23: 0000000000000000
x24: 0000000000000030 x25: 00000000000f41f3
x26: 000000007ff6f000 x27: 0000000000000000
x28: 000000000000fff0 x29: 000000007dec28c0

I cant even read or write to/from address 0xffe00000 via the md & mm uboot commands without such a Synchronous Abort error beeing thrown. Is there anything obvious I missed or why cant I access the TCM from the APU?

 

Thanks

Johannes

0 Kudos
Visitor vincenttrinh
Visitor
212 Views
Registered: ‎10-02-2018

Re: How do I, with u-boot, start an r5-application that the linker put into TCM?

Hi Johannes,

That is interesting.  For me, CONFIG_DEFINE_TCM_OCM_MMAP is set by default from u-boot. 

Symbol: DEFINE_TCM_OCM_MMAP [=y]                                                                                    
Type  : bool                                                                                                        
Prompt: Define TCM and OCM memory in MMU Table                                                                      
  Location:                                                                                                         
  (1) -> ARM architecture                                                                                             
     Defined at arch/arm/mach-zynqmp/Kconfig:80                                                                        
     Depends on: ARM [=y] && ARCH_ZYNQMP [=y]  

Looks like I just got lucky because I used a later uboot which has this set by default.

 

0 Kudos