38
|
1 # How to Create From Scratch a Project for _CPU1-Discovery_ Code #
|
|
2
|
|
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.
|
|
4
|
|
5 ## Start with an Empty Project ##
|
|
6
|
|
7 **Special Notes**:
|
|
8
|
|
9 - _Linux_ users should read about this **well known _Eclipse_ bug** : http://www.openstm32.org/faq1#q22
|
|
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.
|
|
11
|
|
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...
|
|
13
|
|
14 0. Start the IDE. On most machine it will be the `eclipse` in the _Ac6_ folder you installed.
|
|
15 1. Create an empty project: `File` > `New` > `C Project`
|
|
16 2. Choose `AC6 STM32 MCU Project` and `AC6 STM32 MCU GCC`. Click `Next`
|
|
17 Note: **make sure NOT TO CLICK FINISH... as it will skip all the rest of the configuration wizard !**
|
|
18 3. Keep `Debug` and `Release` configurations. Click `Next`
|
|
19 4. Create a new board, that you can name **OSTC4-CPU1-F429**, by choosing:
|
|
20 > Series: `STM32F4`
|
|
21 > Mcu: `STM32F429IITx`
|
|
22 > Debug: `JTAG`
|
|
23 Click `Next`.
|
|
24 5. Keep `No firmware` and select `Don't generate startup files`. Then click `Finish`
|
|
25
|
|
26 ## Configure Various Settings ##
|
|
27
|
|
28 1. In the _C/C++ Projects_ explorer, select your project top-level folder
|
|
29 2. Right on it, select `Properties`, `Resource` and set `Text file encoding` to **UTF-8**
|
|
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).
|
|
31 This should allow to change the project's origin with a single variable change.
|
|
32
|
|
33 # Add Sources Folders #
|
|
34
|
|
35 1. In the _C/C++ Projects_ explorer, select your project top-level folder
|
|
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`
|
|
37 3. Do the same to import the linked folder **OSTC4\Discovery**
|
|
38
|
|
39 ## Make _Eclipse_ aware you just added sources, not junk ##
|
|
40
|
|
41 (_Note: this step is only useful on specific versions of Eclipse. And already done by default on others..._)
|
|
42
|
|
43 1. In the _C/C++ Projects_ explorer, open your project top-level project.
|
|
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.
|
|
45 3. Do the same for the `Discovery` folder.
|
|
46
|
|
47 ## Make _Eclipse_ aware not to compile templates ##
|
|
48
|
|
49 Some sources or directories in the _ST_ distribution contains source you shall not compile. So you should tell _OSE_.
|
|
50
|
|
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.
|
|
52 2. Do the same on the `Common/Drivers/STM32F4xx_v220/Source/Templates` directory.
|
|
53
|
|
54 # Compile #
|
|
55
|
|
56 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.
|
|
57
|
|
58 ## Add include paths ##
|
|
59
|
|
60 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_v210` directory.
|
|
61 2. Do the same for `Common/Drivers/STM32F4xx_v220/Include` directory.
|
|
62 3. Do the same for `Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Inc` directory.
|
|
63 4. Do the same for `Common/Inc` directory.
|
|
64 5. Do the same for `Discovery/Inc` directory.
|
|
65 6. Use the _Move Up_ icon to make sure `Discovery/Inc` is first.
|
|
66 7. Use the `Configuration:` popup to check you have all the includes in both `Debug` and `Release` configuration.
|
|
67
|
|
68 Once done, If you go to the _C/C++ Projects explorer_, open your top-level project, and open the `Includes` item, you should see:
|
|
69
|
|
70 - a few lines added by the system `.../Ac6/Workbench/plugins/.../compiler/...` with include paths required by the GCC compiler.
|
|
71 - 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.
|
|
72
|
|
73 ## Add Link Options ##
|
|
74
|
|
75 1. Select your top-level project, right-click to edit `properties`. In `C/C++ Build` choose `Settings`, then `MCU G++ Linker` and `General`.
|
|
76 And select _linker Script_: `OSTC4/Common/CPU1-F429.ld`
|
|
77
|
|
78 ## Build ELF firmware ##
|
|
79
|
|
80 1. Click the `Build` button (hammer icon) on the top bar. |