nr5-zephyr: use hci_firmware.patch, fix build

This commit is contained in:
Matthias Ringwald 2016-12-02 12:53:55 +01:00
parent 32d5309e57
commit 68dacca219
3 changed files with 13 additions and 68 deletions

View File

@ -1,46 +0,0 @@
diff --git a/samples/bluetooth/hci_uart/src/main.c b/samples/bluetooth/hci_uart/src/main.c
index b103f05..80a82d3 100644
--- a/samples/bluetooth/hci_uart/src/main.c
+++ b/samples/bluetooth/hci_uart/src/main.c
@@ -36,6 +36,9 @@
#include <bluetooth/buf.h>
#include <bluetooth/hci_raw.h>
+#include "ll.h"
+#include "nrf.h"
+
static struct device *hci_uart_dev;
#define STACK_SIZE 1024
@@ -301,6 +304,18 @@ static int hci_uart_init(struct device *unused)
DEVICE_INIT(hci_uart, "hci_uart", &hci_uart_init, NULL, NULL,
APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
+void little_endian_store_16(uint8_t *buffer, uint16_t pos, uint16_t value){
+ buffer[pos++] = value;
+ buffer[pos++] = value >> 8;
+}
+
+void little_endian_store_32(uint8_t *buffer, uint16_t pos, uint32_t value){
+ buffer[pos++] = value;
+ buffer[pos++] = value >> 8;
+ buffer[pos++] = value >> 16;
+ buffer[pos++] = value >> 24;
+}
+
void main(void)
{
/* incoming events and data from the controller */
@@ -320,6 +335,12 @@ void main(void)
(nano_fiber_entry_t)tx_fiber, 0, 0, 7, 0);
bt_enable_raw(&rx_queue);
+
+ // make Random Static Address available via HCI Read BD ADDR as fake public address
+ uint8_t addr[6];
+ little_endian_store_16(addr, 4, NRF_FICR->DEVICEADDR[1] | 0xc000);
+ little_endian_store_32(addr, 0, NRF_FICR->DEVICEADDR[0]);
+ ll_address_set(0, addr);
while (1) {
struct net_buf *buf;

View File

@ -2,23 +2,28 @@
ZEPHYR_BASE=../../..
echo "Adding BTstack sources as subsys/btstack"
echo "Integrating BTstack into Zephyr"
if grep -q -F "NRF_FICR->DEVICEADDR" ${ZEPHYR_BASE}/samples/bluetooth/hci_uart/src/main.c; then
echo "HCI Firmware patch already installed"
else
# assert files don't exist since patch would get irritated
echo "Applying HCI Firmware patch"
rm -f ${ZEPHYR_BASE}/samples/bluetooth/hci_uart/flash*
cat hci_firmware.patch | patch -d ${ZEPHYR_BASE} -p1
fi
echo "Adding subsys/btstack"
# add btstack folder to subsys/Makefile
MAKEFILE_ADD_ON='obj-$(CONFIG_BTSTACK) += btstack/'
NET_MAKEFILE=${ZEPHYR_BASE}/subsys/Makefile
grep -q -F btstack ${NET_MAKEFILE} || echo ${MAKEFILE_ADD_ON} >> ${NET_MAKEFILE}
# add BTstack KConfig to net/Kconfig
# add BTstack KConfig to subsys/Kconfig
SUBSYS_KCONFIG=${ZEPHYR_BASE}/subsys/Kconfig
grep -q -F btstack ${SUBSYS_KCONFIG} || echo 'source "subsys/btstack/Kconfig"' >> ${SUBSYS_KCONFIG}
# set Nordic Semiconductor as manufacturer
CTRL_H=${ZEPHYR_BASE}/subsys/bluetooth/controller/ll/ctrl.h
sed -i "s|#define RADIO_BLE_COMPANY_ID.*0xFFFF.|#define RADIO_BLE_COMPANY_ID (0x0059) // Nordic Semiconductor ASA|g" ${CTRL_H}
# create subsys/btstack
mkdir -p ${ZEPHYR_BASE}/subsys/btstack
@ -52,17 +57,3 @@ rsync -a Makefile.bluedroid-decoder ${ZEPHYR_BASE}/subsys/btstack/bluedroid/deco
# create samples/btstack
./create_examples.py
## Additonal changes for HCI Controller firmware in samples/bluetooth/hci-uart
HCI_UART=${ZEPHYR_BASE}/samples/bluetooth/hci_uart
# add flash scripts to hci-uart
rsync -a flash_nrf51_pca10028.sh ${HCI_UART}/flash_nrf51_pca10028.sh
rsync -a flash_nrf52_pca10040.sh ${HCI_UART}/flash_nrf52_pca10040.sh
# use 115200 baud
sed -i 's|CONFIG_UART_NRF5_BAUD_RATE=1000000|CONFIG_UART_NRF5_BAUD_RATE=115200|g' ${HCI_UART}/nrf5.conf
# provide static random address to host via hci read bd addr
grep -q -F ll_address_set ${HCI_UART}/src/main.c || cat hci_uart.patch | patch -d ${ZEPHYR_BASE} -p1

View File

@ -9,7 +9,7 @@ CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_STACK_HCI_RAW=y
CONFIG_BLUETOOTH_HCI_RAW=y
CONFIG_BLUETOOTH_MAX_CONN=16
CONFIG_BLUETOOTH_CONTROLLER_RX_BUFFERS=4
CONFIG_BLUETOOTH_CONTROLLER_TX_BUFFERS=4