Minimalistic Linux Kernel not compiling - linux

I want to compile an own minimalistic Linux Kernel with make tinyconfig and after doing all steps (like here:)
I get this error message:
arch/x86/kernel/apic/apic.c:2282:6: error: redefinition of ‘apic_id_disabled’
bool apic_id_disabled(unsigned int id)
^~~~~~~~~~~~~~~~
In file included from arch/x86/kernel/apic/apic.c:47:0:
./arch/x86/include/asm/apic.h:529:20: note: previous definition of ‘apic_id_disabled’ was here
static inline bool apic_id_disabled(unsigned int id) { return false; }
^~~~~~~~~~~~~~~~
scripts/Makefile.build:330: recipe for target 'arch/x86/kernel/apic/apic.o' failed
make[6]: *** [arch/x86/kernel/apic/apic.o] Error 1
scripts/Makefile.build:604: recipe for target 'arch/x86/kernel/apic' failed
make[5]: *** [arch/x86/kernel/apic] Error 2
scripts/Makefile.build:604: recipe for target 'arch/x86/kernel' failed
make[4]: *** [arch/x86/kernel] Error 2
Makefile:1077: recipe for target 'arch/x86' failed
make[3]: *** [arch/x86] Error 2
make[3]: Verzeichnis „/home/lukas/kernel/linux-source-4.15.0“ wird verlassen
debian/ruleset/targets/common.mk:295: recipe for target 'debian/stamp/build/kernel' failed
make[2]: *** [debian/stamp/build/kernel] Error 2
make[2]: Verzeichnis „/home/lukas/kernel/linux-source-4.15.0“ wird verlassen
debian/ruleset/common/targets.mk:242: recipe for target 'debian/stamp/do-build-arch' failed
make[1]: *** [debian/stamp/do-build-arch] Error 2
make[1]: Verzeichnis „/home/lukas/kernel/linux-source-4.15.0“ wird verlassen
dpkg-buildpackage: Fehler: debian/rules build Unterprozess gibt Abbruchstatus 2 zurück
debian/ruleset/targets/common.mk:401: recipe for target 'debian/stamp/build/buildpackage' failed
make: *** [debian/stamp/build/buildpackage] Error 2
Thank you in advance

#ifdef CONFIG_SMP
535 bool apic_id_is_primary_thread(unsigned int id);
536 bool apic_id_disabled(unsigned int id);
537 #else
538 static inline bool apic_id_is_primary_thread(unsigned int id) { return false; }
539 static inline bool apic_id_disabled(unsigned int id) { return false; }
540 #endif
actually you can see the conflict code in /arch/x86/include/asm/apic.h
from these code, enable SMP in your config is the easiest way to fix this problem.
PROCESS:
make menuconfig
-> Processor type and features
enable [Symmetric multi-processing support] there
then
make -j8 # will compile successfully now

Related

Error building CXX object gnuradio-runtime

