1*a16c312cSMatthias Ringwald# BTstack Port for POSIX Systems with Dialog Semiconductor DA14531 Controller 2*a16c312cSMatthias Ringwald 3*a16c312cSMatthias RingwaldThis port allows to use the DA14531 connected via UART with BTstack running on a POSIX host system. 4*a16c312cSMatthias Ringwald 5*a16c312cSMatthias RingwaldInstead of storing the HCI firmware in the OTP, it first downloads the hci_531_active_uart_460800.hex firmware 6*a16c312cSMatthias Ringwaldfrom the 6.0.16.1144 SDK, before BTstack starts up. 7*a16c312cSMatthias Ringwald 8*a16c312cSMatthias RingwaldAfter Power Cycle, please start one of the test applications and press the Reset button to trigger firmware download. 9*a16c312cSMatthias Ringwald 10*a16c312cSMatthias RingwaldPlease note that it does not detect if the firmware has already been downloaded, so you need to Power Cycle 11*a16c312cSMatthias Ringwaldthe DA14531 before starting an example again. 12*a16c312cSMatthias Ringwald 13*a16c312cSMatthias RingwaldAlternatively, after running one of the examples once to upload the firmware, you can use the regular 'posix-h4' port 14*a16c312cSMatthias Ringwaldand change the initial UART baud rate to 460800 as long as you don't power cycle the dev kit. 15*a16c312cSMatthias Ringwald 16*a16c312cSMatthias RingwaldFor production use, the DA14531 could be power cycled from the main CPU during startup, e.g. after the call 17*a16c312cSMatthias Ringwaldto btstack_chipset_da145xx_download_firmware_with_uart, or, the HCI firmware could be burned into the OTP. 18*a16c312cSMatthias Ringwald 19*a16c312cSMatthias Ringwald# Software Setup / Firmware 20*a16c312cSMatthias Ringwald 21*a16c312cSMatthias RingwaldOn the [DA14531 USB Development Kit](https://www.dialog-semiconductor.com/products/bluetooth-low-energy/da14531-development-kit-usb), 22*a16c312cSMatthias Ringwaldthe UART is configured via DIP switched. By this, the mapping to the DA14531 GPIOs is fixed. In SDK 6.0.6.1144, the 23*a16c312cSMatthias RingwaldGPIO mapping of RTS and CTS is flipped. In order to be able to us the same HCI firmware on both dev kits, we've 24*a16c312cSMatthias Ringwaldused the following configuration in `user_perip_setup.h` 25*a16c312cSMatthias Ringwald 26*a16c312cSMatthias Ringwald```C 27*a16c312cSMatthias Ringwald #define UART1_TX_PORT GPIO_PORT_0 28*a16c312cSMatthias Ringwald #define UART1_TX_PIN GPIO_PIN_0 29*a16c312cSMatthias Ringwald 30*a16c312cSMatthias Ringwald #define UART1_RX_PORT GPIO_PORT_0 31*a16c312cSMatthias Ringwald #define UART1_RX_PIN GPIO_PIN_1 32*a16c312cSMatthias Ringwald 33*a16c312cSMatthias Ringwald #define UART1_RTSN_PORT GPIO_PORT_0 34*a16c312cSMatthias Ringwald #define UART1_RTSN_PIN GPIO_PIN_4 35*a16c312cSMatthias Ringwald 36*a16c312cSMatthias Ringwald #define UART1_CTSN_PORT GPIO_PORT_0 37*a16c312cSMatthias Ringwald #define UART1_CTSN_PIN GPIO_PIN_3 38*a16c312cSMatthias Ringwald``` 39*a16c312cSMatthias Ringwald 40*a16c312cSMatthias RingwaldWe also increased the UART baudrate to 460800 41*a16c312cSMatthias Ringwald 42*a16c312cSMatthias Ringwald```C 43*a16c312cSMatthias Ringwald#define UART1_BAUDRATE UART_BAUDRATE_460800 44*a16c312cSMatthias Ringwald``` 45*a16c312cSMatthias Ringwald 46*a16c312cSMatthias RingwaldWe also disabled the SLEEP mode in user_config.h: 47*a16c312cSMatthias Ringwald 48*a16c312cSMatthias Ringwald```C 49*a16c312cSMatthias Ringwaldstatic const sleep_state_t app_default_sleep_mode = ARCH_SLEEP_OFF; 50*a16c312cSMatthias Ringwald``` 51*a16c312cSMatthias Ringwald 52*a16c312cSMatthias RingwaldAfter compilation with Keil uVision 5, the generated .hex file is copied into btstack/chipset/da145xx as 53*a16c312cSMatthias Ringwald`hci_531_active_uart_460800.hex`, and then 54*a16c312cSMatthias Ringwald`convert_hex_files" is used to convert it into a C data array. 55*a16c312cSMatthias Ringwald 56*a16c312cSMatthias Ringwald 57*a16c312cSMatthias Ringwald# Hardware Setup - Dev Kit Pro 58*a16c312cSMatthias Ringwald 59*a16c312cSMatthias RingwaldTo use the [DA14531 Dev Kit Pro](https://www.dialog-semiconductor.com/products/bluetooth-low-energy/da14530-and-da14531-development-kit-pro) 60*a16c312cSMatthias Ringwaldwith BTstack, please make the following modifications: 61*a16c312cSMatthias Ringwald- Follow Chapter 4.1 and Figure 4 in the [DA14531 Development Kit Pro Hardware User Manual 62*a16c312cSMatthias Ringwald UM-B-114](https://www.dialog-semiconductor.com/sites/default/files/2021-06/UM-B-114_DA14531_Devkit_Pro_Hardware_User%20manual_1v5.pdf) 63*a16c312cSMatthias Ringwald and set SW1 of the 14531 daughter board into position "BUCK" position marked with an "H" on the left side. 64*a16c312cSMatthias Ringwald- configure the dev kit for Full UART (4-wire) Configuration by adding jumper wires between J1 and J2 65*a16c312cSMatthias Ringwald 66*a16c312cSMatthias Ringwald# Hardware Setup - Dev Kit USB 67*a16c312cSMatthias Ringwald 68*a16c312cSMatthias RingwaldTo use the [Dev Kit USB](https://www.dialog-semiconductor.com/products/bluetooth-low-energy/da14531-development-kit-usb#tab-field_tab_content_overview) 69*a16c312cSMatthias Ringwaldwith BTstack, please make the following modifications: 70*a16c312cSMatthias Ringwald- Follow Chapter 5.6 in the [DA14531 USB Development Kit Hardware UM-B-125](https://www.dialog-semiconductor.com/sites/default/files/um-b-125_da14531_usb_development_kit_hw_manual_1v1.pdf) 71*a16c312cSMatthias Ringwald and set the DIP switches as described. 72*a16c312cSMatthias Ringwald 73*a16c312cSMatthias Ringwald # Example Run 74*a16c312cSMatthias Ringwald 75*a16c312cSMatthias Ringwald``` 76*a16c312cSMatthias Ringwald$ ./gatt_counter 77*a16c312cSMatthias RingwaldPacket Log: /tmp/hci_dump.pklg 78*a16c312cSMatthias RingwaldPhase 1: Download firmware 79*a16c312cSMatthias RingwaldPhase 2: Main app 80*a16c312cSMatthias RingwaldBTstack counter 0001 81*a16c312cSMatthias RingwaldBTstack up and running on 80:EA:CA:70:00:08. 82*a16c312cSMatthias Ringwald``` 83