|
| 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