## Installation ### Set up west This shouldn't need to be re-done. These files are committed ```bash west init -l mellifera_firmware ``` ### Set up Build Environment ```bash pipenv sync pipenv shell west update west zephyr-export west packages pip --install west sdk install ``` ### NRFUtil (Nordic Semiconductor) This is required for flashing Nordic Semiconductor devices This is installed globally, not in the environment ```bash # dependencies first sudo apt install -y libusb-1.0-0 wget https://github.com/NordicSemiconductor/nrf-udev/releases/download/v1.0.1/nrf-udev_1.0.1-all.deb sudo dpkg -i nrf-udev_1.0.1-all.deb curl https://files.nordicsemi.com/artifactory/swtools/external/nrfutil/executables/x86_64-unknown-linux-gnu/nrfutil -o nrfutil chmod +x nrfutil sudo mv nrfutil /usr/bin/nrfutil # I should probably change ownership too... but I'm the only user on this machine so I don't care nrfutil self-upgrade nrfutil install device ``` ## Building ```bash west build -p auto -b nrf52dk/nrf52832 firmware/blinky west build -p auto -b nrf52dk/nrf52832 firmware/app west build -p auto -b mellifera_rev1 firmware/blinky west build -p auto -b mellifera_rev1 firmware/app west flash ``` # Zephyr Example Application ## Getting Started ### Initialization The first step is to initialize the workspace folder (``my-workspace``) where the ``example-application`` and all Zephyr modules will be cloned. Run the following command: ```shell # initialize my-workspace for the example-application (main branch) west init -m https://github.com/zephyrproject-rtos/example-application --mr main my-workspace # update Zephyr modules cd my-workspace west update ``` ### Building and running To build the application, run the following command: ```shell cd mellifera_firmware west build -b mellifera_rev1 app ``` Once you have built the application, run the following command to flash it: ```shell west flash ``` ```shell go install github.com/apache/mynewt-mcumgr-cli/mcumgr@latest ``` ### Bootloader ```shell # build and flash the bootloader west build -p -b mellifera_rev1 ../mcuboot/boot/zephyr/ -- -DCONF_FILE=$(pwd)/boot.conf west flash # define serial connection to device ~/go/bin/mcumgr conn add acm0 type="serial" connstring="dev=/dev/ttyACM0,baud=115200,mtu=512" ~/go/bin/mcumgr conn add ttyusb0 type="serial" connstring="dev=/dev/ttyUSB0,baud=115200,mtu=512" # hold button while power cycling to enter bootloading mode ~/go/bin/mcumgr -c ttyusb0 image list # build the app west build -p -b mellifera_rev1 app ~/go/bin/mcumgr -c ttyusb0 image upload -e build/zephyr/zephyr.signed.bin ~/go/bin/mcumgr -c ttyusb0 image list ``` ### Testing To execute Twister integration tests, run the following command: ```shell west twister -T tests --integration ``` ### Documentation A minimal documentation setup is provided for Doxygen and Sphinx. To build the documentation first change to the ``doc`` folder: ```shell cd doc ``` Before continueing, check if you have Doxygen installed. It is recommended to use the same Doxygen version used in [CI](.github/workflows/docs.yml). To install Sphinx, make sure you have a Python installation in place and run: ```shell pip install -r requirements.txt ``` API documentation (Doxygen) can be built using the following command: ```shell doxygen ``` The output will be stored in the ``_build_doxygen`` folder. Similarly, the Sphinx documentation (HTML) can be built using the following command: ```shell make html ``` The output will be stored in the ``_build_sphinx`` folder. You may check for other output formats other than HTML by running ``make help``. ## Resources This was a useful tutorial for getting a bunch of bluetooth stuff working: - https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-4-bluetooth-le-data-exchange/topic/blefund-lesson-4-exercise-1/ - Source code: https://github.com/NordicDeveloperAcademy/bt-fund/blob/main/l4/l4_e1_sol/src/my_lbs.h