Zephyr를 사용해보십시오 (microbit에서 hello world 빌드, VS Code에서 디버깅까지)

8823 단어 ZephyrmicrobitVSCode

해보는 것



Zephyr(wikipedia) 샘플 프로그램 (Hello world)을 micro:bit 용으로 빌드하십시오.
동작, VS 코드 디버깅 방법을 씁니다.

Zephyr이란?



공식 사이트는 여기

The Zephyr™ Project is a scalable real-time operating system (RTOS) supporting multiple hardware architectures, optimized for resource constrained devices, and built with safety and security in mind.

그렇습니다. 지원되는 보드 정보는 여기(※)
링크를 보면 micro:bit을 지원하는 곳이 마음에 들었습니다

※ 현재 (2019/12/08 현재) 최신 버전은 "v: 2.1.0-rc3"과 같습니다.

환경 구축부터 Hello world 빌드까지



Getting Started Guide에 설명 된대로
환경은 완성됩니다.

Hello world를 micro:bit용으로 빌드하는 것은 아래와 같이 "-b"옵션에 "bbc_microbit"을 붙인다.
$ west build -b bbc_microbit samples/hello_world/

micro : bit에 쓰는 것은
$ west flash

gtkterm 등을 연결하면 다음과 같이 Hello world가 표시됩니다.



디버깅



디버거의 기동도 간단하고 이하의 커멘드를 실행으로 GDB가 기동합니다.
$ west debug
-- west debug: rebuilding
ninja: no work to do.
-- west debug: using runner pyocd
-- runners.pyocd: pyOCD GDB server running on port 3333
GNU gdb (crosstool-NG 1.24.0-rc2-dirty) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=arm-zephyr-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/USERNAME/zephyrproject/zephyr/build/zephyr/zephyr.elf...done.
0000894:INFO:board:Target type is nrf51
0001154:INFO:dap:DP IDR = 0x0bb11477 (v1 MINDP rev0)
0001223:INFO:ap:AP#0 IDR = 0x04770021 (AHB-AP var2 rev0)
0001350:INFO:rom_table:AP#0 ROM table #0 @ 0xf0000000 (designer=244 part=001)
0001417:INFO:rom_table:[0]<e00ff000:ROM class=1 designer=43b part=471>
0001417:INFO:rom_table:  AP#0 ROM table #1 @ 0xe00ff000 (designer=43b part=471)
0001463:INFO:rom_table:  [0]<e000e000:SCS-M0+ class=14 designer=43b part=008>
0001473:INFO:rom_table:  [1]<e0001000:DWT-M0+ class=14 designer=43b part=00a>
0001485:INFO:rom_table:  [2]<e0002000:BPU class=14 designer=43b part=00b>
0001498:INFO:rom_table:[1]<f0002000:??? class=9 designer=43b part=9a3 devtype=13 archid=0000 devid=0:0:0>
0001508:INFO:cortex_m:CPU core #0 is Cortex-M0 r0p0
0001520:INFO:dwt:2 hardware watchpoints
0001534:INFO:fpb:4 hardware breakpoints, 0 literal comparators
0001553:INFO:server:Semihost server started on port 4444
0001555:INFO:gdbserver:GDB server started on port 3333
Remote debugging using :3333
0002388:INFO:gdbserver:One client connected!
arch_cpu_idle () at /home/USERNAME/zephyrproject/zephyr/arch/arm/core/cpu_idle.S:78
78      bx lr
0002650:INFO:gdbserver:Attempting to load Argon
0002651:INFO:gdbserver:Attempting to load FreeRTOS
0002652:INFO:gdbserver:Attempting to load Zephyr
0002654:INFO:gdbserver:Attempting to load RTX5
Loading section text, size 0xa8 lma 0x0
Loading section _TEXT_SECTION_NAME_2, size 0x3046 lma 0xa8
Loading section .ARM.exidx, size 0x8 lma 0x30f0
Loading section sw_isr_table, size 0xd0 lma 0x30f8
Loading section devconfig, size 0x78 lma 0x31c8
Loading section rodata, size 0x13c lma 0x3240
Loading section datas, size 0x30 lma 0x337c
Loading section initlevel, size 0x78 lma 0x33ac
Loading section _k_mutex_area, size 0x14 lma 0x3424
[====================] 100%
0004551:INFO:loader:Erased 0 bytes (0 sectors), programmed 0 bytes (0 pages), skipped 14336 bytes (14 pages) at 7.92 kB/s
Start address 0xc0c, load size 13366
Transfer rate: 7 KB/sec, 891 bytes/write.
(gdb) 

VS Code로 디버깅



west debug에서 GDB가 시작되지만 VS Code를 사용하고 싶습니다

VS Code 준비



launch.json에서 다음을 수행합니다.
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 起動",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/USERNAME/zephyrproject/zephyr/build/zephyr/zephyr.elf",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/home/USERNAME/zephyr-sdk-0.10.3/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb",
            "miDebuggerArgs": "/home/USERNAME/zephyrproject/zephyr/build/zephyr/zephyr.elf -ex 'target remote :3333' -ex 'monitor halt' -ex 'monitor reset' -ex load",
        }
    ]
}

pyocd-gdbserver 시작



pyocd-gdbserver를 아래 옵션으로 시작합니다.
$ pyocd-gdbserver -p 3333 -T 4444 -t nrf51

VS Code로 디버깅 시작



디버깅을 시작하면 main 함수에서 중지됩니다.

좋은 웹페이지 즐겨찾기