Skip to content

Instantly share code, notes, and snippets.

@nobonobo
Last active June 11, 2021 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nobonobo/b695b84c0e2b153bd5a216bd940a7780 to your computer and use it in GitHub Desktop.
Save nobonobo/b695b84c0e2b153bd5a216bd940a7780 to your computer and use it in GitHub Desktop.
TinyGoでシリアル経由の書き込みをadafruit-nrfutil経由で行う方法

「tinygo ... -target config.json ...」という様にターゲット名の代わりにconfig.jsonというカスタム設定を渡すことで、 adafruit-nrfutilを使った書き込みを実行できる様にする。 inheritsには元のターゲット名を書く。

DFUモードにする方法を物理的に確保できないターゲットだったので、リセットして5秒間DFUモードになる様調整したブートローダーを使っている。

書き込み開始前にresetを押す様に促すメッセージが出る。「ー>ターゲットリセットして5秒間DFUモード」のうちに書き込み開始になって書き込めるという算段。

{
"inherits": ["pca10040-s132v6"],
"flash-method": "command",
"flash-command": "echo '** push reset! **'; sleep 2;adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application {hex} --application-version 1 /tmp/tinygo_$$.zip && adafruit-nrfutil dfu serial -t 1200 -pkg /tmp/tinygo_$$.zip -p {port} -b 115200 && rm -f /tmp/tinygo_$$.zip"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment