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: 
Highlighted
Visitor ramanmohan
Visitor
6,332 Views
Registered: ‎06-21-2017

Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

Hello Xilinx community,

I am trying to run multiple application files (.elf files) on a ZC706 board (bare-metal without linux/u-boot) using Xilinx SDK 2016.3 which is to be booted from an SD card and this is what the boot.bin consists of:
1) fsbl.elf
2) wrapper.bit
3) application1.elf
4) application2.elf
in this order.

For simplicity, both the applications are of lighting up one LED each. The problem that I am facing is that only the first LED turns on i.e., only application1 is running. I assumed that it was because the memory locations that the files were using in the DDR memory were same, so i fiddled with the linker scripts (.ld files) of both the applications and I made sure that none of the memory locations were overlapping but the problem persists.

Is it not possible to run multiple .elf files on a baremetal ZC706 or am I doing something wrong?

I want to run both the applications simultaneously in one case and consecutively(one after another) in another.

TL;DR: Only one application file is being run from a boot.bin which contains more than one .elf file on a Zynq ZC706 board.

0 Kudos
12 Replies
Scholar hbucher
Scholar
6,316 Views
Registered: ‎03-22-2016

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

@ramanmohan

 

Yes, of course it is possible to run all them concurrently. I have done this several times. 

 

You can save your time and instead of burning the SD, in the SDK just go to Run Configurations... and in the Application tab, select one application for each core. Of course you would need to create 4 different applications (and BSP) for each core in separate. It is a pain but that's what it takes in standalone mode. Try this method and only then run on the SD.

 

In the picture below I have a ZCU102 that has 4 Cortex A53 cores plus 2 Cortex A9 (same as in the ZC706) plus one RPU. You could program all them at the same time.

 

You could possibly automate this with TCL though. But it's just 4 cores...

 

 

 

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
multiplecpus.PNG
0 Kudos
Scholar ericv
Scholar
6,309 Views
Registered: ‎04-13-2015

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

You will likely not be able to run applications concurrently (I assume you are thinking one app on each core) unless special handling is added for that.

If none of the .elf text / data / bss memory overlap, running them sequentially should work

But you'll need to make sure your application does not assume uninitialized variables (bss) to be zero nor can you use zero preinitialized global static local variables, and that will be an issue with many things "hidden" in the "C" library.

 

Did you include a way to run the 2nd application once the 1st one is done... and so on?

 

Regards

Eric

0 Kudos
Visitor ramanmohan
Visitor
6,213 Views
Registered: ‎06-21-2017

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

Thanks for the reply @hbucher and @ericv!

I made sure that no memory locations overlapped in both the .elf files but I have not coded a way for which the fpga to know to move from one application to another. I looked into the bootloader code and I could not figure out a way to tell the fpga to execute the second application once the first one is done executing. Is there a simple way to do that?

I want to run both the applications from a SD card only and not from a PC.

Thank you
0 Kudos
Scholar ericv
Scholar
6,199 Views
Registered: ‎04-13-2015

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

@ramanmohan

 

An easy way is to use the atexit() "C" function.

At the beginning of your first elf, call atexit() with the argument, a function pointer, set to the address of the base of the vector table of the next elf to execute.

That way, when the first elf program terminates, it will call the next program and start it fresh with a boot.

 

Regards

Scholar hbucher
Scholar
6,190 Views
Registered: ‎03-22-2016

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

@ramanmohan Not sure sure what you mean "start executing". 

 

All the CPUs will start executing main() at the same time - perhaps not exactly the same time.  I think what you mean is how to synchronize all the CPUs in a way that they do meaningful work together.

 

Xilinx standalone supports OpenAMP and inside it there is libmetal that has many features you will find useful for this purpose. But they are pretty much #define wrappers around the builtins the GCC compiler already provides. 

https://github.com/OpenAMP/libmetal/blob/master/lib/compiler/gcc/atomic.h

 

This is a nice overview:

https://openamp.github.io/docs/2016.10/libmetal-in-OpenAMP.pdf

http://docplayer.net/24445284-Openamp-kick-off-xilinx-internal.html

 

 

 

 

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
0 Kudos
Scholar ericv
Scholar
6,173 Views
Registered: ‎04-13-2015

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

If your ultimate goal is to have each of the 2 elf to run in parallel on individual cores, we have a freeware to do that.

