DA14580, linux HCI/bluez

13 posts / 0 new
Last post
spectrum
Offline
Last seen:5 years 9 months ago
加入:2015-03-11 18:26
DA14580, linux HCI/bluez

Dear all,

i am trying to port da14581 patch RAM code to da14580, that have different ROM content.

So, here whai i did until now:

1. Started from DA14581_HCI_Release_v.3.110.2.12 package for da14581
2. On the uVision project i applied DA14580 scatter file from DA1458x_SDK_3.0.6
3. On the uVision project i applied "rom_symdef" as per DA14580 apps into DA1458x_SDK_3.0.6
4.加载与修补hciattach,我可以上传e firmware correctly
5. I can compile without errors. After FW is uploaded and executed, there is no HCI reply, so hciattach times out.
6. actually, code execution locks into "rwip_init" as below:

#ifdef RADIO_580
iq_trim_from_otp();
# endif

/*
************************************************************************************
* BLE initialization
************************************************************************************
*/

init_pwr_and_clk_ble();
//diagnostic();

// rf_init(&rwip_rf);
// SetBits32(BLE_RADIOCNTL1_REG, XRFSEL, 3);

#if UNCALIBRATED_AT_FAB
SetBits16(BANDGAP_REG, BGR_TRIM, 0x0); // trim RET Bandgap
SetBits16(BANDGAP_REG, LDO_RET_TRIM, 0xA); // trim RET LDO
SetWord16(RF_LNA_CTRL1_REG, 0x24E);
SetWord16(RF_LNA_CTRL2_REG, 0x26);
SetWord16(RF_LNA_CTRL3_REG, 0x7);
SetWord16(RF_VCO_CTRL_REG, 0x1);
SetBits16(CLK_16M_REG, RC16M_TRIM, 0xA);
# endif

// Initialize BLE stack
NVIC_ClearPendingIRQ(BLE_SLP_IRQn);
NVIC_ClearPendingIRQ(BLE_EVENT_IRQn);
NVIC_ClearPendingIRQ(BLE_RF_DIAG_IRQn);
NVIC_ClearPendingIRQ(BLE_RX_IRQn);
NVIC_ClearPendingIRQ(BLE_CRYPT_IRQn);
NVIC_ClearPendingIRQ(BLE_FINETGTIM_IRQn);
NVIC_ClearPendingIRQ(BLE_GROSSTGTIM_IRQn);
NVIC_ClearPendingIRQ(BLE_WAKEUP_LP_IRQn);

>>> rwip_init(error);

#if ((BLE_APP_PRESENT == 0 || BLE_INTEGRATED_HOST_GTL == 1) && BLE_HOST_PRESENT )
patch_gtl_task();
# endif// #if (BLE_APP_PRESENT == 0 || BLE_INTEGRATED_HOST_GTL == 1)

Every help is appreciated.
Best regards,
angelo

spectrum
Offline
Last seen:5 years 9 months ago
加入:2015-03-11 18:26
I share my progresses,

I share my progresses, hopefully they can be useful for someone, and maybe dialog can support me a bit on this.

Actually, i see debugging over uart, that all the code executes in the arch_main.c main loop.
After calling

#if (BLE_HCIC_ITF)
// In split mode, initialize the HCI
hci_init(rwip_eif_get(RWIP_EIF_HCIC));
# endif//BLE_HCIC_ITF

in rwble.c , i cannot use uart anymore for debugging, since it's controlled from the HCI layer.
So code executes, but there is no reply to first HCI commands sent to the module
just after fw update.
HCI part is only available currently as object.
By scope i see FW is sent, justafter the CRC OK id displayed, i see linux sending the first HCI command, 4 bytes on TX line, and from module side only some ack bits after each bite received.

JE_Dialog
Offline
Last seen:42 min 35 sec ago
Staff
加入:2013-12-05 14:02
Hi There, we are aware of an

Hi There, we are aware of an issue related to Blue Z... "The reason is that BlueZ sends some HCI commands for standard and not BLE controller and this gets our device mixed up".. We are looking into a patch, but this is some weeks away right now. BR JE_Dialog

