Skip to main content
Senior III
September 2, 2026
Question

MX_FATFS_Init canno't disable generated code

  • September 2, 2026
  • 5 replies
  • 34 views

i have enabled FATFS via CubeMX like below

but for some reason in the code generation settings I can’t disable

I want disable it because CubeMX generates a void function; instead, I want the MX_FATFS_Init return a status code if it is generated or not so, I want to have a uint8_t MX_FATFS_Init()

 

5 replies

mƎALLEm
ST Technical Moderator
September 2, 2026

Hello,

Try the following:

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
nico23Author
Senior III
September 2, 2026

Hi ​@mƎALLEm ; as my first screen suggest, I’ve already ticked the “Do Not Generate Function Call” regarding MX_FATFS_Init. (If I tick it, all the functions are not generated, which I don’t want)

mƎALLEm
ST Technical Moderator
September 2, 2026

Check “Do not Generate Function Call” then “Check MX_FATFS_Int” box in the “Do not Generate Function Call” column as I indicated previously. I’ve just tested it and it works.

You need just to check the box for MX_FATFS_Init not others. Uncheck them (others) if they are checked.

This is the generated code: 

int main(void)
{

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MPU Configuration--------------------------------------------------------*/
MPU_Config();

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SDMMC1_SD_Init();
/* USER CODE BEGIN 2 */

/* USER CODE END 2 */

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}

The FATFs middleware still included in the project.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.