開發與維運

藍牙 Mesh SDK 快速上手 | 《無需從0開發 平頭哥教你1天上手藍牙Mesh應用解決方案》第二章

上一篇:藍牙 Mesh 網絡及 SDK 概述 | 《無需從0開發 平頭哥教你1天上手藍牙Mesh應用解決方案》第一章
下一篇:藍牙 Mesh 標準 Model 開發指南 | 《無需從0開發 平頭哥教你1天上手藍牙Mesh應用解決方案》第三章

點擊免費下載
《無需從0開發 平頭哥教你1天上手藍牙Mesh應用解決方案》>>>

test

1. 簡介

本文介紹如何使用CB6121 開發板進行MESH Light的功能演示。通過本文的指引,開發者可以學會開發環境的搭建、SDK 的編譯與燒錄、基本調試方法,快速上手 CB6121 的開發。

2. 開發環境搭建

2.1 準備

image.png

2.2 Linux 開發環境搭建

● Linux 環境搭建
Win10 用戶,建議前往應用商店下載安裝 Ubuntu18.04 LTS;其他用戶可自行選擇安裝 Linux 或者虛擬機。
● 工具鏈安裝

$ tar -jxvf gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2
 

● 環境變量中添加工具鏈路徑並使其立即生效,其中 toolchain_path 為工具鏈解壓的目錄

$ vi ~/.bashrc ... PATH={toolchain_path}/bin:$PATH ... $ source ~/.bashrc
 

● 驗證工具鏈是否安裝成功

$ arm-none-eabi-gcc -v ... gcc version 8.2.1 20181213 (release) [gcc-8-branch revision 267074](GNU Tools for Arm Embedded Processors 8-2018-q4-major)

● 安裝 make 工具

$ sudo apt-get install make

2.3 仿真器驅動安裝

● 雙擊 JLink_Windows_V620f.exe。
● 點擊下一步直到安裝完成。
● 打開 JLink GDB Server, 選擇 Target Device 為 Cortex-M0。

image.png

image.png

2.4. 開發板準備

CB6121開發板資源介紹
image.png

image.png

3. 編譯燒錄及調試

3.1 編譯

● 例程編譯方法
使用 build.sh 腳本編譯,命令格式為 ./build.sh < 示例目錄 >
[ 多線程數 ]

$ make clean $ ./build.sh defconfigs/defconfig_ch6121_evb_mesh_node applications/ bluetooth/mesh_light_node/ j64

● 編譯後固件位於 applications/bluetooth/meshlightnode/generated

$ ll applications/bluetooth/mesh_light_node/generated ...... -rwxrwxrwx 1 xxx xxx 652920 Mar 13 19:03 total_image.hexf* ....

● 編譯成功將輸出如下圖所示信息
image.png

● 各個示例對應配置文件說明

image.png

3.2 鏡像燒錄
● 打開燒寫工具 PhyPlusKit.exe。 ● 勾選UART Setting,選擇開發板串口,串口配置為波特率:115200,停止 位:1,校驗:NO。 ● 點擊 Connect, 連接串口。 ● 選擇 Flash_writer 標籤頁。 ● 選擇 HEX 燒入方式標籤頁。 ● 雙擊選擇applications/bluetooth/meshlightnode/generated/total_image.hexf。
● 下方選擇 Single 標籤,TYPE 選擇 MAC,VALUE 填寫 MAC 地址。 ● 將撥碼開關撥到 VDD TM 。

image.png

● 按開發板上的 RESET 按鍵,重啟開發板,串口打印 UART RX : cmd>>。 ● 點擊 Erase 擦除。 ● 點擊 Write 燒寫。
● LOG 區域顯示燒錄過程。

image.png

3.3 GDB 調試

● 打開 JLink GDB Server,連接開發板
● 編輯 Linux 環境中配置 GDB 環境變量並保存後退出 , 其中 2331 為默認端口號

$ cd applications/bluetooth/mesh_light_node $ vi .gdbinit target remote 127.0.0.1:2331

● 運行 GDB,開始調試,調試鏡像為 yoc.elf

$ arm-none-eabi-gdb yoc.elf -x .gdbinit

● 若出現無法連接或長時間無響應,請確認
工程目錄下是否存在 .gdbinit 文件
JLink GDB Server 是否成功連接開發板
.gdbinit 文件中的 IP 地址是否正確
● 常用 GDB 命令

image.png

4. 例程運行

基於 CB6121 開發板的燈控示例工程
● 連接串口調試工具 , 配置為
波特率 : 115200, 數據位 : 8, 校驗位 : None, 停止位 : 1, 流控 : None

image.png

● 開發板撥碼開關撥至 GND
● 按 RESET 按鍵,復位開發板
● MESH Light 啟動 Log 如下

[     0.004000][I][init    ]Build:Mar 24 2020,21:52:51 
[     0.017000][I][init    ]find 9 partitions 
Welcome to CLI... 
> [     0.738000][I][DEMO    ]Mesh light node demo

● 關於燈控配網請參考《藍牙 Mesh 燈控開發指南》

Leave a Reply

Your email address will not be published. Required fields are marked *