cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Advisor
Advisor
2,480 Views
Registered: ‎02-12-2013

Vitis bare metal revision control

Jump to solution

Hello,

I need to use Vitis in bare metal mode to test some fpga logic using an R5 processor on an MPSOC.  I am just a casual user but still I want to keep these test programs and Vitis projects under version control for future use.

In the old XSDK days I was able to just commit my couple of C source files and an XSCT project setup script.  The setup script created all the supporting BSP and such that my code needed to build.  Vitis still has XSCT but I have not been able to make this work.

What is the correct way to revision control little bare metal projects like this that have only one or two C source files? 

I use Git.  I did a file count on the workspace and there are 2099 files in there.

 

----------------------------------------
DSP in hardware and software
-----------------------------------------
Tags (2)
1 Solution

Accepted Solutions
Highlighted
Moderator
Moderator
2,412 Views
Registered: ‎11-09-2015

Re: Vitis bare metal revision control

Jump to solution

Hi @pedro_uno 

You can use XSCT as well with Vitis. The commands are a bit different but still quite close. I was able to build a quick SDK flow application following the Vitis documentation and more specifically the XSCT Use Cases page.

This is the steps I used for a embedded design on Zynq-7000 (of course you will need to adapt it depending on your target)

  1. First set the workspace for the project
    setws ./workspace
    cd ./workspace
  2. Then create your application referring your XSA (this will automatically create the platform and the domain)
    app create -name my_app -hw ../system.xsa -os standalone -proc ps7_cortexa9_0 -template {Empty Application}
  3. Then import your sources
    importsources -name my_app -path ../src/
  4. And finally build the application
    app build -name my_app
  5. DONE ;)

So as with SDK, you will be able to simply commit a TCL script and the c sources


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**

View solution in original post

33 Replies
Highlighted
Moderator
Moderator
2,413 Views
Registered: ‎11-09-2015

Re: Vitis bare metal revision control

Jump to solution

Hi @pedro_uno 

You can use XSCT as well with Vitis. The commands are a bit different but still quite close. I was able to build a quick SDK flow application following the Vitis documentation and more specifically the XSCT Use Cases page.

This is the steps I used for a embedded design on Zynq-7000 (of course you will need to adapt it depending on your target)

  1. First set the workspace for the project
    setws ./workspace
    cd ./workspace
  2. Then create your application referring your XSA (this will automatically create the platform and the domain)
    app create -name my_app -hw ../system.xsa -os standalone -proc ps7_cortexa9_0 -template {Empty Application}
  3. Then import your sources
    importsources -name my_app -path ../src/
  4. And finally build the application
    app build -name my_app
  5. DONE ;)

So as with SDK, you will be able to simply commit a TCL script and the c sources


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**

View solution in original post

Highlighted
Advisor
Advisor
2,336 Views
Registered: ‎02-12-2013

Re: Vitis bare metal revision control

Jump to solution
Thanks,
The importsources command was the missing piece for me.
Have a good day.
Pete
----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
Highlighted
2,009 Views
Registered: ‎01-15-2019

Re: Vitis bare metal revision control

Jump to solution

The solution of version control of the tcl script and the source files is all well and good.

However the importsources command copies your versioned source files to the un-version controlled  workspace, just created by the tcl script.

This means that there are now two copies of the source files, so changes will be made to the temporary copied files rather than the original files.  This can lead to problems if your changes are not copied back to the version controlled files(the original source files copied to the project).

Have I missed something here?  This there a straight forward way to save a Vitis project in a version control system without making copies for the source files?  Perhaps someone can list all the Vitis files important to have under version control and the ones not required.  Thank you.

Highlighted
Observer
Observer
1,968 Views
Registered: ‎08-29-2017

Re: Vitis bare metal revision control

Jump to solution

According to UG1400 Chapter 23, the importsources Tcl command does not include the ability to 'link' source files the way that you can by the Import Sources IDE flow.

One way to handle this is to never edit the version of source file that is copied into the Vitis project. You would edit the source in your Git tree instead. When you are ready to test your code, you run your Tcl script to create a fresh project and build the source and run your tests. When satisfied, blow away the Vitis project. Repeat. The more advanced players can optimize this flow to reduce project-level overhead, which with Vitis, is significant. I consider this an industry-standard approach.

