Skip to content

Commit 843baf4

Browse files
committed
Templates: update and simplify steps to create projects
1 parent 22c3e39 commit 843baf4

18 files changed

Lines changed: 469 additions & 564 deletions

Templates/CubeMX/CubeMX.csolution.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,22 @@ solution:
1313
packs:
1414
- pack: Keil::STM32N6xx_DFP
1515
- pack: ARM::CMSIS
16+
- pack: Keil::STM32N6570-DK_BSP
1617

1718
# List different hardware targets that are used to deploy the solution.
1819
target-types:
19-
- type: STM32N6
20-
# device: STMicroelectronics::STM32N657X0HxQ
20+
- type: STM32N657X0HxQ
2121
target-set:
22-
- set: build_ExtMemLoader
22+
- set: ExtMemLoader
2323
images:
2424
- project-context: ExtMemLoader.Debug
25-
- set: build_load_FSBL
25+
- set: FSBL
2626
images:
2727
- project-context: FSBL.Debug
28-
load: none
29-
# - image: $OutDir(FSBL)$/FSBL-trusted.bin
30-
# load-offset: 0x70000000
31-
# load: image
32-
debugger:
33-
name: ST-Link@pyOCD
34-
port: 3333
35-
protocol: swd
36-
clock: 4000000
37-
- set: debug_FSBL
38-
images:
39-
- image: $OutDir(FSBL)$/FSBL-trusted.bin
4028
load: symbols
29+
- image: $OutDir(FSBL)$/FSBL-trusted.bin
30+
load-offset: 0x70000000
31+
load: image
4132
debugger:
4233
name: ST-Link@pyOCD
4334
port: 3333

Templates/CubeMX/ExtMemLoader/ExtMemLoader.cproject.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ project:
1313
# List of miscellaneous settings.
1414
setups:
1515
- setup: Template project setup
16+
for-compiler: AC6
1617
misc:
1718
- C-CPP:
1819
- -fropi
1920
- -frwpi
21+
- Link:
22+
- --entry=main
2023

2124
# List components to use for your application.
2225
# A software component is a re-usable unit that may be configurable.

Templates/CubeMX/README.md

Lines changed: 125 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,86 @@
22
# Basic Template for STM32N6 series
33

44
Project provides a reference basic template that can be used to build 512KB firmware application to execute in internal RAM (Application as part of the FSBL).
5-
Subproject ExtMemLoader is a used to generate a binary library capable of downloading an application to external memory.
5+
The ExtMemLoader subproject is a flash algorithm that generates a binary library capable of programming an application into external memory.
66

77
## Introduction
88

