Programming ATSAME51J19A

Hello all,

I am trying to use the Black Magic Probe to load firmware (.hex w/ bootloader) onto an ATSAME51J19A using a SWD header on a separate PCB. I have updated my BMP firmware as well as the PIO core (I am using the VSCode extension but am totally fine using the CLI). Why won’t it recognize the ‘blackmagic’ tool despite both documentations explicitly stating there is support? Will I have to set up a custom config for the MCU since its technically not the adafruit feather w/ can?

Here is my platformio.ini file:

[env:adafruit_feather_m4_can]
platform = GitHub - platformio/platform-atmelsam: Atmel SAM: development platform for PlatformIO
board = adafruit_feather_m4_can
framework = arduino
debug_tool = blackmagic
debug_port = COM4
upload_port = COM4
upload_protocol = blackmagic

Here is my output:
Resolving adafruit_feather_m4_can dependencies…
Already up-to-date.
Updating metadata for the vscode IDE…
Error: Processing adafruit_feather_m4_can (platform: GitHub - platformio/platform-atmelsam: Atmel SAM: development platform for PlatformIO; board: adafruit_feather_m4_can; framework: arduino)

Verbose mode can be enabled via -v, --verbose option
DebugInvalidOptionsError: Unknown debug tool blackmagic. Please use one of atmel-ice, jlink or custom:
File “C:\Users\lkelley.platformio\penv\lib\site-packages\platformio\builder\main.py”, line 175:
env.SConscript(“$BUILD_SCRIPT”)
File “C:\Users\lkelley.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Script\SConscript.py”, line 598:
return _SConscript(self.fs, *files, **subst_kw)
File “C:\Users\lkelley.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Script\SConscript.py”, line 285:
exec(compile(scriptdata, scriptname, ‘exec’), call_stack[-1].globals)
File “C:\Users\lkelley.platformio\platforms\atmelsam@src-3902fa010271b7fd4b3fe129967364bc\builder\main.py”, line 127:
target_elf = env.BuildProgram()
File “C:\Users\lkelley.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py”, line 242:
return self.method(*nargs, **kwargs)
File “C:\Users\lkelley.platformio\penv\lib\site-packages\platformio\builder\tools\piobuild.py”, line 60:
env.ProcessProgramDeps()
File “C:\Users\lkelley.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py”, line 242:
return self.method(*nargs, **kwargs)
File “C:\Users\lkelley.platformio\penv\lib\site-packages\platformio\builder\tools\piobuild.py”, line 110:
env.PrintConfiguration()
File “C:\Users\lkelley.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py”, line 242:
return self.method(*nargs, **kwargs)
File “C:\Users\lkelley.platformio\penv\lib\site-packages\platformio\builder\tools\pioplatform.py”, line 233:
_get_debug_data(),
File “C:\Users\lkelley.platformio\penv\lib\site-packages\platformio\builder\tools\pioplatform.py”, line 197:
% board_config.get_debug_tool_name(env.GetProjectOption(“debug_tool”)),
File “C:\Users\lkelley.platformio\penv\lib\site-packages\platformio\platform\board.py”, line 126:
raise DebugInvalidOptionsError(
========================== [FAILED] Took 0.86 seconds ==========================

It does mention the blackmagic tool, but it still depends on the platform and board definition whether they include it. E.g., blackmagic might be supported in PlatformIO for th STM32 platform, but not for others. And even when the platform supports it, the board definition might not.

However, in the case of Atmel SAM the platform itself does have support for it.

But the adafruit_feather_m4_can.json board definition doesn’t list it as available protocol.

So, what you can do is

  1. Experimentally edit your C:\Users\<user>\.platformio\platforms\atmelsam\boards\adafruit_feather_m4_can.json file and add "blackmagic" into the protocols array
  2. File an issue at Issues · platformio/platform-atmelsam · GitHub