Forum Replies Created
-
AuthorPosts
-
January 28, 2020 at 09:05 in reply to: BSP STM32 2019.06 fails to reconnect HID-USB on PC restart #27276SRParticipant
Hi Soldy,
we manually rolled back our BSP version in project.vcxproj to <BSP_VERSION>2018.12R2</BSP_VERSION>.
After restarting Visual Studio VisualGDB would go ahead and install the needed STM32 SDK.Our dirty bugfix in the meantime was to ckeck if the USB connection was suspended for longer than 10sec and then stop, deinit, init and start the USB connection.
In regards to the ST-Micro Bug-Report: we tried posting our problem in their forum (https://community.st.com/s/question/0D50X0000BsPpLRSQ0/stm32-sdk-1240-fails-to-reconnect-hidusb-on-pc-reboot) but to no avail. We would appreciate your support over there, maybe it gets some attention.
Seeing that we are not the only ones with this problem, we are going to contact support directly.SRParticipantHi,
reading your post, I managed to work this out by adding the command: “
mon flash write_image erase F:/Path/To/Project/Firmware.bin 0x08000000 bin"
I still have additional questions:
1. When adding “
mon flash write_image erase $(TargetDir)\$(TargetNameWithoutExtension).bin 0x08000000 bin
” to the commands I get the following error in the GDB Session:mon flash write_image erase F:\Path\To\Project\Firmware.bin 0x08000000 bin
&"mon flash write_image erase F:\\Path\\To\\Project\\Firmware.bin 0x08000000 bin\n"
couldn't open F:PathToProjectFirmware.bin
It seem as the windows backslashes are not escaped correctly. Is there any workaround, other than fully qualifying the file with forward slashes?
2. When adding the flash command like above, VisualGDB now writes the Firmware twice to the device.
Is it possible to override/suppress the first “default” flash, as I will override the Firmware anyway?
Thanks in advance.
Attachments:
You must be logged in to view attached files.September 19, 2019 at 10:24 in reply to: Update to BSP stm32 2019.06 caused 490 compiler warnings #25839SRParticipantHi,
I just noticed: every time I regenerated a file (8 times for different gdbsettings and and 1 time for MSBuild toolchain) via the VisualGDB Project Properties, VisualGDB duplicated entries in the “Project.vcxproj.filters” file. I have attached a file with all duplicated entries.
This is no biggie, as it doesn’t have any side-effects, but I imagined you might want to know about this behavior.
September 19, 2019 at 10:08 in reply to: Update to BSP stm32 2019.06 caused 490 compiler warnings #25838SRParticipantHi,
thanks for your prompt response!
Clicking “Embedded Project/Regenerate MCU files” only regenerated the visualgdbsettings-files, not the stm32.props.
But clicking “MSBuild settings/Rebuild MSBuild & IntelliSense files for this toolchain” did the trick.Thanks for your help.
PS: No, this was not caused by missing packages, as this happened on my – already set up – machine, not my new co-worker’s.
October 23, 2018 at 08:40 in reply to: PREPROCESSOR DEFINE WITH CONTENT OF A BUILD VARIABLE (in MSBuild) #22408SRParticipantHi,
I actually tried just that yesterday, but it failed with error:
<ItemDefinitionGroup> is not allowed inside a target.
But with the help of some google I figured that this works as desired.
<ItemGroup> <ClCompile> <PreprocessorDefinitions>%(ClCompile.PreprocessorDefinitions);GIT_BUILD_ID="$(GitCommitHash)";GIT_YEAR=$(GitCommitYear);GIT_MONTH=$(GitCommitMonth);GIT_DAY=$(GitCommitDay);</PreprocessorDefinitions> </ClCompile> </ItemGroup>
Thank you very much for your help!
October 22, 2018 at 12:27 in reply to: PREPROCESSOR DEFINE WITH CONTENT OF A BUILD VARIABLE (in MSBuild) #22383October 22, 2018 at 12:20 in reply to: PREPROCESSOR DEFINE WITH CONTENT OF A BUILD VARIABLE (in MSBuild) #22381SRParticipantHi,
Using the MSBuild Diagnostic setting helped a lot to unterstand the procedure.
I changes small things in the Task to make it more reliable, but it doesn’t seem to be the problem.
My new Task:
using System; using System.Diagnostics; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; namespace GitBuildStep { public class GitPropertiesTask : Task { [Required] public string GitDir { get; set; } [Output] public int GitCommitDay { get; set; } [Output] public int GitCommitMonth { get; set; } [Output] public int GitCommitYear { get; set; } [Output] public string GitCommitHash { get; set; } public override bool Execute() { try { GitCommitHash = GetGitBuildHash(); DateTime buildTime = GetGitBuildDate(); GitCommitYear = buildTime.Year; GitCommitMonth = buildTime.Month; GitCommitDay = buildTime.Day; } catch (Exception e) { Log.LogErrorFromException(e); return false; } return true; } private string GetGitBuildHash() { string buildHash = RunCmd(@"git rev-parse --short=9 HEAD"); return buildHash; } private DateTime GetGitBuildDate() { var buildDate = RunCmd(@"git log -1 --format=%cd --date=short"); return DateTime.Parse(buildDate); } private string RunCmd(string cmd) { ProcessStartInfo startInfo = new ProcessStartInfo { UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, FileName = "cmd.exe", Arguments = $@"/C ({cmd})", RedirectStandardOutput = true, RedirectStandardError = true, WorkingDirectory = GitDir }; string pathEnv = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine); startInfo.EnvironmentVariables.Add("PATH", pathEnv); Process process = new Process { StartInfo = startInfo }; process.Start(); process.WaitForExit(); string error = process.StandardError.ReadToEnd().Trim(); if (!String.IsNullOrWhiteSpace(error)) throw new Exception(error); string buildDate = process.StandardOutput.ReadToEnd().Trim(); return buildDate; } } }
And my changes to Project.vcxproj
<UsingTask TaskName="GitPropertiesTask" AssemblyFile="Utils/GitBuildStep.dll" /> <Target Name="GitPropertiesTarget"> <Message Text="Reading Git Properties!" Importance="high" /> <GitPropertiesTask GitDir="$(SolutionDir)"> <Output TaskParameter="GitCommitDay" PropertyName="GitCommitDay" /> <Output TaskParameter="GitCommitMonth" PropertyName="GitCommitMonth" /> <Output TaskParameter="GitCommitYear" PropertyName="GitCommitYear" /> <Output TaskParameter="GitCommitHash" PropertyName="GitCommitHash" /> </GitPropertiesTask> <Message Text="Git Properties:%0aDate=$(GitCommitDay).$(GitCommitMonth).$(GitCommitYear)%0aHash=$(GitCommitHash)" Importance="high" /> </Target>
And PreProcessor-Settings:
GIT_BUILD_ID=$(GitCommitHash);GIT_YEAR=$(GitCommitYear);GIT_MONTH=$(GitCommitMonth);GIT_DAY=$(GitCommitDay)
Outputs this:
1>Target "GitPropertiesTarget" in file "X:\Firmware\Firmware\Firmware.vcxproj": 1> Using "Message" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". 1> Task "Message" 1> Task Parameter:Text=Reading Git Properties! 1> Task Parameter:Importance=high 1> Reading Git Properties! 1> Done executing task "Message". 1> Using "GitPropertiesTask" task from assembly "X:\Firmware\Firmware\Utils/GitBuildStep.dll". 1> Task "GitPropertiesTask" 1> Task Parameter:GitDir=X:\Firmware\ 1> Git Properties: 1> Date=18.10.2018 1> Hash=530a981c4 1> Output Property: GitCommitDay=18 1> Output Property: GitCommitMonth=10 1> Output Property: GitCommitYear=2018 1> Output Property: GitCommitHash=530a981c4 1> Done executing task "GitPropertiesTask". 1> Task "Message" 1> Task Parameter:Text=Git Properties: 1> Date=18.10.2018 1> Hash=530a981c4 1> Task Parameter:Importance=high 1> Git Properties: 1> Date=18.10.2018 1> Hash=530a981c4 1> Done executing task "Message". 1>Done building target "GitPropertiesTarget" in project "Firmware.vcxproj". ... 1>Target "BuildCppObjectList" in file "C:\Program Files (x86)\Sysprogs\VisualGDB\MSBuild\Targets\gcc.targets": 1> Added Item(s): 1> Obj= 1> VisualGDB\Debug\eeprom.o ... 1> PreprocessorDefinitions=ARM_MATH_CM4;flash_layout;STM32F407VG;USE_USB_FS;STM32F407xx;FAST_SEMIHOSTING_BUFFER_SIZE=4096;FAST_SEMIHOSTING_BLOCKING_MODE=0;FAST_SEMIHOSTING_STDIO_DRIVER=1;FAST_SEMIHOSTING_PROFILER_DRIVER=1;PROFILER_STM32F4;SYSPROGS_PROFILER_DEBUGGER_CHECK_MODE=1;GIT_BUILD_ID=;GIT_YEAR=;GIT_MONTH=;GIT_DAY=;DEBUG=1;;DEBUG=1
To me it seems like the PreprocessorDefinitions get resolved before GitPropertiesTarget is triggered, as the variables seems to get set correctly, but not the PreprocessorDefinitions.
PS: I have attached you a shortened version of MSBuild.log (due to your upload-size limit)
- This reply was modified 6 years, 2 months ago by SR.
October 19, 2018 at 16:12 in reply to: PREPROCESSOR DEFINE WITH CONTENT OF A BUILD VARIABLE (in MSBuild) #22370SRParticipantI have again read the AutoVersion.props as you suggested and added
<PropertyGroup> <BuildDependsOn>$(BuildDependsOn);GitPropertiesTarget</BuildDependsOn> </PropertyGroup>
But the GitPropertiesTarget isn’t invoked.
Does the VisualGDB Embedded ToolChain override these dependencies?
October 19, 2018 at 15:31 in reply to: PREPROCESSOR DEFINE WITH CONTENT OF A BUILD VARIABLE (in MSBuild) #22367SRParticipant@Support: Have to correct myself:
using <Target Name=”Build”> overrides the default build process and nothing works, but <Target Name=”BeforeBuild” BeforeTargets=”Build”> works neither in a .vcxproj.</span>
October 19, 2018 at 14:58 in reply to: PREPROCESSOR DEFINE WITH CONTENT OF A BUILD VARIABLE (in MSBuild) #22366SRParticipant@Support: I have seen that you used a .props file instead of the project file for better reusability.
I have tried this myself, but it didn’t work.
What do i have to configure for MSBuild to automatically load this file?
October 19, 2018 at 14:56 in reply to: PREPROCESSOR DEFINE WITH CONTENT OF A BUILD VARIABLE (in MSBuild) #22365SRParticipantTo summarize for everyone wondering:
- Make new C# Library GitProperties.dll
- Add NuGet-Packages: Microsoft.Build.Framework & Microsoft.Build.Utilities
- Add Task Class
public class GitPropertiesTask : Task { [Output] public string GitCommitHash {get; set; } public override bool Execute() { try { GitCommitHash = GetGitBuildHash(); } catch (Exception e) { Log.LogErrorFromException(e); return false; } return true; } private static string GetGitBuildHash() { ProcessStartInfo startInfo = new ProcessStartInfo { UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, FileName = "cmd.exe", Arguments = "/C git rev-parse --short=9 HEAD", RedirectStandardOutput = true, }; Process process = new Process { StartInfo = startInfo }; process.Start(); string buildHash = process.StandardOutput.ReadToEnd().Trim(); process.WaitForExit(); return buildHash; } }
- Add the following lines at the end of your Project file:
<UsingTask TaskName="GitPropertiesTask" AssemblyFile="./[Path]/GitProperties.dll" /> <Target Name="Build"> <GitPropertiesTask> <Output TaskParameter="GitCommitHash" PropertyName="GitCommitHash"/> </GitPropertiesTask> </Target>
- Add to your Project Settings –> C/C++ –> Preprocessor –> Preprocessor Defines:
GIT_BUILD_ID=$(GitCommitHash)
-
AuthorPosts