LoginSignup
2
2

More than 1 year has passed since last update.

DAPLinkをGCCでお手軽にビルドする

Last updated at Posted at 2021-06-07

Mbed OS対応デバイスやmicro:bit等でターゲットマイコンに書き込むための仕組みとして、DAPLinkが使われています。

DAPLinkは、インターフェスとして使用するArmマイコン上で動作し、オープンソースプロジェクトして公開されていますが、ビルドツールとしては有償ライセンスが必要なKeil MDKが必要でした。

最近、DAPLinkのGitHubリポジトリに作成されたexperimental_compilersブランチを使用することでGCCでビルドが可能になりましたので、試してみました。

Experimental branch for GCC build

https://github.com/ARMmbed/DAPLink/tree/experimental_compilers

この記事ではLPC1114FN28用のDAPLinkをビルドする手順を紹介します。

ビルド手順

ビルドツール

  • ホストOS macOS Big Sur 11.4
  • cmake 3.20.3
  • ninja 1.10.2
  • python 3.9.5
  • arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]

venvのインストールと起動

$ python3 -m venv .venv3
$ source .venv3/bin/activate

DAPLinkのビルド

# リポジトリのクローン
$ git clone -b experimental_compilers https://github.com/ARMmbed/DAPLink daplink-gcc
$ cd daplink-gcc

# 必要なモジュールのインストール
$ pip3 install -r requirements.txt

# ビルド
$ python3 tools/progen_compile.py -t make_gcc_arm lpc11u35_ssci1114_if

ビルド時のログの例

(.venv3) 22:37@daplink-gcc > python3 tools/progen_compile.py -t make_gcc_arm lpc11u35_ssci1114_if
Preprocessing ../../../source/hic_hal/nxp/lpc11u35/gcc/lpc11u35.ld
Compiling ../../../source/board/ssci1114.c
Compiling ../../../source/daplink/HardFault_Handler.c
Compiling ../../../source/daplink/circ_buf.c
Compiling ../../../source/daplink/cmsis-dap/DAP.c
Compiling ../../../source/daplink/cmsis-dap/DAP_queue.c

(中略)

Compiling ../../../source/usb/winusb/usbd_core_winusb.c
Assembling ../../../source/hic_hal/nxp/lpc11u35/gcc/startup_LPC11Uxx.S
Assembling ../../../source/rtos2/RTX/Source/GCC/irq_cm0.S
Linking build/lpc11u35_ssci1114_if.elf
Memory region         Used Size  Region Size  %age Used
    m_interrupts:          1 KB         1 KB    100.00%
          m_text:       53336 B        59 KB     88.28%
        m_cfgrom:           9 B         4 KB      0.22%
          m_data:        7856 B       7904 B     99.39%
        m_cfgram:         142 B        256 B     55.47%
        m_data_2:          2 KB         2 KB    100.00%
       m_usb_ram:          40 B         2 KB      1.95%
   text    data     bss     dec     hex filename
  54352    1308    8791   64451    fbc3 build/lpc11u35_ssci1114_if.elf
  54352    1308    8791   64451    fbc3 (TOTALS)
Converting build/lpc11u35_ssci1114_if.hex
Converting build/lpc11u35_ssci1114_if.bin
build/lpc11u35_ssci1114_if_crc
board_id None
family_id None
bin_offset None
Start 0x0, Length 0xd96c, CRC32 0x63d8970e

ビルドしたバイナリの確認

$ ls projectfiles/make_gcc_arm/lpc11u35_ssci1114_if/build/*.bin
projectfiles/make_gcc_arm/lpc11u35_ssci1114_if/build/lpc11u35_ssci1114_if.bin
projectfiles/make_gcc_arm/lpc11u35_ssci1114_if/build/lpc11u35_ssci1114_if_crc.bin

lpc11u35_ssci1114_if_crc.binがチェックサム付きのバイナリなので、それをインターフェスチップに書き込みます。書き込み方法は、以下を参考にしてください。

https://os.mbed.com/teams/Switch-Science/wiki/Firmware-LPC1114FN28

DAPLinkの今後

公式リポジトリのDiscussionsThe road to DAPLink 0256 (and beyond)という記事が公開されています。
https://github.com/ARMmbed/DAPLink/discussions/819

今後の予定などが記載されているので、興味のある方はご覧ください。

以上です。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2