Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,277 Views

Bluetooth Implementation in DE2-115 with uClinux

Hi everyone, 

 

I want to implement Bluetooth in Altera DE2-115. The board has a usb host (cy7c67200)

I'm considering to use a bluetooth usb dongle to plug into this usb host to receive data from Arduino (which has a Bluetooth module with XBee-shield). 

 

I heard that uclinux has a Bluetooth driver support. But I still have no idea on how to use it and integrate with my project. 

 

Can anyone help me?  

How can I add the driver to the board so that it can detect that a Bluetooth dongle is inserted? Do I need to add anything to Qsys? and how can I read the data received by Bluetooth by writing C program in Nios II Software Build Tool for Eclipse? or anything I need to do to achieve it? 

 

I'm still new to FPGA, please help to explain in more details if possible. Please tell me if there is any other better suggestion in implementing Bluetooth to FPGA. 

Thank you very much for your help. :-)
0 Kudos
8 Replies
Altera_Forum
Honored Contributor I
83 Views

Hi, 

 

 

--- Quote Start ---  

 

I want to implement Bluetooth in Altera DE2-115. The board has a usb host (cy7c67200)

I'm considering to use a bluetooth usb dongle to plug into this usb host to receive data from Arduino (which has a Bluetooth module with XBee-shield). 

 

--- Quote End ---  

 

 

It's easy from the kernel side, if you can use the USB host. To install the Bluetooth drivers, select in the menuconfig like 

 

Networking support ---> <*> Bluetooth subsystem support ---> -- Bluetooth subsystem support <*> L2CAP protocol support <*> SCO links support <*> RFCOMM protocol support RFCOMM TTY support <*> BNEP protocol support Multicast filter support Protocol filter support <*> HIDP protocol support Bluetooth device drivers ---> <*> HCI USB driver <*> HCI BCM203x USB driver

 

But from the software side, you need many things, dbus, bluez-utils,and python etc.  

I tested two Bluetooth USB dongles, CSR8510 and Broadcom BCM20702A0 on DE2-115  

boards, but the combination CSR8510+CY7C67200 will not work well. 

Later, I will upload my test case on Altera Wiki. 

 

Kazu
Altera_Forum
Honored Contributor I
83 Views

 

--- Quote Start ---  

Hi, 

 

 

 

It's easy from the kernel side, if you can use the USB host. To install the Bluetooth drivers, select in the menuconfig like 

 

Networking support ---> <*> Bluetooth subsystem support ---> -- Bluetooth subsystem support <*> L2CAP protocol support <*> SCO links support <*> RFCOMM protocol support RFCOMM TTY support <*> BNEP protocol support Multicast filter support Protocol filter support <*> HIDP protocol support Bluetooth device drivers ---> <*> HCI USB driver <*> HCI BCM203x USB driver

 

But from the software side, you need many things, dbus, bluez-utils,and python etc.  

I tested two Bluetooth USB dongles, CSR8510 and Broadcom BCM20702A0 on DE2-115  

boards, but the combination CSR8510+CY7C67200 will not work well. 

Later, I will upload my test case on Altera Wiki. 

 

Kazu 

--- Quote End ---  

 

 

 

Hi Kazu, 

 

Thank you so much for your information. It's really very helpful for me. Currently I'm just successfully created a normal zImage after suffering for quite a long time. Later I will try to include the bluetooth driver in the kernel. Looking forward for your new post on the test case. :-) 

 

But at the software side, do you have any reference that I can learn and refer to? at the current stage, I'm just able to build the image, but have no idea on the software side. 

Thank you so much for your help! 

 

Best Regards, 

Jun Mun
Altera_Forum
Honored Contributor I
83 Views

Hi, 

 

 

--- Quote Start ---  

 

Thank you so much for your information. It's really very helpful for me. Currently I'm just successfully created a normal zImage after suffering for quite a long time. Later I will try to include the bluetooth driver in the kernel. Looking forward for your new post on the test case. :-) 

 

--- Quote End ---  

 

 

Before to compile the kernel, please revise the codes 

 

