Skip to content

Instantly share code, notes, and snippets.

@ysyyork
Last active July 12, 2023 11:45
Show Gist options
  • Save ysyyork/dffcb9699763719eac6fed80fa7f0012 to your computer and use it in GitHub Desktop.
Save ysyyork/dffcb9699763719eac6fed80fa7f0012 to your computer and use it in GitHub Desktop.
zephyr nrf5340 zephyr test
# 1. Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile
# 2. Install pyenv
brew install pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.profile
# 3. Install pyenv-virtualenv
brew install pyenv-virtualenv
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.profile
# 4. Install python 3.9.10
pyenv install 3.9.10
## create a new virtual env for 3.9.10 for zephyr test
pyenv virtualenv 3.9.10 3.9.10-zephyr
# 5. Install zephyr project
brew install cmake ninja gperf python3 ccache qemu dtc wget libmagic
mkdir ~/zephyrproject
cd ~/zephyrproject
echo 3.9.10-zephyr >> .python-version
pip install west
west init -m https://github.com/zephyrproject-rtos/zephyr
west update
west zephyr-export
pip install -r ~/zephyrproject/zephyr/scripts/requirements.txt
# 6. Install zephyr SDK
cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.1/zephyr-sdk-0.16.1_macos-x86_64.tar.xz
wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.1/sha256.sum | shasum --check --ignore-missing
tar xvf zephyr-sdk-0.16.1_macos-x86_64.tar.xz
cd zephyr-sdk-0.16.1
./setup.sh
# 7. Install nrf commandline tool for mac
# Download the mac dmg file on this link: https://www.nordicsemi.com/Products/Development-tools/nRF-Command-Line-Tools/Download?lang=en#infotabs
# Install both tools when you open it.
# 8. Build a simple bluetooth application for nrf5340. Connect your nrf5340 board to your mac now
cd ~/zephyrproject/zephyr
## build and flash the netcore hci rpmsg program
west build -p always -b nrf5340dk_nrf5340_cpunet samples/bluetooth/hci_rpmsg
west flash
## build and flash the appcore bluetooth periphral program
west build -p always -b nrf5340dk_nrf5340_cpuapp samples/bluetooth/peripheral
west flash
# 9. To test if it's working, on your phone, search for nRF Toolbox. install that app. Open it, press Heart Rate tab. then Press Connect. You should see a device called "Zephyr Peripheral Sample Long". Tap it and you can connect.
# 10. To run HID example
# Add this line "CONFIG_SAMPLE_BT_USE_AUTHENTICATION=n" to the prj.conf file under samples/bluetooth/peripheral_hids. Then build and flash to cpuapp core
west build -p always -b nrf5340dk_nrf5340_cpuapp samples/bluetooth/peripheral_hids
west flash
# Please note, you need to have the hci_rpmsg flashed to the cpunet core first as stated in 8. Then you should be able to search for this device in your laptop bluetooth panel. Once connected, you can click button 1 on board to
# simulate mouse left click. Since it's a sample, it only has that one button functional.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment