annotate wiki/Detailed CPU1-Discovery Project.md @ 861:ad96f99ebc78 Evo_2_23 tip

Synchronize ADC and UART activities: depending on the cable configuration the UART sensor operation may have an impact to the ADC measurement (peaks). To avoid this the ADC measurements are now only started in case no UART communication is pending.
author Ideenmodellierer
date Tue, 07 May 2024 21:25:25 +0200
parents 8d95bab5bf6a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
489
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
1 # How to Create From Scratch a Project for _CPU1-Discovery_ Code #
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
2
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
3 The OpenSTM32 wiki have a [page](http://www.openstm32.org/Getting%2Bstarted%2Bwith%2BSystem%2BWorkbench%2Bfor%2BSTM32) to start a project from scratch. With the latest version of every support libraries and sources from ST. But here I prefer to have a project with the support files validated (and compatible) with the _OSTC4_ code.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
4
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
5 ## Start with an Empty Project ##
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
6
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
7 **Special Notes**:
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
8
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
9 - _Linux_ users should read about this **well known _Eclipse_ bug** : http://www.openstm32.org/faq1#q22
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
10 - We do have a _STM32F427IIT6_ chip as CPU1. But the support file provided by _ST_ lake for _LCD TFT Display Controller_ (aka LTDC), even in the latest available version 1.7.2 from 2017-11-06... So we use the STM32F429IITx support file instead, that seems to be similar enough.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
11
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
12 In the following description, I suppose you used _mercurial_ to clone the sources into a **D:\Dev\OSTC4** directory. Make the changes for your own settings...
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
13
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
14 0. Start the IDE. On most machine it will be the `eclipse` in the _Ac6_ folder you installed.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
15 1. Create an empty project: `File` > `New` > `C Project`
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
16 2. Choose `AC6 STM32 MCU Project` and `AC6 STM32 MCU GCC`. Click `Next`
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
17 Note: **make sure NOT TO CLICK FINISH... as it will skip all the rest of the configuration wizard !**
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
18 3. Keep `Debug` and `Release` configurations. Click `Next`
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
19 4. Create a new board, that you can name **OSTC4-CPU1-F429**, by choosing:
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
20 > Series: `STM32F4`
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
21 > Mcu: `STM32F429IITx`
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
22 > Debug: `JTAG`
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
23 Click `Next`.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
24 5. Keep `No firmware` and select `Don't generate startup files`. Then click `Finish`
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
25
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
26 ## Configure Various Settings ##
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
27
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
28 1. In the _C/C++ Projects_ explorer, select your project top-level folder
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
29 2. Right on it, select `Properties`, `Resource` and set `Text file encoding` to **UTF-8**
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
30 3. Right on it, select `Properties`, `Resource` then `Linked Resources` and click on `New...` to define a new variable **OSTC4** that points to your source folder **D:\Dev\OSTC4** (or whatever path you used on your system).
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
31 This should allow to change the project's origin with a single variable change.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
32
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
33 # Add Sources Folders #
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
34
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
35 1. In the _C/C++ Projects_ explorer, select your project top-level folder
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
36 2. Right-click to add a `New` > `Folder`. In `Advanced settings >` click `Link to alternate location` and then the `Variables...` button. Click on the **OSTC4** variable, then click `Extend...` and select the **Common\\** sub-directory. Click `Finish`
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
37 3. Do the same to import the linked folder **OSTC4\Discovery**
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
38
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
39 ## Make _Eclipse_ aware you just added sources, not junk ##
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
40
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
41 (_Note: this step is only useful on specific versions of Eclipse. And already done by default on others..._)
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
42
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
43 1. In the _C/C++ Projects_ explorer, open your project top-level project.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
44 2. Right click on the `Common` folder, select `Resource Configurations...`, and `Exclude from build`. Make sure to UNCHECK both `Debug` and `Release` check-boxes.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
45 3. Do the same for the `Discovery` folder.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
46
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
47 ## Make _Eclipse_ aware not to compile templates ##
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
48
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
49 Some sources or directories in the _ST_ distribution contains source you shall not compile. So you should tell _OSE_.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
50
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
51 1. In the _Project Explorer_, open item `Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src`. Right click on `stm32f4xx_hal_msp_template.c`source file, select `Resource Configurations...`, and `Exclude from build`. Make sure both `Debug` and `Release` check-boxes are CHECKED.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
52 2. Do the same on the `Common/Drivers/STM32F4xx_v220/Source/Templates` directory.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
53
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
54 # Compile #
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
55
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
56 1. Select your top-level project, right-click to edit `properties`. In `C/C++ Build` choose `Settings`, then `MCU GCC Compiler` and `Optimization`. Choose `Optimization Level`: -Os (To reduce flash time)
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
57
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
58 Ok, sources are there. You can read them. But you need a few more efforts to let the IDE find everything he requires to compile _CPU1 Discovery_ firmware.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
59
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
60 ## Add include paths ##
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
61
568
1eee6fb108cb Minor: Update the documentation for building the code
heinrichsweikamp
parents: 489
diff changeset
62 1. Select your top-level project, right-click to edit `properties`. In `C/C++ Build` choose `Settings`, then `MCU GCC Compiler` and `Includes`. **Make sure to select `Configuration: [All Configurations]` **. Click `Add...` choose `Workspace...` and select the `Common/Drivers/CMIS/Include` directory.
1eee6fb108cb Minor: Update the documentation for building the code
heinrichsweikamp
parents: 489
diff changeset
63 2. Do the same for `Common/Drivers/STM32F4xx/Include` directory.
1eee6fb108cb Minor: Update the documentation for building the code
heinrichsweikamp
parents: 489
diff changeset
64 3. Do the same for `Common/Drivers/STM32F4xx_HAL_DRIVER/Inc` directory.
489
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
65 4. Do the same for `Common/Inc` directory.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
66 5. Do the same for `Discovery/Inc` directory.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
67 6. Use the _Move Up_ icon to make sure `Discovery/Inc` is first.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
68 7. Use the `Configuration:` pop-up to check you have all the includes in both `Debug` and `Release` configuration.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
69
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
70 Once done, If you go to the _C/C++ Projects explorer_, open your top-level project, and open the `Includes` item, you should see:
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
71
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
72 - a few lines added by the system `.../Ac6/Workbench/plugins/.../compiler/...` with include paths required by the GCC compiler.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
73 - then your 5 include directories (shown in alphabetic order, not priority order... too bad). Make sure to open each of them and to double-click on a .h file to check it opens correctly in the IDE.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
74
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
75 ## Add Link Options ##
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
76
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
77 1. Select your top-level project, right-click to edit `properties`. In `C/C++ Build` choose `Settings`, then `MCU G++ Linker` and `General`.
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
78 And select _linker Script_: `OSTC4/Common/CPU1-F429.ld`
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
79 2. In `C/C++ Build` choose `Settings`, then `MCU GCC Linker` and `Miscellaneous`. Add option -u _printf_float in Linker flags. This is necessary to prevent IDE warning "The float formatting support (-u _printf_float) is not enabled from linker flags".
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
80
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
81 ## Prepare generation of bin file ##
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
82 1. Select your top-level project, right-click to edit `properties`. In `C/C++ Build` choose `Settings`, then tab `Build Steps` and `Post build step command`.
589
8d95bab5bf6a Minor: Update the documentation for building the code
heinrichsweikamp
parents: 568
diff changeset
83 2. Add option -R .upper\* and -R.font_firmware_data to the command to removed the upper memory section, which is provided by the font library =>arm-none-eabi-objcopy -R .upper\* -R.font_firmware_data -O binary "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.bin"; arm-none-eabi-size "${BuildArtifactFileName}"
489
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
84
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
85 ## Build ELF firmware ##
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
86
0e7c16dd774d add wiki sub-directory
heinrichsweikamp
parents:
diff changeset
87 1. Click the `Build` button (hammer icon) on the top bar.