Or you can get savvy with the .project file...and dynamically, or otherwise create your own. If you go through the IDE flow to Import Sources, and then look at the .project. file, you will see how the IDE handles this case. This appears to be an IDE feature that rides on top of XSCT. It would be nice if XSCT importsources will add this capability in the future, but I think that most people just do what I describe in the previous paragraph.

See attached Tcl for how I build an FSBL in XSCT. It's early days for my flow, but the basic commands work.

Note that building from XSCT 2019.2 on Windows requires a patch: Link

0 Kudos
Highlighted
Newbie
Newbie
1,892 Views
Registered: ‎03-16-2019

Re: Vitis bare metal revision control

Jump to solution

Yikes, I assumed that importsources command only created a link in the project to your actual source files.   If it makes a copy of the files that is unacceptable.

Highlighted
Adventurer
Adventurer
1,606 Views
Registered: ‎03-16-2020

Re: Vitis bare metal revision control

Jump to solution

Hello florentw,

I have been attempting to get up and running version control of Vitis project files. During searching through this forum I found this hint how to do that. Now I would like to try the procedure described above i.e. checking in the src directory and .tcl script. I have prepared modified version of the .tcl script mentioned above for this purpose. Please can you tell me how I can run the prepared .tcl file after checking it out from my version control system? I have attempted to create Vitis workspace in the directory where the .tcl script is placed but Vitis probably does not "see" it so I guess it is incorrect way. 

0 Kudos
Highlighted
Advisor
Advisor
1,598 Views
Registered: ‎02-12-2013

Re: Vitis bare metal revision control

Jump to solution

Xilinx,  perhaps the importsources command could have an option to create a symbolic link to the source instead of copying the files. That way we could have only the one copy of the file under version control.

I don't think recreating the whole project structure each time you edit a source file is practical.

----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
Highlighted
Observer
Observer
1,566 Views
Registered: ‎08-29-2017

Re: Vitis bare metal revision control

Jump to solution
You execute the tcl script, or manually enter the commands as shown at an XSCT prompt.

XSCT ships with Vitis, it's a command line tool. See UG1400 for more details
0 Kudos
Highlighted
Adventurer
Adventurer
1,499 Views
Registered: ‎03-16-2020

Re: Vitis bare metal revision control

Jump to solution

Hello bwhitlock,

thank you for your reaction. I meant for the first time that the Vitis looks for the tcl script during starting process. Maybe it is true but it is probably necessary to set some path variable. So I decided to write the above mentioned commands directly into the xsct console. This also did not work for me. Whenever I attempted to run the app create command I received that the passed .xsa file does not exist (despite the fact that it was present in specified location). Based on that experience I attempted to record the xsct commands which are written into the console window during manual creation of platform project. I have recorded following

platform create -name PLATFORM} -hw {D:\SW\PROJECT\HWConfig\PL_LED_wrapper.xsa} -proc {ps7_cortexa9_0} -os {freertos10_xilinx} -out {D:/SW/PROJECT};platform write
platform read {D:\SW\PROJECT\PLATFORM\platform.spr}
platform active {PLATFORM}
domain active {zynq_fsbl}
::scw::get_hw_path
::scw::regenerate_psinit D:/SW/PROJECT/PLATFORM/hw/PL_LED_wrapper.xsa
::scw::get_mss_path
domain active {freertos10_xilinx_domain}
::scw::get_hw_path
::scw::regenerate_psinit D:/SW/PROJECT/PLATFORM/hw/PL_LED_wrapper.xsa
::scw::get_mss_path

Then I attempted to run the recorded commands in the xsct console. This resulted in creation of platform project in specified directory but I am not able to see the platform project in Vitis. I have attempted to import the platform project somehow but without success. Do you have any idea how to import the previously created platform project into the Vitis? 

0 Kudos
Highlighted
Adventurer
Adventurer
1,493 Views
Registered: ‎03-16-2020

Re: Vitis bare metal revision control

Jump to solution

I have found how to import the previously created platform project into the Vitis:

1) File->Import ...

2) Choose "Eclipse workspace or zip file"

3) Choose directory containing the platform project

4) Uncheck the checkbox "Copy projects into workspace"

5) Press button "Refresh"

