STM32F745VET FMC address read fail #62841
-
Hello. My core MCU is STM32F745VET and using Zephyr 3.2. Here's some information and what I did for FMC ethernet. and this is part of fmc dts node.
I'm using BANK1 NE1, and A16 for address line. #define FSMC_NE1_ADDR (0x60000000)
#define NET_BASE_ADDR (FSMC_NE1_ADDR)
#define NET_REG_ADDR (*((volatile uint16_t *) NET_BASE_ADDR))
#define NET_REG_DATA (*((volatile uint16_t *) (NET_BASE_ADDR | (1<<17)) )) and I tried to read most simple register which show vendor ID & product ID. uint8_t DM9k_ior(uint8_t reg)
{
NET_REG_ADDR = reg;
return NET_REG_DATA;
}
static int dm9006_init(const struct device *dev)
{
uint8_t vid1, vid2, pid1, pid2;
vid1 = DM9k_ior(VID) & 0xFF;
vid2 = DM9k_ior(VID+1) & 0xFF;
pid1 = DM9k_ior(PID) & 0xFF;
pid2 = DM9k_ior(PID+1) & 0xFF;
printk("vid %02x%02x, pid %02x%02x\n", vid1, vid2, pid1, pid2);
} But the result shows only 0 like below. I referenced official manual and datasheet, and also find FMC LCD things on zephyr. https://github.com/zephyrproject-rtos/zephyr/pull/45654/files Is there something I can do for FMC? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
Hi @kookoo2997! We appreciate you submitting your first issue for our open-source project. 🌟 Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙 |
Beta Was this translation helpful? Give feedback.
-
I've converted this to discussion, to first clarify the need and direction..
I guess @GeorgeCGV you would have a good view on this. |
Beta Was this translation helpful? Give feedback.
-
Dear @erwango @GeorgeCGV . and this is the waveform from STM32F745. Here is another waveform that control FMC lines by using GPIO API. I think there're two problems that
Thank you for reading. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@kookoo2997 the FMC initialization in Zephyr is HAL based and it is pretty much a direct mapping from DT to the HAL structs. Therefore, not a lot of things to go wrong with it. If the configuration matches with Cube's and the timings are correct, then the only parts to check are:
There is no abstraction for the FMC. That means drivers have to care about low-level things. That is pretty much the reason why #45654 has stalled. |
Beta Was this translation helpful? Give feedback.
-
Finally I make it work, but I do not understand clearly why this works. Here is what I did.
diff --git a/soc/arm/st_stm32/stm32f7/Kconfig.series b/soc/arm/st_stm32/stm32f7/Kconfig.series
index 860aea7e..723a6ecf 100644
--- a/soc/arm/st_stm32/stm32f7/Kconfig.series
+++ b/soc/arm/st_stm32/stm32f7/Kconfig.series
@@ -12,6 +12,8 @@ config SOC_SERIES_STM32F7X
select SOC_FAMILY_STM32
select HAS_STM32CUBE
select CPU_HAS_ARM_MPU
+ select USE_STM32_HAL_CORTEX
select HAS_SWO
+ select CPU_HAS_CUSTOM_FIXED_SOC_MPU_REGIONS
help
Enable support for STM32F7 MCU series I got inspiration from #62841 (reply in thread) , so I compared configrations between STM32H7 and STM32F7.
void MPU_Config(void)
{
MPU_Region_InitTypeDef MPU_InitStruct = {0};
/* Disables the MPU */
HAL_MPU_Disable();
/** Initializes and configures the Region and the memory to be protected
*/
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
MPU_InitStruct.BaseAddress = 0x0;
MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
MPU_InitStruct.SubRegionDisable = 0x87;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
/* Enables the MPU */
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
} I added this code to drivers/.../my_driver.c. After that, I flashed to STM32F745VET custom board, and got the result what I want. Then again, I dont know clearly why and how this solution works... but wish that this can be some help when add FMC stuff to another STM32F MCU series. |
Beta Was this translation helpful? Give feedback.
Finally I make it work, but I do not understand clearly why this works.
Here is what I did.
I …