1*225f4ba4SMatthias Ringwald# BTstack port for STM32 F4 Discovery Board with CC256x 2*225f4ba4SMatthias Ringwald 3*225f4ba4SMatthias RingwaldThis port uses the STM32 F4 Discovery Board with TI's CC256XEM ST Adapter Kit that allows to plug in a CC256xB or CC256xC Bluetooth module. 4*225f4ba4SMatthias RingwaldSTCubeMX was used to provide the HAL, initialize the device, and the Makefile. For easy development, Ozone project files are generated as well. 5*225f4ba4SMatthias Ringwald 6*225f4ba4SMatthias Ringwald## Hardware 7*225f4ba4SMatthias Ringwald 8*225f4ba4SMatthias RingwaldSTM32 Development kit and adapter for CC256x module: 9*225f4ba4SMatthias Ringwald- [STM32 F4 Discovery Board](http://www.st.com/en/evaluation-tools/stm32f4discovery.html) 10*225f4ba4SMatthias Ringwald- [CC256xEM Bluetooth Adatper Kit for ST](https://store.ti.com/CC256XEM-STADAPT-CC256xEM-Bluetooth-Adapter-Kit-P45158.aspx) 11*225f4ba4SMatthias Ringwald 12*225f4ba4SMatthias RingwaldCC256x Bluetooth module: 13*225f4ba4SMatthias Ringwald- [CC2564B Dual-mode Bluetooth® Controller Evaluation Module](https://store.ti.com/cc2564modnem.aspx) 14*225f4ba4SMatthias Ringwald- [CC2564C Dual-mode Bluetooth® Controller Evaluation Module](https://store.ti.com/CC256XCQFN-EM-CC2564C-Dual-Mode-Bluetooth-Controller-Evaluation-Module-P51277.aspx) 15*225f4ba4SMatthias Ringwald 16*225f4ba4SMatthias RingwaldThe module with the older CC2564B is around USD 20, while the one with the new CC2564C costs around USD 60. The projects are configured for the CC2564B. When using the CC2564C, *bluetooth_init_cc2564C_1.0.c* should be used as cc256x_init_script. 17*225f4ba4SMatthias Ringwald 18*225f4ba4SMatthias Ringwald## Software 19*225f4ba4SMatthias Ringwald 20*225f4ba4SMatthias RingwaldTo build all examples, run make 21*225f4ba4SMatthias Ringwald 22*225f4ba4SMatthias Ringwald $ make 23*225f4ba4SMatthias Ringwald 24*225f4ba4SMatthias RingwaldAll examples and the .jedbug Ozone project files are placed in the 'build' folder. 25*225f4ba4SMatthias Ringwald 26*225f4ba4SMatthias Ringwald 27*225f4ba4SMatthias Ringwald## Flash And Run The Examples 28*225f4ba4SMatthias Ringwald 29*225f4ba4SMatthias RingwaldThe Makefile builds different versions: 30*225f4ba4SMatthias Ringwald- example.elf: .elf file with all debug information 31*225f4ba4SMatthias Ringwald- example.bin: .bin file that can be used for flashing 32*225f4ba4SMatthias Ringwald 33*225f4ba4SMatthias RingwaldThere are different options to flash and debug the F4 Discovery board. The F4 Discovery 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. 34*225f4ba4SMatthias Ringwald 35*225f4ba4SMatthias Ringwald## Run Example Project using Ozone 36*225f4ba4SMatthias Ringwald 37*225f4ba4SMatthias RingwaldWhen using an external J-Link programmer or after installing J-Link OB on the F4 Discovery 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. 38*225f4ba4SMatthias Ringwald 39*225f4ba4SMatthias RingwaldJust 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. 40*225f4ba4SMatthias Ringwald 41*225f4ba4SMatthias Ringwald 42*225f4ba4SMatthias Ringwald## Debug output 43*225f4ba4SMatthias Ringwald 44*225f4ba4SMatthias RingwaldAll debug output can be either send via SEGGER RTT or via USART2. To get the console from USART2, connect PA2 (USART2 TX) of the Discovery board to an USB-2-UART adapter and open a terminal at 115200. 45*225f4ba4SMatthias Ringwald 46*225f4ba4SMatthias RingwaldIn 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. 47*225f4ba4SMatthias Ringwald 48*225f4ba4SMatthias RingwaldAlso, the full packet log can be enabled in src/port.c resp. btstack/port/stm32-f4discovery-cc256x/src/port.c by uncommenting the hci_dump_open(..) line. The console output can then be converted into .pklg files for OS X PacketLogger or WireShark by running tool/create_packet_log.py 49*225f4ba4SMatthias Ringwald 50*225f4ba4SMatthias Ringwald## GATT Database 51*225f4ba4SMatthias RingwaldIn BTstack, the GATT Database is defined via the .gatt file in the example folder. The Makefile contains rules to update the .h file when the .gatt was modified. 52*225f4ba4SMatthias Ringwald 53*225f4ba4SMatthias RingwaldNote: In theory, this can be integrated into the Eclipse project, in fact, it's easy to configure it as an Eclipse Builder, but it got tricky to 54*225f4ba4SMatthias Ringwald 55*225f4ba4SMatthias Ringwald 56*225f4ba4SMatthias Ringwald## Maintainer Notes - Updating The Port 57*225f4ba4SMatthias Ringwald 58*225f4ba4SMatthias RingwaldThe Audio BSP is from the STM32F4Cube V1.16 firmware and not generated from STM32CubeMX. To update the HAL, run 'generate code' in CubeMX. After that, make sure to re-apply the patches to the UART and check if the hal config was changed. 59*225f4ba4SMatthias Ringwald 60