[#5934] Attach uart based bluetooth HCI failed on bf537-stamp with ADZS-BFBLUET-EZEXT

Document created by Aaronwu Employee on Sep 10, 2013
Version 1Show Document
  • View in full screen mode

[#5934] Attach uart based bluetooth HCI failed on bf537-stamp with ADZS-BFBLUET-EZEXT

Submitted By: Vivi Li

Open Date

2010-02-26 04:39:03     Close Date

2010-04-11 23:34:23

Priority:

Medium     Assignee:

Mike Frysinger

Michael Hennerich

Status:

Closed     Fixed In Release:

N/A

Found In Release:

2010R1     Release:

Category:

Drivers     Board:

N/A

Processor:

BF537     Silicon Revision:

Is this bug repeatable?:

Yes     Resolution:

Fixed

Uboot version or rev.:

    Toolchain version or rev.:

gcc4.3-2010_Jan_22-svn3815

App binary format:

N/A     

Summary: Attach uart based bluetooth HCI failed on bf537-stamp with ADZS-BFBLUET-EZEXT

Details:

 

Attaching a UART based Bluetooth HCI failed on bf537-stamp with ADZS-BFBLUET-EZEXT card.

 

Last passed version:

--

kernel:    Linux release 2.6.32.6-ADI-2010R1-pre-svn8233, build #93 Wed Jan 27 04:06:08 GMT 2010

toolchain: bfin-uclinux-gcc release gcc version 4.3.4 (ADI-trunk/svn-3771)

user-dist: release svn-9413, build #1161 Wed Jan 27 03:57:25 GMT 2010

--

 

First failed version:

--

kernel:    Linux release 2.6.32.7-ADI-2010R1-pre-svn8261, build #4 Fri Jan 29 18:26:26 GMT 2010

toolchain: bfin-uclinux-gcc release gcc version 4.3.4 (ADI-trunk/svn-3815)

user-dist: release svn-9424, build #22 Fri Jan 29 18:25:32 GMT 2010

--

 

Bellow is the log:

--

Linux version 2.6.32.9-ADI-2010R1-pre-svn8339 (test@uclinux58-mmc-usblan-btuart) (gcc version 4.3.4 (ADI-trunk/svn-3815) ) #8 We0

register early platform devices

bootconsole [early_shadow0] enabled

bootconsole [early_BFuart0] enabled

early printk enabled on early_BFuart0

Limiting kernel memory to 56MB due to anomaly 05000263

Board Memory: 64MB

Kernel Managed Memory: 64MB

Memory map:

  fixedcode = 0x00000400-0x00000490

  text      = 0x00001000-0x001265d0

  rodata    = 0x001265d0-0x0018526c

  bss       = 0x00186000-0x00196d1c

  data      = 0x00196d1c-0x001aa000

    stack   = 0x001a8000-0x001aa000

  init      = 0x001aa000-0x0099c000

  available = 0x0099c000-0x03800000

  DMA Zone  = 0x03f00000-0x04000000

Hardware Trace Active and Enabled

Boot Mode: 0

Reset caused by Software reset

Blackfin support (C) 2004-2009 Analog Devices, Inc.

Compiled for ADSP-BF537 Rev 0.2

Blackfin Linux support by http://blackfin.uclinux.org/

Processor Speed: 500 MHz core clock and 125 MHz System Clock

NOMPU: setting up cplb tables

Instruction Cache Enabled for CPU0

  External memory: cacheable in instruction cache

Data Cache Enabled for CPU0

  External memory: cacheable (write-back) in data cache

Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 14224

Kernel command line: root=/dev/mtdblock0 rw clkin_hz=25000000 earlyprintk=serial,uart0,57600 console=ttyBF0,57600 ip=10.100.4.50f

PID hash table entries: 256 (order: -2, 1024 bytes)

Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)

Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)

Memory available: 46936k/65536k RAM, (8136k init code, 1173k kernel code, 527k data, 1024k dma, 7740k reserved)

Hierarchical RCU implementation.

NR_IRQS:138

Configuring Blackfin Priority Driven Interrupts

console [ttyBF0] enabled, bootconsole disabled

console [ttyBF0] enabled, bootconsole disabled

Calibrating delay loop... 997.37 BogoMIPS (lpj=1994752)

Security Framework initialized

Mount-cache hash table entries: 512

Blackfin Scratchpad data SRAM: 4 KB

Blackfin L1 Data A SRAM: 16 KB (16 KB free)

