cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Advisor
Advisor
3,598 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)
49 Replies
Highlighted
Advisor
Advisor
1,128 Views
Registered: ‎02-12-2013

Hello Guys,

I am trying to do some stuff with Vitis again so I took the time to try the symbolic link workaround for referencing source files.

I think the idea to copy source files into the Vitis project and then remember to copy them back into the version controlled folder is unacceptable.  I prefer to use symbolic links to reference my source files.  That way only one copy of the file exists, the one in version control. Luckily, tcl is fully capable of creating symbolic links.  I just create the links in the setup.tcl file that I use to create the Vitis project.  Only my source files and setup.tcl are committed to version control.

Below is a simple example where my only source file is main.c.  I create an Empty Application and then a symbolic link so that main.c appears to be in the src folder of that app.  Watch out, the "file link" command is a little tricky. The location of the target is relative to the link not the CWD.

What do you guys think?

# run at linux command line "xsct setup.tcl"
set sdk_dir ./dma_test.sdk
 
file delete -force $sdk_dir
 
set plat ../../../fpga/implement/results/top.xsa
#set proc "ps7_cortexa9_0"
#set proc "psu_cortexr5_0"
set proc "psu_cortexa53_0"
set os "standalone"
 
setws $sdk_dir
 
platform create -name "streamer" -hw $plat -proc $proc -os $os
 
platform generate
 
domain create -name "streamer_domain" -os $os -proc $proc
 
app create -name test2 -platform streamer -domain streamer_domain -template "Empty Application"
 
file link -symbolic $sdk_dir/test2/src/main.c ../../../src/main.c
 
app build test2
----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
1,083 Views
Registered: ‎02-19-2020

Hi all,

2020.1 is released (I did not notice for quite a while):

https://www.xilinx.com/html_docs/xilinx2020_1/vitis_doc/bob1585821550069.html?hl=importsources

It seems like the option "-soft-link" is exactly what this thread asked for

-soft-link 	Links the sources from source-path and does not copy the source

I was not able to test this yet, but I do so ASAP since this change would speed up our upgrade to 2020.1 quite a bit! Quite happy to see this option!

Furthermore, the online docs has changed appearance slightly from 2019.2 to 2020.1, which improves readability quite a bit in my opinion!

Highlighted
Participant
Participant
1,046 Views
Registered: ‎10-17-2019
We're still in 2019.1 waiting for this whole Vitis thing to stabilize. Dunno if XSCT can be upgraded standalone or is it too different in Vitis already
0 Kudos
Highlighted
Advisor
Advisor
1,033 Views
Registered: ‎02-12-2013

Hello,

I spent a couple of hours trying to use the importsources command with the -soft-link option.  I failed to ever construct an XSCT tcl script that did anything useful.

I will stick with the "file link -symbolic" command.

 

----------------------------------------
DSP in hardware and software
-----------------------------------------
Highlighted
Observer
Observer
951 Views
Registered: ‎08-29-2018
Highlighted
Visitor
Visitor
913 Views
Registered: ‎07-08-2020

I have gotten the soft link option working in Linux, I use the following tcl script to create a new project and import my source code using the soft-link option. In this example the absolute paths to the input xsa and source code folder must be used.

 

 

if { $argc != 2 } {
    puts "please input path to an xsa and a path to the source code"
    exit
}
setws ./workspace
cd ./workspace
app create -name app_name -hw [lindex $argv 0] -os standalone -proc ps7_cortexa9_0 -template {Hello World}
importsources -name app_name -path [lindex $argv 1] -soft-link
file delete -force ./app_name/src/helloworld.c
app config -name app_name -add include-path ../../app_name/src
app build -name app_name

 

 

0 Kudos
Highlighted
Observer
Observer
900 Views
Registered: ‎08-29-2018

@AaronCrump 