spectrum
Offline
Last seen:5 years 9 months ago
加入:2015-03-11 18:26
Hi, good to know, i am

Hi, good to know, i am progressing, if i succed i can publish the patch then.

What i have seen is:
With oscilloscope i see there is a UART reply, but of 2 bytes, 0x04 and 0x10. This is why current hciattach is not showing anything and times out, since hciattach.c read_hci_event() expects other bytes, at least 3 (byte 3 is params count).

So i modified hciattach to see what the return code is: i get

bash-3.2# .hciattach ttymxc1 dialog 115200
Downloading hci-firmware.bin...
CRC OK (cd).
Sending HCI reset before starting conversation...
Dialog custom protocol: EVT_HARDWARE_ERROR

Hardware error. Is it possible the code is for da14581 and checks some manufact id, or is it possible my module is damaged ? In the meantime i test on another board.

spectrum
Offline
Last seen:5 years 9 months ago
加入:2015-03-11 18:26
Well, hw error was just due

Well, hw error was just due to the global "error" variable uninitialized.
Seems i can send HCI messages if queued from main loop app, but HCI thread / module itself is not replying to any message i send.

This seems to be related to the different ROM kernel code of da14580.

spectrum
Offline
Last seen:5 years 9 months ago
加入:2015-03-11 18:26
Hi all,

Hi all,
progressed again.
- still with a mix of da14580, da14581 code (DA14581_HCI_Release_v.3.110.2.12) and SDK 3.0, c file / scatter file mix, and keeping da14580 symdefs
- also, i replaced some uart functions from uart.c driver
- also, i added HCI tasks in the last part of the jump table, that was not defined for da14580
- also, for misterious reasons still to clarify, i had to "uart_flow_off_func" before the main loop in arch_main.c function.

bash-3.2# ./start.sh
Downloading hci-firmware.bin...
CRC OK (90).
Sending HCI reset before starting conversation...
resp: 03 0c

===============================================
HCI ver: Bluetooth Core Spec 4.0 (0x06)
WARNING : module's manufacturer is not Dialog Semiconductor (0x0060)!!!
HCI revision : 0x0706
Module LMP version : 0x06
Module LMP sub-version : 0x0706
Device setup complete
bash-3.2# hciconfig
hci0: Type: BR/EDR Bus: UART
BD Address: 00:13:43:0D:09:83 ACL MTU: 0:0 SCO MTU: 0:0
DOWN
RX bytes:64 acl:0 sco:0 events:5 errors:0
TX bytes:20 acl:0 sco:0 commands:5 errors:0

But still there are some issues powering on:

bash-3.2# hciconfig hci0 up
Bluetooth: hci0 command 0x1003 tx timeout
Bluetooth: hci0 command 0x1001 tx timeout
Bluetooth: hci0 command 0x1009 tx timeout
Can't init device hci0: Connection timed out (110)

Maybe i am now facing the issue you mentioned above ?
Will continue next week.

Reagrds

spectrum
Offline
Last seen:5 years 9 months ago
加入:2015-03-11 18:26
Still a step forward,

Still a step forward,
i solved some uart flow control issues and actually communication is correct.

But seems the firmware is actually not replying correctly to "Read Class of Device " command,
and strangely MTU values are read as 0.

bash-3.2# Bluetooth monitor ver 5.14
= New Index: 00:13:43:0D:09:83 (BR/EDR,UART,hci0) [hci0] 0.657956

