| 1 |
# |
| 2 |
# Create SDK project |
| 3 |
# |
| 4 |
|
| 5 |
# geting parsed arguments |
| 6 |
set index 1 |
| 7 |
foreach argument $argv { |
| 8 |
set parameter($index) $argument |
| 9 |
incr index 1 |
| 10 |
} |
| 11 |
|
| 12 |
# setting the parsed arguments |
| 13 |
if { [catch {set system_hdf_location_arg $parameter(1)} fid] } { |
| 14 |
puts "The tcl script was called with less parameters than required" |
| 15 |
exit 1 |
| 16 |
} |
| 17 |
if { [catch {set project_location_arg $parameter(2)} fid] } { |
| 18 |
puts "The tcl script was called with less parameters than required" |
| 19 |
exit 1 |
| 20 |
} |
| 21 |
|
| 22 |
# check if the hdf exists |
| 23 |
if {[file exists $system_hdf_location_arg]} { |
| 24 |
set system_hdf_location [file join [pwd] $system_hdf_location_arg] |
| 25 |
puts "hdf file used: $system_hdf_location" |
| 26 |
} else { |
| 27 |
puts "No such hdf file: $system_hdf_location_arg" |
| 28 |
exit |
| 29 |
} |
| 30 |
|
| 31 |
# define, create, set, project directories |
| 32 |
puts "The build directory is: $project_location_arg" |
| 33 |
if {[file exists $project_location_arg]} { |
| 34 |
puts "$project_location_arg already exists" |
| 35 |
set project_location [file join [pwd] $project_location_arg] |
| 36 |
puts $project_location |
| 37 |
} else { |
| 38 |
file mkdir $project_location_arg |
| 39 |
set project_location [file join [pwd] $project_location_arg] |
| 40 |
puts "$project_location was created" |
| 41 |
} |
| 42 |
|
| 43 |
set source_directory [pwd] |
| 44 |
set input "input_files" |
| 45 |
file mkdir $project_location/$input/sources |
| 46 |
set project_destination $project_location/$input/sources |
| 47 |
|
| 48 |
# acknowledge the board processor |
| 49 |
cd $project_location/$input |
| 50 |
file copy -force -- $system_hdf_location $project_location/$input |
| 51 |
hsi open_hw_design system_top.hdf |
| 52 |
set cpu_name [lindex [hsi get_cells -filter {IP_TYPE==PROCESSOR}] 0] |
| 53 |
puts "FPGA CPU: $cpu_name" |
| 54 |
|
| 55 |
# create project |
| 56 |
cd $project_location |
| 57 |
if {[file exists ./workspace/hw]} { |
| 58 |
puts "Delete old workspace" |
| 59 |
file delete -force -- $project_location/workspace |
| 60 |
} |
| 61 |
sdk setws $project_location/workspace |
| 62 |
|
| 63 |
sdk createhw -name hw -hwspec $system_hdf_location |
| 64 |
sdk createbsp -name bsp -hwproject hw -proc $cpu_name -os standalone |
| 65 |
sdk createapp -name sw -hwproject hw -proc $cpu_name -bsp bsp -os standalone -lang C -app {Empty Application} |
| 66 |
|
| 67 |
# import sources |
| 68 |
source $source_directory/../build_scripts/xilinx/parse_readme_copy_sources.tcl; |
| 69 |
file copy -force -- $project_location/workspace/sw/src/lscript.ld $project_destination |
| 70 |
|
| 71 |
if { $cpu_name == "sys_mb" } { |
| 72 |
set fp1 [open $project_destination/lscript.ld r+] |
| 73 |
set file_data [read $fp1] |
| 74 |
if { [regsub -all {_HEAP_SIZE : 0x800;} $file_data {_HEAP_SIZE : 0x10000;} file_data] } { |
| 75 |
puts "successfully increase the heap size to 0x10000" |
| 76 |
} else { puts "faild to increase the heap size" |
| 77 |
exit -1 |
| 78 |
} |
| 79 |
chan truncate $fp1 0 ;#delete the content |
| 80 |
seek $fp1 0 start |
| 81 |
puts $fp1 $file_data |
| 82 |
close $fp1 |
| 83 |
} |
| 84 |
|
| 85 |
sdk build_project -type all |
| 86 |
|
| 87 |
# delete the copy of source files |
| 88 |
file delete -force -- $project_location/$input |
| 89 |
puts "Done." |
| 90 |
exit |