0 Kudos
Highlighted
Adventurer
Adventurer
1,477 Views
Registered: ‎03-16-2020

Re: Vitis bare metal revision control

Jump to solution

Now I achieved a state when I am able to create the platform project along with application project via xsct commands. As a next step I would like to create both projects automatically via invoking the tcl script. So I inserted all the xsct commands previously manually written in xsct console into tcl script and I attempted to run the script via source D:/SW/PROJECT/data/init.tcl. Unfortunatelly this attempt resulted in error message: "No platforms available in repository with matching name: PLATFORM". Do you know how to resolve that?

0 Kudos
Highlighted
Visitor
Visitor
1,315 Views
Registered: ‎02-19-2020

Re: Vitis bare metal revision control

Jump to solution

Setupt: one has a version controlled folder with c-files and a build-tcl script with the XSCT command.

After one executes the tcl script with importsources, there is a workspace with the project and the project can be compiled. However, the c-files are not longer version controlled, therefore the problem is still not solved!

Any idears of changing files in the workspace and copying them back to the source controlled folder are ludicrous.

Please describe how to set up a properly source controlled vitis project. I am ofcourse aware of all the other not answered threads about this major issue so no reason to link to them

Highlighted
Advisor
Advisor
1,219 Views
Registered: ‎02-12-2013

Re: Vitis bare metal revision control

Jump to solution

In the past I have used tcl commands to create symbolic links to my source files.  It is a lot of extra commands, one for each source file. Would it be possible to make a symbolic link for top source folder? I haven't tried it but where there is a will there is a way to make Eclipse based project compatible with revision control.

----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
Highlighted
Adventurer
Adventurer
1,184 Views
Registered: ‎03-16-2020

Re: Vitis bare metal revision control

Jump to solution

Hello pedro_uno,

thank you for your reaction. Please can you share the above mentioned tcl script with links to source files? It would be very helpful for me. Thanks.

0 Kudos
Highlighted
1,147 Views
Registered: ‎05-30-2018

Re: Vitis bare metal revision control

Jump to solution

same question here.  How can these tools still think that copying the source files is the right thing to do ?  Out of place build is the standard everywhere, how do we link to our source files in any version of SDK ?   The idea of creating the project from tcl and source in cm and then using the GUI to edit/debug etc. and check the changed files back into CM is the standard development practice for everything else I have ever used, why cant SDK see this?  a simple  -link option for importsources cannot be that hard.

Please Xilinx, provide a decent way to have source code and tcl in one directory tree and the automated build artifacts in another and then answer these posts, Please.

Bryan
Highlighted
Advisor
Advisor
1,121 Views
Registered: ‎02-12-2013

Re: Vitis bare metal revision control

Jump to solution
Steven, I pulled up Vitis to test my script before posting but could not get anything at all to work in that tool. I even tried to create a simple Hello app but could not get that to run either. So here is what I had tried before. The idea is that I created an app and copied in the source files. I tried to replace the copy with the symbolic link but my recollection is that it never worked. I hope your luck is better than mine.

file delete -force ./workspace
setws ./workspace
#app create -name test1 -hw ../../implement/results/top.xsa -proc psu_cortexr5_0 -os standalone -lang C -template {Empty Application}
app create -name test1 -hw ../../implement/results/top.xsa -proc psu_cortexr5_0 -os standalone -lang C -template {Hello World}
file copy -force ./main.c ./workspace/test1/src
#file link -symbolic ./workspace/test1/src/main.c ./main.c
file delete -force ./workspace/test1/src/helloworld.c
app build -name test1

----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
1,080 Views
Registered: ‎02-19-2020

Re: Vitis bare metal revision control

Jump to solution

I just want to highlight Brayn's point that it is not only about getting it to work "somehow", but to have this working in a usable way!

Highlighted
Adventurer
Adventurer
1,059 Views
Registered: ‎03-16-2020

Re: Vitis bare metal revision control

Jump to solution

Hello pedro_uno,

thank you for your willingness. The problem is that I need to avoid the copying operation. I have been usign following tcl script which suppose that you have following directory structure under version control:

*Scripts (contains the .tcl script)

*APP

 -drivers (contains the source codes for custom IP cores)

 -src (contains the source codes for the application)

Here is the tcl script:

 

