From 1ccae2ebeda64f52c9b151d34387cca0792199c2 Mon Sep 17 00:00:00 2001 From: Gatsby Date: Tue, 29 Oct 2024 14:40:53 +0800 Subject: [PATCH 01/11] docs: add common issue regarding symbolic links on Windows --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 081e788..88f377d 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,14 @@ 这是因为源文件在导入时被直接链接或复制到了工程目录中,未触发 C++ Indexer 更新索引。此外,新版本的 Vitis 没有直接的命令或 UI 选项来重建或更新索引。最简单的解决方法是随意打开一个源文件,在任意行末输入一个空格并保存。IDE 会自动删除该空格,不会对源文件造成任何更改,但此操作可触发索引的自动更新。 +2. 在 Windows 上运行 `.bat` 构建脚本时可能会出现以下错误: + + ```plaintext + Failed to create file symbolic link using mklink: 你没有足够的权限执行此操作。 + ``` + + 这是因为 `tcl` 在 Windows 上只能为文件夹创建符号链接,无法直接为文件创建链接。为文件创建符号链接需要使用 `mklink` 命令,该命令要求管理员权限。解决方法是以管理员身份运行 `.bat` 脚本。 + ## 待办事项 - [x] 支持 Xilinx SDK 的 XSCT 接口 @@ -163,4 +171,4 @@ ## 贡献指南 -如果您对该项目有任何改进意见或功能需求,欢迎提交 issue 或 pull request,commit 格式请参考 [Angular convention](https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional). +如果您对该项目有任何改进意见或功能需求,欢迎提交 issue 或 pull request,commit 格式请参考 [Angular convention](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit). From c042d2c391b38248711f7983f051949f74d8e7bc Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Thu, 31 Oct 2024 11:33:31 +0800 Subject: [PATCH 02/11] fix(platform/xilinx): fix(platform/xilinx): ensure domain is generated post-creation --- platform/xilinx/util.tcl | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/xilinx/util.tcl b/platform/xilinx/util.tcl index ca8864d..a191e14 100644 --- a/platform/xilinx/util.tcl +++ b/platform/xilinx/util.tcl @@ -81,6 +81,7 @@ proc _configure_bsp {bsp_name bsp_config platform_name is_vitis} { if {$is_vitis} { bsp regenerate + platform generate -domains "$bsp_name" } else { regenbsp -bsp $bsp_name projects -build -type bsp -name $bsp_name From 61da61b28efb3024d0ace26ca4e0a8991975f37e Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Thu, 31 Oct 2024 11:35:41 +0800 Subject: [PATCH 03/11] refactor(platform/xilinx): modify default BSP/Domain names to reduce conflicts --- platform/xilinx/HOWTO.md | 2 +- platform/xilinx/util.tcl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/xilinx/HOWTO.md b/platform/xilinx/HOWTO.md index 3f339d7..f012208 100644 --- a/platform/xilinx/HOWTO.md +++ b/platform/xilinx/HOWTO.md @@ -175,7 +175,7 @@ - **target_cpu**: 目标 CPU ID[^2]; - **os**: 操作系统类型[^1],必须与 BSP/Domain 匹配; - **language**: 编程语言,"C" 或 "C++"; -- *bsp*: 应用所使用的 BSP 名称,若未指定则会自动创建名为 `_` 的 BSP/Domain. +- *bsp*: 应用所使用的 BSP 名称,若未指定则会自动创建名为 `_bsp` 的 BSP/Domain. - *bsp_lib*: 针对自动创建的 BSP/Domain 所使用库的配置,与 [bsps](#bsps) 中 `libs` 对应; - *bsp_config*: 针对自动创建的 BSP/Domain 配置与 [bsps](#bsps) 中 `config` 对应; - *mem_layout*: 应用内存布局,包括堆栈大小和堆大小等; diff --git a/platform/xilinx/util.tcl b/platform/xilinx/util.tcl index a191e14..671a4bd 100644 --- a/platform/xilinx/util.tcl +++ b/platform/xilinx/util.tcl @@ -250,7 +250,7 @@ proc _create_app {app_name app_config platform_name is_vitis} { set os [dict get $app_config os] set lang [dict get $app_config language] set sources [dict get $app_config sources] - set bsp_name "${os}_${cpu}" + set bsp_name "${app_name}_bsp" # Configure BSP/Domain for application if {[dict exists $app_config bsp] && [dict get $app_config bsp] ne ""} { From af92cd0a53187b9a916a2725be415df634d281c1 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Thu, 31 Oct 2024 11:36:07 +0800 Subject: [PATCH 04/11] feat(platform/xilinx): add support for specifying application template --- platform/xilinx/HOWTO.md | 2 ++ platform/xilinx/template.json | 1 + platform/xilinx/util.tcl | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/platform/xilinx/HOWTO.md b/platform/xilinx/HOWTO.md index f012208..625fd0b 100644 --- a/platform/xilinx/HOWTO.md +++ b/platform/xilinx/HOWTO.md @@ -135,6 +135,7 @@ "target_cpu": "", "os": "", "language": "", + "template": "", "bsp": "", "bsp_lib": { "": { @@ -175,6 +176,7 @@ - **target_cpu**: 目标 CPU ID[^2]; - **os**: 操作系统类型[^1],必须与 BSP/Domain 匹配; - **language**: 编程语言,"C" 或 "C++"; +- *template*: 所使用的应用模板名称,不指定则默认为对应语言的 “Empty Application”; - *bsp*: 应用所使用的 BSP 名称,若未指定则会自动创建名为 `_bsp` 的 BSP/Domain. - *bsp_lib*: 针对自动创建的 BSP/Domain 所使用库的配置,与 [bsps](#bsps) 中 `libs` 对应; - *bsp_config*: 针对自动创建的 BSP/Domain 配置与 [bsps](#bsps) 中 `config` 对应; diff --git a/platform/xilinx/template.json b/platform/xilinx/template.json index a42c0c6..5ac3580 100644 --- a/platform/xilinx/template.json +++ b/platform/xilinx/template.json @@ -31,6 +31,7 @@ "target_cpu": "", "os": "", "language": "", + "template": "", "bsp": "", "bsp_lib": { "": { diff --git a/platform/xilinx/util.tcl b/platform/xilinx/util.tcl index 671a4bd..9ab4476 100644 --- a/platform/xilinx/util.tcl +++ b/platform/xilinx/util.tcl @@ -248,9 +248,22 @@ proc _update_app_build_config {app_name build_type build_config is_vitis} { proc _create_app {app_name app_config platform_name is_vitis} { set cpu [dict get $app_config target_cpu] set os [dict get $app_config os] - set lang [dict get $app_config language] set sources [dict get $app_config sources] set bsp_name "${app_name}_bsp" + set lang [dict get $app_config language] + if { $lang ne "C" && $lang ne "C++" } { + _error "Unsupport language" "language should be C or C++" + } + if { [dict exists $app_config template] } { + set template [dict get $app_config template] + } elseif { !$is_vitis } { + set template "Empty Application" + } elseif { $lang eq "C++" } { + set template "Empty Application (C++)" + } else { + set template "Empty Application(C)" + } + # Configure BSP/Domain for application if {[dict exists $app_config bsp] && [dict get $app_config bsp] ne ""} { @@ -280,7 +293,7 @@ proc _create_app {app_name app_config platform_name is_vitis} { -os $os \ -lang $lang \ -sysproj $::project_name \ - -template "Empty Application($lang)" + -template "$template" _info "Application '$app_name' created for Vitis." } else { sdk createapp -name $app_name \ @@ -289,7 +302,7 @@ proc _create_app {app_name app_config platform_name is_vitis} { -proc $cpu \ -os $os \ -lang $lang \ - -app "Empty Application" + -template "$template" _info "Application '$app_name' created for Xilinx SDK." } From eb3ca273b4ea0e5c71cabd2dd3b2aa02e97bb5b8 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Fri, 1 Nov 2024 00:26:48 +0800 Subject: [PATCH 05/11] refactor(platform/xilinx): strengthen parameter validation --- platform/xilinx/util.tcl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platform/xilinx/util.tcl b/platform/xilinx/util.tcl index 9ab4476..fb12f71 100644 --- a/platform/xilinx/util.tcl +++ b/platform/xilinx/util.tcl @@ -268,6 +268,13 @@ proc _create_app {app_name app_config platform_name is_vitis} { # Configure BSP/Domain for application if {[dict exists $app_config bsp] && [dict get $app_config bsp] ne ""} { set bsp_name [dict get $app_config bsp] + if {![dict exists $::config bsps]} { + _error "BSP configuration missing" "The 'bsps' section is not found in the configuration." + } elseif {![dict exists [dict get $::config bsps] $bsp_name]} { + _error "BSP configuration missing" "No configuration found for BSP '$bsp_name' in the 'bsps' section." + } else { + _info "Configuring BSP '$bsp_name' for application '$app_name'." + } } else { set bsp_config [dict create] set bsp_config [dict set bsp_config target_cpu $cpu] @@ -280,6 +287,7 @@ proc _create_app {app_name app_config platform_name is_vitis} { set bsp_cfg [dict get $app_config bsp_config] set bsp_config [dict merge $bsp_config [dict create config $bsp_cfg]] } + _info "Creating BSP $bsp_name for Application $app_name ..." _configure_bsp $bsp_name $bsp_config $platform_name $is_vitis } From 38d3fd56673bb3f491c21b4ff5a1a7701d600e1b Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Fri, 1 Nov 2024 00:28:41 +0800 Subject: [PATCH 06/11] chore(makefile): add @ to silence specific print commands --- generic.mk | 24 ++++++++++++------------ platform/xilinx/xilinx.mk | 14 ++++++-------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/generic.mk b/generic.mk index 52dd006..798df5b 100644 --- a/generic.mk +++ b/generic.mk @@ -30,16 +30,16 @@ else endif ifndef PROJECT - $(error "PROJECT variable needs to be set") + @$(error "PROJECT variable needs to be set") endif ifndef PLATFORM - $(error "PLATFORM variable needs to be set") + @$(error "PLATFORM variable needs to be set") endif ifndef BUILD_DIR - $(error "BUILD_DIR variable needs to be set") + @$(error "BUILD_DIR variable needs to be set") endif ifndef CONFIG_FILE - $(error "CONFIG_FILE variable needs to be set") + @$(error "CONFIG_FILE variable needs to be set") endif ifndef SCRIPT_DIR CURRENT_FILE := $(lastword $(MAKEFILE_LIST)) @@ -66,15 +66,15 @@ endif PHONY += all ifneq ($(wildcard $(BUILD_LOCK)),) all: - $(call print_build_type,$(PLATFORM)) + @$(call print_build_type,$(PLATFORM)) $(MAKE) --no-print-directory build - $(call print,Done ($(notdir $(BUILD_DIR)))) + @$(call print,Done ($(notdir $(BUILD_DIR)))) else all: - $(call print_build_type,$(PLATFORM)) + @$(call print_build_type,$(PLATFORM)) $(MAKE) --no-print-directory project $(MAKE) --no-print-directory build - $(call print,Done ($(notdir $(BUILD_DIR)))) + @$(call print,Done ($(notdir $(BUILD_DIR)))) endif project: $(PLATFORM)_project @@ -93,18 +93,18 @@ sdkopen: $(PLATFORM)_sdkopen PHONY += clean ifneq ($(wildcard $(BUILD_LOCK)),) clean: - $(call print,Cleaning sdk build uploaded to board) + @$(call print,Cleaning sdk build uploaded to board) $(MAKE) --no-print-directory $(PLATFORM)_sdkclean else clean: - $(call print,No project found, cleaning dummy files) + @$(call print,No project found, cleaning dummy files) $(MAKE) --no-print-directory reset endif # Remove the whole build directory PHONY += reset reset: $(PLATFORM)_reset - $(call print,[Delete] $(BUILD_DIR)) - $(call remove_dir,$(BUILD_DIR)) + @$(call print,[Delete] $(BUILD_DIR)) + @$(call remove_dir,$(BUILD_DIR)) .PHONY: $(PHONY) diff --git a/platform/xilinx/xilinx.mk b/platform/xilinx/xilinx.mk index ab895f2..0981081 100644 --- a/platform/xilinx/xilinx.mk +++ b/platform/xilinx/xilinx.mk @@ -8,7 +8,7 @@ define tcl_util endef xilinx_sdkopen: - $(call print,Launching IDE...) + @$(call print,Launching IDE...) @if [ "$(call check_command,vitis)" = "y" ]; then \ if [ "$(XILINX_VITIS_CLASSIC)" = "y" ]; then \ vitis -classic -workspace=$(BUILD_DIR); \ @@ -23,20 +23,18 @@ xilinx_sdkopen: PHONY += xilinx_sdkbuild xilinx_sdkbuild: - $(call print,[Build] SDK projects in $(BUILD_DIR)) + @$(call print,[Build] SDK projects in $(BUILD_DIR)) $(call tcl_util, build) $(HIDE) PHONY += xilinx_sdkclean xilinx_sdkclean: - $(call print,[Delete] SDK artefacts from $(BUILD_DIR)) + @$(call print,[Delete] SDK artefacts from $(BUILD_DIR)) $(call tcl_util, clean_project) $(HIDE) xilinx_project: + @$(call print,Creating and configuring the IDE project) $(call mk_dir,$(BUILD_DIR)) - $(call print,Creating and configuring the IDE project) $(call tcl_util, create_project) $(HIDE) -xilinx_reset: xilinx_clean_all - -xilinx_clean_all: - $(call remove_dir,.Xil) $(HIDE) +xilinx_reset: + $(call remove_dir,.Xil) $(HIDE) \ No newline at end of file From 906df8b40a535639409541ef2f81bff1089055d5 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Fri, 1 Nov 2024 14:19:09 +0800 Subject: [PATCH 07/11] fix(platform/xilinx): correct option from -template to -app in Xilinx SDK setup Replaces the incorrect `-template` option with `-app` for proper Xilinx SDK project configuration, resolving an issue introduced in the last commit. --- platform/xilinx/util.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/xilinx/util.tcl b/platform/xilinx/util.tcl index fb12f71..963be15 100644 --- a/platform/xilinx/util.tcl +++ b/platform/xilinx/util.tcl @@ -310,7 +310,7 @@ proc _create_app {app_name app_config platform_name is_vitis} { -proc $cpu \ -os $os \ -lang $lang \ - -template "$template" + -app "$template" _info "Application '$app_name' created for Xilinx SDK." } From 94aea3524eee12df400b351707307c32a2b23426 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Tue, 5 Nov 2024 23:49:32 +0800 Subject: [PATCH 08/11] chore: fix typo --- template.bat | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/template.bat b/template.bat index 93837b5..66f2a49 100644 --- a/template.bat +++ b/template.bat @@ -1,14 +1,14 @@ @echo off set "platform=xilinx" -set "pltform_ver=2019.1" +set "platform_ver=2019.1" set "work_dir=%~dp0build" set "config=%~dp0config.json" set "tools_dir=%~dp0scripts\platform\%platform%" -REM Set up enviroment -call "%tools_dir%\setenv.bat" "%pltform_ver%" +REM Set up environment +call "%tools_dir%\setenv.bat" "%platform_ver%" if "%ERRORLEVEL%" neq "0" ( - echo Error: Failed to installize enviroment. + echo Error: Failed to initialize environment. pause >nul exit /b 1 ) @@ -21,8 +21,8 @@ if "%ERRORLEVEL%" neq "0" ( exit /b 1 ) -REM Lauch SDK -call "%tools_dir%\launch.bat" "%pltform_ver%" "%work_dir%" +REM Launch SDK +call "%tools_dir%\launch.bat" "%platform_ver%" "%work_dir%" if "%ERRORLEVEL%" neq "0" ( echo Error: Failed to launch SDK. pause >nul From caa636018b1e81b7c3f7c3d3d68f01f9fcd92064 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Wed, 6 Nov 2024 00:32:04 +0800 Subject: [PATCH 09/11] refactor: make paths relative to current working directory - Allows configuration files to be placed in separate folders, with paths in config files now relative to the config file's location. - Added `cd /d "%~dp0"` at the beginning of the `.bat` template to ensure paths are based on the script's location, enhancing portability and consistency. --- platform/xilinx/util.tcl | 4 ++-- template.bat | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/xilinx/util.tcl b/platform/xilinx/util.tcl index 963be15..d548f6e 100644 --- a/platform/xilinx/util.tcl +++ b/platform/xilinx/util.tcl @@ -437,10 +437,10 @@ _info "Working at $ws" set config_file_id [open $config_file r] set config_data [read $config_file_id] close $config_file_id -set root [file dirname [file normalize $config_file]] +set root [pwd] set config [json::json2dict $config_data] set project_name [dict get $config project_name] -set hw_file [file normalize [file join [file dirname $config_file] [dict get $config hw_design]]] +set hw_file [file normalize [file join $root [dict get $config hw_design]]] _info "Starting process: $function" _info "Project name: $project_name" diff --git a/template.bat b/template.bat index 66f2a49..d3b1c29 100644 --- a/template.bat +++ b/template.bat @@ -1,4 +1,6 @@ @echo off +cd /d "%~dp0" + set "platform=xilinx" set "platform_ver=2019.1" set "work_dir=%~dp0build" From af260c1610963bd97c014d6c64b066bbbc875b94 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Wed, 6 Nov 2024 00:33:15 +0800 Subject: [PATCH 10/11] docs(platform/xilinx): update path descriptions in documentation --- platform/xilinx/HOWTO.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/xilinx/HOWTO.md b/platform/xilinx/HOWTO.md index 625fd0b..7ff263e 100644 --- a/platform/xilinx/HOWTO.md +++ b/platform/xilinx/HOWTO.md @@ -44,7 +44,7 @@ - **project_name**: 项目名称,例如 `"demo"`。 - **version**: 项目版本,例如 `"0.0.0"`。 -- **hw_design**: 硬件设计文件(`.hdf` 或 `.xsa` 文件)路径(相对配置文件路径),例如 `"demo_v0.0.0.hdf"`。 +- **hw_design**: 硬件设计文件(`.hdf` 或 `.xsa` 文件)路径(相对档案工作路径),例如 `"demo_v0.0.0.hdf"`。 ### *fsbl_patch* (TODO) @@ -172,7 +172,7 @@ } ``` -- **sources**: 源文件列表,应为相对当前配置文件的路径,可使用通配符。例如,`"src/*"` 会将配置文件所在目录下的 `src` 文件夹中的所有文件复制或链接到相应工程目录下的 `src` 文件夹中。 +- **sources**: 源文件列表,可使用通配符。例如,`"src/*"` 会将当前工作路径下的 `src` 文件夹中的所有文件复制或链接到相应工程目录下的 `src` 文件夹中。 - **target_cpu**: 目标 CPU ID[^2]; - **os**: 操作系统类型[^1],必须与 BSP/Domain 匹配; - **language**: 编程语言,"C" 或 "C++"; @@ -188,12 +188,12 @@ - `compiler-misc`: 其他编译器选项; - `compiler-optimization`: 编译优化选项; - `linker-misc`: 链接器选项; - - `linker-script`: 链接脚本路径; + - `linker-script`: 链接脚本路径[^3]; - `define-compiler-symbols`: 自定义的编译器宏定义符号列表; - `undef-compiler-symbols`: 要取消定义的符号列表; - - `include-path`: 包含文件路径; + - `include-path`: 包含文件路径[^3]; - `libraries`: 需要链接的库; - - `library-search-path`: 库搜索路径; + - `library-search-path`: 库搜索路径[^3]; 以下配置添加了一个名为 `demo_app` 的 Application 工程,该工程没有指定 BSP/Domain 但能够通过 `bsp_lib` 和 `bsp_config` 自动生成一个名为 `standalone_ps7_cortexa9_0` 的 BSP/Domain 工程。 @@ -239,3 +239,5 @@ [^1]: 具体可配置项取决于对应 IDE 版本; [^2]: 具体可选 CPU ID 取决于硬件型号; + +[^3]: 相对对应工程的文件夹的路径; From 751071d670ebba4fd514cfb846df6d650c534f27 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Mon, 24 Feb 2025 01:40:14 +0800 Subject: [PATCH 11/11] refactor(platform/xilinx): use tcl command to create links eliminating the need for administrator privileges on Windows --- platform/xilinx/util.tcl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platform/xilinx/util.tcl b/platform/xilinx/util.tcl index d548f6e..b14ac00 100644 --- a/platform/xilinx/util.tcl +++ b/platform/xilinx/util.tcl @@ -126,13 +126,12 @@ proc _handle_sources {app_name sources} { switch $link_srcs { "y" { # Create symbolic link - # -- TCL cannont create symbolic link for files on Windows - # -- Fallback to use mklink command - if {$::tcl_platform(platform) eq "windows" && ![file isdirectory $eval_source]} { + # -- Symbolic link for file dose not support on NTFS + if {$::tcl_platform(platform) eq "windows" && [file isfile $eval_source]} { if {[catch { - exec cmd /c mklink [file nativename $target_path] [file nativename $eval_source] + file link -hard $target_path $eval_source } err]} { - error "Failed to create file symbolic link using mklink: $err" + error "Failed to create file hard link: $err" } } else { if {[catch {