Skip to content

Commit 9af71b0

Browse files
committed
feat: add stm32h7 port
Signed-off-by: sakumisu <1203593632@qq.com>
1 parent ffd5d11 commit 9af71b0

File tree

6 files changed

+564
-0
lines changed

6 files changed

+564
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ if(CONFIG_CHERRYECAT)
3131
endif()
3232
endif()
3333

34+
if(CHERRYECAT_NETDEV_STM32H7)
35+
list(APPEND cherryec_srcs port/netdev_stm32h7.c)
36+
endif()
37+
3438
if(HPM_SDK_BASE)
3539
list(APPEND cherryec_srcs port/netdev_hpmicro.c)
3640
sdk_inc(${cherryec_incs})

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ Generating C code...
109109

110110
- HPM6750EVK2/HPM6800EVK/**HPM5E00EVK**(hybrid internal)
111111
- RT-Thread RZN2L-EtherKit/RA8P1 Titan/RuiQing Pai
112+
- STM32H7
113+
112114

113115
## Contact
114116

README_zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Generating C code...
109109

110110
- HPM6750EVK2/HPM6800EVK/**HPM5E00EVK**(hybrid internal)
111111
- RT-Thread RZN2L-EtherKit/RA8P1 Titan/RuiQing Pai
112+
- STM32H7
112113

113114
## 联系
114115

SConscript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ if GetDepend(['PKG_CHERRYECAT_NETDEV_HPMICRO']):
3131
if GetDepend(['PKG_CHERRYECAT_NETDEV_RENESAS']):
3232
src += Glob('port/netdev_renesas.c')
3333

34+
if GetDepend(['PKG_CHERRYECAT_NETDEV_STM32H7']):
35+
src += Glob('port/netdev_stm32h7.c')
36+
3437
group = DefineGroup('CherryECAT', src, depend = ['PKG_USING_CHERRYECAT'], LIBS = LIBS, LIBPATH=LIBPATH, CPPPATH = path, CPPDEFINES = CPPDEFINES)
3538

3639
Return('group')

demo/stm32h7/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# CherryECAT STM32
2+
3+
Use ``git clone https://github.com/sakumisu/cherryecat_stm32h7.git --recursive``
4+
5+
**Please do not modify main.c and xxx_it.c when generating code with cubemx.**
6+
7+
## Caution
8+
9+
- Must enable `USE_HAL_TIM_REGISTER_CALLBACKS to 1 in stm32h7xx_hal_conf.h`
10+
- STM32H7 HAL version must >= 1.11.x
11+
- Must modify sct file for `RxDescripSection`, `TxDescripSection` and `TRx_PoolSection`
12+
13+
```
14+
; *************************************************************
15+
; *** Scatter-Loading Description File generated by uVision ***
16+
; *************************************************************
17+
18+
LR_IROM1 0x08000000 0x00200000 { ; load region size_region
19+
ER_IROM1 0x08000000 0x00200000 { ; load address = execution address
20+
*.o (RESET, +First)
21+
*(InRoot$$Sections)
22+
.ANY (+RO)
23+
.ANY (+XO)
24+
}
25+
RW_IRAM2 0x24000000 0x00080000 { ; RW data
26+
.ANY (+RW +ZI)
27+
}
28+
RW_DMARxDscrTab 0x30000000 0x80 {
29+
*(.RxDescripSection)
30+
}
31+
RW_DMATxDscrTab 0x30000080 0x80 {
32+
*(.TxDescripSection)
33+
}
34+
memory_TRX_POOL_base 0x30000100 0x3F00 {
35+
*(.TRx_PoolSection)
36+
}
37+
38+
}
39+
40+
```
41+
42+
- Must config mpu with nocache for 0x30000000 base
43+
44+
```
45+
void MPU_Config(void)
46+
{
47+
MPU_Region_InitTypeDef MPU_InitStruct = {0};
48+
49+
/* Disables the MPU */
50+
HAL_MPU_Disable();
51+
52+
/** Initializes and configures the Region and the memory to be protected
53+
*/
54+
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
55+
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
56+
MPU_InitStruct.BaseAddress = 0x0;
57+
MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
58+
MPU_InitStruct.SubRegionDisable = 0x87;
59+
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
60+
MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
61+
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
62+
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
63+
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
64+
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
65+
66+
HAL_MPU_ConfigRegion(&MPU_InitStruct);
67+
68+
/** Initializes and configures the Region and the memory to be protected
69+
*/
70+
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
71+
MPU_InitStruct.BaseAddress = 0x30000000;
72+
MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
73+
MPU_InitStruct.SubRegionDisable = 0x0;
74+
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
75+
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
76+
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
77+
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
78+
79+
HAL_MPU_ConfigRegion(&MPU_InitStruct);
80+
/* Enables the MPU */
81+
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
82+
83+
}
84+
```
85+
86+
- Must add PHY_RESET macro in ec_config.h
87+
88+
```
89+
#define CONFIG_EC_PHY_RESET_PORT 0 // 0 for GPIOA
90+
#define CONFIG_EC_PHY_RESET_PIN 8
91+
92+
```

0 commit comments

Comments
 (0)