Blackfin L1 Data B SRAM: 16 KB (16 KB free)

Blackfin L1 Instruction SRAM: 48 KB (36 KB free)

NET: Registered protocol family 16

Blackfin DMA Controller

stamp_init(): registering device resources

bio: create slab <bio-0> at 0

Bluetooth: Core ver 2.15

NET: Registered protocol family 31

Bluetooth: HCI device and connection manager initialized

Bluetooth: HCI socket layer initialized

Switching to clocksource bfin_cs_cycles

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 2048 (order: 2, 16384 bytes)

TCP bind hash table entries: 2048 (order: 1, 8192 bytes)

TCP: Hash tables configured (established 2048 bind 2048)

TCP reno registered

NET: Registered protocol family 1

msgmni has been set to 91

io scheduler noop registered

io scheduler anticipatory registered (default)

io scheduler cfq registered

bfin-uart: Blackfin serial driver

bfin-uart.0: ttyBF0 at MMIO 0xffc00400 (irq = 18) is a BFIN-UART

bfin-uart.1: ttyBF1 at MMIO 0xffc02000 (irq = 20) is a BFIN-UART

brd: module loaded

bfin-spi bfin-spi.0: Blackfin on-chip SPI Controller Driver, Version 1.0, regs_base@ffc00500, dma channel@7

bfin_mii_bus: probed

bfin_mac: attached PHY driver [SMSC LAN83C185] (mii_bus:phy_addr=0:01, irq=-1, mdc_clk=2500000Hz(mdc_div=24)@sclk=125MHz)

bfin_mac bfin_mac.0: Blackfin on-chip Ethernet MAC driver, Version 1.1

rtc-bfin rtc-bfin: rtc core: registered rtc-bfin as rtc0

bfin-wdt: initialized: timeout=20 sec (nowayout=0)

Bluetooth: HCI UART driver ver 2.2

Bluetooth: HCI H4 protocol initialized

Bluetooth: HCI BCSP protocol initialized

TCP cubic registered

NET: Registered protocol family 17

Bluetooth: L2CAP ver 2.14

Bluetooth: L2CAP socket layer initialized

Bluetooth: SCO (Voice Link) ver 0.6

Bluetooth: SCO socket layer initialized

Bluetooth: RFCOMM TTY layer initialized

Bluetooth: RFCOMM socket layer initialized

Bluetooth: RFCOMM ver 1.11

Bluetooth: BNEP (Ethernet Emulation) ver 1.3

Bluetooth: BNEP filters: protocol multicast

Bluetooth: HIDP (Human Interface Emulation) ver 1.2

&IP-Config: Complete:tting system clock to 1970-01-13 11:33:23 UTC (1078403)

     device=eth0, addr=10.100.4.50, mask=255.255.255.0, gw=10.100.4.174,

     host=bf537-stamp, domain=, nis-domain=(none),

     bootserver=10.100.4.174, rootserver=10.100.4.174, rootpath=

Freeing unused kernel memory: 8136k freed

dma_alloc_init: dma_page @ 0x02a0b000 - 256 pages at 0x03f00000

                           _____________________________________

        a8888b.           / Welcome to the uClinux distribution \

       d888888b.         /       _     _                         \

       8P"YP"Y88        /       | |   |_|            __  __ (TM)  |

       8|o||o|88  _____/        | |    _ ____  _   _ \ \/ /       |

       8'    .88       \        | |   | |  _ \| | | | \  /        |

       8`._.' Y8.       \       | |__ | | | | | |_| | /  \        |

      d/      `8b.       \      \____||_|_| |_|\____|/_/\_\       |

     dP   .    Y8b.       \   For embedded processors including   |

    d8:'  "  `::88b        \    the Analog Devices Blackfin      /

   d8"         'Y88b        \___________________________________/

  :8P    '      :888

   8a.   :     _a88P         For further information, check out:

._/"Yaa_:   .| 88P|            - http://blackfin.uclinux.org/

\    YP"    `| 8P  `.          - http://docs.blackfin.uclinux.org/

/     \.___.d|    .'           - http://www.uclinux.org/

`--..__)8888P`._.'  jgs/a:f    - http://www.analog.com/blackfin

 

Have a lot of fun...

 

 

BusyBox v1.15.3 (2010-02-24 10:55:21 GMT) hush - the humble shell

 

root:/> PHY: 0:01 - Link is Up - 100/Full

 

