什么是Zephyr?
zephyr操作系统是一个用于资源受限和嵌入式系统的小型内核(出自名门),针对的应用场景,从简单的嵌入式环境传感器和可穿戴设备到复杂的嵌入式控制器、智能手表和物联网无线应用程序。
Zephyr内核支持多种体系结构,包括ARM Cortex-M, Intel x86, ARC, NIOS II, Tensilica Xtensa and RISC-V 32.。
此外个人觉得zephyr的ble statck被广大芯片厂商所认可,目前主流蓝牙芯片一般都已经支持了。
zephyr的ble stack 包含如下 ble central ble peripheral ble hid等等,此外zephyr的ble mesh 也被大家所认可。
https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/bluetooth
- samples/bluetooth/beacon
- samples/bluetooth/broadcaster
- samples/bluetooth/central
- samples/bluetooth/central_hr
- samples/bluetooth/central_ht
- samples/bluetooth/central_multilink
- samples/bluetooth/eddystone
- samples/bluetooth/observer
- samples/bluetooth/peripheral
- samples/bluetooth/peripheral_csc
- samples/bluetooth/peripheral_dis
- samples/bluetooth/peripheral_esp
- samples/bluetooth/peripheral_hids
- samples/bluetooth/peripheral_hr
- samples/bluetooth/peripheral_ht
- samples/bluetooth/peripheral_identity
- samples/bluetooth/peripheral_ots
- samples/bluetooth/peripheral_sc_only
- samples/bluetooth/scan_adv
TLSR9系列在单芯片上支持包括蓝牙5.2在内的最领先的物联网标准和行业联盟规范,包括基本速率(BR),增强速率(EDR),低功耗(LE),长距离(Long Range),多天线室内定位(AoA/AoD)和Bluetooth^®^ Mesh,Zigbee 3.0,HomeKit,6LoWPAN,Thread和2.4 GHz专有协议。TLSR9标配256KB SRAM和1 MB~2MB Flash,并将高质量无线音频和可穿戴产品所需的特性和功能整合到单个SoC中,高配版本将包含更多的硬件资源用于对这些产品的支持。
大家可以在Zephyr支持的设备中发现TLSR9系列:
1. 代码获取
git clone https://github.com/zephyrproject-rtos/zephyr.git
2下载交叉编译工具链:
http://wiki.telink-semi.cn/tools_and_sdk/Tools/IDE/telink_riscv_linux_toolchain.zip
配置环境变量:
export PATH=$PATH:~/toolchains/nds32le-elf-mculib-v5f/bin/
配置完在中断输出riscv32-elf看看有没有相关gcc之类的提示,有的话说明工作正常。
- 修改 dts配置clock
boards/riscv/tlsr9518adk80d/tlsr9518adk80d.dts
&cpu0 {
clock-frequency = <48000000>;
};
为什么是48M呢,因为外部晶体是24M 经过PLL倍频后是48Mhz
4.编译
west build -b tlsr9518adk80d samples/hello_world
5.接线如图
6.全部命令如下:
sudo apt update
sudo apt upgrade
sudo apt install --no-install-recommends git cmake ninja-build gperf ccache dfu-util device-tree-compiler wget python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev
pip3 install --user -U west
echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
source ~/.bashrc
west init ~/zephyrproject
cd ~/zephyrproject
west update
pip3 install --user -r ~/zephyrproject/zephyr/scripts/requirements.txt
wget https:
chmod +x zephyr-sdk-0.13.1-linux-x86_64-setup.run
./zephyr-sdk-0.13.1-linux-x86_64-setup.run -- -d ~/zephyr-sdk-0.13.1
sudo cp ~/zephyr-sdk-0.13.1/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
sudo udevadm control --reload
west build -b tlsr9518adk80d samples/hello_world