Here is an extended hello world project for the SAML21G18B Cortex-M0+ controller by Atmel with full integration in VS Code like build, clean and program tasks are setup and debugging is configured without the need of an extension. You only need a Windows 10 with WSL enabled as the makefile was intentionally created for unix like systems and has now been ported to Windows/WSL.
- Make the project via
make all - Start openocd via
make server_startin a second shell or background however - Hook up a serial terminal and connect to processor
- Flash the program via
make program - Type in
led onandled offto toggle the userled on the sammyl21 board - Stop openocd via
make server_stop
- open makefile and change the path variables according to your installation
# ARM GCC installation path
ARM_GCC_PATH := /mnt/d/arm-dev/gcc-arm-none-eabi-8-2019-q3-update
# OpenOCD installation path
OPENOCD_PATH := /mnt/d/arm-dev/OpenOCD-20190715-0.10.0
# ASF installation path
ASF_PATH := /mnt/d/arm-dev/xdk-asf-3.45.0- make sure you are in the projects directory with the current shell
$ cd [path to project]- Link project to the ASF
$ make links- In file xdk-asf/system_saml1.c add the weak attribute to the functions
SystemInitandSystemCoreClockUpdate
void __attribute__((weak)) SystemInit(void){...}
void __attribute__((weak)) SystemCoreClockUpdate(void){...}Adding this attribute to the functions let's us override them somewhere else without causing the gcc to raise a multiple definition of 'function' error.
- build it
$ make allDon't forget to multithread this with the argument -j [Number of concurrent jobs]
$ make -j 4 all- make sure you are in the projects directory
$ cd [path to project]- Configure your debugging hardware in the
openocd.cfgfile. The one I used is the ARM-USB-OCD-H with the SWD adapter by Olimex.
# 1. Setup your debugger
source [find interface/ftdi/olimex-arm-usb-ocd-h.cfg]
# 2. and the SWD adapter if needed
source [find interface/ftdi/olimex-arm-jtag-swd.cfg]- start openocd server Either manually in a seperate shell (makes sense if the debugging/flashing fails)
$ openocdor in the same shell but started in the background
$ make server_startTo kill it if run in the background run
$ make server_stop- run debug command (this automatically flashes the target but leaves open the gdb console)
$ make debugor only for programming the target
$ make programScan through the file .vscode/c_cpp_properties.json and change all paths to your installation.
In case you are using a different gcc version you can get the default includes by running
echo | [full path to your gcc]/bin/arm-none-eabi-gcc -Wp,-v -x c++ - -fsyntax-onlyScan through the file .vscode/launch.json and configure all paths to your installation
- In the makefile you have to change the make links target in such a way that the files for your processor are linked.
- In openocd.cfg you have to setup your processor and your debugger