bash-3.2# hciconfig hci0 up
< HCI Command: Read Local Supported Fea.. (0x04|0x0003) plen 0 [hci0] 8.186353
> HCI Event: Command Complete (0x0e) plen 12 [hci0] 8.672730
Read Local Supported Features (0x04|0x0003) ncmd 10
Status: Success (0x00)
Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
< HCI Command: Read Local Version Infor.. (0x04|0x0001) plen 0 [hci0] 8.672877
> HCI Event: Command Complete (0x0e) plen 12 [hci0] 8.677712
Read Local Version Information (0x04|0x0001) ncmd 10
Status: Success (0x00)
HCI version: Bluetooth 4.0 (0x06) - Revision 1798 (0x0706)
LMP version: Bluetooth 4.0 (0x06) - Subversion 1798 (0x0706)
Manufacturer: RivieraWaves S.A.S (96)
< HCI Command: Read BD ADDR (0x04|0x0009) plen 0 [hci0] 8.677804
> HCI Event: Command Complete (0x0e) plen 10 [hci0] 8.682438
Read BD ADDR (0x04|0x0009) ncmd 10
Status: Success (0x00)
Address: 00:13:43:0D:09:83 (Matsushita Electronic Components (Europe) GmbH)
< HCI Command: Read Buffer Size (0x04|0x0005) plen 0 [hci0] 8.682617
> HCI Event: Command Complete (0x0e) plen 11 [hci0] 8.687327
Read Buffer Size (0x04|0x0005) ncmd 10
Status: Success (0x00)
ACL MTU: 0 ACL max packet: 0
SCO MTU: 0 SCO max packet: 0
< HCI Command: Read Class of Device (0x03|0x0023) plen 0 [hci0] 8.687407
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 8.691511
Read Class of Device (0x03|0x0023) ncmd 10
Status: Unknown HCI Command (0x01)

Some other info:

bash-3.2# cd blue/
bash-3.2# ./start.sh
Downloading hci-firmware.bin...
CRC OK(18)。
Sending HCI reset before starting conversation...
resp: 03 0c

===============================================
HCI ver: Bluetooth Core Spec 4.0 (0x06)
Manufacturer: RivieraWaves SAS(0x0060)
HCI revision : 0x0706
Module LMP version : 0x06
Module LMP sub-version : 0x0706
Device setup complete

bash-3.2# hciconfig hci0 up
Can't init device hci0: Invalid request code (56)

bash-3.2# dmesg | grep Blue
[ 0.312654] Bluetooth: Core ver 2.16
[ 0.312693] Bluetooth: HCI device and connection manager initialized
[ 0.312705] Bluetooth: HCI socket layer initialized
[ 0.312716] Bluetooth: L2CAP socket layer initialized
[ 0.312737] Bluetooth: SCO socket layer initialized
[ 3.675536] Bluetooth: HCI UART driver ver 2.2
[ 3.678705] Bluetooth: HCI H4 protocol initialized
[ 3.682216] Bluetooth: HCI BCSP protocol initialized
[ 3.685916] Bluetooth: HCILL protocol initialized
[ 4.653492] Bluetooth: RFCOMM TTY layer initialized
[ 4.657130] Bluetooth: RFCOMM socket layer initialized
[ 4.660993] Bluetooth: RFCOMM ver 1.11
[ 4.663465] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 4.667507] Bluetooth: BNEP filters: protocol multicast
[ 4.671459] Bluetooth: BNEP socket layer initialized
[ 4.675154] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[ 4.679800] Bluetooth: HIDP socket layer initialized

bash-3.2# hciconfig -a
hci0: Type: BR/EDR Bus: UART
BD Address: 00:13:43:0D:09:83 ACL MTU: 0:0 SCO MTU: 0:0
DOWN
RX bytes:640 acl:0 sco:0 events:50 errors:0
TX bytes:200 acl:0 sco:0 commands:50 errors:0
Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Packet type: DM1 DH1 HV1
Link policy:
Link mode: SLAVE ACCEPT

bash-3.2# hciconfig hci0 up
Can't init device hci0: Invalid request code (56)

spectrum
Offline
Last seen:5 years 9 months ago
加入:2015-03-11 18:26
Ok, seems at least main

Ok, seems at least main features now work.

bash-3.2# hciconfig -a
hci0: Type: BR/EDR Bus: UART
BD Address: 00:13:43:0D:09:83 ACL MTU: 27:18 SCO MTU: 0:0
UP RUNNING
RX bytes:339 acl:0 sco:0 events:37 errors:0
TX bytes:370 acl:0 sco:0 commands:37 errors:0
Features: 0x00 0x00 0x00 0x00 0x60 0x00 0x00 0x00
Packet type: DM1 DH1 HV1
Link policy:
Link mode: SLAVE ACCEPT

