summaryrefslogtreecommitdiffstats
path: root/meta-rcar-gen3-adas
diff options
context:
space:
mode:
Diffstat (limited to 'meta-rcar-gen3-adas')
-rw-r--r--meta-rcar-gen3-adas/conf/layer.conf1
-rw-r--r--meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0001-Improve-debug-output.patch125
-rw-r--r--meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0001-fix-poll-restart-after-fail.patch52
-rw-r--r--meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0002-Fix-possible-cross-compile-issue.patch29
-rw-r--r--meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/uim-sysfs36
-rw-r--r--meta-rcar-gen3-adas/recipes-bsp/ti-bt/ti-bt_git.bb35
6 files changed, 278 insertions, 0 deletions
diff --git a/meta-rcar-gen3-adas/conf/layer.conf b/meta-rcar-gen3-adas/conf/layer.conf
index 3194c25..8557d88 100644
--- a/meta-rcar-gen3-adas/conf/layer.conf
+++ b/meta-rcar-gen3-adas/conf/layer.conf
@@ -51,6 +51,7 @@ IMAGE_INSTALL_append_rcar-gen3 += " \
si-tools \
linux-firmware-wl18xx \
wireless-tools \
+ ti-bt \
ti-bt-firmware \
bluez5 \
bluez5-testtools \
diff --git a/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0001-Improve-debug-output.patch b/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0001-Improve-debug-output.patch
new file mode 100644
index 0000000..85c7407
--- /dev/null
+++ b/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0001-Improve-debug-output.patch
@@ -0,0 +1,125 @@
+From 3dd59ce6ef2bb0470e325be1fc5fb79b50842e31 Mon Sep 17 00:00:00 2001
+From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
+Date: Tue, 13 Dec 2016 19:21:00 +0300
+Subject: [PATCH] Improve debug output
+
+Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
+---
+ uim.c | 51 +++++++++++++++++++++++++++++----------------------
+ 1 file changed, 29 insertions(+), 22 deletions(-)
+
+diff --git a/uim.c b/uim.c
+index 89bafd8..9a58eab 100644
+--- a/uim.c
++++ b/uim.c
+@@ -86,9 +86,10 @@ int read_hci_event(int fd, unsigned char *buf, int size)
+
+ UIM_START_FUNC();
+
+- UIM_VER(" read_hci_event");
+- if (size <= 0)
+- return -1;
++ if (size <= 0) {
++ UIM_VER(" invalid size: %d", size);
++ return -EINVAL;
++ }
+
+ /* The first byte identifies the packet type. For HCI event packets, it
+ * should be 0x04, so we read until we get to the 0x04. */
+@@ -98,7 +99,8 @@ int read_hci_event(int fd, unsigned char *buf, int size)
+ nanosleep(&tm, NULL);
+ continue;
+ } else if (rd_retry_count >= 4) {
+- return -1;
++ UIM_VER(" no retry left. nothing readed");
++ return -EBUSY;
+ }
+
+ if (buf[0] == RESP_PREFIX) {
+@@ -110,8 +112,10 @@ int read_hci_event(int fd, unsigned char *buf, int size)
+ /* The next two bytes are the event code and parameter total length. */
+ while (count < 3) {
+ rd = read(fd, buf + count, 3 - count);
+- if (rd <= 0)
+- return -1;
++ if (rd <= 0) {
++ UIM_VER(" read failed: %d", rd);
++ return -EINVAL;
++ }
+ count += rd;
+ }
+
+@@ -123,8 +127,10 @@ int read_hci_event(int fd, unsigned char *buf, int size)
+
+ while ((count - 3) < remain) {
+ rd = read(fd, buf + count, remain - (count - 3));
+- if (rd <= 0)
+- return -1;
++ if (rd <= 0) {
++ UIM_VER(" failed to read buffer tail: %d", rd);
++ return -EINVAL;
++ }
+ count += rd;
+ }
+
+@@ -139,42 +145,43 @@ int read_hci_event(int fd, unsigned char *buf, int size)
+ */
+ static int read_command_complete(int fd, unsigned short opcode)
+ {
++ int ret = 0;
+ command_complete_t resp;
+
+ UIM_START_FUNC();
+
+- UIM_VER(" Command complete started");
+- if (read_hci_event(fd, (unsigned char *)&resp, sizeof(resp)) < 0) {
+- UIM_ERR("Invalid response");
+- return -1;
++ ret = read_hci_event(fd, (unsigned char *)&resp, sizeof(resp));
++ if (ret < 0) {
++ UIM_ERR("Failed to read response: %d", ret);
++ return ret;
+ }
+
+ /* Response should be an event packet */
+ if (resp.uart_prefix != HCI_EVENT_PKT) {
+- UIM_ERR ("Error in response: not an event packet, 0x%02x!",
+- resp.uart_prefix);
+- return -1;
++ UIM_ERR ("Error in response: not an event packet, 0x%02x != 0x%02x!",
++ resp.uart_prefix, HCI_EVENT_PKT);
++ return -EINVAL;
+ }
+
+ /* Response should be a command complete event */
+ if (resp.hci_hdr.evt != EVT_CMD_COMPLETE) {
+ /* event must be event-complete */
+- UIM_ERR("Error in response: not a cmd-complete event,0x%02x!",
+- resp.hci_hdr.evt);
+- return -1;
++ UIM_ERR("Error in response: not a cmd-complete event,0x%02x != 0x%02x!",
++ resp.hci_hdr.evt, EVT_CMD_COMPLETE);
++ return -EINVAL;
+ }
+
+ if (resp.hci_hdr.plen < 4) {
+ /* plen >= 4 for EVT_CMD_COMPLETE */
+- UIM_ERR("Error in response: plen is not >= 4, but 0x%02x!",
++ UIM_ERR("Error in response: length < 4, but 0x%02x!",
+ resp.hci_hdr.plen);
+- return -1;
++ return -EINVAL;
+ }
+
+ if (resp.cmd_complete.opcode != (unsigned short)opcode) {
+- UIM_ERR("Error in response: opcode is 0x%04x, not 0x%04x!",
++ UIM_ERR("Error in response: opcode is 0x%04x != 0x%04x!",
+ resp.cmd_complete.opcode, opcode);
+- return -1;
++ return -EINVAL;
+ }
+
+ UIM_DBG("Command complete done");
+--
+1.8.3.1
+
diff --git a/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0001-fix-poll-restart-after-fail.patch b/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0001-fix-poll-restart-after-fail.patch
new file mode 100644
index 0000000..3eeddec
--- /dev/null
+++ b/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0001-fix-poll-restart-after-fail.patch
@@ -0,0 +1,52 @@
+From c4b8eca95c37d728c39c57811d975c50900605fd Mon Sep 17 00:00:00 2001
+From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
+Date: Tue, 31 May 2016 19:50:27 +0300
+Subject: [PATCH] fix poll restart after fail
+
+also add some delay before starting speaking with BT
+
+Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
+---
+ uim.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/uim.c b/uim.c
+index 6bde5ca..89bafd8 100644
+--- a/uim.c
++++ b/uim.c
+@@ -286,6 +286,8 @@ int st_uart_config(unsigned char install)
+
+ UIM_START_FUNC();
+
++ usleep(100 * 1000);
++
+ if (install == '1') {
+ memset(buf, 0, UART_DEV_NAME_LEN);
+ fd = open(DEV_NAME_SYSFS, O_RDONLY);
+@@ -375,6 +377,7 @@ int st_uart_config(unsigned char install)
+
+ /* Read the response for the Change speed command */
+ if (read_command_complete(dev_fd, HCI_HDR_OPCODE) < 0) {
++ tcflush(dev_fd, TCIOFLUSH);
+ close(dev_fd);
+ return -1;
+ }
+@@ -534,7 +537,6 @@ int main(int argc, char *argv[])
+ return -1;
+ }
+
+-RE_POLL:
+ /* read to start proper poll */
+ err = read(st_fd, &install, 1);
+ /* special case where bluetoothd starts before the UIM, and UIM
+@@ -547,6 +549,7 @@ RE_POLL:
+
+ UIM_DBG("begin polling...");
+
++RE_POLL:
+ memset(&p, 0, sizeof(p));
+ p.fd = st_fd;
+ p.events = POLLERR | POLLPRI;
+--
+1.7.10.4
+
diff --git a/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0002-Fix-possible-cross-compile-issue.patch b/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0002-Fix-possible-cross-compile-issue.patch
new file mode 100644
index 0000000..e305dcd
--- /dev/null
+++ b/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/0002-Fix-possible-cross-compile-issue.patch
@@ -0,0 +1,29 @@
+From 961301d5f9c8369f96b26d9255d249c8c26a8903 Mon Sep 17 00:00:00 2001
+From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
+Date: Fri, 26 May 2017 13:07:10 +0300
+Subject: [PATCH] Fix possible cross-compile issue
+
+Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
+---
+ uim.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/uim.c b/uim.c
+index 197bfd4..61a89a5 100644
+--- a/uim.c
++++ b/uim.c
+@@ -367,8 +367,10 @@ int st_uart_config(unsigned char install)
+ UIM_VER("Setting speed to %ld", cust_baud_rate);
+ /* Forming the packet for Change speed command */
+ cmd.uart_prefix = HCI_COMMAND_PKT;
++ /* FIXME: endian */
+ cmd.hci_hdr.opcode = HCI_HDR_OPCODE;
+- cmd.hci_hdr.plen = sizeof(unsigned long);
++ cmd.hci_hdr.plen = sizeof(uint32_t);
++ /* FIXME: endian */
+ cmd.speed = cust_baud_rate;
+
+ /* Writing the change speed command to the UART
+--
+2.13.0
+
diff --git a/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/uim-sysfs b/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/uim-sysfs
new file mode 100644
index 0000000..93c2cac
--- /dev/null
+++ b/meta-rcar-gen3-adas/recipes-bsp/ti-bt/files/uim-sysfs
@@ -0,0 +1,36 @@
+#! /bin/sh
+
+uim="/usr/bin/uim"
+test -x "$uim" || exit 0
+
+case "$1" in
+ start)
+ echo -n "Starting uim-sysfs daemon"
+ modprobe st_drv
+ NODE=`cd /sys; find . | grep kim | grep install`
+ if [ $NODE ]
+ then
+ echo UIM SYSFS Node Found at /sys/$NODE
+ else
+ echo UIM SYSFS Node Not Found
+ rmmod st_drv
+ exit 0
+ fi
+ uim_args="-f `dirname /sys/$NODE`"
+ start-stop-daemon --start --quiet --pidfile /var/run/uim.pid --make-pidfile --exec $uim -- $uim_args &
+ modprobe btwilink
+ echo "."
+ ;;
+ stop)
+ echo -n "Stopping uim-sysfs daemon"
+ start-stop-daemon --stop --quiet --pidfile /var/run/uim.pid
+ rmmod btwilink
+ rmmod st_drv
+ echo "."
+ ;;
+ *)
+ echo "Usage: /etc/init.d/uim-sysfs {start|stop}"
+ exit 1
+esac
+
+exit 0
diff --git a/meta-rcar-gen3-adas/recipes-bsp/ti-bt/ti-bt_git.bb b/meta-rcar-gen3-adas/recipes-bsp/ti-bt/ti-bt_git.bb
new file mode 100644
index 0000000..6986e2e
--- /dev/null
+++ b/meta-rcar-gen3-adas/recipes-bsp/ti-bt/ti-bt_git.bb
@@ -0,0 +1,35 @@
+SUMMARY = "UIM tool for WL18xx module"
+SECTION = "misc"
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://uim.c;beginline=3;endline=16;md5=ee2f4f9fa92404f383fc3e6315b9dda3"
+
+inherit update-rc.d
+INITSCRIPT_NAME="uim-sysfs"
+INITSCRIPT_PARAMS = "start 20 2 3 4 5 ."
+
+PR = "0+gitr${SRCPV}"
+PV = "0.1"
+
+SRC_URI = "git://git.ti.com/ti-bt/uim.git;protocol=git \
+ file://0001-fix-poll-restart-after-fail.patch \
+ file://0001-Improve-debug-output.patch \
+ file://0002-Fix-possible-cross-compile-issue.patch \
+ file://uim-sysfs"
+SRCREV = "a75f45be2d5c74fc1dd913d08afc30f09a230aa9"
+
+S = "${WORKDIR}/git"
+
+do_install() {
+ install -d ${D}${bindir}
+ install -d ${D}${sysconfdir}/init.d
+
+ install -m 0755 uim ${D}${bindir}/
+ install -m 0755 ${WORKDIR}/uim-sysfs ${D}${sysconfdir}/init.d
+
+ # Blacklist st_drv and btwilink to prevent modules autoload
+ # /etc/init.d/uim-sysfs will do the work with the proper parameters
+ install -d ${D}/${sysconfdir}/modprobe.d
+ echo "blacklist st_drv" > ${D}/${sysconfdir}/modprobe.d/ti_bt.conf
+ echo "blacklist btwilink" >> ${D}/${sysconfdir}/modprobe.d/ti_bt.conf
+} \ No newline at end of file