btfilter: rework package's recipe
- use Yocto's INITSCRIPT/update-rc.d infrastructure to install the bootscript. - add patch that make cross-compilation easier and thus simplify bitbake recipe. - launch 'abtfilter' with '-b' parameter (use only D-Bus filtering) to avoid alignment errors (when using hci filter mode): Alignment trap: abtfilt (721) PC=0x00017f24 Instr=0xe1d330b0 Address=0x419fec91 FSR 0x013 Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
parent
51f75c56ad
commit
1e888be133
|
|
@ -0,0 +1,85 @@
|
|||
From: Javier Viguera <javier.viguera@digi.com>
|
||||
Date: Tue, 7 Aug 2012 14:00:03 +0200
|
||||
Subject: [PATCH] cross-compile
|
||||
|
||||
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
|
||||
---
|
||||
Makefile | 43 +++++++++++++++++++++++++++----------------
|
||||
1 file changed, 27 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 66f469e..f485b01 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -24,13 +24,13 @@ SBINDIR ?= $(PREFIX)/sbin
|
||||
MANDIR ?= $(PREFIX)/share/man
|
||||
|
||||
PKG_CONFIG ?= pkg-config
|
||||
-ifdef V210
|
||||
-CC= $(ATH_CROSS_COMPILE_TYPE)gcc
|
||||
-LD= $(ATH_CROSS_COMPILE_TYPE)ld
|
||||
-else
|
||||
-CC= $(ATH_CROSSS_COMPILE_TYPE)gcc
|
||||
-LD= $(ATH_CROSSS_COMPILE_TYPE)ld
|
||||
-endif
|
||||
+# ifdef V210
|
||||
+# CC= $(ATH_CROSS_COMPILE_TYPE)gcc
|
||||
+# LD= $(ATH_CROSS_COMPILE_TYPE)ld
|
||||
+# else
|
||||
+# CC= $(ATH_CROSSS_COMPILE_TYPE)gcc
|
||||
+# LD= $(ATH_CROSSS_COMPILE_TYPE)ld
|
||||
+# endif
|
||||
SOURCES=abtfilt_main.c \
|
||||
abtfilt_wlan.c \
|
||||
abtfilt_core.c \
|
||||
@@ -39,19 +39,19 @@ SOURCES=abtfilt_main.c \
|
||||
nl80211_utils.c\
|
||||
btfilter_core.c
|
||||
|
||||
-INCLUDES= -Iinclude \
|
||||
+override INCLUDES += -Iinclude \
|
||||
-Ios/linux/include \
|
||||
- -Icommon/include \
|
||||
- -I$(V210_DIR)/usr/include/dbus-1.0/ \
|
||||
- -I$(V210_DIR)/usr/lib/dbus-1.0/include \
|
||||
- -I$(V210_DIR)/usr/local/include/dbus-1.0 \
|
||||
- -I$(V210_DIR)/usr/local/lib/dbus-1.0/include \
|
||||
- -I$(V210_DIR)/usr/include/bluetooth \
|
||||
- -I$(V210_DIR)/usr/local/include/bluetooth \
|
||||
+ -Icommon/include
|
||||
+# -I$(V210_DIR)/usr/include/dbus-1.0/ \
|
||||
+# -I$(V210_DIR)/usr/lib/dbus-1.0/include \
|
||||
+# -I$(V210_DIR)/usr/local/include/dbus-1.0 \
|
||||
+# -I$(V210_DIR)/usr/local/lib/dbus-1.0/include \
|
||||
+# -I$(V210_DIR)/usr/include/bluetooth \
|
||||
+# -I$(V210_DIR)/usr/local/include/bluetooth \
|
||||
|
||||
CFLAGS= -Wall -g -DABF_DEBUG
|
||||
#LIBS= -ldbus-1 -lpthread -lbtfilt -lrt -lbluetooth
|
||||
-LIBS= -ldbus-1 -lpthread -lrt -lbluetooth
|
||||
+# LIBS= -ldbus-1 -lpthread -lrt -lbluetooth
|
||||
|
||||
NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
|
||||
NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y)
|
||||
@@ -79,6 +79,13 @@ endif
|
||||
LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
|
||||
CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
|
||||
|
||||
+# dbus
|
||||
+LIBS += $(shell $(PKG_CONFIG) --libs --static dbus-1)
|
||||
+CFLAGS += $(shell $(PKG_CONFIG) --cflags dbus-1)
|
||||
+
|
||||
+# BlueZ
|
||||
+LIBS += $(shell $(PKG_CONFIG) --libs bluez)
|
||||
+CFLAGS += $(shell $(PKG_CONFIG) --cflags bluez)
|
||||
|
||||
ifdef USE_HCIUTILS
|
||||
SOURCES += abtfilt_bluez_hciutils.c
|
||||
@@ -120,3 +127,7 @@ all: $(OBJECTS)
|
||||
|
||||
clean:
|
||||
rm -f $(FILTERAPP) $(OBJECTS)
|
||||
+
|
||||
+install:
|
||||
+ mkdir -p $(DESTDIR)$(SBINDIR)
|
||||
+ install -m 0755 $(FILTERAPP) $(DESTDIR)$(SBINDIR)
|
||||
|
|
@ -3,30 +3,27 @@ SECTION = "network"
|
|||
LICENSE = "ISC"
|
||||
LIC_FILES_CHKSUM = "file://Makefile;beginline=1;endline=14;md5=8f6614b37751445a5f6a9bdc69be26b3"
|
||||
|
||||
DEPENDS = "libnl bluez4"
|
||||
DEPENDS = "bluez4 dbus libnl"
|
||||
|
||||
PR = "r0"
|
||||
|
||||
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
|
||||
SRC_URI = "${DIGI_LOG_MIRROR}${PN}-${PV}.tar.bz2 \
|
||||
file://0001-enable-libnl3.patch \
|
||||
file://S65bluez-bg.sh"
|
||||
|
||||
S = "${WORKDIR}/${PN}-${PV}"
|
||||
|
||||
EXTRA_OEMAKE += "V210_DIR=${STAGING_DIR_TARGET}"
|
||||
CFLAGS_prepend = "-I ${STAGING_DIR_TARGET}/usr/include -DCONFIG_LIBNL20 -DCONFIG_NO_HCILIBS"
|
||||
file://0001-enable-libnl3.patch \
|
||||
file://0002-cross-compile.patch \
|
||||
file://bluez-init"
|
||||
|
||||
SRC_URI[md5sum] = "149b025f7a43f1f3abfa12462c48559a"
|
||||
SRC_URI[sha256sum] = "bbb358ce25ec36b32f99e66036ff52f375f3c1272b1425fafbef2c240a55d1a4"
|
||||
|
||||
inherit update-rc.d
|
||||
|
||||
EXTRA_OEMAKE = "INCLUDES=-I${STAGING_INCDIR}/bluetooth"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}/${bindir}
|
||||
install -m 0755 ${S}/abtfilt ${D}${bindir}/abtfilt
|
||||
install -d ${D}${sysconfdir}/rc5.d
|
||||
install -m 0755 ${WORKDIR}/S65bluez-bg.sh ${D}${sysconfdir}/rc5.d/
|
||||
install -d ${D}${bindir} ${D}${sysconfdir}/init.d/
|
||||
install -m 0755 abtfilt ${D}${bindir}
|
||||
install -m 0755 ${WORKDIR}/bluez-init ${D}${sysconfdir}/init.d/bluez
|
||||
}
|
||||
|
||||
FILES_${PN} = "${bindir}/abtfilt"
|
||||
FILES_${PN} += "${sysconfdir}/rc5.d/S65bluez-bg.sh"
|
||||
CONFFILES_${PN} += "${sysconfdir}/rc5.d/S65bluez-bg.sh"
|
||||
INITSCRIPT_NAME = "bluez"
|
||||
INITSCRIPT_PARAMS = "start 10 5 ."
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# S65bluez-bg.sh
|
||||
# bluez
|
||||
#
|
||||
# Copyright (C) 2012 by Digi International Inc.
|
||||
# Copyright (C) 2012-2013 by Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
|
|
@ -17,7 +17,11 @@
|
|||
|
||||
set -e
|
||||
|
||||
SCRIPTNAME="S65bluez-bg.sh"
|
||||
if [ "${1}" != "start" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPTNAME="${0}"
|
||||
|
||||
ccardwmx28js_bt_init() {
|
||||
#
|
||||
|
|
@ -26,16 +30,15 @@ ccardwmx28js_bt_init() {
|
|||
BLUE_TOOTH_VARIANTS="0x02 0x03 0x04"
|
||||
MOD_VARIANT="$(cat /sys/kernel/ccardimx28/mod_variant)"
|
||||
if ! echo ${BLUE_TOOTH_VARIANTS} | grep -qs ${MOD_VARIANT}; then
|
||||
[ -z "${quietboot}" ] && echo "${SCRIPTNAME}: FAILED (variant ${MOD_VARIANT} does not support bluetooth)"
|
||||
echo "${SCRIPTNAME}: FAILED (variant ${MOD_VARIANT} does not support bluetooth)"
|
||||
exit
|
||||
fi
|
||||
|
||||
#
|
||||
# Get the Bluetooth MAC address from NVRAM. Use a default
|
||||
# value if the address has not been set.
|
||||
# Get the Bluetooth MAC address from NVRAM. Use a default value if the
|
||||
# address has not been set.
|
||||
#
|
||||
|
||||
BTADDR=`cat /proc/cmdline | sed 's/\s/\n/g' | awk '/btaddr1/ {print}' | sed 's/btaddr1=//g'`
|
||||
BTADDR="$(sed -e 's,^.*btaddr1=\([^[:blank:]]\+\),\1,g' /proc/cmdline)"
|
||||
if [ -z "${BTADDR}" -o "${BTADDR}" = "00:00:00:00:00:00" ]; then
|
||||
BTADDR="00:04:F3:FF:FF:BB"
|
||||
fi
|
||||
|
|
@ -60,45 +63,40 @@ ccardwmx28js_bt_init() {
|
|||
HCIATTACH_OPTIONS_115K="${BT_DEVICE} ${BT_DRIVER} 115200"
|
||||
TRIES="1"
|
||||
MAX_TRIES="11111"
|
||||
while ! hciattach ${HCIATTACH_OPTIONS} 1>/dev/null && [ "${TRIES}" != "${MAX_TRIES}" ] ;
|
||||
do
|
||||
while ! hciattach ${HCIATTACH_OPTIONS} 1>/dev/null && [ "${TRIES}" != "${MAX_TRIES}" ]; do
|
||||
echo "${SCRIPTNAME}: (hciattach), retrying..."
|
||||
#
|
||||
# If hciattach at 4Kbps doesn't work, then try it at 115K bps
|
||||
# If hciattach at 4Mbps doesn't work, then try it at 115Kbps
|
||||
# just to get the chip working.
|
||||
#
|
||||
if hciattach ${HCIATTACH_OPTIONS_115K} 1>/dev/null ; then
|
||||
if hciattach ${HCIATTACH_OPTIONS_115K} 1>/dev/null; then
|
||||
#
|
||||
# It worked at 115Kbps. The chip should be recovered now.
|
||||
# Kill the daemon so we can retry at 4Mbps.
|
||||
# It worked at 115Kbps. The chip should be recovered now.
|
||||
# Kill the daemon so we can retry at 4Mbps.
|
||||
#
|
||||
kill -s 9 `pidof hciattach`
|
||||
kill -9 $(pidof hciattach)
|
||||
fi
|
||||
TRIES="${TRIES}1"
|
||||
done
|
||||
if [ "${TRIES}" == "${MAX_TRIES}" ] ; then
|
||||
[ -z "${quietboot}" ] && echo "${SCRIPTNAME}: FAILED (hciattach)"
|
||||
exit
|
||||
if [ "${TRIES}" = "${MAX_TRIES}" ]; then
|
||||
echo "${SCRIPTNAME}: FAILED (hciattach)"
|
||||
exit
|
||||
fi
|
||||
BT_FILTER_ARGS="-d -x -s -w wlan0"
|
||||
BT_FILTER_ARGS="-b -x -s -w wlan0"
|
||||
if ! abtfilt ${BT_FILTER_ARGS} 1>/dev/null; then
|
||||
[ -z "${quietboot}" ] && echo "${SCRIPTNAME}: FAILED (abtfilt)"
|
||||
echo "${SCRIPTNAME}: FAILED (abtfilt)"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
[ -z "${quietboot}" ] && echo "Starting bluetooth services."
|
||||
echo "Starting bluetooth services."
|
||||
|
||||
# Initialize driver for 'ccardwmx28js'
|
||||
read -r platform < /sys/kernel/machine/name
|
||||
[ "${platform}" = "ccardimx28" ] && ccardwmx28js_bt_init
|
||||
[ "$(cat /sys/kernel/machine/name)" = "ccardimx28" ] && ccardwmx28js_bt_init
|
||||
|
||||
# Run bluetooth daemon
|
||||
if hciconfig hci0 up && bluetoothd; then
|
||||
: # No-op
|
||||
else
|
||||
[ -z "${quietboot}" ] && echo "${SCRIPTNAME}: FAILED"
|
||||
echo "${SCRIPTNAME}: FAILED"
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue