btstack on bluetooth usb dongle + stm32f4-discovery board

1,321 views
Skip to first unread message

Vitaly

unread,
Dec 27, 2011, 2:17:21 PM12/27/11
to btstack-dev
Hi!

I've managed to observe signs of life for the subject. Not that it's
fully operational, but I see several commands and events exchanged
over usb and even ``hcitool name xx:xx...'' sees it ;) Is anybody
interested?

Bruno Montenegro

unread,
Dec 27, 2011, 2:21:22 PM12/27/11
to btsta...@googlegroups.com
I´m interested. I wonder if it works in nxp controllers too...
---------------------------
Bruno Montenegro







--
You received this message because you are subscribed to the Google Groups "btstack-dev" group.
To post to this group, send email to btsta...@googlegroups.com.
To unsubscribe from this group, send email to btstack-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/btstack-dev?hl=en.


Vitaly

unread,
Dec 27, 2011, 3:42:37 PM12/27/11
to btstack-dev
It is based on btstack + ST libs, so it doesn't work in nxp.

This code needs debugging, so if you are interested I'll try to write
a little README and assemble the pieces of code. Hopefully I'll make
it in couple of days, i.e. this year ;)

On Dec 27, 11:21 pm, Bruno Montenegro <brunomontene...@gmail.com>
wrote:
> I´m interested. I wonder if it works in nxp controllers too...
> ---------------------------
> Bruno Montenegro
>
> *
> *

Bruno Montenegro

unread,
Dec 27, 2011, 6:45:59 PM12/27/11
to btsta...@googlegroups.com
ok, so I will try to port it to nxp...
---------------------------
Bruno Montenegro

Vitaly

unread,
Dec 29, 2011, 12:41:58 PM12/29/11
to btstack-dev
It looks I finally managed to defeat the major hurdle: it appears that
starting poll to ACL IN never gets chance for user code to run until
finished. So now I'm going to proceed with my code a bit...

On Dec 28, 3:45 am, Bruno Montenegro <brunomontene...@gmail.com>
wrote:
> ok, so I will try to port it to nxp...
> ---------------------------
> Bruno Montenegro
>

Vitaly

unread,
Dec 30, 2011, 9:59:54 AM12/30/11
to btstack-dev
Ok, I have prepared some files and README for release. It's just I'm
not sure where to upload this stuff.
May be I'll setup github account later.

Matthias Ringwald

unread,
Dec 30, 2011, 10:44:55 AM12/30/11
to btsta...@googlegroups.com
Hi Vitaly

you can send me a (link to a) zip of your changes. I'm also open on clever ideas how to add ports for different boards/mcus in the BTstack SVN as e.g. the code for exp430-msp5438 is almost identical to the one for ez430-rf2560.

I've also got an STM discovery board (for free) but didn't even try "blink" as there wasn't an obvious way to flash it on the mac (and I didn't had Parallels at the time).

Best
Matthias

Bruno Montenegro

unread,
Dec 30, 2011, 1:24:40 PM12/30/11
to btsta...@googlegroups.com
it should be uploaded at btstack wiki page a link for your project, Vitaly. What do you think about this idea? the wikipage could also has an specific wiki page for microcontrollers implementation, based on the microcontroller architeture, e.g PIC implementation, Texas msp, atmel avr, arm 7 and so on.
---------------------------
Bruno Montenegro

Vitaly

unread,
Dec 30, 2011, 3:09:29 PM12/30/11
to btstack-dev
One more handsome victory over my own bug ;)
Now it looks reasonably stable: after several connects and pings at
BTstack counter 1276 :)
Please find a diff:

diff --git a/0my/bt-noos/usbh_bt_core.c b/0my/bt-noos/usbh_bt_core.c
index 909c5bd..04b2f5f 100644
--- a/0my/bt-noos/usbh_bt_core.c
+++ b/0my/bt-noos/usbh_bt_core.c
@@ -24,6 +24,7 @@
#include <string.h>

#define WIRELESS_CLASS 0xe0
+#define FRNUM_PERIOD 0x4000

// most of descriptors data is currently hardcoded:

