2020-05-01 08:35 AM
I've switched to mac and like any responsible adult all of my projects are handled by git. But when I generated the code with CubeMX it was a little confusing to see so many files have changed. A quick search brought me to this topic without any answer:
https://community.st.com/s/question/0D50X00009XkgaG/cubemx-line-ends-in-generated-code
The solution is that CubeMX uses a repository of files in the background (which have DOS line ending) and it appends different files together to generate your code. So the easy way to fix the problem is to do the following steps:
This should take care of the problem mostly (there are some residue I haven't figured how to fix yet).
I had to change a few files manually as they had some weird symbols in them. But you get the gist. Modify anything that's annoying to you there (don't touch the code, just simple stuff).
Another alternative solution for SW4STM32 users is to:
The last, probably easiest, is to set the git to change the line ending itself by setting the `autocrlf
`. When installing git in windows `auto` should be selected. In mac and linux use `it config --global core.autocrlf input` (the default is `false`). So it changes the DOS line ending to unix when you add the files automatically. After generating the code you might have 70 unstaged changed in git but once you add them the number shrinks to only a few files that have actually been changed.