static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val) { struct l2cap_conf_opt *opt = *ptr; BT_DBG("type 0x%2.2x len %d val 0x%lx", type, len, val); opt->type = type; opt->len = len; // switch (len) { // case 1: // *((u8 *) opt->val) = val; // break; // // case 2: // *((__le16 *) opt->val) = cpu_to_le16(val); // break; // // case 4: // *((__le32 *) opt->val) = cpu_to_le32(val); // break; // // default: // memcpy(opt->val, (void *) &val, len); // break; // } memcpy(opt->val, (void *) &val, len); *ptr += L2CAP_CONF_OPT_SIZE + len; }  

in the file 'l2cap(_core).c' and  

/* * Only data is little endian, addr has cpu endianess */ static void hpi_write_words_le16(struct c67x00_device *dev, u16 addr, __le16 *data, u16 count) { unsigned long flags; int i; spin_lock_irqsave(&dev->hpi.lock, flags); hpi_write_reg(dev, HPI_ADDR, addr); if ((unsigned long)data & 0x1) { u8 *tmp_p; u16 tmp_d; for (i = 0; i < count; i++, data++) { tmp_p = (u8 *)data; tmp_d = *tmp_p | (*(tmp_p+1) << 8); hpi_write_reg(dev, HPI_DATA, tmp_d); } } else for (i = 0; i < count; i++) hpi_write_reg(dev, HPI_DATA, le16_to_cpu(*data++)); spin_unlock_irqrestore(&dev->hpi.lock, flags); } /* * Only data is little endian, addr has cpu endianess */ static void hpi_read_words_le16(struct c67x00_device *dev, u16 addr, __le16 *data, u16 count) { unsigned long flags; int i; spin_lock_irqsave(&dev->hpi.lock, flags); hpi_write_reg(dev, HPI_ADDR, addr); if ((unsigned long)data & 0x1) { u8 *tmp_p; u16 tmp_d; for (i = 0; i < count; i++, data++) { tmp_d = cpu_to_le16(hpi_read_reg(dev, HPI_DATA)); tmp_p = (u8 *)data; *tmp_p = (u8)tmp_d; *(tmp_p+1) = (u8)(tmp_d >> 8); } } else for (i = 0; i < count; i++) *data++ = cpu_to_le16(hpi_read_reg(dev, HPI_DATA)); spin_unlock_irqrestore(&dev->hpi.lock, flags); }  

in the file 'c67x00-ll-hpi.c', because Nios2 CPU can't do unaligned memory accesses. 

 

 

--- Quote Start ---  

 

But at the software side, do you have any reference that I can learn and refer to? at the current stage, I'm just able to build the image, but have no idea on the software side. 

 

--- Quote End ---  

 

 

From the view point of the software side, I think that the easiest way is to use 'BlueZ'. 

 

http://www.bluez.org/ 

 

But this tool uses Python scripts, so you need a Python interpreter and many modules. 

 

Kazu
Altera_Forum
Honored Contributor I
83 Views

 

--- Quote Start ---  

 

 

I tested two Bluetooth USB dongles, CSR8510 and Broadcom BCM20702A0 on DE2-115  

boards, but the combination CSR8510+CY7C67200 will not work well. 

Later, I will upload my test case on Altera Wiki. 

 

--- Quote End ---  

 

 

Hi Kazu, 

 

Currently I'm learning Bluetooth programming from this site. 

https://people.csail.mit.edu/albert/bluez-intro/index.html 

Hope it helps! 

 

By the way, I would like to ask, is Broadcom BCM20702A0 work well with CY7C67200? 

Because I plan to purchase a bluetooth usb first while I'm learning it for my final year project.  

May I know is this the one you are using? 

http://www.ebay.com/itm/gmyle-bluetooth-4-0-dual-mode-micro-usb-broadcom-bcm20702-adapter-dongle-/30... 

Thanks a lot. 

 

Regards, 

Jun Mun
Altera_Forum
Honored Contributor I
83 Views

Hi, 

 

 

--- Quote Start ---  

 

By the way, I would like to ask, is Broadcom BCM20702A0 work well with CY7C67200? 

Because I plan to purchase a bluetooth usb first while I'm learning it for my final year project.  

May I know is this the one you are using? 

http://www.ebay.com/itm/gmyle-bluetooth-4-0-dual-mode-micro-usb-broadcom-bcm20702-adapter-dongle-/30... 

 

--- Quote End ---  

 

 

I used I-O DATA's 'USB-BT40LE'. It's a Japanese maker, but the product is manufactured in China :-). 

Maybe other USB dongles which use Broadcom BCM20702A0 will work well. 

CSR8510 will not respond the command 

< HCI Command: Accept Connection Request (0x01|0x0009) plen 7 0000: 3b f5 0d a6 e7 88 00 ;......  

, and Nios2 will issue this when the CY7C67200 is used. 

 

Of course, I don't know the reason. 

 

Kazu
Altera_Forum
Honored Contributor I
83 Views