proc generate_workspace {args} {
  
	set hw 0
	set workspace "C:/SW/WORKSPACE"
	set source_dir 0
	set ip_drivers_dir 0
	set help 0
	
	for {set i 0} {$i < [llength $args]} {incr i} {

		if {[lindex $args $i] == "-hw"} {
			
			set hw [lindex $args [expr {$i + 1}]]
			if {[file extension $hw] != ".xsa"} {
				set hw 0
			} else { 
				set hw $hw
			}
		}

		if {[lindex $args $i] == "-workspace"} {
			
			set workspace [lindex $args [expr {$i + 1}]]

			if {[file exists $workspace] == 1} {
				file delete $workspace
			}
		}

		if {[lindex $args $i] == "-src_dir"} {
			set source_dir [lindex $args [expr {$i + 1}]]
		}

		if {[lindex $args $i] == "-ip_drivers_dir"} {

			set ip_drivers_dir [lindex $args [expr {$i + 1}]]
		}

		if {[lindex $args $i] == "-help"} {
			
			puts "generate_workspace -hw <path to xsa>.xsa"
			puts "optional -workspace <workspace name>: default workspace"
			puts "optional -src_dir <path to source directory>: default 0"
			puts "optional -ip_drivers_dir <path to ip core drivers directory>: default 0"
			set help 1
		}
	}

	if {$hw != 0} {
	
		setws $workspace

		platform create -name PLATFORM -hw $hw

		if {$source_dir != 0} {

			domain create -name DOMAIN -os freertos10_xilinx -proc ps7_cortexa9_0

			app create -name APP -domain DOMAIN -template "Empty Application"

			importsources -name APP -path ${source_dir}

			importsources -name APP -path ${ip_drivers_dir}
		}

	} else {

		if {$help == 0} {
			puts "Please pass the XSA file. Use -help for more info"
		}
	}
}

 

The importsources commands are unnecessary because the drivers and src directories are already present in the APP but without them I was not able to create the application project in Vitis. 

0 Kudos
Highlighted
Advisor
Advisor
1,057 Views
Registered: ‎02-12-2013

Re: Vitis bare metal revision control

Jump to solution

Steven,

The whole point of this thread is to avoid the importsources command in XSCT.  importsources copies files into your workspace which works against good version control.  You use the -path option that has the same effect, copying over any files in the workspace.

-path <source-path>
Path from which the source files should be imported.
If <source-path> is a file, it is imported to application project.
If <source-path> is a directory, all the files/sub-directories from
the <source-path> are imported to application project. All existing
source files will be overwritten in the application, and new files
will be copied. Linker script will not be copied to the application
directory, unless -linker-script option is used.

Have you tried using the "file link -symbolic" command to create links to your source files without copying? 

----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
951 Views
Registered: ‎05-26-2019

Re: Vitis bare metal revision control

Jump to solution

Dear @pedro_uno,

If you are using Vitis GUI then you can see that the only problem path is a path to platform project. To work properly workspace also needs. This method doesn't involve importsources. So I suggest that the solution can be:

1) create a workspace with your platform, system, app;

2) clean project, since the platform can be regenerated; 

3) commit and push whole workspace (including metadata).

The second paragraph means, that for proper work we need ./platform/export directory, so by clicking the right button on the platform -> Build Project we will recreate them.

 

Now let us see how it looks like from the guy who just cloned your project for the first time:

1) I must open Vitis and select workspace with platform, system, and app;

2) regenerate platform project;

3) in menu panel Xilinx -> Add Custom Platform... specify new platform which was cloned;

4) compile the app.

So you even don't need to edit prj-file where you can find the absolute path to the platform. Also, you can add workspace files to repository only once, then you should add most of them in .gitignore - since different users will change some absolute paths. All these steps you should do only in the beginning, so it is a kinda convenient way.

The platform link to the app is the only place where the absolute path is, cause even if you will save the paths, but delete platform from "Platform Repositories" - then errors again and your projects can't see this. And you can't use any predefined variables in any way, because there is no variable like "WORKSPACE_LOCATION" (there are some eclipse variables, but they don't work with Xilinx stuff)

P.s. I didn't check this method with git, I only tested it with renaming and moving directories

P.p.s. If you think that you should keep libraries in the way they generated firstly (or maybe you just edited them) just do not use paragraph 2 in both lists.

 

VITIS_question.JPG
0 Kudos
Highlighted
Adventurer
Adventurer
924 Views
Registered: ‎03-16-2020

Re: Vitis bare metal revision control

Jump to solution

Hello sosnitzkij,

thank you for your reply. Let´s say I need to have following source codes under version control:

a) application source codes