9-
The boot ROM code uses the 512KB area in the AXI SRAM2 to store the FSBL image, Once the clock is set, the green LED (GPIO PO.01) toggles in an infinite loop with a 0.5 second period.
10-
11-
## Steps to Configure, Build, Load, and Debug using the Basic Template csolution project
12-
13-
> **Note:**
14-
> **Installed packs and extensions:**
15-
> - Keil.STM32N6xx_DFP.1.0.1-dev3
16-
> - Keil.STM32N6570-DK_BSP.1.0.0-dev
17-
> - Arm CMSIS Debugger 1.3.0
18-
> - Arm CMSIS Solution 1.62.2
19-
> - Cbridge27.exe
20-
> - STM32CubeMX.6.16.1
21-
> - STM32Cube_FW_U0_V1.3.0
22-
> - STM32_SigningTool_CLI_V2.20.0
23-
> - STM32CubeProgrammer_V2.18.0
24-
9+
The bootROM copies FSBL image (512KB) from external Flash (Octo SPI Flash Memory) to the internal RAM (AXI SRAM2) and starts executing it.
10+
In the application, once the clock is configured, the green LED (GPIO PO.01) toggles in an infinite loop with a 0.5 second period.
11+
12+
## Steps to Configure, Build, Load and Debug using the Basic Template csolution project
13+
14+
> **Note:**
15+
>
16+
>- **Required Packs:**
17+
> - Keil.STM32N6xx_DFP.1.1.0
18+
> - Keil.STM32N6570-DK_BSP.1.0.0
19+
>- **Required CMSIS Tools and Extensions:**
20+
> - Arm CMSIS Solution 1.64.1 (todo:check latest cbridge.exe)
21+
> - Arm CMSIS Debugger 1.3.0
22+
>- **Required ST tools and Firmware Package:**
23+
> - [STM32CubeMX 6.16.1](https://www.st.com/en/development-tools/stm32cubemx.html)
24+
> - [STM32Cube_FW_N6 1.3.0](https://www.st.com/en/embedded-software/stm32cuben6.html)
25+
> - [STM32CubeProgrammer 2.21.0](https://www.st.com/en/development-tools/stm32cubeprog.html)
26+
> - STM32_SigningTool_CLI: Ensure the environment variable `STM32_PRG_PATH` points to the folder that contains `STM32_SigningTool_CLI.exe`
2527
2628
## In VSCode
2729

28-
### In Activity bar under CMSIS click **Create Solution**
30+
### In Activity bar under CMSIS view click **Create Solution**
2931

3032
- Select **STM32N6570-DK** Target Board (from BSP) and **CubeMX Basic solution** (from DFP) and click **Create**
3133
- Select **AC6** compiler and click **OK**
32-
- Launch STM32CubeMX (CMSIS → Components → Device:CubeMX) and click **Run Configuration Generator**
34+
- Launch STM32CubeMX (CMSIS view → expand Project Target → expand and locate Device:CubeMX component) and click **Run Configuration Generator**
3335

3436
## In STM32CubeMX
3537

3638
### Select **Secure domain only** TrustZone feature
3739

38-
### Navigate to Project Manager:
40+
### Navigate to Project Manager
3941

40-
- Project tab: Ensure the **FSBL** and **ExtMemLoader** checkbox are selected
41-
- Core Generator tab: Check that **Copy only necessary library files** are selected
42+
- Project tab: Ensure the **FSBL** and **ExtMemLoader** checkboxes are selected and **Appli** checkbox is unselected
43+
- Code Generator tab: Check that **Copy only necessary library files** is selected
4244

43-
### Navigate to Pinout & Configuration:
45+
### Navigate to Pinout & Configuration
4446

45-
#### System core:
47+
#### System core
4648

47-
- CORTEX_M55M_FSBL: Enable CPU ICache and DCache
48-
- GPIO: Select PO1 pin as **GPIO_output**:
49+
- CORTEX_M55M_FSBL: Enable **CPU ICache** and **CPU DCache**
50+
- GPIO: Select PO1 pin as **GPIO_output** and configure PO1 configuration:
4951
- Pin Context Assignement: **First State Booot Loader**
50-
- GPIO output level: High
51-
- Add user label: `LED1_green`
52+
- GPIO output level: Low
53+
- Add user label: `LD1_green`
5254

53-
#### Connectivity:
55+
#### Connectivity
5456

55-
- SDMMC2: Unselect **First Stage Boot Loader** (disable this peripheral, because have configuration issue)
56-
- XSPI1: Unselect **First Stage Boot Loader** (disable this peripheral, because have partly conflict with PO1 `LED1_green`)
57-
- XSPI2: Check that **First Stage Boot Loader** and **External Memory Loader** is selected under Runtime contexts and modify following parameter settings:
57+
- SDMMC2: Unselect **First Stage Boot Loader** checkbox to disable this peripheral (To avoid configuration issues)
58+
- XSPI1: Unselect **First Stage Boot Loader** checkbox to disable this peripheral (To avoid configuration issues with PO1 `LD1_green`)
59+
- XSPI2: Check that **First Stage Boot Loader** and **External Memory Loader** are selected under Runtime contexts and modify following parameter settings:
5860
- Fifo Treshold: **4**
5961
- Memory Type: **Macronix**
6062
- Memory size: **1GBits**
6163

62-
#### Middleware:
64+
#### Middleware
65+
66+
- EXTMEM_MANAGER: Select **Activate External Memory Manager** checkbox and configure **Memory 1** parameters:
67+
- Select the memory driver: **EXTMEM_NOR_SFDP**
68+
- Memory Instance: **XSPI2**
69+
- Number of memory data lines: **EXTMEM_LINK_CONFIG_8LINES**
6370

64-
- EXTMEM_MANAGER: Select **First Stage Boot Loader** under Runtime contexts and select **Activate External Memory Manager** checkbox
65-
- Memory 1:
66-
- Memory Instance: XSPI2
67-
- Number of memory data lines: EXTMEM_LINK_CONFIG_8LINES
71+
- EXTMEM_LOADER: Select **Activate External Memory Loader** checkbox and configure following **External Memory Loader** parameters:
72+
- Number of sectors: **0x8000** (32768)
73+
- Sector size: **0x1000** Bytes (4096)
6874

69-
- EXTMEM_LOADER: Select **Activate External Memory Loader** and configure following External Memory Loader parameters:
70-
- Number of sectors: 0x8000 (32768)
71-
- Sector size: 0x1000 Bytes (4096)
75+
### Navigate to Clock Configuration
7276

73-
### Navigate to Clock Configuration:
77+
- Under **IC3 Clock Source** PLL section configure **IC3 Div** to **/24** to have **IC3 Clock** **50 MHz**
7478

75-
- PLL1 select **/24** divider for "50" To IC3 (MHz)
76-
- XSPI2 Source Mux: IC3; **50** To XSPI2 (MHz)
79+
![STM32CubeMX IC3 CLOCK CONFIGURATION](ic3_clock_conf.png)
80+
- Under **XSPI2 Source Mux** select IC3 to have **XSPI2 Clock** **50 MHz**
7781

78-
### Click **GENERATE CODE** and confirm warnings
82+
![STM32CubeMX XSPI2 SOURCE CONFIGURATION](xspi2_source_mux_conf.png)
83+
84+
### Click **GENERATE CODE** if you get warnings click Yes to generate code
7985

8086
## In VSCode: FSBL and ExtMemLoader modifications
8187

@@ -84,38 +90,47 @@ The boot ROM code uses the 512KB area in the AXI SRAM2 to store the FSBL image,
8490
- #### Add linker script
8591

8692
```yaml
87-
# Linker script definition
88-
linker:
89-
- script: ../STM32CubeMX/STM32N657X0HxQ/STM32CubeMX/MDK-ARM/FSBL/stm32n657xx_axisram2_fsbl.sct
90-
for-compiler: AC6
93+
# Linker script definition
94+
linker:
95+
- script: ../STM32CubeMX/STM32N657X0HxQ/STM32CubeMX/MDK-ARM/FSBL/stm32n657xx_axisram2_fsbl.sct
96+
for-compiler: AC6
9197
```
9298
9399
- #### Add post-build command to add header to the generated binary
94100
95101
```yaml
96-
# Post-build commands to add header
97-
executes:
98-
- execute: Generate_trusted_bin
99-
run: STM32_SigningTool_CLI.exe -bin $input$ -s -nk -of 0x80000000 -t fsbl -o $output$ -hv 2.3
100-
input:
101-
- $bin()$
102-
output:
103-
- $OutDir()$/FSBL-trusted.bin
102+
# Post-build commands to add header
103+
executes:
104+
- execute: Generate_trusted_bin
105+
run: $ENV{STM32_PRG_PATH}/STM32_SigningTool_CLI.exe -bin $input$ -s -nk -of 0x80000000 -align -t fsbl -o $output$ -hv 2.3
106+
input:
107+
- $bin()$
108+
output:
109+
- $OutDir()$/FSBL-trusted.bin
104110
```
105-
> **Note:** Note: The OTP configuration for flash source selection is configurable via BOOTROM_CONFIG2 - OTP_WORD11 using **STM32CubeProgrammer**. For more information, please check [UM3234](https://www.st.com/resource/en/user_manual/um3234-how-to-proceed-with-boot-rom-on-stm32n6-mcus-stmicroelectronics.pdf)
111+
112+
> **Note:** The OTP configuration for flash source selection is configurable via fuses in BOOTROM_CONFIG_2[8:5], OTP_WORD11 using **STM32CubeProgrammer**. Requires the **default** boot configuration to have sNOR device (connected to XSPIM_P2) attached boot. For more information, please check [UM3234](https://www.st.com/resource/en/user_manual/um3234-how-to-proceed-with-boot-rom-on-stm32n6-mcus-stmicroelectronics.pdf)
106113
---
107114
108115
### STM32CubeMX/STM32N657X0HxQ/FSBL.cgen.yml
109116
110-
- #### Comment following redundant files (temporarily issue with cmsis toolbox extension)
117+
- #### Comment following redundant files
111118
112119
```yaml
113-
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/core/memory_wrapper.c
114-
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/core/systick_management.c
115-
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/MDK-ARM/FlashDev.c
116-
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/MDK-ARM/FlashPrg.c
117-
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/STM32Cube/stm32_device_info.c
118-
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/STM32Cube/stm32_loader_api.c
120+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/stm32_extmem.c
121+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/sal/stm32_sal_xspi.c
122+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/sal/stm32_sal_sd.c
123+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/nor_sfdp/stm32_sfdp_data.c
124+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/nor_sfdp/stm32_sfdp_driver.c
125+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/psram/stm32_psram_driver.c
126+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/sdcard/stm32_sdcard_driver.c
127+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/user/stm32_user_driver.c
128+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/core/memory_wrapper.c
129+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/core/systick_management.c
130+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/MDK-ARM/FlashDev.c
131+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/MDK-ARM/FlashPrg.c
132+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/STM32Cube/stm32_device_info.c
133+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/STM32Cube/stm32_loader_api.c
119134
```
120135

121136
---
@@ -125,38 +140,39 @@ executes:
125140
- #### Add following line to toggle green led
126141

127142
```c
128-
/* USER CODE BEGIN 3 */
129-
HAL_GPIO_TogglePin(LED1_green_GPIO_Port, LED1_green_Pin);
130-
HAL_Delay(500);
131-
/* USER CODE END 3 */
143+
/* USER CODE BEGIN 3 */
144+
HAL_GPIO_TogglePin(LD1_green_GPIO_Port, LD1_green_Pin);
145+
HAL_Delay(500);
146+
}
147+
/* USER CODE END 3 */
132148
```
133149
134150
---
135151
136152
### ExtMemLoader/ExtMemLoader.cproject.yml
137153
138-
- #### Modify TrustZone mode from **secure** to **off**
154+
- #### Modify TrustZone mode from secure to "off"
139155
140156
- #### Add linker script
141157
142158
```yaml
143-
# Linker script definition
144-
linker:
145-
- script: ../STM32CubeMX/STM32N657X0HxQ/STM32CubeMX/MDK-ARM/ExtMemLoader/stm32n6xx_extmemloader_mdkarm.sct
146-
for-compiler: AC6
159+
# Linker script definition
160+
linker:
161+
- script: ../STM32CubeMX/STM32N657X0HxQ/STM32CubeMX/MDK-ARM/ExtMemLoader/stm32n6xx_extmemloader_mdkarm.sct
162+
for-compiler: AC6
147163
```
148164

149165
- #### Add post build commands to move .axf to root
150166

151167
```yaml
152-
# Post-build commands
153-
executes:
154-
- execute: Copy_ExtMemLoader_to_root
155-
run: ${CMAKE_COMMAND} -E copy $input$ $output$
156-
input:
157-
- ../out/ExtMemLoader/STM32N657X0HxQ/Debug/ExtMemLoader.axf
158-
output:
159-
- ../ExtMemLoader.axf
168+
# Post-build commands
169+
executes:
170+
- execute: Copy_ExtMemLoader_to_root
171+
run: ${CMAKE_COMMAND} -E copy $input$ $output$
172+
input:
173+
- ../out/ExtMemLoader/STM32N657X0HxQ/Debug/ExtMemLoader.axf
174+
output:
175+
- ../ExtMemLoader.axf
160176
```
161177
162178
---
@@ -166,46 +182,53 @@ executes:
166182
- #### Comment following redundant file
167183
168184
```yaml
169-
# - file: ./STM32CubeMX/MDK-ARM/startup_stm32n657xx_fsbl.c
185+
# - file: ./STM32CubeMX/MDK-ARM/startup_stm32n657xx_fsbl.c
170186
```
171187

172188
---
173189

174190
### In Activity bar under CMSIS click **Manage Solution Settings**
175191

176-
- Select **build_ExtMemLoader** Target Set and click **Build solution**
192+
- Select **ExtMemLoader** Target Set and click **Build solution**
177193
- **ExtMemLoader** project should successfully build to have configured flash algorithm (check in root folder if ExtMemLoader.axf file appears)
178194

179-
- Continue with select **build_load_FSBL** Target Set and click **Save** then click **Build solution**
180-
- FSBL project should successfully build to out folder
181-
- Open the CubeMX.csolution.yml file, **uncomment** the following entries, and **save** the file
182-
183-
```yaml
184-
# - image: $OutDir(FSBL)$/FSBL-trusted.bin
185-
# load-offset: 0x70000000
186-
# load: image
187-
```
188-
- In STM32N6570-DK board: Set the boot mode in **development mode** (BOOT1 switch position is 1-3) and reset board
195+
- Continue with select **FSBL** Target Set
196+
- Ensure **ST-Link@pyOCD** Debug Adapter is selected and **Update launch.json and tasks.json** checkbox is selected and click **Save** then click **Build solution**
197+
- FSBL project should successfully build into out folder
198+
- On STM32N6570-DK board: Set the boot mode in **development mode** (BOOT1 switch position is 1-3) and reset board
189199
- To flash device click **Views and More Actions** and click **Load application to target**
190-
- In STM32N6570-DK board: Set the boot mode in **flash mode** (BOOT1 switch position is 1-2) and reset board
200+
- On STM32N6570-DK board: Set the boot mode in **flash mode** (BOOT1 switch position is 1-2) and reset board
191201
- Green led should blink as we configured previous (in FSBL/Src/main.c)
192202

193-
- To debug application, select **debug_FSBL** Target Set and click **Save**
203+
- To debug application in:
194204
- **FLASH MODE:**
195-
- In STM32N6570-DK board: Set the boot mode in **flash mode** (BOOT1 switch position is 1-2) and reset board
205+
- On STM32N6570-DK board: Set the boot mode in **flash mode** (BOOT1 switch position is 1-2) and reset board
206+
207+
- Open .vscode\launch.json file and add following modification to the configuration named "STLink@pyOCD (launch)" under **initCommands** and **customResetCommands** commands:
208+
- Modify the command name from **tbreak main** to **thbreak main**
196209
- Click **Load & Debug application** button and now program should wait in main function to start debug
197210
- With Continue (F5) button green led should blink in flash mode
198211

199212
- **DEVELOPMENT MODE:**
200-
- In STM32N6570-DK board: Set the boot mode in **development mode** (BOOT1 switch position is 1-3) and reset board
201-
- Open .vscode\launch.json and add commands in initCommands after **monitor reset halt**:
213+
- On STM32N6570-DK board: Set the boot mode in **development mode** (BOOT1 switch position is 1-3) and reset board
214+
- Open .vscode\launch.json file and add following modification to the configuration named "STLink@pyOCD (launch)"
215+
- Comment line
216+
217+
```json
218+
// "preLaunchTask": "CMSIS Load",
219+
```
220+
221+
- add commands into initCommands
202222

203223
```json
204-
"load",
205-
"set $pc = Reset_Handler",
206-
"set $sp = (int) &Image$$ARM_LIB_STACK$$ZI$$Limit",
224+
"initCommands": [
225+
"monitor reset halt",
226+
"load",
227+
"set $pc = Reset_Handler",
228+
"set $sp = (int) &Image$$ARM_LIB_STACK$$ZI$$Limit",
229+
"thbreak main"
207230
```
208231

209232
- Save launch.json
210233
- Click **Load & Debug application** button and now program should wait in main function to start debug
211-
- With Continue (F5) button green led should blink in development mode
234+
- With Continue (F5) button green led should blink in development mode (todo:error handler (SCB_EnableDCach function))

0 commit comments

Comments
 (0)