root:/> iwrap_boot -b /dev/ttyBF1

root:/>

root:/> hcid -n &

[1] 173 hcid -n

root:/> hcid[173]: Bluetooth HCI daemon

 

root:/>

root:/> hciattach -n /dev/ttyBF1 bcsp &

[2] 174 hciattach -n /dev/ttyBF1 bcsp

root:/> BCSP initialization timed out

 

[2] Done                   hciattach -n /dev/ttyBF1 bcsp

root:/>

--

 

Follow-ups

 

--- Michael Hennerich                                        2010-03-18 09:38:57

Works pretty reliable for me.

Please make sure that SW5 1,2 are turned off.(SW5: OFF, OFF, X, X)

And that no other card is attached that may use the UART1 RX, TX pins for other

functions.

 

Also important to know - this stuff only works after power cycle ones.

If you use the reboot command after you used the iwrap_boot tool - successive

hciattach may fail.

This is due to the fact that on the 10-Pin STAMP UART connector is no signal

that can be used as card reset, without using the flow control capabilities.

  

 

root:/> version

kernel:    Linux release 2.6.33.1-ADI-2010R1-pre-svn8500, build #12328 Thu Mar

18 14:19:52 CET 2010

toolchain: bfin-linux-uclibc-gcc release gcc version 4.3.4

(ADI-trunk/svn-3951)

user-dist: release svn-9469, build #4422 Thu Mar 18 14:19:20 CET 2010

 

root:/> cat /proc/cpuinfo

processor       : 0

vendor_id       : Analog Devices

cpu family      : 0x27c8

model name      : ADSP-BF537 500(MHz CCLK) 125(MHz SCLK) (mpu off)

stepping        : 2

cpu MHz         : 500.000/125.000

bogomips        : 995.32

Calibration     : 497664000 loops

cache size      : 16 KB(L1 icache) 32 KB(L1 dcache) 0 KB(L2 cache)

dbank-A/B       : cache/cache

external memory : cacheable in instruction cache

external memory : cacheable (write-back) in data cache

icache setup    : 4 Sub-banks/4 Ways, 32 Lines/Way

dcache setup    : 2 Super-banks/4 Sub-banks/2 Ways, 64 Lines/Way

board name      : ADI BF537-STAMP

board memory    : 65536 kB (0x(null) -> 0x04000000)

kernel memory   : 57340 kB (0x00001000 -> 0x03800000)

 

root:/> 

 

root:/> hcid -n&

[1] 171 hcid -n

root:/> hcid[171]: Bluetooth HCI daemon

 

root:/> iwrap_boot -b /dev/ttyBF1

root:/> hciattach -n /dev/ttyBF1 bcsp &

[2] 173 hciattach -n /dev/ttyBF1 bcsp

root:/> hcid[171]: HCI dev 0 registered

hdev=0

bcsp_recv: Out-of-order packet arrived, got 1 expected 0

hcid[171]: HCI dev 0 up

hcid[171]: Starting security manager 0

 

root:/> hciconfig

hci0:   Type: UART

        BD Address: 00:07:80:89:8F:08 ACL MTU: 310:10 SCO MTU: 64:8

        UP RUNNING PSCAN ISCAN

        RX bytes:745 acl:0 sco:0 events:20 errors:0

        TX bytes:881 acl:0 sco:0 commands:19 errors:0

 

root:/> hcitool scan

Scanning ...

        00:25:56:D3:11:12       APELLKOF-L03

 

--- Vivi Li                                                  2010-03-19 05:26:03

I attach only ADZS-BFBLUET-EZEXT card to my 537-stamp board, no other add-on

boards. And reset board by re-plug power.

 

It still doesn't work with my latest image. But the same hardware can work with

my old image on 2010_Jan_26.

 

Bellow is BF537-STAMP settings:

Board version: 1.3

SW2, SW6: all ON

SW3, SW5: all OFF

SW4: 2 ON, other OFF

 

I also attach my latest image.

 

Bellow is the log:

--

root:/> iwrap_boot -b /dev/ttyBF1

root:/>

root:/>

root:/> hcid -n &

[1] 175 hcid -n

root:/> hcid[175]: Bluetooth HCI daemon

 

root:/>

root:/>

root:/>

root:/> hciattach -n /dev/ttyBF1 bcsp &

[2] 176 hciattach -n /dev/ttyBF1 bcsp

root:/> BCSP initialization timed out

 

