I'm attempting to modify the basic firmware, and I'm progressing quite well however there are a couple of sneaky scenarios which require a lower level debugging capability.
Can you please advise how you debug the firmware, on the device?
I've modified the firmware to call 'AudioMoth_setupSWOForPrint' at the end of AudioMoth_initialise() and added a couple of debug statements such as printf("Debugging enabled"); Throughout the code, being executed. These changes, along with my other alterations were then successfully flashed to the AudioMoth device.
1. PC -> USB -> AudioMoth USB plug (normal USB connection for an AudioMoth)
2. PC -> USB -> JLink Debug Probe -> SWD via Dupont Connectors -> AudioMoth Debug pads
Here's a couple of photos to highlight what I'm doing. Sure, those connections are soldered a little rough but have been verified to be fine.
As a simple dump, here's what I'm using. I'm expecting you're doing something similar when modifying the firmware.
JLinkExeSEGGER J-Link Commander V6.52c (Compiled Oct 11 2019 15:44:58)DLL version V6.52c, compiled Oct 11 2019 15:44:50....Type "connect" to establish a target connection, '?' for helpJ-Link>connectPlease specify device / core. <Default>: EFM32WG980F256Type '?' for selection dialogDevice>Please specify target interface: J) JTAG (Default) S) SWD T) cJTAGTIF>SSpecify target interface speed [kHz]. <Default>: 4000 kHzSpeed>Device "EFM32WG980F256" selected.Connecting to target via SWDFound SW-DP with ID 0x2BA01477Scanning AP map to find all available APsAP: Stopped AP scan as end of AP map has been reachedAP: AHB-AP (IDR: 0x24770011)Iterating through AP map to find AHB-AP to useAP: Core foundAP: AHB-AP ROM base: 0xE00FF000CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)Found Cortex-M4 r0p1, Little endian.FPUnit: 6 code (BP) slots and 2 literal slotsCoreSight components:ROMTbl @ E00FF000ROMTbl: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7ROMTbl: E0001000, CID: B105E00D, PID: 003BB002 DWTROMTbl: E0002000, CID: B105E00D, PID: 002BB003 FPBROMTbl: E0000000, CID: B105E00D, PID: 003BB001 ITMROMTbl: E0040000, CID: B105900D, PID: 003BB923 TPIU-LiteROMTbl: E0041000, CID: B105900D, PID: 000BB925 ETMCortex-M4 identified.J-Link>SWORead0 bytes read (0 bytes in host buffer)J-Link>SWOViewReceiving SWO data @ 4000 kHz.Data from stimulus port 0:-----------------------------------------------
Occasionally I'll get SWO output, but its all garbled and meaningless. On other hardware I would think this was a mismatch of the receiving clock (4000 kHz), but maybe I'm attacking this incorrectly.
I appreciate this is getting down into the lower levels of core programming on the device but I suspect other users may wish to also understand these debugging aspects when modifying the firmware to suit their needs also. Without a device level debugging capability the only way to check out changes is to flash the device with extra LED flashes to highlight state changes, or log to the microSD via the AudioMoth_appendFile operation.
Which SWO debug probe do you use to validate changes to the base firmware?
What code changes do you make to enable debugging?
Are there Simplicity Studio changes which you utilise to support debugging on the device?
Are you debugging the code off the device instead, on a PC using a 32-bit ARM emulator or 32-bit x86 target toolchain?
Are you implementing Unit Testing on your version of the firmware?