cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMx creates some bugs

stm32forum
Associate II
Posted on January 21, 2016 at 14:43

CubeMx 4.12.0 Mcu: STM32L476RETx Fimware Package: L4V1.2.0

-Cube is generating code for port H, but there's no port H on the L476RET

  /*Configure GPIO pins : PH0 PH1 */

 

  GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1;

 

  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;

 

  GPIO_InitStruct.Pull = GPIO_NOPULL;

 

  HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

-In sd_diskio.c

const Diskio_drvTypeDef SD_Driver =

Should be without the const

5 REPLIES 5
Nesrine M_O
Lead II
Posted on January 21, 2016 at 15:40

Hi Edje,

1-Cube is generating code for port H, but there's no port H on the L476RET

Please refer to the product datasheet, in fact the port H exist (PH0-OSC_IN (PH0) – PH1/OSC_OUT)

2-Const Diskio_drvTypeDef SD_Driver = Should be without the const

Could you please let us know what kind of problem did you faced with this declaration that leads to this conclusion?

-Syrine-

stm32forum
Associate II
Posted on January 21, 2016 at 16:46

Hi Syrine,

Thanks for your quick reply.

1. That's really stupid of me, missed those 2 pins. Need some fresh coffee.

2. fmount() will return a FR_INVALIDE_DRIVE, because the path argument is not valid.

And that's is because Disknum in FATFS_LinkDriverEx is 0xbd instead of 0x00.

In your example c:\Users\e\STM32Cube\Repository\STM32Cube_FW_L4_V1.2.0\Projects\STM32L476G_EVAL\Demonstrations\MB1144\Core\Src\k_sd_diskio.c it was without the const  and that made it work for me.

Nesrine M_O
Lead II
Posted on January 25, 2016 at 08:56

Hi Edje,

You said that the demonstration project works fine for you, try to add const to the structure declaration and the demo will still work properly (I tested it). So, I don’t think that this declaration is the root cause of your problem.

Can you please share your project with us? Forum users may bring you some help.

-Syrine-

stm32forum
Associate II
Posted on January 27, 2016 at 16:09

Hi Syrine,

Thanks for your reply.

I didn't say that the example project was working, I ''said'' that there are differences comparing the code generate by CubeMx and the example project. The difference found made my project work.

Attached my test project including the ioc file.

________________

Attachments :

SdCardTest.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htjl&d=%2Fa%2F0X0000000aWL%2F0WK.xKSfmJ_.l5eela3nyPfaN0I6Qur2fMRM04xyHpg&asPdf=false
David Brooks
Associate II
Posted on April 05, 2016 at 16:19

In regard to the ''const'' problem mentioned above and using Cube 4.13.0:

Error[Pe1061]: declaration of variable ''SD_Driver'' is incompatible with a declaration in another translation unit C:\Software\In House Projects\Lab Card Reader\Middlewares\Third_Party\FatFs\src\drivers\sd_diskio.h 36

''struct <unnamed> SD_Driver'' (declared at line 36 of ''C:\Software\In House Projects\Lab Card Reader\EWARM/../Middlewares/Third_Party/FatFs/src/drivers\sd_diskio.h'') (from translation unit ''C:\Software\In House Projects\Lab 

Card Reader\Src\fatfs.c'')

''struct <unnamed> const SD_Driver'' (declared at line 52 of ''C:\Software\In House Projects\Lab Card Reader\Middlewares\Third_Party\FatFs\src\drivers\sd_diskio.c'') (from translation unit ''C:\Software\In House Projects\Lab Card 

Reader\Middlewares\Third_Party\FatFs\src\drivers\sd_diskio.c'')