[2] Done                   hciattach -n /dev/ttyBF1 bcsp

root:/>

root:/> version

kernel:    Linux release 2.6.33.1-ADI-2010R1-pre-svn8506, build #32 Fri Mar 19

15:04:20 GMT 2010

toolchain: bfin-uclinux-gcc release gcc version 4.3.4 (ADI-trunk/svn-3815)

user-dist: release svn-9515, build #595 Fri Mar 19 15:03:23 GMT 2010

root:/>

root:/> cat /proc/cpuinfo

processor       : 0

vendor_id       : Analog Devices

cpu family      : 0x27c8

model name      : ADSP-BF537 500(MHz CCLK) 125(MHz SCLK) (mpu off)

stepping        : 2

cpu MHz         : 500.000/125.000

bogomips        : 995.32

Calibration     : 497664000 loops

cache size      : 16 KB(L1 icache) 32 KB(L1 dcache) 0 KB(L2 cache)

dbank-A/B       : cache/cache

external memory : cacheable in instruction cache

external memory : cacheable (write-back) in data cache

icache setup    : 4 Sub-banks/4 Ways, 32 Lines/Way

dcache setup    : 2 Super-banks/4 Sub-banks/2 Ways, 64 Lines/Way

board name      : ADI BF537-STAMP

board memory    : 65536 kB (0x(null) -> 0x04000000)

kernel memory   : 57340 kB (0x00001000 -> 0x03800000)

 

root:/>

--

 

--- Michael Hennerich                                        2010-03-19 05:42:09

Your image doesn't work on my side as well.

Try attached one...

I try to figure out why yours doesn't work

 

--- Michael Hennerich                                        2010-03-19 05:51:30

looking at the kernel config file - I can't tell why yours issn't working.

But I notice that your trunk kernel is not up to date.

I use 2.6.33.1 while yours is 2.6.32.9

 

Can you update?

-Michael

 

 

--- Vivi Li                                                  2010-03-22 03:56:24

Hi, Michael

 

  Please refer to my last test log on 2010-03-19, linux version is already

2.6.33.1.

--

kernel:    Linux release 2.6.33.1-ADI-2010R1-pre-svn8506, build #32 Fri Mar 19

15:04:20 GMT 2010

toolchain: bfin-uclinux-gcc release gcc version 4.3.4 (ADI-trunk/svn-3815)

user-dist: release svn-9515, build #595 Fri Mar 19 15:03:23 GMT 2010

--

 

I attached my latest kernel config file. The old one was attached on Feb, so it

is not up to date.

 

The image you attached can work here, so please help to check with the configs.

 

--- Michael Hennerich                                        2010-03-22 04:33:46

It's not your kernel config - I build a kernel using your .config and it works

fine.

Can you post your uclinux-dist config?

-Michael

 

 

--- Vivi Li                                                  2010-03-22 04:51:48

I see. Attached is my user config.

 

--- Michael Hennerich                                        2010-03-22 05:44:08

I build kernel and user space using your config files - bluetooth HCI works ok

for me.

I take a look at your image again.

 

 

--- Vivi Li                                                  2010-03-22 06:33:56

I'm updating toolchain as mine is much older than yours.

I don't know if that would help.

 

--- Michael Hennerich                                        2010-03-22 06:49:14

My build of hciattach

 

root:/> strace hciattach -n /dev/ttyBF1 bcsp &

[2] 177 strace hciattach -n /dev/ttyBF1 bcsp

root:/> ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or

TCGETS, 0x2cabe48) = -1 ENOTTY (Inappropriate ioctl for device)

ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B57600 opost -isig -icanon -echo ...}) = 0

rt_sigaction(SIGALRM, {0x2ca0e60, [], SA_NOCLDSTOP}, NULL, 8) = 0

alarm(5)                                = 0

open("/dev/ttyBF1", O_RDWR|O_NOCTTY)    = 3

ioctl(3, TCFLSH, 0x2)                   = 0

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B115200 -opost -isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B115200 -opost

-isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B115200 -opost -isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B115200 -opost

-isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B115200 -opost -isig -icanon -echo ...}) = 0

ioctl(3, TCFLSH, 0x2)                   = 0

ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B115200 -opost

-isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B115200 -opost -isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B115200 -opost

-isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B115200 -opost -isig -icanon -echo ...}) = 0

alarm(0)                                = 5

rt_sigaction(SIGALRM, {0x2ca0b0c, [], SA_NOCLDSTOP}, NULL, 8) = 0

