Now, we need to setup our new project with the J-Link, and turn on GDB.
Be sure to connect your J-Link to your computer. AS7 requires it to be connected, so that the backagent can query its information.
If the Project Properties window it isn't already open, click on the Project->[Project Name] Properties menu or press Alt+F7.
First, we'll setup the J-Link programmer settings.
- Select the J-Link you wish to use in the "Selected debugger/programmer" dropdown list. The "Interface" dropdown will automatically populate with "SWD", since it's the only available option for J-Link. A button to open the J-Link Control Panel will also appear.
- The SWD Clock setting will be set to the default. I have found no need to change this.
- In the "Programming Settings" section lies a very, very important setting. You will notice a dropdown list that most likely says "Erase entire chip". If you were programming/debugging firmware that contained its own bootloader, you could leave this. However, CircuitPython's firmware and bootloader are separate, and this setting can cause you much headache. So, change this to "Erase only program area".
When configured, your properties window should look like this:
Now we'll set up GDB.
All you need to do is make sure the "Use GDB" checkbox is checked. I didn't change any of the GDB Settings, but feel free to explore.
Now save the project. This is another good time to repeat this adage: save often!
The above steps only need to be done once if you continue to use the same project file. I will suggest that you use a different project file for each board you debug, even though you could probably re-map the object files. This project file will still be usable if you make a change to the firmware and re-compile, as explained in the Using New Firmware section.
This guide does not cover laying out your AS7 environment, that’s up to personal preference. I like using an environment configured with these windows: Disassembly, Breakpoints, Output, GDB Console, and Call Stack (found within Debug->Windows menu)