2024-02-03 01:46 PM - edited 2024-02-04 02:32 AM
Hello,
I have a STM32F746-DISCO development board and I use TouchGFX. When creating projects in TouchGFX and saving the project under the name APL1, this project appears in TouchGFX as APL1, but when imported into STM32CUBEIDE, it is imported as STM32F746_DISCO. When I create another design using TouchGFX for the same board, in TouchGFX I have the names APL1 and APL2, but in STM32CUBEIDE they have the same name and it is not possible to import the second type (APL2) without removing the first one. Is it just my ignorance or is it the functionality of the generator in TouchGFX?
I made a PS script that renames the project to the name from TouchGFX, but I guess that's not the right solution. After running this script I can import as I like, but I assume I'm probably doing something wrong.
# before running the script, you need to enable the PS script to run
# This is done from the PowerShell command line like this:
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Clear-Host
# number of arguments
$argumentCount = $args.Count
if ($argumentCount -lt 2) {
Write-Output "Argument count is less than two."
Write-Output " first argument: workspace folder"
Write-Output "second argument: new project name (name of address book, or what you filled in TouchGFX)"
Write-Output "example"
Write-Output "RenameSTMProject.ps1 D:\workspace MyTestProject"
Write-Output " folder must exist D:\workspace\MyTestProject"
Write-Output ""
exit
}
$workspacePath = $args[0]
$newName = $args[1]
$files = Get-ChildItem -Path "$workspacePath\$newName\*.ioc"
$firstFileName = $files[0].Name
$oldName = $firstFileName.Replace(".ioc", "")
Write-Output "files $files"
Write-Output "firstFileName $firstFileName"
Write-Output "oldName $oldName"
Rename-Item -Path "$workspacePath\$newName\$oldName.ioc" -NewName "$newName.ioc"
# EWARM
Rename-Item -Path "$workspacePath\$newName\EWARM\$oldName.ewd" -NewName "$newName.ewd"
Rename-Item -Path "$workspacePath\$newName\EWARM\$oldName.ewp" -NewName "$newName.ewp"
# MDK-ARM
Rename-Item -Path "$workspacePath\$newName\MDK-ARM\$oldName.sct" -NewName "$newName.sct"
Rename-Item -Path "$workspacePath\$newName\MDK-ARM\$oldName.uvoptx" -NewName "$newName.uvoptx"
Rename-Item -Path "$workspacePath\$newName\MDK-ARM\$oldName.uvprojx" -NewName "$newName.uvprojx"
# STM32CubeIDE
Rename-Item -Path "$workspacePath\$newName\STM32CubeIDE\$oldName Debug.launch" -NewName "$newName Debug.launch"
# nahrazení obsahu souborů
$fileName = "$workspacePath\$newName\$newName.ioc"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
# STM32CubeIDE
$fileName = "$workspacePath\$newName\STM32CubeIDE\.cproject"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\STM32CubeIDE\.project"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\STM32CubeIDE\$newName Debug.launch"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
# EWARM
$fileName = "$workspacePath\$newName\TouchGFX\ApplicationTemplate.touchgfx.part"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\TouchGFX\$newName.touchgfx"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\EWARM\$newName.ewd"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\EWARM\$newName.ewp"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\EWARM\Project.eww"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
# MDK-ARM
$fileName = "$workspacePath\$newName\MDK-ARM\$newName.uvoptx"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\MDK-ARM\$newName.uvprojx"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
I did not deal with any optimization or cycles in the script. I just replace each occurrence.
However, it would be better for me if the TouchGFX environment did this directly
JN
2024-02-04 02:31 AM
I don't know where I put my eyes, but I uploaded a version that has bad quotes on two lines. Wrong are ' and right ".
I'm putting the corrected PS script here.
I haven't mentioned yet that it is necessary to enable PS scripts to run. This is disabled by default. How to enable or disable the execution of PS scripts can be found for example here:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
# before running the script, you need to enable the PS script to run
# This is done from the PowerShell command line like this:
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Clear-Host
# number of arguments
$argumentCount = $args.Count
if ($argumentCount -lt 2) {
Write-Output "Argument count is less than two."
Write-Output " first argument: workspace folder"
Write-Output "second argument: new project name (name of address book, or what you filled in TouchGFX)"
Write-Output "example"
Write-Output "RenameSTMProject.ps1 D:\workspace MyTestProject"
Write-Output " folder must exist D:\workspace\MyTestProject"
Write-Output ""
exit
}
$workspacePath = $args[0]
$newName = $args[1]
$files = Get-ChildItem -Path "$workspacePath\$newName\*.ioc"
$firstFileName = $files[0].Name
$oldName = $firstFileName.Replace(".ioc", "")
Write-Output "files $files"
Write-Output "firstFileName $firstFileName"
Write-Output "oldName $oldName"
Rename-Item -Path "$workspacePath\$newName\$oldName.ioc" -NewName "$newName.ioc"
# EWARM
Rename-Item -Path "$workspacePath\$newName\EWARM\$oldName.ewd" -NewName "$newName.ewd"
Rename-Item -Path "$workspacePath\$newName\EWARM\$oldName.ewp" -NewName "$newName.ewp"
# MDK-ARM
Rename-Item -Path "$workspacePath\$newName\MDK-ARM\$oldName.sct" -NewName "$newName.sct"
Rename-Item -Path "$workspacePath\$newName\MDK-ARM\$oldName.uvoptx" -NewName "$newName.uvoptx"
Rename-Item -Path "$workspacePath\$newName\MDK-ARM\$oldName.uvprojx" -NewName "$newName.uvprojx"
# STM32CubeIDE
Rename-Item -Path "$workspacePath\$newName\STM32CubeIDE\$oldName Debug.launch" -NewName "$newName Debug.launch"
# nahrazení obsahu souborů
$fileName = "$workspacePath\$newName\$newName.ioc"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
# STM32CubeIDE
$fileName = "$workspacePath\$newName\STM32CubeIDE\.cproject"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\STM32CubeIDE\.project"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\STM32CubeIDE\$newName Debug.launch"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
# EWARM
$fileName = "$workspacePath\$newName\TouchGFX\ApplicationTemplate.touchgfx.part"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\TouchGFX\$newName.touchgfx"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\EWARM\$newName.ewd"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\EWARM\$newName.ewp"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\EWARM\Project.eww"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
# MDK-ARM
$fileName = "$workspacePath\$newName\MDK-ARM\$newName.uvoptx"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
$fileName = "$workspacePath\$newName\MDK-ARM\$newName.uvprojx"
(Get-Content -Path $fileName) -replace "$oldName", "$newName" | Set-Content -Path $fileName
Is it just me having a problem with the same project name or is this common.
JN
2024-02-07 02:41 AM
Hello @JNova.0 ,
Yes, you are right. Unfortunately, the name of your TouchGFX project does not reflect in the STM32CubeIDE project.
Thank you so much for pointing out this issue, we will try to fix it as soon as possible. Meanwhile, you can just simply change the name of the STM32CubeIDE project (.project file), by opening it in an text editor and changing the name to your preferred one. Or, you can just open your project in a new workspace.
Thank you again for your help