write(3, "\300\0A\0\276\332\334\355\355\300", 10) = 10

alarm(1)                                = 0

read(3, "\300", 1)                      = 1

read(3, "\0", 1)                        = 1

read(3, "\300\0@", 3)                   = 3

read(3, "\0", 1)                        = 1

read(3, "A", 1)                         = 1

 

Your build of hciattach

 

root:/> strace hciattach -n /dev/ttyBF1 bcsp &

[2] 179 strace hciattach -n /dev/ttyBF1 bcsp

root:/> ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or

TCGETS, 0x2d5be48) = -1 ENOTTY (Inappropriate ioctl for device)

ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B57600 opost -isig -icanon -echo ...}) = 0

rt_sigaction(SIGALRM, {0x2d50e60, [], SA_NOCLDSTOP}, NULL, 8) = 0

alarm(5)                                = 0

open("/dev/ttyBF1", O_RDWR|O_NOCTTY)    = 3

ioctl(3, TCFLSH, 0x2)                   = 0

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B115200 -opost -isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B115200 -opost

-isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B115200 -opost -isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B115200 -opost

-isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B115200 -opost -isig -icanon -echo ...}) = 0

ioctl(3, TCFLSH, 0x2)                   = 0

ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B115200 -opost

-isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B115200 -opost -isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B115200 -opost

-isig -icanon -echo ...}) = 0

ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,

{B115200 -opost -isig -icanon -echo ...}) = 0

alarm(0)                                = 5

rt_sigaction(SIGALRM, {0x2d50b0c, [], SA_NOCLDSTOP}, NULL, 8) = 0

ioctl(3, TCFLSH, 0x2)                   = 0

write(2, "BCSP initialization timed out\n", 30BCSP initialization

timed out

) = 30

_exit(1)                                = ?

 

[2] Done                   strace hciattach -n /dev/ttyBF1 bcsp

root:/>

 

Now looking at the function:

 

static void bcsp_tshy_sig_alarm(int sig)

{

        static int retries=0;

        unsigned char bcsp_sync_pkt[10] =

{0xc0,0x00,0x41,0x00,0xbe,0xda,0xdc,0xed,0xed,0xc0};

 

        if (retries < 10) {

                retries++;

                write(serial_fd, &bcsp_sync_pkt, 10);

                alarm(1);

                return;

        }

        tcflush(serial_fd, TCIOFLUSH);

        fprintf(stderr, "BCSP initialization timed out\n");

        exit(1);

}

 

It looks like in your build static int retries is initialized to something

>=10.

From the trace I can't see that this function was ever called before.

So it must be a toolchain bug here?

 

 

--- Vivi Li                                                  2010-03-23 00:05:27

Hi, Michael

 

I build a image with latest toolchain and kernel, it still can't work.

--

kernel:    Linux release 2.6.33.1-ADI-2010R1-pre-svn8527, build #4 Tue Mar 23

01:05:44 GMT 2010

toolchain: bfin-uclinux-gcc release gcc version 4.3.4 (ADI-trunk/svn-3951)

user-dist: release svn-9522, build #22 Tue Mar 23 01:04:46 GMT 2010

--

 

Are you using a 32 or 64 bit machine to build kernel and toolchain? Mine is 32

bit.

 

And I also attach the configuration logs of bluez libs and utils.

 

--- Michael Hennerich                                        2010-03-23 04:17:59

I use a 64-bit build machine. For me this looks like a toolchain bug.

A static variable in a function not properly initialized.

 

Can you apply this patch and rebuild - then post the command line output?

 

Index: user/bluez-utils/bluez-utils-2.25/tools/hciattach.c

===================================================================

--- user/bluez-utils/bluez-utils-2.25/tools/hciattach.c (revision 9525)

+++ user/bluez-utils/bluez-utils-2.25/tools/hciattach.c (working copy)

@@ -609,13 +609,14 @@

        unsigned char bcsp_sync_pkt[10] =

{0xc0,0x00,0x41,0x00,0xbe,0xda,0xdc,0xed,0xed,0xc0};

 

        if (retries < 10) {

+               fprintf(stderr, "%s: retries = %d\n", __func__,

retries);

                retries++;

                write(serial_fd, &bcsp_sync_pkt, 10);

                alarm(1);

                return;

        }

        tcflush(serial_fd, TCIOFLUSH);

-       fprintf(stderr, "BCSP initialization timed out\n");