I am trying to install a specific version of gnuradio (3.7.10.1). To do so I am not using Pybombs, but I try to do it from source (I am following this).
First I've cloned the github repository, then checkout the appropriate version. It worked fine until I've tried to invoke CMake and build GNU Radio:
mkdir build
cd build
cmake ../
make
During the make, after 6% done, I have the following error:
In file included from /usr/include/c++/7/type_traits:35:0,
from /usr/include/cppunit/tools/StringHelper.h:7,
from /usr/include/cppunit/TestAssert.h:8,
from /usr/include/cppunit/TestCase.h:6,
from /usr/include/cppunit/TestCaller.h:5,
from /usr/include/cppunit/extensions/HelperMacros.h:9,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/c++/7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^~~~~
In file included from /usr/include/cppunit/TestAssert.h:8:0,
from /usr/include/cppunit/TestCase.h:6,
from /usr/include/cppunit/TestCaller.h:5,
from /usr/include/cppunit/extensions/HelperMacros.h:9,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/tools/StringHelper.h:22:15: error: ‘enable_if’ in namespace ‘std’ does not name a template type
typename std::enable_if<!std::is_enum<T>::value, std::string>::type toString(const T& x)
^~~~~~~~~
/usr/include/cppunit/tools/StringHelper.h:22:24: error: expected unqualified-id before ‘<’ token
typename std::enable_if<!std::is_enum<T>::value, std::string>::type toString(const T& x)
^
/usr/include/cppunit/tools/StringHelper.h:31:15: error: ‘enable_if’ in namespace ‘std’ does not name a template type
typename std::enable_if<std::is_enum<T>::value, std::string>::type toString(const T& x)
^~~~~~~~~
/usr/include/cppunit/tools/StringHelper.h:31:24: error: expected unqualified-id before ‘<’ token
typename std::enable_if<std::is_enum<T>::value, std::string>::type toString(const T& x)
In file included from /usr/include/cppunit/TestCase.h:6:0,
from /usr/include/cppunit/TestCaller.h:5,
from /usr/include/cppunit/extensions/HelperMacros.h:9,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/TestAssert.h: In static member function ‘static std::__cxx11::string CppUnit::assertion_traits<T>::toString(const T&)’:
/usr/include/cppunit/TestAssert.h:74:42: error: ‘toString’ is not a member of ‘CppUnit::StringHelper’
return CPPUNIT_NS::StringHelper::toString(x);
^~~~~~~~
In file included from /usr/include/cppunit/extensions/HelperMacros.h:9:0,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/TestCaller.h: At global scope:
/usr/include/cppunit/TestCaller.h:159:37: error: ‘std::function’ has not been declared
TestCaller(std::string name, std::function<void()> test_function, Fixture* fixture):
^~~~~~~~
/usr/include/cppunit/TestCaller.h:159:45: error: expected ‘,’ or ‘...’ before ‘<’ token
TestCaller(std::string name, std::function<void()> test_function, Fixture* fixture):
^
/usr/include/cppunit/TestCaller.h:200:8: error: ‘function’ in namespace ‘std’ does not name a template type
std::function<void()> m_test_function;
^~~~~~~~
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, CppUnit::TestCaller<Fixture>::TestMethod)’:
/usr/include/cppunit/TestCaller.h:121:6: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
m_test_function( std::bind(test, m_fixture) )
^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:121:28: error: ‘bind’ is not a member of ‘std’
m_test_function( std::bind(test, m_fixture) )
^~~~
/usr/include/cppunit/TestCaller.h:121:28: note: suggested alternative: ‘find’
m_test_function( std::bind(test, m_fixture) )
^~~~
find
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, CppUnit::TestCaller<Fixture>::TestMethod, Fixture&)’:
/usr/include/cppunit/TestCaller.h:138:6: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
m_test_function( std::bind(test, &fixture) )
^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:138:28: error: ‘bind’ is not a member of ‘std’
m_test_function( std::bind(test, &fixture) )
^~~~
/usr/include/cppunit/TestCaller.h:138:28: note: suggested alternative: ‘find’
m_test_function( std::bind(test, &fixture) )
^~~~
find
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, CppUnit::TestCaller<Fixture>::TestMethod, Fixture*)’:
/usr/include/cppunit/TestCaller.h:155:6: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
m_test_function( std::bind(test, fixture) )
^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:155:28: error: ‘bind’ is not a member of ‘std’
m_test_function( std::bind(test, fixture) )
^~~~
/usr/include/cppunit/TestCaller.h:155:28: note: suggested alternative: ‘find’
m_test_function( std::bind(test, fixture) )
^~~~
find
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, int)’:
/usr/include/cppunit/TestCaller.h:162:17: error: ‘fixture’ was not declared in this scope
m_fixture(fixture),
^~~~~~~
/usr/include/cppunit/TestCaller.h:162:17: note: suggested alternative: ‘Fixture’
m_fixture(fixture),
^~~~~~~
Fixture
/usr/include/cppunit/TestCaller.h:163:7: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
m_test_function(test_function)
^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:163:23: error: ‘test_function’ was not declared in this scope
m_test_function(test_function)
^~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h: In member function ‘void CppUnit::TestCaller<Fixture>::runTest()’:
/usr/include/cppunit/TestCaller.h:175:7: error: there are no arguments to ‘m_test_function’ that depend on a template parameter, so a declaration of ‘m_test_function’ must be available [-fpermissive]
m_test_function();
^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:175:7: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
In file included from /usr/include/cppunit/extensions/HelperMacros.h:14:0,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/extensions/TestNamer.h: In member function ‘std::__cxx11::string CppUnit::TestNamer::getTestNameFor(const string&, const E&) const’:
/usr/include/cppunit/extensions/TestNamer.h:70:95: error: ‘toString’ is not a member of ‘CppUnit::StringHelper’
return getTestNameFor(testMethodName) + " with parameter: " + CPPUNIT_NS::StringHelper::toString(val);
^~~~~~~~
In file included from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26:0,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h: In static member function ‘static CppUnit::TestSuite* qa_fxpt::suite()’:
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:36:3: error: ‘unique_ptr’ is not a member of ‘std’
CPPUNIT_TEST_SUITE_END();
^
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:36:3: error: expected primary-expression before ‘>’ token
CPPUNIT_TEST_SUITE_END();
^
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:36:3: error: ‘guard’ was not declared in this scope
CPPUNIT_TEST_SUITE_END();
^
In file included from /usr/include/cppunit/extensions/HelperMacros.h:9:0,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/TestCaller.h: In instantiation of ‘void CppUnit::TestCaller<Fixture>::runTest() [with Fixture = qa_fxpt]’:
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:102:1: required from here
/usr/include/cppunit/TestCaller.h:175:22: error: ‘m_test_function’ was not declared in this scope
m_test_function();
~~~~~~~~~~~~~~~^~
/usr/include/cppunit/TestCaller.h:175:22: note: suggested alternative: ‘__fortify_function’
m_test_function();
~~~~~~~~~~~~~~~^~
__fortify_function
gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/build.make:62: recipe for target 'gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/math/qa_fxpt.cc.o' failed
make[2]: *** [gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/math/qa_fxpt.cc.o] Error 1
CMakeFiles/Makefile2:726: recipe for target 'gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/all' failed
make[1]: *** [gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
I am not a Linux expert and I am not very familiar to this compiler/library support. I don't really understand where the error comes from and how to correct it.
I use Ubuntu 18.04.
Coud you give me a hand on this please?
Any help would be very appreciated.
Thanks a lot.
/usr/include/c++/7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
To resolve the above error you need to compile with -std=c++11 flag. Open CMakeLists.txt, find all occurrences or -std=c++98 and change them to -std=c++11. Then go to the build directory, remove CMakeCache.txt and rebuild
sed -i 's/-std=c++98/-std=c++11/g' CMakeLists.txt
cd build
rm CMakeCache.txt
cmake ..
make
Also as the error is in the cppunit and it's used for testing you can try disabling all tests
cd build
rm CMakeCache.txt
cmake -DENABLE_TESTING=OFF ..
make

kernel demo build error

In my limited experience with kernel program, my os is Ubuntu16.04,and use sudo apt-get install linux-headers-`uname -r` to install kernel header,and the kernel_hello.c file is
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("DUAL BSD/GPL")
MODULE_AUTHOR("YANQIN")
MODULE_DESCRIPTION("kernel module hello")
MODULE_VERSION("1.0")
static int hello_init(void)
{
printk(KERN_ALERT "hello_init() start\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "hello_exit() start\n");
}
module_init(hello_init);
module_exit(hello_exit);
and the Makefile is
KERNAL_DIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
obj-m := kernel_hello.o
default:
$(MAKE) -C $(KERNAL_DIR) M=$(PWD) modules
but the build result is like this
yq#ubuntu:~/kernelProgram$ make
make -C /lib/modules/4.10.0-28-generic/build M=/home/yq/kernelProgram modules
make[1]: Entering directory '/usr/src/linux-headers-4.10.0-28-generic'
CC [M] /home/yq/kernelProgram/kernel_hello.o
In file included from ./include/linux/module.h:18:0,
from /home/yq/kernelProgram/kernel_hello.c:2:
./include/linux/moduleparam.h:21:1: error: expected ‘,’ or ‘;’ before ‘static’
static const char __UNIQUE_ID(name)[] \
^
./include/linux/module.h:161:32: note: in expansion of macro ‘__MODULE_INFO’
#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
^
/home/yq/kernelProgram/kernel_hello.c:6:1: note: in expansion of macro ‘MODULE_AUTHOR’
MODULE_AUTHOR("YANQIN")
^
In file included from /home/yq/kernelProgram/kernel_hello.c:2:0:
/home/yq/kernelProgram/kernel_hello.c: In function ‘__inittest’:
/home/yq/kernelProgram/kernel_hello.c:19:13: error: ‘hello_init’ undeclared (first use in this function)
module_init(hello_init);
^
./include/linux/module.h:131:11: note: in definition of macro ‘module_init’
{ return initfn; } \
^
/home/yq/kernelProgram/kernel_hello.c: At top level:
./include/linux/module.h:132:6: error: ‘init_module’ aliased to undefined symbol ‘hello_init’
int init_module(void) __attribute__((alias(#initfn)));
^
/home/yq/kernelProgram/kernel_hello.c:19:1: note: in expansion of macro
‘module_init’
module_init(hello_init);
^
scripts/Makefile.build:301: recipe for target
'/home/yq/kernelProgram/kernel_hello.o' failed
make[2]: *** [/home/yq/kernelProgram/kernel_hello.o] Error 1
Makefile:1524: recipe for target '_module_/home/yq/kernelProgram' failed
make[1]: *** [_module_/home/yq/kernelProgram] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.10.0-28-generic'
Makefile:7: recipe for target 'default' failed
make: *** [default] Error 2
i don't know why it saids the linux kernel header has error
Calls to MODULE_LICENSE and other MODULE_* macros, which setup information about the module, should be terminated with ; like common C instructions

Compiling VNC Server Binary Files (error when running $make)

Hey folks I'm trying to compile a ELF binary server files from here:https://github.com/LibVNC/libvncserver
To do this I follow the steps here: (starting line 10 - 31). I set the NDK toolchains correctly and now I'm trying to run the $configure command
I'm using a 14.04 Ubuntu Machine.
The following command is succesful
$./configure --host=arm-eabi CC=arm-linux-androideabi-gcc
I then run
$make
and get the following error ($make clean ... doesn't help):
root#ip-172-31-35-74:~/Desktop/libvncserver-LibVNCServer-0.9.10#
root#ip-172-31-35-74:~/Desktop/libvncserver-LibVNCServer-0.9.10# make
make all-recursive
make[1]: Entering directory `/home/ubuntu/Desktop/libvncserver-LibVNCServer-0.9.10'
Making all in libvncserver
make[2]: Entering directory `/home/ubuntu/Desktop/libvncserver-LibVNCServer-0.9.10/libvncserver'
CC main.lo
CC rfbserver.lo
rfbserver.c: In function 'rfbProcessFileTransfer':
rfbserver.c:1690:69: warning: pointer targets in passing argument 1 of 'gmtime' differ in signedness [-Wpointer-sign]
strftime(timespec, sizeof(timespec), "%m/%d/%Y %H:%M",gmtime(&statbuf.st_ctime));
^
In file included from rfbserver.c:87:0:
/tmp/my-android-toolchain/sysroot/usr/include/time.h:76:20: note: expected 'const time_t *' but argument is of type 'long unsigned int *'
extern struct tm* gmtime(const time_t *timep);
^
CC rfbregion.lo
CC auth.lo
CC sockets.lo
CC websockets.lo
CC rfbssl_none.lo
CC rfbcrypto_included.lo
In file included from rfbcrypto_included.c:25:0:
../common/md5.h: In function '__md5_init_ctx':
../common/md5.h:101:50: error: expected declaration specifiers before '__THROW'
extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW;
^
../common/md5.h:108:39: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW'
struct md5_ctx *ctx) __THROW;
^
../common/md5.h:115:39: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW'
struct md5_ctx *ctx) __THROW;
^
../common/md5.h:124:67: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW'
extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW;
^
../common/md5.h:133:71: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW'
extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
^
../common/md5.h:139:56: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW'
extern int __md5_stream (FILE *stream, void *resblock) __THROW;
^
../common/md5.h:146:32: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW'
void *resblock) __THROW;
^
In file included from rfbcrypto_included.c:26:0:
../common/sha1.h:62:1: warning: empty declaration
enum
^
../common/sha1.h:89:3: error: storage class specified for parameter 'SHA1Context'
} SHA1Context;
^
../common/sha1.h:94:17: error: expected declaration specifiers or '...' before 'SHA1Context'
int SHA1Reset( SHA1Context *);
^
../common/sha1.h:95:17: error: expected declaration specifiers or '...' before 'SHA1Context'
int SHA1Input( SHA1Context *,
^
../common/sha1.h:98:17: error: expected declaration specifiers or '...' before 'SHA1Context'
int SHA1Result( SHA1Context *,
^
rfbcrypto_included.c:30:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
rfbcrypto_included.c:41:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
In file included from rfbcrypto_included.c:25:0:
../common/md5.h:101:13: error: old-style parameter declarations in prototyped function definition
extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW;
^
rfbcrypto_included.c:49:1: error: expected '{' at end of input
}
^
make[2]: *** [rfbcrypto_included.lo] Error 1
make[2]: Leaving directory `/home/ubuntu/Desktop/libvncserver-LibVNCServer-0.9.10/libvncserver'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ubuntu/Desktop/libvncserver-LibVNCServer-0.9.10'
make: *** [all] Error 2
root#ip-172-31-35-74:~/Desktop/libvncserver-LibVNCServer-0.9.10#
root#ip-172-31-35-74:~/Desktop/libvncserver-LibVNCServer-0.9.10#

BlueZ scotest App and with Linux Config Can't Connect to SCO Socket

I am using BlueZ 4.101 on an embedded Linux project with Kernel 3.4.79+. Normal Bluetooth operations work great and I can use many headset with my device to transfer Audio. Now I am working towards Bluetooth Compliance and so I am using the Bluetooth SIG's USB PTS Dongle. I am passing every test except for part of the incoming call test where I need to open the SCO connection after accepting a call with the PTS dongle.
The SCO connection attempt works with the headsets but not with the PTS dongle. The error is given from bluetoothd as:
bluetoothd[6306]: audio/headset.c:headset_set_state() State changed /org/bluez/6306/hci0/dev_00_1B_DC_07_30_40: HEADSET_STATE_PLAY_IN_PROGRESS -> HEADSET_STATE_CONNECTED
bluetoothd[6306]: audio/headset.c:headset_set_state() State changed /org/bluez/6306/hci0/dev_00_1B_DC_07_30_40: HEADSET_STATE_CONNECTED -> HEADSET_STATE_PLAY_IN_PROGRESS
bluetoothd[6306]: Protocol not supported (93)
So I compiled scotest from the test directory of BlueZ and ran that after connecting with the dongle and got the same result:
# ./scotest -s -b HELLO 00:1B:DC:07:30:40
scotest[1687]: Can't connect: Protocol not supported (93)
scotest[1687]: Can't connect to the server: Protocol not supported (93)
Here is the do_connect function in scotest.c that is failing in:
static int do_connect(char *svr)
{
struct sockaddr_sco addr;
struct sco_conninfo conn;
socklen_t optlen;
int sk;
/* Create socket */
sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
if (sk < 0) {
syslog(LOG_ERR, "Can't create socket: %s (%d)",
strerror(errno), errno);
return -1;
}
/* Bind to local address */
memset(&addr, 0, sizeof(addr));
addr.sco_family = AF_BLUETOOTH;
bacpy(&addr.sco_bdaddr, &bdaddr);
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
syslog(LOG_ERR, "Can't bind socket: %s (%d)",
strerror(errno), errno);
goto error;
}
/* Connect to remote device */
memset(&addr, 0, sizeof(addr));
addr.sco_family = AF_BLUETOOTH;
str2ba(svr, &addr.sco_bdaddr);
if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
syslog(LOG_ERR, "Can't connect: %s (%d)",
strerror(errno), errno);
goto error;
}
/* Get connection information */
memset(&conn, 0, sizeof(conn));
optlen = sizeof(conn);
if (getsockopt(sk, SOL_SCO, SCO_CONNINFO, &conn, &optlen) < 0) {
syslog(LOG_ERR, "Can't get SCO connection information: %s (%d)",
strerror(errno), errno);
goto error;
}
syslog(LOG_INFO, "Connected [handle %d, class 0x%02x%02x%02x]",
conn.hci_handle,
conn.dev_class[2], conn.dev_class[1], conn.dev_class[0]);
return sk;
error:
close(sk);
return -1;
}
What am I missing in the Kernel Config to allow the PTS dongle to be put into a Playing state with an open SCO connection?
Here is my .config for Linux ( I'm using backports-3.13.2-1 to support the TI WL1271 BT/WiFi module ):
CPTCFG_IPV6_SUBTREES=y
CPTCFG_NFT_RBTREE=m
CPTCFG_BRIDGE_NF_EBTABLES=m
CPTCFG_BRIDGE_EBT_BROUTE=m
CPTCFG_BRIDGE_EBT_T_FILTER=m
CPTCFG_BRIDGE_EBT_T_NAT=m
CPTCFG_BRIDGE_EBT_802_3=m
CPTCFG_BRIDGE_EBT_AMONG=m
CPTCFG_BRIDGE_EBT_ARP=m
CPTCFG_BRIDGE_EBT_IP=m
CPTCFG_BRIDGE_EBT_IP6=m
CPTCFG_BRIDGE_EBT_LIMIT=m
CPTCFG_BRIDGE_EBT_MARK=m
CPTCFG_BRIDGE_EBT_PKTTYPE=m
CPTCFG_BRIDGE_EBT_STP=m
CPTCFG_BRIDGE_EBT_VLAN=m
CPTCFG_BRIDGE_EBT_ARPREPLY=m
CPTCFG_BRIDGE_EBT_DNAT=m
CPTCFG_BRIDGE_EBT_MARK_T=m
CPTCFG_BRIDGE_EBT_REDIRECT=m
CPTCFG_BRIDGE_EBT_SNAT=m
CPTCFG_BRIDGE_EBT_LOG=m
CPTCFG_BRIDGE_EBT_NFLOG=m
CPTCFG_MAC_EMUMOUSEBTN=m
CPTCFG_RTLBTCOEXIST=m
CPTCFG_TABLET_USB_KBTAB=m
CPTCFG_INPUT_ATLAS_BTNS=m
CPTCFG_SND_BT87X=m
CPTCFG_LIRC_BT829=m
CPTCFG_USB_BTMTK=m
CPTCFG_TOSHIBA_BT_RFKILL=m
CPTCFG_BTRFS_FS=m
CPTCFG_BTRFS_FS_POSIX_ACL=y
CPTCFG_RBTREE_TEST=m
CPTCFG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y
CPTCFG_BTREE=y
CPTCFG_BACKPORT_OPTION_BT_SOCK_CREATE_NEEDS_KERN=y
CPTCFG_BT=m
CPTCFG_BT_RFCOMM=m
# CPTCFG_BT_RFCOMM_TTY is not set
CPTCFG_BT_BNEP=m
CPTCFG_BT_BNEP_MC_FILTER=y
CPTCFG_BT_BNEP_PROTO_FILTER=y
# CPTCFG_BT_CMTP is not set
CPTCFG_BT_HIDP=m
CPTCFG_BT_HCIBTUSB=m
CPTCFG_BT_HCIBTSDIO=m
CPTCFG_BT_HCIUART=m
CPTCFG_BT_HCIUART_H4=y
CPTCFG_BT_HCIUART_BCSP=y
# CPTCFG_BT_HCIUART_ATH3K is not set
CPTCFG_BT_HCIUART_LL=y
CPTCFG_BT_HCIUART_3WIRE=y
# CPTCFG_BT_HCIBCM203X is not set
# CPTCFG_BT_HCIBPA10X is not set
# CPTCFG_BT_HCIBFUSB is not set
# CPTCFG_BT_HCIDTL1 is not set
# CPTCFG_BT_HCIBT3C is not set
# CPTCFG_BT_HCIBLUECARD is not set
CPTCFG_BT_HCIBTUART=m
CPTCFG_BT_HCIVHCI=m
# CPTCFG_BT_MRVL is not set
# CPTCFG_BT_ATH3K is not set
CPTCFG_BT_WILINK=m
I instrumented the sco.c file in the kernel with printks.
On success with a normal headset it looks like this after successfully opening SCO connection:
*** sco_sock_create
*** sco_sock_alloc
*** sco_sock_init
*** sco_sock_bind
*** sco_sock_connect
*** sco_connect
*** sco_conn_add
*** sco_chan_add
*** __sco_chan_add
*** sco_sock_set_timer
*** sco_connect_cfm
*** sco_conn_add
*** sco_conn_ready
*** sco_sock_clear_timer
*** sco_sock_getsockopt
*** sco_sock_setsockopt_old
*** sco_sock_getsockopt
*** sco_sock_setsockopt_old
*** sco_sock_sendmsg
*** sco_send_frame
*** sco_sock_sendmsg
*** sco_send_frame
*** sco_sock_sendmsg
*** sco_send_frame
On failure it looks like this:
*** sco_sock_create
*** sco_sock_alloc
*** sco_sock_init
*** sco_sock_bind
*** sco_sock_connect
*** sco_connect
*** sco_conn_add
*** sco_chan_add
*** __sco_chan_add
*** sco_sock_set_timer
*** sco_connect_cfm
*** sco_conn_del
*** sco_chan_get
*** sco_sock_clear_timer
*** sco_chan_del
*** sco_sock_release
*** sco_sock_close
*** sco_sock_kill
*** sco_sock_clear_timer
*** __sco_sock_connect
*** sco_sock_kill
*** sco_sock_kill
*** sco_sock_destruct
Further instrumentation shows the failures are happening in this sco.c function:
void sco_connect_cfm(struct hci_conn *hcon, __u8 status)
{
printk("*** sco_connect_cfm start\n");
BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status);
printk("*** sco_connect_cfm_stat hcon %p bdaddr %pMR status %d\n", hcon, &hcon->dst, status);
if (!status) {
struct sco_conn *conn;
conn = sco_conn_add(hcon);
printk("*** sco_connect_cfm sco_conn_add: %d\n",conn);
if (conn)
printk("*** sco_connect_cfm ready\n");
sco_conn_ready(conn);
} else
printk("*** sco_connect_delete: %d\n",status);
sco_conn_del(hcon, bt_to_errno(status));
}
That output looks like this:
*** sco_sock_create
*** sco_sock_alloc
*** sco_sock_init
*** sco_sock_bind
*** sco_sock_connect
*** sco_connect
*** sco_conn_add
*** sco_chan_add
*** __sco_chan_add
*** sco_sock_set_timer
*** sco_connect_cfm start
*** sco_connect_cfm_stat hcon d9ec2400 bdaddr 40:30:07:dc:1b:00 status 26
*** sco_connect_delete: 26
*** sco_conn_del
*** sco_chan_get
*** sco_sock_clear_timer
*** sco_chan_del
*** sco_sock_release
*** sco_sock_close
*** sco_sock_clear_timer
*** sco_sock_kill
*** __sco_sock_connect
*** sco_sock_kill
*** sco_sock_kill
*** sco_sock_destruct
The problem was not the configuration of the Kernel but rather the set of drivers I was using. I had compiled the linux backports ( http://drvbp1.linux-foundation.org/~mcgrof/rel-html/backports/) version of the bluetooth drivers, because I needed the backported wifi drivers, and that gave me the Protocol Not Supported (93) error. I switched back to the drivers distributed with the Kernel 3.4.79+ and it worked.

Kernel module with multiple files - unknown symbol

Hello stackoverflowers :)
For the last several hours I've been trying to compile+load a multiple file module. The compilation emits a strange warning and the module fails to load. Here are the module, Makefile, compilation output and dmesg.
header:
// header.h
#ifndef _HEADER_H
#define _HEADER_H
void do_module_func(void);
void do_other_func(void);
#endif
'main' module file:
//mymodule.c
#include <linux/module.h>
#include <linux/kernel.h>
#include "header.h"
void do_module_func(void)
{
printk(KERN_INFO "module_func\n");
}
static int mymodule_init(void)
{
printk(KERN_INFO "Hello world\n");
do_other_func();
return 0;
}
module_init(mymodule_init);
static void mymodule_exit(void)
{
printk(KERN_INFO "Goodbye, cruel world\n");
}
module_exit(mymodule_exit);
MODULE_LICENSE("GPL")
other c file, which calls do_module_func() that sits in the 'main' module
//other_file.c
#include "header.h"
#include <linux/kernel.h>
void do_other_func(void)
{
printk(KERN_INFO "other_func\n");
do_module_func();
}
Makefile
//Makefile
obj-m := mymodule.o
mymodule-objs := other_file.o
CROSS:=arm-unknown-linux-gnueabi-
KERNEL:= ~/work/linux-davinci-2.6.38/
ARCH:=arm
PWD:=$(shell pwd)
all:
$(MAKE) CROSS_COMPILE=$(CROSS) ARCH=$(ARCH) -C $(KERNEL) M=$(PWD) modules
clean:
$(MAKE) CROSS_COMPILE=$(CROSS) ARCH=$(ARCH) -C $(KERNEL) M=$(PWD) clean
I'm cross compiling but I believe this shouldn't be a problem.
make output:
make CROSS_COMPILE....
make[1]: Entering directory .../linux-davinci-2.6.38
CC [M] .../other_file.o
LD [M] .../mymodule.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: "do_module_func" [.../mymodule.o] undefined! <--- warning here
CC .../mymodule.mod.o
LD [M] .../mymodule.ko
make[1]: Leaving directory .../linux-davinci-2.6.38
insmod output:
can't insert 'mymodule.ko': unknown symbol in module, or unknown parameter
dmesg:
mymodule: Unknown symbol do_mdule_func (err 0)
Thus the module compiles with a (linkage?) warning and the module doesn't load.
Now, I see that in the make output there appears to be a linkage attempt after compiling other_file.c, but shouldn't there be a compilation of also mymodule.c before the linkage?
Thanks! :)
Turns out the problem was in the Makefile. The 'trick' is that you define in obj-m the module that will be compiled (into a .ko) and in the -objs you write all the source files.
Thus the definitions in this Makefile turn to:
obj-m := moduleko.o
moduleko-objs := other_file.o mymodule.o
and this is compiled into moduleko.ko.
This is because file_2 required file_1 symbol reference for building file_2 as LKM.
To overcome this, build file_1(LKM) and place the Module.symvers of file_1 in file_2 location. And build the file_2 again.
all:
$(MAKE) CROSS_COMPILE=$(CROSS) ARCH=$(ARCH) -C $(KERNEL) M=$(PWD) modules
instead try like this
$(MAKE) -C $(KERNEL) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS) M=$(PWD) /
this will run each file and links with object.hope this would solve your problem

Resources