This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BlueZ and CC2540 HCI mode

Other Parts Discussed in Thread: CC2540

Hi there,

I am trying to use CC2540 on Linux with Bluez. I loaded the HostTestApp to my USB dongle and then connect it to my Ubuntu Linux running version 13.04

> sudo hciattach -n /dev/ttyACM0 any 115200

> sudo hciconfig hci0 lestates

These commands work. But I was unable to use "hcitool lescan", it said "Set scan parameters failed: Connection timed out".

Anyone tried before?

--YC

  • Hi YC,

    Try with the attached hex file maybe. It has only the Controller, not Host as well.

    Best regards,
    Aslak 

    HCITestApp_USBController_CC2540.hex
  • Hi Aslak,

    Thanks for your file. It did not work, too. It said,

    LE Scan ...

    Could not receive advertising events: Broken pipe

    --YC

  • That's unfortunate. Sadly I don't have a linux machine to try this out on. Perhaps you could look through the source code for BlueZ for Broken pipe. I don't know what caused this, or even if the Controller only image will work with BlueZ.

  • Aslak,

    Whenever i run lescan using this firmware, the dongle gets disconnected, which is why the boken pipe error. The only way to reconnect the dongle back is to remove and then plug it back in. I will try it again with hcidump to pinpoint the exact command which causes this to happen.

  • Its the hci_le_set_scan_enable command which disconnects the dongle. This can be easily tested on windows machine using HCI tester tool. just connect the dongle, open hci tester, select hci_le_set_scan_enable, change "LE Scan Enable" property to enable and just send it. This will result in the dongle being disconnected from the system.

  •  bluez-5.8 # strace -x -f -ff -o /dev/shm/x hcitool lescan
    Set scan parameters failed: Input/output error
    

     
    
    
    
    serach the source file hcitool.c of bluez-5.8 shows it is codes from line 2579 to 2584 that trigger the error:
    2579         err = hci_le_set_scan_parameters(dd, scan_type, interval, window,
    2580                                                 own_type, filter_policy, 1000);
    2581         if (err < 0) {
    2582                 perror("Set scan parameters failed");
    2583                 exit(1);
    2584         }
    

    there might be some parameter incompatible for the c

    bluez-5.8 # cat /dev/shm/x.6663
    execve("/usr/bin/hcitool", ["hcitool", "lescan"], [/* 49 vars */]) = 0
    brk(0)                                  = 0x617000
    mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63de505000
    access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
    open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
    fstat(3, {st_mode=S_IFREG|0644, st_size=240042, ...}) = 0
    mmap(NULL, 240042, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f63de4ca000
    close(3)                                = 0
    open("/usr/lib64/libglib-2.0.so.0", O_RDONLY|O_CLOEXEC) = 3
    read(3, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x3e\x00\x01\x00\x00\x00\x90\xcf\x01\x00\x00\x00\x00\x00"..., 832) = 832
    fstat(3, {st_mode=S_IFREG|0755, st_size=1237960, ...}) = 0
    mmap(NULL, 3335488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f63ddfb6000
    mprotect(0x7f63de0e3000, 2093056, PROT_NONE) = 0
    mmap(0x7f63de2e2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12c000) = 0x7f63de2e2000
    mmap(0x7f63de2e4000, 1344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f63de2e4000
    close(3)                                = 0
    open("/usr/lib64/libudev.so.1", O_RDONLY|O_CLOEXEC) = 3
    read(3, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x3e\x00\x01\x00\x00\x00\x90\x3d\x00\x00\x00\x00\x00\x00"..., 832) = 832
    fstat(3, {st_mode=S_IFREG|0755, st_size=71552, ...}) = 0
    mmap(NULL, 2168912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f63ddda4000
    mprotect(0x7f63dddb5000, 2093056, PROT_NONE) = 0
    mmap(0x7f63ddfb4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10000) = 0x7f63ddfb4000
    close(3)                                = 0
    open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
    read(3, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x3e\x00\x01\x00\x00\x00\x10\x4d\x02\x00\x00\x00\x00\x00"..., 832) = 832
    fstat(3, {st_mode=S_IFREG|0755, st_size=1732824, ...}) = 0
    mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63de4c9000
    mmap(NULL, 3844600, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f63dd9f9000
    mprotect(0x7f63ddb9a000, 2097152, PROT_NONE) = 0
    mmap(0x7f63ddd9a000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a1000) = 0x7f63ddd9a000
    mmap(0x7f63ddda0000, 14840, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f63ddda0000
    close(3)                                = 0
    open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
    read(3, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x3e\x00\x01\x00\x00\x00\x10\x7d\x00\x00\x00\x00\x00\x00"..., 832) = 832
    fstat(3, {st_mode=S_IFREG|0755, st_size=134922, ...}) = 0
    mmap(NULL, 2212816, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f63dd7dc000
    mprotect(0x7f63dd7f3000, 2097152, PROT_NONE) = 0
    mmap(0x7f63dd9f3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7f63dd9f3000
    mmap(0x7f63dd9f5000, 13264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f63dd9f5000
    close(3)                                = 0
    open("/lib64/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
    read(3, "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x3e\x00\x01\x00\x00\x00\xb0\x28\x00\x00\x00\x00\x00\x00"..., 832) = 832
    fstat(3, {st_mode=S_IFREG|0755, st_size=31600, ...}) = 0
    mmap(NULL, 2128920, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f63dd5d4000
    mprotect(0x7f63dd5db000, 2093056, PROT_NONE) = 0
    mmap(0x7f63dd7da000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7f63dd7da000
    close(3)                                = 0
    mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63de4c8000
    mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63de4c7000
    mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63de4c6000
    arch_prctl(ARCH_SET_FS, 0x7f63de4c7700) = 0
    mprotect(0x7f63ddd9a000, 16384, PROT_READ) = 0
    mprotect(0x7f63dd9f3000, 4096, PROT_READ) = 0
    mprotect(0x7f63dd7da000, 4096, PROT_READ) = 0
    mprotect(0x7f63ddfb4000, 4096, PROT_READ) = 0
    mprotect(0x7f63de2e2000, 4096, PROT_READ) = 0
    mprotect(0x613000, 4096, PROT_READ)     = 0
    mprotect(0x7f63de506000, 4096, PROT_READ) = 0
    munmap(0x7f63de4ca000, 240042)          = 0
    set_tid_address(0x7f63de4c79d0)         = 6663
    set_robust_list(0x7f63de4c79e0, 24)     = 0
    futex(0x7ffff3752f60, FUTEX_WAKE_PRIVATE, 1) = 0
    futex(0x7ffff3752f60, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, 7f63de4c7700) = -1 EAGAIN (Resource temporarily unavailable)
    rt_sigaction(SIGRTMIN, {0x7f63dd7e37a0, [], SA_RESTORER|SA_SIGINFO, 0x7f63dd7ec6b0}, NULL, 8) = 0
    rt_sigaction(SIGRT_1, {0x7f63dd7e3830, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7f63dd7ec6b0}, NULL, 8) = 0
    rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
    getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
    socket(PF_BLUETOOTH, SOCK_RAW|SOCK_CLOEXEC, 1) = 3
    brk(0)                                  = 0x617000
    brk(0x638000)                           = 0x638000
    ioctl(3, HCIGETDEVLIST, 0x617010)       = 0
    ioctl(3, HCIGETDEVINFO, 0x7ffff3752e20) = 0
    close(3)                                = 0
    socket(PF_BLUETOOTH, SOCK_RAW|SOCK_CLOEXEC, 1) = 3
    bind(3, {sa_family=AF_BLUETOOTH, sa_data="\x00\x00\x00\x00\x00\x00\xba\x8e\x40\x00\x00\x00\x00\x00"}, 6) = 0
    getsockopt(3, SOL_IP, IP_TTL, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", [16]) = 0
    setsockopt(3, SOL_IP, IP_TTL, "\x10\x00\x00\x00\x01\xc0\x00\x00\x00\x00\x00\x40\x0b\x20\x00\x00", 16) = 0
    writev(3, [{"\x01", 1}, {"\x0b\x20\x07", 3}, {"\x01\x10\x00\x10\x00\x00\x00", 7}], 3) = 11
    poll([{fd=3, events=POLLIN}], 1, 1000)  = 1 ([{fd=3, revents=POLLIN}])
    read(3, "\x04\x0e\x04\x01\x0b\x20\x0c", 260) = 7
    setsockopt(3, SOL_IP, IP_TTL, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16) = 0
    dup(2)                                  = 4
    fcntl(4, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
    fstat(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
    mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f63de504000
    lseek(4, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
    write(4, "Set scan parameters failed: Inpu"..., 47) = 47
    close(4)                                = 0
    munmap(0x7f63de504000, 4096)            = 0
    exit_group(1)                           = ?
    +++ exited with 1 +++
    

    c2540 hic.

    25782579         err = hci_le_set_scan_parameters(dd, scan_type, interval, window,2580                                                 own_type, filter_policy, 1000);2581         if (err < 0) {2582                 perror("Set scan parameters failed");2583                 exit(1);2584         }

  • BlueZ and CC2540 HCI mode are not compatible. TI`s HCI protocol is proprietary. You will need to port HostTestApp which comes with BLE stack to Linux to make this work.