bash-3.2# hciconfig hci0 leadv

And i see the module detected from cell phone.

sbourahla
Offline
Last seen:5 years 5 months ago
Expert
加入:2015-02-25 09:51
Hello spectrum,

Hello spectrum,

I am interesting by how you fixed your problem, I try to do the same but actually it doesn't work.

BR

spectrum
Offline
Last seen:5 years 9 months ago
加入:2015-03-11 18:26
Hi sbourahla,

Hi sbourahla,
i did many changes to original "DA14581_HCI_Release_v.3.110.2.12" package, ending up with a PAN1740 compatible fw.
I am looking now into licence things, let's see if i can share the uVision project.
I would also do some more tests before sharing it.

Best regards
Angelo

spectrum
Offline
Last seen:5 years 9 months ago
加入:2015-03-11 18:26
Hi,

Hi,
well after some testings seems there are at least some connections issues:

$ sudo gatttool -b 00:13:43:0D:09:83 -I
[00:13:43:0D:09:83][LE]> connect
Attempting to connect to 00:13:43:0D:09:83
[00:13:43:0D:09:83][LE]> < HCI Command: LE Create Connection (0x08|0x000d) plen 25 [hci0] 8.243814
Scan interval: 60.000 msec (0x0060)
Scan window: 30.000 msec (0x0030)
Filter policy: White list is not used (0x00)
Peer address type: Public (0x00)
Peer address: 00:13:43:0D:09:83 (Matsushita Electronic Components (Europe) GmbH)
Own address type: Public (0x00)
Min connection interval: 50.00 msec (0x0028)
Max connection interval: 70.00 msec (0x0038)
Connection latency: 0x0000
Supervision timeout: 420 msec (0x002a)
Min connection length: 0.000 msec (0x0000)
Max connection length: 0.000 msec (0x0000)
> HCI Event: Command Status (0x0f) plen 4 [hci0] 8.248374
LE Create Connection (0x08|0x000d) ncmd 1
Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19 [hci0] 15.921321
LE Connection Complete (0x01)
Status: Success (0x00)
Handle: 72
Role: Master (0x00)
Peer address type: Public (0x00)
Connection successful
[00:13:43:0D:09:83][LE]> Peer address: 00:13:43:0D:09:83 (Matsushita Electronic Components (Europe) GmbH)
Connection interval: 70.00 msec (0x0038)
Connection latency: 0.00 msec (0x0000)
Supervision timeout: 420 msec (0x002a)
Master clock accuracy: 0x00
@ Device Connected: 00:13:43:0D:09:83 (1) flags 0x0000
> HCI Event: Disconnect Complete (0x05) plen 4 [hci0] 16.411320
Status: Success (0x00)
Handle: 72
Reason: Connection Timeout (0x08)
@ Device Disconnected: 00:13:43:0D:09:83 (1) reason 1

Seems the final disconnection arrives after a time near to the supervisor timeout.

Now i don't know if this is an issue visible also on da14581 or if it can be something related to my modified firmware.
Is there anyone with HCI on da14581 working properly ?

Regards
angelo

spectrum
Offline
Last seen:5 years 9 months ago
加入:2015-03-11 18:26
Hi,

Hi,
i share the code i have at this point. Still connection is not working properly, disconnection happen just after the connection succeed.

https://github.com/spectrum70/pan1740-firmware

Best regards
Angelo

JE_Dialog
Offline
Last seen:42 min 35 sec ago
Staff
加入:2013-12-05 14:02
Hi Spectrum, we have

你好,我们有客户使用HCI成功ly on DA14581 with external MPU. We have an internal project working on a Blue-Z implementation as we speak (3rd party is working on this for us).

Do you have a 14581 set-up to test ? you could re-build your image for 14581 and test.

BR JE_Dialog