Go in the freeware section at

www.code-time.com

and download uAbassi (not mAbassi).

In that package, there is a "bare-metal" demo with 2 simple pieces of code running in parallel.

The differences with that, and doing a packaging of 2 elf are the following:

- One elf only.

- Instead of 2 main() and 2 build, it's one build.

- you'll have to replace your 2 individual main() with App_0(), and  App_1().

 

Once you get your head around the way to use a SMP RTOS, you will most likely end up having lots of fun running things sequentially and in parallel at will.

 

Regards

0 Kudos
Visitor ramanmohan
Visitor
6,159 Views
Registered: ‎06-21-2017

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

 

Thanks for the replies @ericv and @hbucher. You guys are helping me a lot.


My problem in detail is as follows:

 

 

I have an.elf file to perform Digital PreDistortion (DPD) provided by Xilinx. I also have the .bit file for DPD. I w ant to combine the DPD application along with a user-application ( i.e., blinking an on-board LED). 

 

So, I have:

1. Xilinx provided DPD.elf

2. My own custom application led.c ---> led.elf.

 

I want to run both these applications ( led after DPD ) on a single processor one after another and I want to loop them. (LED after DPD and again LED after DPD and so on)

 

The only problem is that I do not have the .c source code for DPD. As I have only the .elf file, I cannot make changes to it.

 

How do I go about this? Any suggestion will be highly appreciated.

 

Thank you

Raman

question.jpg
0 Kudos
Scholar hbucher
Scholar
6,148 Views
Registered: ‎03-22-2016

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

@ramanmohan

You could possibly have processor #0 to loop:

- use remoteproc to run the DPD

- blink the LED

 

Remoteproc docs:

https://github.com/Xilinx/linux-xlnx/blob/master/Documentation/remoteproc.txt

 

It is not for the faint of heart. 

Check the "Simplest bare metal" example here:

http://henryomd.blogspot.com/2015/02/zynq-amp-linux-on-cpu0-and-bare-metal.html

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
0 Kudos
Scholar ericv
Scholar
6,142 Views
Registered: ‎04-13-2015

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

Another way, if the elf has the debug symbols included, would be to try this:

- use objdump to find the address of the _exit symbol

- In your LED application, which will have to run first, write to that address the instruction to branch back to the base of the vector table of the LED application and at the end of the LED application, use the atexit() to go into the 2nd elf.

 

What has to be written at the address of _exit would be either b offset or ldr pc, =Address.

The ldr PC, =Address requires 1 instruction + 1  data word and _exit is quite likely a single instruction (branch to itself)

If that's the case, you'll have to be careful where to put the 1 data word to not corrupt \code / data.

You could also try to do the same with exit (not _exit), but if exit() is not called, that won't work.

 

Yes it's a bit tricky.

Good luck

 

.

 

 

Scholar hbucher
Scholar
3,368 Views
Registered: ‎03-22-2016

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

@ericv That's some very fun code injection there, Mr Mitnick. Perhaps the easiest solution.

 

Can't the FSBL be customized to achieve this? 

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
0 Kudos
Adventurer
Adventurer
2,394 Views
Registered: ‎11-10-2017

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

Hi @hbucher,

 

I tried the bare-metal approach to run two apps simultaneously (found your video on youtube as well, which i actually followed : https://www.youtube.com/watch?v=n0hbwp36hBs ) ..and it worked...but now i want to try out loading Linux in two different processor cores say A53_0 and A53_1 and then run two different apps from there .. i am already running and testing my apps via single core .. using SD card boot ..and want to load that image in two different cores now. is it possible ?

 

if so could you please share  the detailed / setp-by step procedure on how to do it ?

 

regards

 

Vishal 

0 Kudos
2,269 Views
Registered: ‎04-23-2018

Re: Running multiple application files (.elf) from single boot.bin on Xilinx ZC706 Evaluation Board

Hi ,

I had gone through the problem as well as solution. I am facing a problem with memory as you mentioned in your explanation. I would like to know how you used linker script to solve problem. Kindly help me code / all possible documents regarding this. I am working ZCU102 and SDK2017.2 . If you don't have linker script details of ZCU102 give me a solution based on what board you have worked .

 

 

Thanks and Regards,

Sarath

0 Kudos