Developing Keil MDK-ARM Projects with VisualGDB
[Copy link]
I saw it on a foreign website, which is an idea of adding a compiler This tutorial shows how to use VisualGDB to create, build and debug an MSBuild-based project using the Keil MDK-ARM compiler. Starting from VisualGDB 5.4 Preview 10, the Keil compiler is fully supported on par with the GCC compiler, so you can use the regular VisualGDB GUI to create your projects and manage their settings. - Open Visual Studio and begin creating a new Embedded VisualGDB project:
- Select “Create a new project” -> “MSBuild”:[ color=rgb(30, 115, 190)]VisualGDB can also create GNU Make-based projects using the Keil compiler, however the MSBuild -based projects provide better GUI integration and build faster.
- Select your Keil toolchain on the Device Selection page. Note that VisualGDB supports both the classic ARMCC compiler (V5) and the newer Clang-based compiler (V6): If the Keil compilers don't appear in the toolchain list, double-check the Keil installation path in registry (HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Keil\Products\MDK\Path).
- Once the toolchain is selected, pick your
- device from the list. When using the Keil toolchains, VisualGDB will automatically load device lists from the Keil packs, so you will be able to target any device supported by the Keil environment even if it's not directly supported by VisualGDB:[img =886,693]https://visualgdb.com/w/wp-content/uploads/2015/05/04-device.png[/img]
- Projects created using the Keil toolchain always start empty, so simply press “Next” on the Sample Selection page:
- Finally select the debug method for your device and press “Finish” to create the project:
- VisualGDB will create an empty project with no source files that will target the selected device: [ font=inherit]
- If you are using the Custom edition of VisualGDB or higher, right-click on the project in Solution Explorer, click “VisualGDB Project Properties” and go to the “Keil Components” page. Ensure that the “Automatically manage RTE_Components” flag is set:For lower editions of VisualGDB, use the regular Add-> Existing Item menu to manually adds sources and headers to the project.
- Check the “Device->Startup” and “Device->STM32Cube HAL->GPIO” components. VisualGDB will automatically detect their dependencies and suggest adding them as well:
- Click “OK” to proceed. VisualGDB will show a list of file templates offered by the selected components. Check the “main module for STM32Cube HAL” template and click “OK”:
- VisualGDB will automatically add files from the selected components (including a copy of the main.c file) to your project, allowing you to build it:
- Open the regular VS Project Properties. Note that the properties reflect the Keil-specific flags (eg allowing you to use scatter files instead of linker scripts):
- Open the Keil Components page of VisualGDB Project Properties again, pick your development board from the list and check the “LED” component:
- Include the com/w/wp-content/uploads/2015/05/empty.png[/img][/url]
- If you are using the Custom edition of VisualGDB or higher, right- click on the project in Solution Explorer, click “VisualGDB Project Properties” and go to the “Keil Components” page. Ensure that the “Automatically manage RTE_Components” flag is set:[font =inherit]For lower editions of VisualGDB, use the regular Add->Existing Item menu to manually adds sources and headers to the project.
- Check the “Device->Startup” and “Device->STM32Cube HAL->GPIO” components. VisualGDB will automatically detect their dependencies and suggest adding them as well:
- Click “OK” to proceed. VisualGDB will show a list of file templates offered by the selected components. Check the “main module for STM32Cube HAL” template and click "OK":
- VisualGDB will automatically add files from the selected components (including a copy of the main.c file) to your project, allowing you to build it:
- Open the regular VS Project Properties. Note that the properties reflect the Keil-specific flags (eg allowing you to use scatter files instead of linker scripts):
- Open the Keil Components page of VisualGDB Project Properties again, pick your development board from the list and check the “LED” component:
- Include the com/w/wp-content/uploads/2015/05/empty.png[/img][/url]
- If you are using the Custom edition of VisualGDB or higher, right- click on the project in Solution Explorer, click “VisualGDB Project Properties” and go to the “Keil Components” page. Ensure that the “Automatically manage RTE_Components” flag is set:[font =inherit]For lower editions of VisualGDB, use the regular Add->Existing Item menu to manually adds sources and headers to the project.
- Check the “Device->Startup” and “Device->STM32Cube HAL->GPIO” components. VisualGDB will automatically detect their dependencies and suggest adding them as well:
- Click “OK” to proceed. VisualGDB will show a list of file templates offered by the selected components. Check the “main module for STM32Cube HAL” template and click "OK":
- VisualGDB will automatically add files from the selected components (including a copy of the main.c file) to your project, allowing you to build it:
- Open the regular VS Project Properties. Note that the properties reflect the Keil-specific flags (eg allowing you to use scatter files instead of linker scripts):
- Open the Keil Components page of VisualGDB Project Properties again, pick your development board from the list and check the “LED” component:
- Include the //visualgdb.com/w/wp-content/uploads/2015/05/07-packs.png[/img][/url]For lower editions of VisualGDB, use the regular [b ]Add->Existing Item menu to manually adds sources and headers to the project.
- Check the “Device->Startup” and “Device->STM32Cube HAL->GPIO” components. VisualGDB will automatically detect their dependencies and suggest adding them as well:
- Click “OK” to proceed. VisualGDB will show a list of file templates offered by the selected components. Check the “main module for STM32Cube HAL” template and click “OK”:
- VisualGDB will automatically add files from the selected components (including a copy of the main.c file) to your project, allowing you to build it:
- Open the regular VS Project Properties. Note that the properties reflect the Keil-specific flags (eg allowing you to use scatter files instead of linker scripts):
- Open the Keil Components page of VisualGDB Project Properties again, pick your development board from the list and check the “LED” component:
- Include the //visualgdb.com/w/wp-content/uploads/2015/05/07-packs.png[/img][/url]For lower editions of VisualGDB, use the regular [b ]Add->Existing Item menu to manually adds sources and headers to the project.
- Check the “Device->Startup” and “Device->STM32Cube HAL->GPIO” components. VisualGDB will automatically detect their dependencies and suggest adding them as well:
- Click “OK” to proceed. VisualGDB will show a list of file templates offered by the selected components. Check the “main module for STM32Cube HAL” template and click “OK”:
- VisualGDB will automatically add files from the selected components (including a copy of the main.c file) to your project, allowing you to build it:
- Open the regular VS Project Properties. Note that the properties reflect the Keil-specific flags (eg allowing you to use scatter files instead of linker scripts):
- Open the Keil Components page of VisualGDB Project Properties again, pick your development board from the list and check the “LED” component:
- Include the png][/url] [* ]VisualGDB will automatically add files from the selected components (including a copy of the main.c file) to your project, allowing you to build it:[url =https://visualgdb.com/w/wp-content/uploads/2015/05/10-build.png][/url]
- Open the regular VS Project Properties. Note that the properties reflect the Keil-specific flags (eg allowing you to use scatter files instead of linker scripts):[/ font]
- Open the Keil Components page of VisualGDB Project Properties again, pick your development board from the list and check the “LED” component:
- Include the png][/url]
[* ]VisualGDB will automatically add files from the selected components (including a copy of the main.c file) to your project, allowing you to build it:[url =https://visualgdb.com/w/wp-content/uploads/2015/05/10-build.png][/url] - Open the regular VS Project Properties. Note that the properties reflect the Keil-specific flags (eg allowing you to use scatter files instead of linker scripts):[/ font]
- Open the Keil Components page of VisualGDB Project Properties again, pick your development board from the list and check the “LED” component:
- Include the file from your main file and add the following code to the end of main():
1 [color=rgb(49, 124, 197) !important]2[/font ] 3 [color=rgb(49, 124, 197) !important]4 5 [color=rgb(49, 124, 197) !important]6 7 [color=rgb( 49, 124, 197) !important]8 | [color=rgb(0, 0, 0) ][color=rgb(0, 78, 208) !important]LED_Initialize[color=rgb(51, 51, 51) !important][font =inherit]([color=rgb(51, 51, 51) !important])[color=rgb(51, 51, 51) !important]; [ font=inherit][color=rgb(128, 0, 128) !important]for[color=rgb(0, 111, 224) !important] [color=rgb(51, 51, 51) !important]([color=rgb(51, 51, 51) !important ];[color=rgb(51, 51, 51) !important];[color=rgb(51, 51, 51) !important]) [ font=inherit][color=rgb(51, 51, 51) !important]{ [color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]LED_On[color=rgb (51, 51, 51) !important]([color=rgb(206, 0, 0) !important]0[color=rgb(51, 51, 51) !important])[color=rgb( 51, 51, 51) !important]; [color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]HAL_Delay[color=rgb(51, 51, 51) !important ]([color=rgb(206, 0, 0) !important]100[color=rgb(51, 51, 51) !important])[color=rgb( 51, 51, 51) !important]; [color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]LED_Off[color=rgb(51, 51, 51) !important ]([color=rgb(206, 0, 0) !important]0[color=rgb(51, 51, 51) !important])[color=rgb( 51, 51, 51) !important]; [color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]HAL_Delay[color=rgb(51, 51, 51) !important]([color=rgb(206, 0, 0) !important]100[color=rgb(51 , 51, 51) !important])[color=rgb(51, 51, 51) !important]; [color=rgb(51, 51, 51) !important]} [ /td][/tr] | Also add a basic SysTick_handler implementation: 1 [color=rgb(49, 124, 197) !important]2 3 [color= rgb(49, 124, 197) !important]4 | [color=rgb(128, 0, 128) !important]void[color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]SysTick_Handler[color=rgb(51 , 51, 51) !important]([color=rgb(128, 0, 128) !important]void [color=rgb(51, 51, 51) !important]) [color=rgb(51, 51, 51) !important ]{ [color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]HAL_IncTick[color =rgb(51, 51, 51) !important]([color=rgb(51, 51, 51) !important]) [color=rgb(51, 51, 51) !important]; [color=rgb(51, 51, 51) !important]} | - Press F5 to begin debugging. Once the on-board LED starts blinking, set a breakpoint in the main loop and wait for it to trigger:
- Note that VisualGDB will automatically load the memory layout and the hardware register definitions from the Keil packs, so you won't need to specify them manually:
"] 1 [color =rgb(49, 124, 197) !important]2 3 [ align=center][color=rgb(49, 124, 197) !important]4 | [color =rgb(0, 0, 0)][color=rgb(128, 0, 128) !important]void[color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]SysTick_Handler[color=rgb (51, 51, 51) !important]([color=rgb(128, 0, 128) !important]void[/ color][color=rgb(51, 51, 51) !important]) [color=rgb(51, 51, 51) !important]{ [color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]HAL_IncTick[color=rgb(51, 51, 51) !important]([color=rgb(51, 51, 51) ! important])[color=rgb(51, 51, 51) !important]; [font =inherit][color=rgb(51, 51, 51) !important]} | [ *]Press F5 to begin debugging. Once the on-board LED starts blinking, set a breakpoint in the main loop and wait for it to trigger: [url =https://visualgdb.com/w/wp-content/uploads/2015/05/13-blink.png][/url] Note that VisualGDB will automatically load the memory layout and the hardware register definitions from the Keil packs, so you won 't need to specify them manually: [img =1353,863]https://visualgdb.com/w/wp-content/uploads/2015/05/14-regs.png[/img] "] 1 [color =rgb(49, 124, 197) !important]2 3 [ align=center][color=rgb(49, 124, 197) !important]4 | [color =rgb(0, 0, 0)][color=rgb(128, 0, 128) !important]void[color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]SysTick_Handler[color=rgb (51, 51, 51) !important]([color=rgb(128, 0, 128) !important]void[/ color][color=rgb(51, 51, 51) !important]) [color=rgb(51, 51, 51) !important]{ [color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]HAL_IncTick[color=rgb(51, 51, 51) !important]([color=rgb(51, 51, 51) ! important])[color=rgb(51, 51, 51) !important]; [font =inherit][color=rgb(51, 51, 51) !important]} | [ *]Press F5 to begin debugging. Once the on-board LED starts blinking, set a breakpoint in the main loop and wait for it to trigger: [url =https://visualgdb.com/w/wp-content/uploads/2015/05/13-blink.png][/url] Note that VisualGDB will automatically load the memory layout and the hardware register definitions from the Keil packs, so you won 't need to specify them manually: [img =1353,863]https://visualgdb.com/w/wp-content/uploads/2015/05/14-regs.png[/img] important]{ [color=rgb(0, 111, 224) !important] [/ color][color=rgb(0, 78, 208) !important]HAL_IncTick[color=rgb(51, 51, 51) !important]( [color=rgb(51, 51, 51) !important])[color=rgb(51, 51, 51) !important] ; [color=rgb(51, 51, 51) !important]} [/td][/tr] [/table] [ *]Press F5 to begin debugging. Once the on-board LED starts blinking, set a breakpoint in the main loop and wait for it to trigger: [url =https://visualgdb.com/w/wp-content/uploads/2015/05/13-blink.png][/url] Note that VisualGDB will automatically load the memory layout and the hardware register definitions from the Keil packs, so you won 't need to specify them manually: [img =1353,863]https://visualgdb.com/w/wp-content/uploads/2015/05/14-regs.png[/img] important]{ [color=rgb(0, 111, 224) !important] [/ color][color=rgb(0, 78, 208) !important]HAL_IncTick[color=rgb(51, 51, 51) !important]( [color=rgb(51, 51, 51) !important])[color=rgb(51, 51, 51) !important] ; [color=rgb(51, 51, 51) !important]} [/td][/tr] [/table] [ *]Press F5 to begin debugging. Once the on-board LED starts blinking, set a breakpoint in the main loop and wait for it to trigger: [url =https://visualgdb.com/w/wp-content/uploads/2015/05/13-blink.png][/url] Note that VisualGDB will automatically load the memory layout and the hardware register definitions from the Keil packs, so you won 't need to specify them manually: [img =1353,863]https://visualgdb.com/w/wp-content/uploads/2015/05/14-regs.png[/img]
|