+       fprintf(stderr, "BCSP initialization timed out (retries =

%d)\n", retries);

        exit(1);

}

 

@@ -624,13 +625,15 @@

        static int retries=0;

        unsigned char bcsp_conf_pkt[10] =

{0xc0,0x00,0x41,0x00,0xbe,0xad,0xef,0xac,0xed,0xc0};

        if (retries < 10){

+               fprintf(stderr, "%s: retries = %d\n", __func__,

retries);

                retries++;

                write(serial_fd, &bcsp_conf_pkt, 10);

                alarm(1);

                return;

        }

        tcflush(serial_fd, TCIOFLUSH);

-       fprintf(stderr, "BCSP initialization timed out\n");

+       fprintf(stderr, "BCSP initialization timed out (retries =

%d)\n", retries);!Kubilay

+

        exit(1);

}

 

 

 

--- Vivi Li                                                  2010-03-23 05:54:16

I applied your patch and bellow is the log:

--

root:/> iwrap_boot -b /dev/ttyBF1

root:/> hcid -n &

[1] 176 hcid -n

root:/> hcid[176]: Bluetooth HCI daemon

 

root:/> hciattach -n /dev/ttyBF1 bcsp &

[2] 177 hciattach -n /dev/ttyBF1 bcsp

root:/> BCSP initialization timed out (retries = 46121197)

 

[2] Done                   hciattach -n /dev/ttyBF1 bcsp

root:/>

--

 

--- Michael Hennerich                                        2010-03-23 06:05:24

Yeah - that looks like a toolchain bug.

 

static int retries=0;

never gets initialized to zero.

Adding Mike...

 

static void bcsp_tshy_sig_alarm(int sig)