@@ -57,7 +58,7 @@ typedef struct BT_State_s {

int evt_state;
uint8_t evt_hcn;
- int evt_tmo;
+ uint16_t evt_tmo;

int aclo_busy;
int aclo_state;
@@ -206,7 +207,10 @@ static int usb_bt_cmd_process()
static int usb_bt_evt_process()
{
int len, r;
+ uint16_t cur_fn, fn_diff;

+ cur_fn = HCD_GetCurrentFrame(BT_State.pdev);
+ fn_diff = (FRNUM_PERIOD + cur_fn - BT_State.evt_tmo) %
FRNUM_PERIOD;
switch(BT_State.evt_state){
case 0:
//while(!USB_OTG_IsEvenFrame(BT_State.pdev)); //
hopefully rare and harmless
@@ -217,11 +221,11 @@ static int usb_bt_evt_process()
EVT_ALIGNED_MAX_SIZE,
BT_State.evt_hcn
);
- BT_State.evt_tmo = 20 +
HCD_GetCurrentFrame(BT_State.pdev);
+ BT_State.evt_tmo = (2 + cur_fn) % FRNUM_PERIOD;
BT_State.evt_state = 1;
return 0;
case 1:
- if((int)HCD_GetCurrentFrame(BT_State.pdev) -
BT_State.evt_tmo >= 0){
+ if(fn_diff < FRNUM_PERIOD / 2){
BT_State.evt_state = 0;
break;
}
@@ -241,8 +245,9 @@ static int usb_bt_evt_process()
}
break;
case 2:
- if((int)HCD_GetCurrentFrame(BT_State.pdev) -
BT_State.evt_tmo >= 0)
+ if(fn_diff < FRNUM_PERIOD / 2){
BT_State.evt_state = 0;
+ }
break;
default: return -1;
}


On Dec 30, 10:24 pm, Bruno Montenegro <brunomontene...@gmail.com>
wrote:
> it should be uploaded at btstack wiki page a link for your project, Vitaly.
> What do you think about this idea? the wikipage could also has an specific
> wiki page for microcontrollers implementation, based on the microcontroller
> architeture, e.g PIC implementation, Texas msp, atmel avr, arm 7 and so on.
> ---------------------------
> Bruno Montenegro
>
> *
> *

JHenkel

unread,
Jan 2, 2012, 11:28:13 AM1/2/12
to btstack-dev
Also interested in your port. A few of us have been crawling towards
getting BTStack working with FreeRTOS on the STM32F1, but it sounds
like you're way ahead of us.

-j

Bruno Montenegro

unread,
Jan 2, 2012, 12:43:39 PM1/2/12
to btsta...@googlegroups.com
In time, the source code files was uploaded????
---------------------------
Bruno Montenegro

Vitaly

unread,
Jan 2, 2012, 2:18:44 PM1/2/12
to btstack-dev
I'm currently trying to create simple wrapper for my code to integrate
it with ChibiOS.

Anyway, I hope to upload code somewhere in a couple of days.

In the meantime, if you are implementing your driver using ST usb
libs, you may be interested in my patches for ST usb code.
Let me know and I'll email it to you directly.

Vitaly

unread,
Jan 3, 2012, 12:48:37 PM1/3/12
to btstack-dev
Ok, I finally uploaded something to https://github.com/byly/uubt, so
try it out!
But don't be surprized if it breaks ;)

Vitaly

unread,
Jan 6, 2012, 2:43:19 PM1/6/12
to btstack-dev
I have uploaded early support for ChibiOS/RT to https://github.com/byly/uubt,
try it out!

On Jan 3, 9:48 pm, Vitaly <vitaly.belostot...@gmail.com> wrote:
> Ok, I finally uploaded something tohttps://github.com/byly/uubt, so

JHenkel

unread,
Feb 12, 2012, 12:17:26 AM2/12/12
to btstack-dev
Vitaly - thanks for upping your code. I finally got a chance to take
a look. Nice work! It wasn't strictly applicable to my board, but
did give me some hope of get things working. I'm on an STM32F103 with
only 20kB of Ram, FreeRTOS, and DMA USART for HCI.

BTW, if you ever use a BlueCore 6 ROM: they autobaud. So you won't
ever get a response for the first message or two.

...and finally, as of tonight:

TaskID 20000C48
BTStack memory init.
BTStack run loop init.
BTStack HCI init.
BTStack l2cap init.
BTStack BSP UART init.
BTStack HCI POWER ON.

***RESET***
Start Patch Command Download

BTStack run loop execute.
Start Configuration Command Download

Starting inquiry scan..
rx:0f040c010104
rx:220f01d87515af2e1001020c025abf45ca
Device found: 10:2e:af:15:75:d8 with COD: 0x5a020c, pageScan 1, clock
offset 0x45bf, rssi 0xca
rx:220f01d87515af2e1001020c025abf45f3
rx:220f01d87515af2e1001020c025abf45f3
rx:220f01d87515af2e1001020c025abf45d1
Get remote name of 10:2e:af:15:75:d8...
rx:0f0400011904
No keyboard found :( rx:07
Name: 'DROID2'
Queried all devices, restart.


-jkh

On Jan 6, 1:43 pm, Vitaly <vitaly.belostot...@gmail.com> wrote:
> I have uploaded early support for ChibiOS/RT tohttps://github.com/byly/uubt,
Reply all
Reply to author
Forward
Message has been deleted
0 new messages