CC2540 HCI over UART0 using CC2540EB build.



I have managed to get both the HostTestRelease (via USB) and the SimpleBLEPeripheral compliling, working, and communicating between the two devices using BTool no problem. What I'd like to do now is redirect the HCI communication (on HostTestRelease side) with BTool, from USB to serial (UART0). It looks like in the build if I associate CC2540EB directory with the build instead of the default CC2540USB, it should use the UART instead of USB for HCI coms to BTool - is this correct? 

If not what is the best solution and suggested way forward? 


If I and correct, then am I missing a define somewhere? Any information would be a help.

Also if it is possible to use HCI over UART; 

Where is the baud rate set, parity, stop bits etc (defaults?),

Should the code for HCI-over-serial use the DMA option or ISR (which one is it built for)? 

BYW, the reason for wanting HCI over serial (UART) is our next stage in embedding the CC2540 into a non-USB platform; and spying BTool when necessary would be an advantage.


Thanks in advance,


31 Replies

  • The "CC2540EM Master" and "CC2540EM Slave" configurations of the HostTestRelease project are made for use with a physical UART and not USB. The port settings are 57600 baud rate/N/8/1, with hardware (RTS/CTS) flow control.

  • In reply to Willis1:

    Thanks for that, I actually sorted it out myself in the end. My board is a custom board that supports both USB and UART Hardware options. I have both going now, turns out all I had to to (which I missed) was just to select the CC2540EM workspace instead of the USB one. HCI over uart is working well with BTool.




  • In reply to Willis1:

    Hi Willis,

    Hopefully you don't mind me piggybacking off this threa.  We've have recently designed a custom target OMAP3-based (OMAP3525) board on which we added the CC2540 chip for Bluetooth functionality.  The CC2540 is wired to the OMAP3 via UART0 (we'll be using serial to communicate with the CC2540).  I have been searching all over the web without luck for the source code to the CC2540 with which we can use on the Montavista Linux (2.6.29-6) or any open source OMAP3 Linux (GIT) currently running on our OMAP3-custom target.  Does you know where I can find the driver source code?  Sorry, I'm a newbie with BT comm; I have configured (PINMUX) the OMAP3 UART0 to "talk" to the CC2540.  If you can point me in the right direction to where I can find the driver code (if any), I would appreciate it.  Thanks!



  • Guru 16250 points

    In reply to Andy_Omap:

    Hi Andy,

    if you install the BLE stack, the project in

    C:\Texas Instruments\BLE-CC2540-1.1a\Projects\ble\HostTestApp\CC2540


    Is exactly what are you searching for. Try to read the Internet about HCI commands. It should be also useful to you tu read some literature about BLE concepts like Advertising, Connection Events... which you can also find in the "Bluetooth Low Energy Software developer's guide" in order to identify which HCI commands will you need.


    Good luck.


    Please click the     Verify Answer     button on a post if it answers your question! :)

  • In reply to kazola:

    Hi Kaz,

    Thanks a lot for your help and the links of resources you provided to me.  At this time, I haven't gone through all of them yet.  Yes, based on your response, we would want to use the BLE stack using the UART interface as the physical comm medium between our OMAP3-based target host and the CC2540 device.  We are currently checking out the custom hardware we just built; at a first step, I need to verify the CC2540 is powering up and running fine; what would you recommend doing just to see if I can talk to the CC2540.  Should I use the bluez utility hcitool to try to communicate with it?  I downloaded the BLE-CC2540-1.1a source code but the only utility available is BTool, which runs on Windows only.  Sorry for all these newbie questions as I'm a little overwhelmed now.  Thank you.



  • Guru 16250 points

    In reply to Andy_Omap:

    Sorry for the delay in answering. I'm from Catalonia and perhaps we have some time differences. In fact, these are the "hciconfig -h" and "hcitool" outputs of my Linux Mint 11 system, kernel. 2.6.38. I've not slept a lot of hours but I think I've separated some classical BT commands from some BLE ones with the "..." symbol. The BTool output is useful, since would match the HCI command reference I gave you in other post.


    kaz@?? ~/Baixades/bluez-4.95 $ hciconfig -h


    hciconfig [-a] hciX [command ...]


    up                 Open and initialize HCI device

    down               Close HCI device

    reset               Reset HCI device

    iscan               Enable Inquiry scan


    lerandaddr <bdaddr> Set LE Random Address

    leadv               Enable LE advertising

    noleadv             Disable LE advertising

    lestates           Display the supported LE states


    kaz@?? ~/Baixades/bluez-4.95 $ hcitool

    hcitool [options] <command> [command parameters]


    --help Display help

    -i dev HCI device


    dev Display local devices

    inq Inquire remote devices


    lescan Start LE scan

    lewladd Add device to LE White List

    lewlrm Remove device from LE White List

    lewlsz Read size of LE White List

    lewlclr Clear LE White list

    lecc Create a LE Connection

    ledc Disconnect a LE Connection

    lecup LE Connection Update


    So perhaps you'll be able to do most of your work in your development machine, which I guess will be different of the OMAP one. Please have in mind the BLE work in Linux seems to not be completed. Please also have into account I'm just trying to help you, since I've not tested this commands or even if you can test CC2540 with this info, so it would also be nice by your side to attach the CC2540 via UART, test them, and post your success here, if any :). Check also this pdf.

    Good luck.


    Please click the     Verify Answer     button on a post if it answers your question! :)

  • Guru 16250 points

    In reply to kazola:

    It seems the following link could also be useful to you, Andy:

    base operations required to bring up UART Bluetooth

    Look in the "start up the system" section.


    Please click the     Verify Answer     button on a post if it answers your question! :)

  • In reply to kazola:

    Hi Kaz,

    Thanks a lot for your help and quick responses.  Just to refresh, we have the CC2540 hooked up to our OMAP3525-based target board via the UART interface (/dev/ttyS1); the UART interface is the only physical medium they are talking to each other.  The tx/rx/cts/rts lines are hooked up between them.  So we recently got our target board from FAB and I'm in the process of just trying to get our OMAP3525 to talk to the CC2540 over /dev/ttyS1.  The PINMUX on the OMAP3525 are all configured correctly.  We're running Montavista Linux 2.6.29-6 on our OMAP3525.  I downloaded the latest bluez source and tried to cross-build for our OMAP3525 board but ran into problems (DBUS library not found, etc) so I gave up for the moment.  However, I was able to find the hciattach/hciconfig/hcitool/etc binaries from the latest Angstrom distribution which contains the full rootfs for the OMAP3 processor.  I uploaded those binaries and here's what I've tried so far but got a failure

    # hciattach /dev/ttyS1 texas 115200 flow
    Initialization timed out.  

    I'm going to have our hardware guys make sure the tx/rx/cts/rts are hooked up correctly between the OMAP3525 /dev/ttyS1 and the CC2540.

    If I can get past the initialization stage, I may be able to do some more stuff just to verify that the CC2540 is working electrically.

    So I have another question for you: since the UART is the only physical medium (as opposed to USB or SPI) between the OMAP3525 and the CC2540, the bandwidth of any BT application running our our OMAP3525 target board is confined to the highest speed of the UART (/dev/ttyS0), is that correct?  In which case, it's 115200bps.  Does CC2540 support hi-speed UART (1-2Mbps)?




  • Guru 16250 points

    In reply to Andy_Omap:

    Hi Andy,

    please remember from now on I'm only trying to answer things I have not tested. In fact, right now perhaps I'm more interested in what you are doing than you in whatever I can try to figure out to help you.

    I strongly recommend you to take a look in hal_uart.h since it will provide you more information at once than the one I can give it to you :) This is a fragment of hal_uart.h, I think it can give you some clues about what you are asking for (look comments).

    /* UART Ports */


       Serial Port Baudrate Settings

       Have to match with baudrate table


      Note that when using interrupt service based UART configuration (as opposed to DMA)

      higher baudrate such as 115200bps may have problem when radio is operational at the same time.


    #define HAL_UART_BR_9600   0x00

    #define HAL_UART_BR_19200  0x01

    #define HAL_UART_BR_38400  0x02

    #define HAL_UART_BR_57600  0x03

    #define HAL_UART_BR_115200 0x04



    Good luck in your tests and don't forget to post your progress if you success.


    Please click the     Verify Answer     button on a post if it answers your question! :)

  • In reply to kazola:

    Hi Kaz,

    I was busy working on something else for the past 2 weeks and now I'm back on this.  So to refresh, we have the CC2540 hooked up to a OMAP3525 on our custom target board runing Linux 2.6.29-6 via the serial interface (/dev/ttyS1).  I installed some hci tool executables (hmiattach, hmitool, etc) on our OMAP3 board in order to try to initailize / attach to the CC2540 but am having no luck.  I use this link ( that you had me referred and issue the following command to establish communication with the CC2540 over serial:

    hciattach /dev/ttyS1 texas 57600 flow

    It keeps timing out and the initialization failed.  I tried it with 115200, 38400, 9600 and with the noflow option and still no luck.  So I have a few question that may helped us get the ball rolling to get our CC2540 up and running:

    1) Does the CC2540 come with firmware already installed and it should just come up running?  Or do you have to flash/program firmware on it to get the 8501 MCU running?  How would you do so on a target board like ours?

    2) If it does have software running when power is applied, what is the default speed on the serial interface (57600, 115200, etc)?  Besides having the 32MHz crystal hooked up and power applied to it, is there something we have to do to initialize it or can we just use hciattach to try to establish communication.  Is there any debugging log messages that come from the 8501 MCU on it we can look at to make sure it's powering up?

    I'm not sure if we have our TX/RX/CTS/RTS lines/pins on this chip hooked up correctly with respect to the lines of the OMAP3525; the pins on the CC2540 are not labeled explicitly with its specific functions with respect to TX/RX/CTS/RTS; I have recommended to our hardware engineers to look at the schematic of the BLE CC2540 Mini Dev Kit to see how it's hooked up there.

    I'm ready to recommend to our hardware engineers switch over to use the CSR BC6 ROM chip instead due to the lack of software driver/resources for the CC2540.  We were hoping just to use the CC2540 as is, power it up and have it running with the Linux software/driver support for it without any hassle.  This only software resource I can find is on this forum and it's really to a standalone development system (IAR) that comes with the Mini Dev Kit; I can't find any references to it being run in an embedded Linux system.  The CSR BlueCore chips (BC6 ROM included) have Linux software/driver support so we're seriously considering it.  Can any TI expert/employee help answer these questions also, point us to any Linux software/driver resources we can use?

    We're going to spend until the end of this week to try to get the CC2540 going.  At this point, we're just trying to establish serial communication between the OMAP3 and CC2540.  I think we will need a lot more software port / development from the available IAR development code on the OMAP to get this working fully.  Please advise.  Thank you.

    Regards, Andy