Skip to content

Commit 92638f6

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

15 files changed

Lines changed: 437 additions & 547 deletions
9.95 KB
Loading

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: 118 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,85 @@
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 copy FSBL image (512KB) from external Flash (Octo SPI Flash Memory) to the internal RAM (AXI SRAM2).
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-Toolbox 2.12](https://www.keil.arm.com/artifacts/#tools/open-cmsis-pack/cmsis-toolbox) (todo:cbridge27.exe)
21+
> - Arm CMSIS Debugger 1.3.0
22+
> - Arm CMSIS Solution 1.62.2
23+
>- **Required ST tools and Firmware Package:**
24+
> - [STM32CubeMX.6.16.1](https://www.st.com/en/development-tools/stm32cubemx.html)
25+
> - [STM32CubeProgrammer_V2.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`
27+
> - [STM32Cube_FW_N6_V1.3.0](https://www.st.com/en/embedded-software/stm32cuben6.html)
2528
2629
## In VSCode
2730

28-
### In Activity bar under CMSIS click **Create Solution**
31+
### In Activity bar under CMSIS view click **Create Solution**
2932

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

3437
## In STM32CubeMX
3538

3639
### Select **Secure domain only** TrustZone feature
3740

38-
### Navigate to Project Manager:
41+
### Navigate to Project Manager
3942

4043
- Project tab: Ensure the **FSBL** and **ExtMemLoader** checkbox are selected
41-
- Core Generator tab: Check that **Copy only necessary library files** are selected
44+
- Code Generator tab: Check that **Copy only necessary library files** are selected
4245

43-
### Navigate to Pinout & Configuration:
46+
### Navigate to Pinout & Configuration
4447

45-
#### System core:
48+
#### System core
4649

47-
- CORTEX_M55M_FSBL: Enable CPU ICache and DCache
50+
- CORTEX_M55M_FSBL: Enable **CPU ICache** and **CPU DCache**
4851
- GPIO: Select PO1 pin as **GPIO_output**:
4952
- Pin Context Assignement: **First State Booot Loader**
50-
- GPIO output level: High
51-
- Add user label: `LED1_green`
53+
- GPIO output level: Low
54+
- Add user label: `LD1_green`
5255

53-
#### Connectivity:
56+
#### Connectivity
5457

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:
58+
- SDMMC2: Unselect **First Stage Boot Loader** checkbox to disable this peripheral (Because have configuration issue)
59+
- XSPI1: Unselect **First Stage Boot Loader** checkbox to disable this peripheral (Because have partly conflict with PO1 `LD1_green`)
60+
- XSPI2: Check that **First Stage Boot Loader** and **External Memory Loader** are selected under Runtime contexts and modify following parameter settings:
5861
- Fifo Treshold: **4**
5962
- Memory Type: **Macronix**
6063
- Memory size: **1GBits**
6164

62-
#### Middleware:
65+
#### Middleware
6366

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
67+
- EXTMEM_MANAGER: Select **Activate External Memory Manager** checkbox and configure **Memory 1** parameters:
68+
- Select the memory driver: **EXTMEM_NOR_SFDP**
69+
- Memory Instance: **XSPI2**
70+
- Number of memory data lines: **EXTMEM_LINK_CONFIG_8LINES**
6871

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)
72+
- EXTMEM_LOADER: Select **Activate External Memory Loader** checkbox and configure following **External Memory Loader** parameters:
73+
- Number of sectors: **0x8000** (32768)
74+
- Sector size: **0x1000** Bytes (4096)
7275

73-
### Navigate to Clock Configuration:
76+
### Navigate to Clock Configuration
7477

75-
- PLL1 select **/24** divider for "50" To IC3 (MHz)
76-
- XSPI2 Source Mux: IC3; **50** To XSPI2 (MHz)
78+
- Under **IC3 Clock Source** PLL section configure **IC3 Div** to **/24** to have **IC3 Clock** **50 MHz**
79+
- Under **XSPI2 Source Mux** select IC3 to have **XSPI2 Clock** **50 MHz**
7780

78-
### Click **GENERATE CODE** and confirm warnings
81+
![STM32CubeMX Clock Configuration](Clock_configuration.png)
82+
83+
### Click **GENERATE CODE** if you get warnings click Yes to generate code
7984

8085
## In VSCode: FSBL and ExtMemLoader modifications
8186

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

8691
```yaml
87-
# Linker script definition
88-
linker:
89-
- script: ../STM32CubeMX/STM32N657X0HxQ/STM32CubeMX/MDK-ARM/FSBL/stm32n657xx_axisram2_fsbl.sct
90-
for-compiler: AC6
92+
# Linker script definition
93+
linker:
94+
- script: ../STM32CubeMX/STM32N657X0HxQ/STM32CubeMX/MDK-ARM/FSBL/stm32n657xx_axisram2_fsbl.sct
95+
for-compiler: AC6
9196
```
9297
9398
- #### Add post-build command to add header to the generated binary
9499
95100
```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
101+
# Post-build commands to add header
102+
executes:
103+
- execute: Generate_trusted_bin
104+
run: $ENV{STM32_PRG_PATH}/STM32_SigningTool_CLI.exe -bin $input$ -s -nk -of 0x80000000 -align -t fsbl -o $output$ -hv 2.3
105+
input:
106+
- $bin()$
107+
output:
108+
- $OutDir()$/FSBL-trusted.bin
104109
```
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)
110+
111+
> **Note:** The OTP configuration for flash source selection is configurable via fuses in BOOTROM_CONFIG_2[8:5], OTP_WORD11 using **STM32CubeProgrammer**. Ensure that boot configuration is set to **default** 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)
106112
---
107113
108114
### STM32CubeMX/STM32N657X0HxQ/FSBL.cgen.yml
109115
110-
- #### Comment following redundant files (temporarily issue with cmsis toolbox extension)
116+
- #### Comment following redundant files (temporarily issue with cmsis toolbox)
111117
112118
```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
119+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/stm32_extmem.c
120+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/sal/stm32_sal_xspi.c
121+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/sal/stm32_sal_sd.c
122+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/nor_sfdp/stm32_sfdp_data.c
123+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/nor_sfdp/stm32_sfdp_driver.c
124+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/psram/stm32_psram_driver.c
125+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/sdcard/stm32_sdcard_driver.c
126+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Manager/user/stm32_user_driver.c
127+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/core/memory_wrapper.c
128+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/core/systick_management.c
129+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/MDK-ARM/FlashDev.c
130+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/MDK-ARM/FlashPrg.c
131+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/STM32Cube/stm32_device_info.c
132+
# - file: ./STM32CubeMX/Middlewares/ST/STM32_ExtMem_Loader/STM32Cube/stm32_loader_api.c
119133
```
120134

121135
---
@@ -125,10 +139,11 @@ executes:
125139
- #### Add following line to toggle green led
126140

127141
```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 */
142+
/* USER CODE BEGIN 3 */
143+
HAL_GPIO_TogglePin(LD1_green_GPIO_Port, LD1_green_Pin);
144+
HAL_Delay(500);
145+
}
146+
/* USER CODE END 3 */
132147
```
133148
134149
---
@@ -140,23 +155,23 @@ HAL_Delay(500);
140155
- #### Add linker script
141156
142157
```yaml
143-
# Linker script definition
144-
linker:
145-
- script: ../STM32CubeMX/STM32N657X0HxQ/STM32CubeMX/MDK-ARM/ExtMemLoader/stm32n6xx_extmemloader_mdkarm.sct
146-
for-compiler: AC6
158+
# Linker script definition
159+
linker:
160+
- script: ../STM32CubeMX/STM32N657X0HxQ/STM32CubeMX/MDK-ARM/ExtMemLoader/stm32n6xx_extmemloader_mdkarm.sct
161+
for-compiler: AC6
147162
```
148163

149164
- #### Add post build commands to move .axf to root
150165

151166
```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
167+
# Post-build commands
168+
executes:
169+
- execute: Copy_ExtMemLoader_to_root
170+
run: ${CMAKE_COMMAND} -E copy $input$ $output$
171+
input:
172+
- ../out/ExtMemLoader/STM32N657X0HxQ/Debug/ExtMemLoader.axf
173+
output:
174+
- ../ExtMemLoader.axf
160175
```
161176
162177
---
@@ -166,46 +181,50 @@ executes:
166181
- #### Comment following redundant file
167182
168183
```yaml
169-
# - file: ./STM32CubeMX/MDK-ARM/startup_stm32n657xx_fsbl.c
184+
# - file: ./STM32CubeMX/MDK-ARM/startup_stm32n657xx_fsbl.c
170185
```
171186

172187
---
173188

174189
### In Activity bar under CMSIS click **Manage Solution Settings**
175190

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

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
194+
- Continue with select **FSBL** Target Set and click **Save** then click **Build solution**
195+
- FSBL project should successfully build into out folder
196+
- On STM32N6570-DK board: Set the boot mode in **development mode** (BOOT1 switch position is 1-3) and reset board
189197
- 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
198+
- On STM32N6570-DK board: Set the boot mode in **flash mode** (BOOT1 switch position is 1-2) and reset board
191199
- Green led should blink as we configured previous (in FSBL/Src/main.c)
192200

193-
- To debug application, select **debug_FSBL** Target Set and click **Save**
201+
- To debug application in:
194202
- **FLASH MODE:**
195-
- In STM32N6570-DK board: Set the boot mode in **flash mode** (BOOT1 switch position is 1-2) and reset board
203+
- On STM32N6570-DK board: Set the boot mode in **flash mode** (BOOT1 switch position is 1-2) and reset board
196204
- Click **Load & Debug application** button and now program should wait in main function to start debug
197205
- With Continue (F5) button green led should blink in flash mode
198206

199207
- **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**:
208+
- On STM32N6570-DK board: Set the boot mode in **development mode** (BOOT1 switch position is 1-3) and reset board
209+
- Open .vscode\launch.json and add following modification:
210+
- Comment line
211+
212+
```json
213+
// "preLaunchTask": "CMSIS Load",
214+
```
215+
216+
- add commands into initCommands:
202217

203218
```json
204-
"load",
205-
"set $pc = Reset_Handler",
206-
"set $sp = (int) &Image$$ARM_LIB_STACK$$ZI$$Limit",
219+
"initCommands": [
220+
"symbol-file \"out/FSBL/STM32N657X0HxQ/Debug/FSBL.axf\"",
221+
"monitor reset halt",
222+
"load",
223+
"set $pc = Reset_Handler",
224+
"set $sp = (int) &Image$$ARM_LIB_STACK$$ZI$$Limit",
225+
"tbreak main"
207226
```
208227

209228
- Save launch.json
210229
- 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
230+
- With Continue (F5) button green led should blink in development mode (todo:error handler)

0 commit comments

Comments
 (0)