{"id":21059003,"url":"https://github.com/robotdad/blinkfreertos-nucleo-l55","last_synced_at":"2025-07-14T03:10:39.525Z","repository":{"id":186505963,"uuid":"609668237","full_name":"robotdad/BlinkFreeRTOS-Nucleo-L55","owner":"robotdad","description":"Using CubeMX to generate a FreeRTOS project and import it into VS Code","archived":false,"fork":false,"pushed_at":"2023-03-05T02:14:58.000Z","size":1296,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T00:41:28.895Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robotdad.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-04T21:43:49.000Z","updated_at":"2023-04-20T14:38:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"37f163f7-1e2d-4546-9b81-010afa0e2075","html_url":"https://github.com/robotdad/BlinkFreeRTOS-Nucleo-L55","commit_stats":null,"previous_names":["robotdad/blinkfreertos-nucleo-l55"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robotdad/BlinkFreeRTOS-Nucleo-L55","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotdad%2FBlinkFreeRTOS-Nucleo-L55","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotdad%2FBlinkFreeRTOS-Nucleo-L55/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotdad%2FBlinkFreeRTOS-Nucleo-L55/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotdad%2FBlinkFreeRTOS-Nucleo-L55/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robotdad","download_url":"https://codeload.github.com/robotdad/BlinkFreeRTOS-Nucleo-L55/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotdad%2FBlinkFreeRTOS-Nucleo-L55/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265237072,"owners_count":23732505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T17:09:40.945Z","updated_at":"2025-07-14T03:10:39.450Z","avatar_url":"https://github.com/robotdad.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nucleo-L552ZE-Q\n\nThis repository was created by following the steps below. This walks you through creating a FreeRTOS project in CubeMX, importing it into VS Code, building it, adding application code to blink LEDs on the device, and debugging the running firmware on the board.\n\nTo use this just clone this repo and you can open in VS Code. Make sure you have completed the setup steps, then you can jump ahead to building the firmware.\n\n```\ngit clone https://github.com/robotdad/BlinkFreeRTOS-Nucleo-L55.git\ncd BlinkFreeRTOS-Nucleo-L55\ncode .\n```\n# Setup\nHave CubeMX, CubeIDE, and VS Code with Embedded Tools VS Code Extension installed.\n\nMake sure you have updated your STLink firmware on your board.\n\nI have included the steps for creating git repos and connecting them to GitHub below. If you are following along with those steps as well you need git and the GitHub cli installed.\n\n# FreeRTOS from scratch with CubeMX\n\nIn CubeMX go to board selector, search for the Nucleo-L552ZE-Q, select it, and start project. Initialize all peripherals to default state, do not enable TrustZone.\n\nStarting on the Pinout tab, under Categories, Middleware select FreeRTOS and enable CMSIS_V2. Select Tasks and Queues under the Configuration options. Change the default task name to blinkRed and the entry function to StartBlinkRed. Add a new task blinkGreen, entry function StartBlinkGreen, and set osPriorityBelowNormal. Add a new task blinkBlue, entry function StartBlinkBlue, and set osPriorityLow. Select Advanced settings and anable USE_NEWLIB_REENTRANT.\n\nUnder Categories, System Code, select Sys and change the Time base source to TIM6. Now select ICACHE and enable 1-way mode.\n\nSelect the Project Manager tab give it a name and select your project location. Select STM32CubeIDE for the toolchain and generate under root.\n\nNavigate to where you saved your generated project and setup a git repo.\n```\ngit init -b main\ngit add . \u0026\u0026 git commit -m \"initial commit\"\ngh repo create\n```\nFollow the prompts for creating the repo on GitHub. You will want to add a remote, defaults are fine.\n\n## Importing an ST Project\nOpen VS Code, in the command palette (Ctrl + Shift + P) use Create project from ST Project. This will launch the file browser, navigate to where the project you created in CubeMX is, and select the .cproject. If prompted to trust the authors, agree. You will be prompted to choose a configuration, select debug.\n\nThe result of the above actions is that a CMake project will be generated, default tasks will be created for the project for use in VS Code and VS, and a vcpkg-configuration file will be created and activated. The vcpkg step configures the environment so that CMake, Ninja, and the ST compilers from the STM32IDE are all on path and ready to use.\n\nIn VS Code you can select the git activity and commit the generated artifacts from the import.\n\nYou should now create a .gitignore file. Minimally make sure to exclude the build folder by adding the line \"build/\" to the file. You can also copy [a complete .gitignore from here](https://raw.githubusercontent.com/robotdad/BlinkFreeRTOS-Nucleo-L55/main/.gitignore). When done commit the file. \n\n## Updating tasks\nWe want to add implementations to the blink tasks we generated in CubeMX. In the file explorer in VS Code expand the folder Core \u003e Src and select main.c. Select Ctrl + T to search for symbols, and search for StartBlinkRed and select it (not the declaration).\n\nNotice that there are comments of USER CODE BEGIN and USER CODE END throughout the source. Always place your changes between these blocks as it will be preserved if you need to regenerate code using CubeMX. You may need to do that if you make changes to peripheral options under pinout for example.\n\nIn the user code for StartBlinkRed there is an infinite loop with an osDelay call. This function is called by FreeRTOS as a task so it runs in parallel to other tasks. Delete the osDelayCall and add the following lines.\n```\nHAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);\nosDelay(1000);\n```\nNow, to understand what is being used on the hardware right select LED_RED_GPIO_Port and select Peek, Peek Definition. You will see that this is defined as GPIOA. Do the same thing for LED_RED_PIN, or select Alt F12, and notice it is GPIO Pin 9.\n\nLet's complete the implementation for StartBlinkGreen as above.\n```\nHAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);\nosDelay(1000);\n```\nUsing peek definition again note this corresponds to GPIO C, Pin 7.\n\nNow for StartBlinkBlue.\n```\nHAL_GPIO_TogglePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin);\nosDelay(1000);\n```\nUsing peek definition again note this corresponds to GPIO B, Pin 7.\n\n## Building the firmware\n\nSelect the CMakeLists.txt file in the file explorer and from the context menu select Clean Reconfigure All Projects. This ensures we have generated the build files using the proper compilers that are now on the path. From the context menu for CMakeLists.txt you can now select Build All Projects. This should build your firmware under the build directory.\n\n## Debugging\nSelect the Debug icon in the activity bar. Launch should already be selected. You can select the gear icon to see the details of the provided launch configuration. Note that the miDebuggerPath and debugServerPath are configured using environment variables provided by the Embedded Tools extension that use ST's gdb and gdbserver executables provided by STM32IDE.\n\nThe postRemoteConnectCommands has been generated with the firmware name from the CMake project target to be loaded onto the device. There is also an svdPath configured to load the correct SVD file for our part.\n\nBy default stopAtConnect is set to True which will cause us to break in the startup handler.\n\nPlace a breakpoint in any of the StartBlink functions created above.\n\nConnect your board and select the play button to start debugging, or press F5.\n\n### Examine peripheral registers\nWhen you hit a break point open the peripheral view from the command palette, select Focus on peripheral view. Expand the view that opens in the debug pane. Find the GPIO section corresponding to your breakpoint. The pins are under the ODR section. You can step over the HAL_GPIO_TogglePin call and either watch the value for ODR change, or expand it to see the specific pin value update.\n\nGPIOs for LEDs:\n* Red: GPIOA ODR9\n* Green: GPIOC ODR7\n* Blue: GPIOB ODR7\n\n### Inspect the RTOS threads\nWhen you hit a break point, or while the debugger is paused, open the RTOS view from the command palette, select Focus on RTOS view. \n\nThis view will show you the RTOS threads in your application, what state they are in, the size, and other details. This varies somewhat depending on what the RTOS makes available. The view is automatically set to the detected RTOS for threadx, FreeRTOS, and Zephyr.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobotdad%2Fblinkfreertos-nucleo-l55","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobotdad%2Fblinkfreertos-nucleo-l55","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobotdad%2Fblinkfreertos-nucleo-l55/lists"}