I was a Keil user. With the projects I'm dealing with are getting bigger, the free trial version of Keil with 32K byte limit no longer a choice for me. My teacher even encourage us to use a pirate version of Keil.
I'm a fan of opensource and VS Code. Microsoft does a great job on optimization and F1
command is so convinient. But there are still lots of steps to do for debugging in VS Code, I choosed STM32CubeIDE
, which is based on ECLIPSE and intergrated with stm32Cube.
This note is written with STM32CubeIDE Version: 1.4.0
FLASH_DESC_STR
, longest size is 127 chars. Doesn't go any further even you change any parameter found in CubeMX.If you are including something like stdio.h
, then you can probably compile and call your function without error. But when you are trying to include a header file elsewhere(not in project folder), such as stm32746g_discovery_lcd.h
, it becomes triky.
For the compiler to know where stm32746g_discovery_lcd.h
is, you need to add it to Include Paths
:
Project ==> Properties ==> C/C++ General ==> Paths and Symbol
==> Includes ==> GNU C ==> Add…, then paste the folder path where your header file located.
Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
And for linker to know where your .c
file located(), you need to add the folder to Link Folder...
:
Project ==> Properties ==> C/C++ General ==> Paths and Symbol
==> Source Location ==> Link Folder ==> Check Link to folder…, then paste the folder path where.c
loacted at the second textbar.
Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Get the path of the library
Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Add in
Libraries
andLibrary search path
For*.a
files, you can either removelib
and.a
as shown in the picture
or you can type:*.a
Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
File ==> Export ==> General ==> Preference, Click Next
Check Export all ==> Choose To preference file, click Finish.
File ==> Import ==> General ==> Preference, Click Next
Choose From preference file ==> Check Import all, click Finish.
Not realy useful, not recommanded.
It seems that STM32CubeIDE does not support folding on any {}, so I will use#if 1
and#endif
to fold codes that I'm not editing, especially those parts generated by Cube. Here is a cleanmain.c
with#if 1
and#endif
at specific lines. When your project just built and you have the first code generation, erase everything in./Core/Src/main.c
and paste the following snippet in it. It's important that you can only do this when the project just built and there is nothing from you in./Core/Src/main.c
, otherwise you have to do it line by line manually.
main.c
/* USER CODE BEGIN Header */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
// Folding Private variables by Cube
#if 1
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
//
// Folding
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
#endif
// Folding Private function prototypes of Cube
#if 1
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
#endif
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
// Folding Private variables initialization of Cube
#if 1
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
/* USER CODE BEGIN 2 */
#endif
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
// Folding Private functions implementation of Cube
#if 1
/* USER CODE END 3 */
}
/* USER CODE BEGIN 4 */
#endif
/* USER CODE END 4 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/