b) custom IP cores drivers source codes.

The cathegory a) source codes are used by the Vitis application project and the cathegory b) source codes are used by the Vitis platform project. Please can you tell me how can you use your approach in this situation? Thanks.

0 Kudos
Highlighted
Adventurer
Adventurer
919 Views
Registered: ‎03-16-2020

Re: Vitis bare metal revision control

Jump to solution

Hello pedro_uno,

thank you for your reply. I think that we are on the same page. The idea behind the above mentioned script is that the source codes for the application and custom IP cores are already present in the directory which is under version control and the importsources command is used only for creating the workspace. I don´t understand why but without this command I am not able to create the Vitis workspace via the tcl script. I have attempted to describe this already in the last sentence in my response above.  As far as the tcl command file link -symbolic. It doesn´t work for me also.

0 Kudos
Highlighted
Visitor
Visitor
884 Views
Registered: ‎05-26-2019

Re: Vitis bare metal revision control

Jump to solution

Dear @Steven ,

I think you can use the way I described but after the last step add your libs to .gitignore

 

0 Kudos
Highlighted
Adventurer
Adventurer
803 Views
Registered: ‎03-16-2020

Re: Vitis bare metal revision control

Jump to solution

Hello @sosnitzkij

Thank you for your reply. I am sorry but I don´t understand why I should place the libraries into the ignore list. I need to have them under version control.

0 Kudos
Highlighted
Visitor
Visitor
787 Views
Registered: ‎05-26-2019

Re: Vitis bare metal revision control

Jump to solution

Dear @Steven ,

Sorry for confusion, it's just my practice to add in .gitignore everything that I want to have under version control. It's a regular practice with Vivado: firstly, you add everything to gitignore, then you add exception strings, e.g.:

*
!.gitignore
!*.srcs

 

0 Kudos
Highlighted
Adventurer
Adventurer
775 Views
Registered: ‎03-16-2020

Re: Vitis bare metal revision control

Jump to solution

Hello @sosnitzkij,

now I see. I have been thinking about your idea and it seems to me that it could be simplified in this manner. Only the application source files and custom IP cores drivers source files will be under version control as far as the Vitis project (as far as the associated Vivado project I am going to have only the .xpr file under version control). Based on the .xsa file with hardware configuration I am able to recreate the platform project. Based on that I can create the application project with "Empty application" template usage. At this moment I can use the "Link folder" construct of the underlying Eclipse IDE (Application project->Properties->C/C++ General->Paths and Symbols->Link Folder and then set the path to the linked folder).

From any other team member point of view it is suficient only to pull the Vivado .xpr file (most probably in its own repository) and the source files for the application and custom IP drivers. Then he can recreate the .xsa file from the .xpr file, based on that he creates the Vitis platform project and appliction project and via "Linked Folder" he bindes the source files with the application project. I have tested the proposed approach and it works. What do you think about that?

0 Kudos
Highlighted
Advisor
Advisor
753 Views
Registered: ‎02-12-2013

Re: Vitis bare metal revision control

Jump to solution

Is there a way to automate this "linked folder" approach in the XSCT setup script?

If no, then I still think it is an awkward solution.

I feel bad for companies that have build their toolchains on top of Eclipse.  I have found from the beginning that Eclipse based projects are very difficult to manage, version control  or automate.  These obstacles really discourage collaboration.

Am I wrong?

----------------------------------------
DSP in hardware and software
-----------------------------------------
Highlighted
Visitor
Visitor
743 Views
Registered: ‎05-26-2019

Re: Vitis bare metal revision control

Jump to solution
Dear @Steven
Interesting idea, but you should check if it works when the absolute path changes - both link folder and project
0 Kudos
Highlighted
Observer
Observer
289 Views
Registered: ‎10-17-2019

Re: Vitis bare metal revision control

Jump to solution
I think more companies should make the command line workflows first-class citizens and only make GUIs on top as a bonus. Would save time trying to go backwards when trying to automate workflows.