Hi, 

 

I uploaded the test case of bluetooth USB adapter. Please refer to  

 

http://www.alterawiki.com/wiki/linux_with_mmu_on_veek/t-pad 

 

Kazu
Altera_Forum
Honored Contributor I
83 Views

Hi, 

 

 

--- Quote Start ---  

Hi, 

 

I uploaded the test case of bluetooth USB adapter. Please refer to  

 

http://www.alterawiki.com/wiki/linux_with_mmu_on_veek/t-pad 

 

Kazu 

--- Quote End ---  

 

 

Thank you for your sharing. 

 

 

 

And I have a question here, before using bluetooth usb, I'm now testing CY7C67200 to detect a normal mass storage usb. I added the IP for CY7C67200 in Qsys and then generated dts file using sopc2dts generator. However, CY7C67200 cannot be recognized. How can I make it recognizable? 

 

I did try to make the zImage and download to DE2-115, but it seems cannot detect the USB. I'm wondering if it is because of the USB IP cannot be recognized. 

 

Here are part of the .dts file: 

 

CY7C67200_IF_0: unknown@0x23860 { compatible = "unknown,unknown-1.0"; reg = <0x00023860 0x00000010>; interrupt-parent = <&nios2_qsys_0>; interrupts = <3>; }; //end unknown@0x23860 (CY7C67200_IF_0) 

 

And in menuconfig,  

for the USB Host controller drivers, I found Cypress C67x00 HCD support. 

Is it applicable to CY7C67200? 

 

 

 

 

For your information, I did includes these as well: 

 

File systems --> 

********************************** 

<*> Ext3 journalling file system support  

DOS/FAT/NT Filesystems ---> 

********************************** 

<*> MSDOS fs support 

<*> VFAT (Windows-95) fs support 

 

Device Drivers ---> 

******************************** 

SCSI device support ---> 

******************************** 

<*> SCSI device support 

<*> SCSI disk support 

******************************** 

[*] USB support ---> 

******************************** 

<*> Support for Host-side USB 

[*] USB anounce new devices 

[*] USB Mass Storage support 

<*> Cypress C67x00 HCD support  

 

 

Regards, 

Jun Mun
Altera_Forum
Honored Contributor I
83 Views

Hi, 

 

 

--- Quote Start ---  

And I have a question here, before using bluetooth usb, I'm now testing CY7C67200 to detect a normal mass storage usb. I added the IP for CY7C67200 in Qsys and then generated dts file using sopc2dts generator. However, CY7C67200 cannot be recognized. How can I make it recognizable? 

 

I did try to make the zImage and download to DE2-115, but it seems cannot detect the USB. I'm wondering if it is because of the USB IP cannot be recognized. 

 

Here are part of the .dts file: 

 

CY7C67200_IF_0: unknown@0x23860 { compatible = "unknown,unknown-1.0"; reg = <0x00023860 0x00000010>; interrupt-parent = <&nios2_qsys_0>; interrupts = <3>; }; //end unknown@0x23860 (CY7C67200_IF_0) 

 

And in menuconfig,  

for the USB Host controller drivers, I found Cypress C67x00 HCD support. 

Is it applicable to CY7C67200? 

 

--- Quote End ---  

 

 

Yes, you can use the C67x00 HCD driver for CY7C67x00 series. 

For platform devices, you must notify your kernel of the name to initialize it. 

Please refer to  

 

https://lwn.net/articles/448502/ 

 

and  

 

https://github.com/enclustra-bsp/xilinx-linux/blob/master/drivers/usb/c67x00/c67x00-drv.c 

 

, especially the last part of the code. 

 

c67x00_ll_release(c67x00); return 0; } # ifdef CONFIG_OF /* Match table for OF platform binding - from xilinx_emaclite */ static struct of_device_id c67x00_of_match = { { .compatible = "cypress,c67x00", }, // <----!! { /* end of list */ }, }; MODULE_DEVICE_TABLE(of, c67x00_of_match); # endif static struct platform_driver c67x00_driver = { .probe = c67x00_drv_probe, .remove = c67x00_drv_remove, .driver = { .name = "c67x00", .of_match_table = of_match_ptr(c67x00_of_match), // <----!! }, }; module_platform_driver(c67x00_driver); MODULE_AUTHOR("Peter Korsgaard, Jan Veldeman, Grant Likely"); MODULE_DESCRIPTION("Cypress C67X00 USB Controller Driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:c67x00");  

 

Kazu
Reply