{

        static int retries=0;

        unsigned char bcsp_sync_pkt[10] =

{0xc0,0x00,0x41,0x00,0xbe,0xda,0xdc,0xed,0xed,0xc0};

 

        if (retries < 10) {

 

 

 

--- Michael Hennerich                                        2010-03-24 04:51:24

Vivi,

 

Can you try to build all user as FDPIC?

I bet this makes the issue go away.

 

-Michael

 

 

--- Vivi Li                                                  2010-03-25 00:20:35

Yeah, it does work when I change binary format to FDPIC.

 

--- Michael Hennerich                                        2010-03-25 04:12:00

One last test - can you switch back to BFLT and increase the stacksize?

-Michael

 

 

--- Vivi Li                                                  2010-03-25 06:49:02

I increase stack size to 0x6000, and it can work now...

 

--- Michael Hennerich                                        2010-03-25 07:02:06

Vivi,

 

Can you please mail me your hciattach.o .gdb and BFLT files with the default

stack size?

 

-Michael

 

 

--- Vivi Li                                                  2010-03-25 23:19:45

Michael,

 

Files are in attachment hciattach.tar.gz.

 

-Vivi

 

--- Michael Hennerich                                        2010-03-26 06:43:31

For some reason the files generate on your machine are slightly different from

mine.

However I'm now convinced that this is a stack overflow issue.

hciattach: main() allocates

char dev[PATH_MAX];

on the stack, since PATH_MAX = 4096 we exceed the 4k default stack.

Fixed on trunk and 2009R1 by increasing the default BFLT stack size to 8k.

 

--- Vivi Li                                                  2010-03-29 03:03:51

After your fix on stack size, I've seen following error message in test.

So I increase stack size to 16k and check it later.

 

--

root:/> hcitool scan

Scanning ...

        11:11:11:11:11:11       BlueZ uclinux57-usb1761-vs6624-ad1371 (0)

        90:4C:E5:CC:35:F9       Dell Wireless 365 Bluetooth Module

NULL pointer access

Deferred Exception context

CURRENT PROCESS:

COMM=hcid PID=175  CPU=0

TEXT = 0x02bc0040-0x02bce500        DATA = 0x02bce520-0x02bd4598

BSS = 0x02bd4598-0x02bd5b60  USER-STACK = 0x02bd7f60

 

return address: [0x02bca832]; contents of:

0x02bca810:  42f0  e300  0139  3038  e140  02bd  e14a  02bc

0x02bca820:  e100  42f4  e10a  ba34  0062  0c07  1c06  3217

0x02bca830:  b9f0 [9210] 0c42  1407  e3ff  e71a  3210  6060

0x02bca840:  9310  6802  e801  0000  3042  0530  0010  0000

 

ADSP-BF537-0.2 500(MHz CCLK) 125(MHz SCLK) (mpu off)

Linux version 2.6.33.1-ADI-2010R1-pre-svn8560

(test@uclinux58-mmc-usblan-btuart) (gcc version 4.3.4 (ADI-trunk/svn-3951) ) #24

S0

 

SEQUENCER STATUS:               Not tainted

SEQSTAT: 00000027  IPEND: 0008  IMASK: ffff  SYSCFG: 0006

  EXCAUSE   : 0x27

  physical IVG3 asserted : <0xffa00730> { _trap + 0x0 }

RETE: <0x00000000> /* Maybe null pointer? */

RETN: <0x02b8a000> /* kernel dynamic memory */

RETX: <0x00000480> /* Maybe fixed code section */

RETS: <0x02bca7ae> [ hcid + 0xa76e ]

PC  : <0x02bca832> [ hcid + 0xa7f2 ]

DCPLB_FAULT_ADDR: <0x0000003c> /* Maybe null pointer? */

ICPLB_FAULT_ADDR: <0x02bca832> [ hcid + 0xa7f2 ]

PROCESSOR STATE:

R0 : 0000003c    R1 : 0000003c    R2 : 0206afc4    R3 : 0206aff4

R4 : 02bd79f8    R5 : 00000033    R6 : 00000011    R7 : 0000003c

P0 : 02bd42f0    P1 : 02bd7a18    P2 : 0000003c    P3 : 02bd79f8

P4 : 00000006    P5 : 02bd7af4    FP : 02bd6904    SP : 02b89f24

LB0: 02bc9dc9    LT0: 02bc9dc8    LC0: 00000000

LB1: 02bc8ff9    LT1: 02bc8ff8    LC1: 00000000

B0 : 00000000    L0 : 00000000    M0 : 00000000    I0 : 02bd4178

B1 : 00000000    L1 : 00000000    M1 : 00000000    I1 : 02bd5a44

B2 : 00000000    L2 : 00000000    M2 : 00000000    I2 : 00000000

B3 : 00000000    L3 : 00000000    M3 : 00000000    I3 : 00000000

A0.w: 00000000   A0.x: 00000000   A1.w: 00000000   A1.x: 00000000

USP : 02bd68e8  ASTAT: 02003004

 

Hardware Trace:

   0 Target : <0x00003f78> { _trap_c + 0x0 }

     Source : <0xffa006c4> { _exception_to_level5 + 0xa4 } JUMP.L

   1 Target : <0xffa00620> { _exception_to_level5 + 0x0 }

     Source : <0xffa004d4> { _bfin_return_from_exception + 0x20 } RTX

   2 Target : <0xffa004b4> { _bfin_return_from_exception + 0x0 }

     Source : <0xffa00578> { _ex_trap_c + 0x74 } JUMP.S

   3 Target : <0xffa00504> { _ex_trap_c + 0x0 }

     Source : <0xffa003dc> { _ex_workaround_261 + 0x1c } JUMP.S

   4 Target : <0xffa003c0> { _ex_workaround_261 + 0x0 }

     Source : <0xffa00798> { _trap + 0x68 } JUMP (P4)

   5 Target : <0xffa0074e> { _trap + 0x1e }

     Source : <0xffa0074a> { _trap + 0x1a } IF CC JUMP pcrel

   6 Target : <0xffa00730> { _trap + 0x0 }

      FAULT : <0x02bca832> [ hcid + 0xa7f2 ] [P2++] = R0

     Source : <0xffa004d4> { _bfin_return_from_exception + 0x20 } RTX

   7 Target : <0xffa004b4> { _bfin_return_from_exception + 0x0 }

     Source : <0xffa003d2> { _ex_workaround_261 + 0x12 } IF !CC JUMP

pcrel

   8 Target : <0xffa003c0> { _ex_workaround_261 + 0x0 }

     Source : <0xffa00798> { _trap + 0x68 } JUMP (P4)

   9 Target : <0xffa0074e> { _trap + 0x1e }

     Source : <0xffa0074a> { _trap + 0x1a } IF CC JUMP pcrel

  10 Target : <0xffa00730> { _trap + 0x0 }

     Source : <0x02bca830> [ hcid + 0xa7f0 ] 0xb9f0

  11 Target : <0x02bca82e> [ hcid + 0xa7ee ]

     Source : <0x02bca7b0> [ hcid + 0xa770 ] IF !CC JUMP pcrel (BP)

  12 Target : <0x02bca7ae> [ hcid + 0xa76e ]

     Source : <0x02bcba40> [ hcid + 0xba00 ] RTS

  13 Target : <0x02bcba34> [ hcid + 0xb9f4 ]

     Source : <0x02bca7ac> [ hcid + 0xa76c ] CALL (P2)

  14 Target : <0x02bca79a> [ hcid + 0xa75a ]

     Source : <0x02bcaaee> [ hcid + 0xaaae ] RTS

  15 Target : <0x02bcaae8> [ hcid + 0xaaa8 ]

     Source : <0x02bcaadc> [ hcid + 0xaa9c ] JUMP.S

Userspace Stack

Stack info:

SP: [0x02bd68e8] <0x02bd68e8> [ hcid + 0x168e8 ]

Memory from 0x02bd68e0 to 02bd7000

02bd68e0: 02bd6904 <02bca7ae>[02bd7af4] ffffffff  0206a0cc  04000021

0000000c  00000627

02bd6900: 0000003c  02bd6924  02bc6ba6  00000036  00000011  00000008  008e4aeb

00000000

02bd6920: 008e4ae0  02bd69bc  02bc6fa0  0000003c  02bd7af4  00000000  00000011

00000006

02bd6940: 02bea000  02bd687c  20000000  02bd79f8  00002002  00000006  00000000

02bd7b05

02bd6960: 02bd7af4  0000000c  00000000  00000000  00000627  000081a4  00000001

00000000

02bd6980: 00000000  00000000  00000000  00000000  0000003c  00001000  00000008

008e4aeb

02bd69a0: 00000000  008e4ae0  00000000  008e4ae0  00000000  00000000  00000000

02bd7b08

02bd69c0: 02bc1e78  02bd69f4  02bcf64c  00000065  02bd7af4  0206a012  02bd7ddc

00000000

02bd69e0: 00000000  00000000  00000000  02bd16c4  02bd7af4  7261762f  62696c2f

62696c2f

02bd6a00: 756c622f  6f6f7465  302f6874  37303a30  3a30383a  383a3938  36303a46

6d616e2f

02bd6a20: 00007365  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6a40: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6a60: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6a80: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6aa0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6ac0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6ae0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6b00: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6b20: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6b40: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6b60: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6b80: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6ba0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6bc0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6be0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6c00: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6c20: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6c40: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6c60: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6c80: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6ca0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6cc0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6ce0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6d00: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6d20: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6d40: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6d60: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6d80: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6da0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6dc0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6de0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6e00: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6e20: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6e40: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6e60: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6e80: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6ea0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6ec0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6ee0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6f00: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6f20: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6f40: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6f60: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6f80: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6fa0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6fc0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

02bd6fe0: 00000000  00000000  00000000  00000000  00000000  00000000  00000000

00000000

Return addresses in stack:

    address : <0x02bca7ae> [ hcid + 0xa76e ]

        90:4C:E5:CC:A0:4B       Dell Wireless 365 Bluetooth Module

[1] Done                   hcid -n

        90:4C:E5:CC:9A:19       Dell Wireless 365 Bluetooth Module

        00:21:86:42:86:C0       YXUAN-L01

        00:1A:DC:1B:0B:DF       Rainman

        0C:60:76:95:FD:EC       Dell Wireless 365 Bluetooth Module

        00:1F:3A:F0:82:60       RCHENG-L02

        00:1F:3A:F0:8A:B9       RRUI-L02

root:/>

--

 

--- Vivi Li                                                  2010-04-11 23:32:47

8k stack size is still not enough, 16k is better.

Fixed on trunk and 2009R1.

Close it.

 

 

 

    Files

    Changes

    Commits

    Dependencies

    Duplicates

    Associations

    Tags

 

File Name     File Type     File Size     Posted By

hciattach.tar.gz    application/x-gzip    190180    Vivi Li

uImage.bluetoothuart    application/octet-stream    5255233    Vivi Li

uImage.BCSP_BT    application/octet-stream    4632935    Michael Hennerich

config.btuart.2010_Mar_20    application/octet-stream    37648    Vivi Li

config.user.bluetoothuart    application/octet-stream    48319    Vivi Li

config.log_bluez-utils    application/octet-stream    250256    Vivi Li

config.log_bluez-libs    application/octet-stream    176719    Vivi Li

Outcomes