134fd36daSMatthias Ringwald# BTstack Port for STM32WB55 Nucleo Boards using FreeRTOS 20561b2d8STREFOU Felix 30561b2d8STREFOU FelixThis port supports the Nucleo68 and the USB dongle of the [P-NUCLEO-WB55 kit](https://www.st.com/en/evaluation-tools/p-nucleo-wb55.html). Both have 1 MB of Flash memory. 40561b2d8STREFOU Felix 50561b2d8STREFOU FelixThe STM32Cube_FW_WB_V1.3.0 provides the HAL and WPAN, and initializes the device and the initial Makefile. 60561b2d8STREFOU FelixFor easy development, Ozone project files are generated as well. 70561b2d8STREFOU Felix 80561b2d8STREFOU Felix## Hardware 90561b2d8STREFOU Felix 100561b2d8STREFOU FelixIn this port, the Nucelo68 or the USB Dongle from the P-NUCLEO-WB55 can be used. 110561b2d8STREFOU Felix 12*8e8577aaSMatthias RingwaldLast test was done using FUS v1.2 and HCI BLE Firmware v1.13 on Nucleo68 13*8e8577aaSMatthias RingwaldSee STM32Cube_FW_WB_V1.13.0/Projects/STM32WB_Copro_Wireless_Binaries/Release_Notes.html for firmware install instructions. 14*8e8577aaSMatthias Ringwald 15*8e8577aaSMatthias RingwaldNote: Segger RTT is currently not really usable. When sleep modes ared disabled for debuggin (see port_thread()) 16*8e8577aaSMatthias RingwaldRTT works, but the output buffer quickly overflows. In Block mode, radio stops working. 170561b2d8STREFOU Felix 180561b2d8STREFOU Felix### Nucleo68 190561b2d8STREFOU Felix 200561b2d8STREFOU FelixThe debug output is sent over USART1 and is available via the ST-Link v2. 210561b2d8STREFOU Felix 220561b2d8STREFOU Felix### USB Dongle 230561b2d8STREFOU Felix 240561b2d8STREFOU FelixTo flash the dongle, SWD can be used via the lower 6 pins on CN1: 250561b2d8STREFOU Felix - 3V3 260561b2d8STREFOU Felix - PB3 - SWO (semi hosting not used) 270561b2d8STREFOU Felix - PA14 - SCLK 280561b2d8STREFOU Felix - PA13 - SWDIO 290561b2d8STREFOU Felix - NRST 300561b2d8STREFOU Felix - GND 310561b2d8STREFOU Felix 320561b2d8STREFOU FelixThe debug output is sent over USART1 and is available via PB6. 330561b2d8STREFOU Felix 340561b2d8STREFOU Felix## Software 350561b2d8STREFOU Felix 360561b2d8STREFOU FelixFreeRTOS V10.2.0 is used to run stack, you can get this example version by checking out official repo: 370561b2d8STREFOU Felix 380561b2d8STREFOU Felix $ cd Middlewares 390561b2d8STREFOU Felix $ git submodule add https://github.com/aws/amazon-freertos.git 400561b2d8STREFOU Felix $ git submodule update 410561b2d8STREFOU Felix & cd amazon-freertos && git checkout v1.4.8 420561b2d8STREFOU Felix 430561b2d8STREFOU FelixOr by specifying path to FreeRTOS 440561b2d8STREFOU Felix 450561b2d8STREFOU Felix $ make FREERTOS_ROOT=path_to_freertos 460561b2d8STREFOU Felix 470561b2d8STREFOU FelixTo build all examples, run make 480561b2d8STREFOU Felix 490561b2d8STREFOU Felix $ make 500561b2d8STREFOU Felix 510561b2d8STREFOU FelixAll examples and the .jedbug Ozone project files are placed in the 'build' folder. 520561b2d8STREFOU Felix 530561b2d8STREFOU Felix## Flash And Run The Examples 540561b2d8STREFOU Felix 550561b2d8STREFOU FelixThe Makefile builds different versions: 560561b2d8STREFOU Felix- example.elf: .elf file with all debug information 570561b2d8STREFOU Felix- example.bin: .bin file that can be used for flashing 580561b2d8STREFOU Felix 590561b2d8STREFOU Felix### Nucleo68 600561b2d8STREFOU Felix 610561b2d8STREFOU FelixThere are different options to flash and debug the Nucleo68 board. The Nucleo68 boards comes with an on-board [ST-Link programmer and debugger](https://www.st.com/en/development-tools/st-link-v2.html). As an alternative, the ST-Link programmer can be replaced by an [SEGGER J-Link OB](https://www.segger.com/products/debug-probes/j-link/models/other-j-links/st-link-on-board/). Finally, the STM32 can be programmed with any ARM Cortex JTAG or SWD programmer via the SWD jumper. 620561b2d8STREFOU Felix 630561b2d8STREFOU Felix### USB Dongle 640561b2d8STREFOU Felix 650561b2d8STREFOU FelixPlease use any ARM Cortex SWD programmer via the SWD interface desribed in the hardware section. 660561b2d8STREFOU Felix 670561b2d8STREFOU Felix## Run Example Project using Ozone 680561b2d8STREFOU Felix 690561b2d8STREFOU FelixWhen using an external J-Link programmer or after installing J-Link OB on the Nucleo68 board, you can flash and debug using the cross-platform [SEGGER Ozone Debugger](https://www.segger.com/products/development-tools/ozone-j-link-debugger/). It is included in some J-Link programmers or can be used for free for evaluation usage. 700561b2d8STREFOU Felix 710561b2d8STREFOU FelixJust start Ozone and open the .jdebug file in the build folder. When compiled with "ENABLE_SEGGER_RTT", the debug output shows up in the Terminal window of Ozone. Note: as mentioned before, Segger RTT currently stops working when CPU2 has started up. 720561b2d8STREFOU Felix 730561b2d8STREFOU Felix## Debug output 740561b2d8STREFOU Felix 750561b2d8STREFOU FelixAll debug output can be either send via SEGGER RTT or via USART1. To get the console from USART1, simply connect your board under STLink-v2 to your PC or connect PB6 (USART1 TX) of the Nucleo board to an USB-2-UART adapter and open a terminal at 115200. 760561b2d8STREFOU Felix 770561b2d8STREFOU FelixIn src/btstack_config.h resp. in example/btstack_config.h of the generated projects, additional debug information can be enabled by uncommenting ENABLE_LOG_INFO. 780561b2d8STREFOU Felix 7909df40bdSMatthias RingwaldAlso, the full packet log can be enabled in src/btstack_port.c by uncommenting the hci_dump_init(..) line. The console output can then be converted into .pklg files for OS X PacketLogger or WireShark by running tool/create_packet_log.py 800561b2d8STREFOU Felix 810561b2d8STREFOU Felix## GATT Database 820561b2d8STREFOU FelixIn BTstack, the GATT Database is defined via the .gatt file in the example folder. During the build, the .gatt file is converted into a .h file with a binary representation of the GATT Database and useful defines for the application. 83