This is strange. Your example does not work for me on Windows or Linux. I changed the CPU name to match my FPGA design (in which it's a MicroBlaze called "cpu"), but that's all.

I wondered if the fact that you're using the Hello World template was significant - I use Empty Application - but apparently not. As an aside, I had a permissions error when I tried

  file delete -force ./app_name/src/platform_config.h

I've posted a MCVE with a script very similar to yours in this thread:

  https://forums.xilinx.com/t5/Vitis-Acceleration-SDAccel-SDSoC/Vitis-and-version-control-git/m-p/1125836

This shows -soft-link breaking importsources under WIndows and Linux. Perhaps this issue is connected to the XSA file in some way.

Would you mind trying my example?

0 Kudos
Highlighted
Visitor
Visitor
806 Views
Registered: ‎07-08-2020

@amb5l 

Your script works fine for me once I added the correct path to the source files. Your script does not import sources because the path to your sources is relative, try adding the absolute path to your sources to the script instead. You must select a specific processor, you cannot just choose "cpu"

Highlighted
Observer
Observer
791 Views
Registered: ‎08-29-2018

@AaronCrump 

I need to use a relative path for the script to play nicely with version control. Haven’t tried an absolute path. The “good.tcl” script works perfectly for me - with relative paths - and my MicroBlaze processor instance is called “cpu”. The design works on my hardware. 

0 Kudos
Highlighted
Visitor
Visitor
786 Views
Registered: ‎07-08-2020

You can experiment with the location of the relative path or use the [lindex $argv 0] convention I used in my script to pass in the path.  

Highlighted
Observer
Observer
773 Views
Registered: ‎08-29-2018

@AaronCrump 

Thank you - you're right. If I change the relative source path to an absolute one in "bad.tcl", it works.

So... I've developed a new script - "fix.tcl" - which puts what we know so far together. It uses -soft-link but with an absolute path, then hacks the .project file to substitute relative paths back in. Works on Windows and Linux.

Here's the script:

set ws_name fix
set app_name myapp

# create project
setws ./$ws_name
cd $ws_name
app create -name $app_name -hw ../fpga.xsa -os standalone -proc cpu -template {Empty Application}

# import sources
# *** the line below does not work ***
#importsources -name $app_name -path ../src -soft-link
# so import the sources using an absolute path...
set abs_path [file normalize ../src]
importsources -name $app_name -path $abs_path -soft-link
# ...then hack .project to convert absolute to relative paths
set rel_path "\${PARENT-2-PROJECT_LOC}/src"
set f [open "./$app_name/.project" "r"]
set lines [split [read $f] "\n"]
proc lmap {_var list body} {
    upvar 1 $_var var
    set res {}
    foreach var $list {lappend res [uplevel 1 $body]}
    set res
}
set lines [lmap line $lines {string map [list $abs_path $rel_path] $line}]
set f [open "./$app_name/.project" "w"]
puts $f [join $lines "\n"]
close $f

# build
app config -name $app_name include-path "../../../src"
app build -name $app_name

 

Note that ${PARENT-2-PROJECT_LOC} relates to the number of directory levels to get up to the root of the file set from the application directory in the Vitis workspace; 2 in this case.

Highlighted
Visitor
Visitor
695 Views
Registered: ‎07-13-2020

@nutang @chaitany 

Great find @AaronCrump , Great hack @amb5l , good job.  Now we just need Xilinx to fix relative path support when using -soft-link so that we don't have to hack the project file.  

0 Kudos
Highlighted
Visitor
Visitor
689 Views
Registered: ‎07-08-2020

You should not have to hack the project file. Just delete your workspace and recreate it with one of the posted scripts.

Highlighted
Advisor
Advisor
662 Views
Registered: ‎02-12-2013

# run at linux command line "xsct setup.tcl"
file delete -force ./workspace

set hw ../../../fpga/implement/results/top.xsa
set proc "psu_cortexa53_0"

setws ./workspace

platform create -name "standalone_plat" -hw $hw -proc $proc -os standalone

app create -name xscugic_test -platform standalone_plat -domain standalone_domain -template "Empty Application"
file link -symbolic ./workspace/xscugic_test/src/xscugic_example.c ../../../src/xscugic_example.c

 

----------------------------------------
DSP in hardware and software
-----------------------------------------
Highlighted
Historian
Historian
648 Views
Registered: ‎02-25-2008

AMAZING.

Long-time users have been complaining FOR YEARS about how the Xilinx tools are hostile to proper source-code control.

And it's just gotten worse.

Come on, Xilinx, get your act together. This situation is beyond stupid.

----------------------------Yes, I do this for a living.
Highlighted
Visitor
Visitor
604 Views
Registered: ‎02-19-2020

@florentwwhen can we expect the hotfix for this issue?

The abstance of xilinx employees in this thread is not encouraging to us users (and costumers) btw.

Highlighted
Visitor
Visitor
571 Views
Registered: ‎07-13-2020

@AaronCrump , the script itself that @amb5l posted is "hacking" the project file.  That's what i'm referring to, not manually editing the project file.  

0 Kudos
Highlighted
Contributor
Contributor
541 Views
Registered: ‎01-31-2018

Thanks for the work on this. It'll be helpful.

The project I'm working on takes things a step further. We have modifications to our BSP that aren't accounted for in the mainline, so for the app_create we'll instead have to start with a platform_create, then create a domain with existing sources in a relative path.  I haven't fully gotten this to work yet, but hopefully I can soon and couple it with your script and be off to the races.

0 Kudos
Highlighted
Explorer
Explorer
197 Views
Registered: ‎10-04-2017

This whole thing is a mess.  Xilinx why can't you just provide guidance on how to do this???

I'm trying a slightly different approach by using a shell script that does a combination of tcl scripts and shell commands.  For example, I can create the project with tcl but create the links in the shell.   Or the other thing is I can just checkout my git repo with src and create the vitis project on top of it.  Like

git co <url> my_app   // creates a directory like my_app/src 

and then app create -name my_app creates everything around my src.   

I'm still working out the kinks but I like this approach since I don't have to do everything in tcl

I need to modify the BSP also, so I'm taking a bit of a psuedo yocto approach.  I create a list of patches against the generated BSP then apply them after app create and before building.  I found a page that talks about modifying the source and using an external repo which would be useful if the BSP changes were large.

jeff 

0 Kudos
Highlighted
Explorer
Explorer
53 Views
Registered: ‎10-04-2017

Another sad thing is that the same scripts/process that worked from the command line wouldn't work from a yocto recipe.  I have a freertos app on RPU0 that I want built and added to the BOOT.BIN and the linux rootfs.  

 

jeff

0 Kudos