2015-06-05 14:38:52 +02:00
## General Tools
2015-05-05 00:21:33 +02:00
2017-01-16 22:10:42 +01:00
Most ports use a regular Makefile to build the examples.
2015-05-05 00:21:33 +02:00
On Unix-based systems, git, make, and Python are usually installed. If
not, use the system’ s packet manager to install them.
2017-01-16 22:10:42 +01:00
On Windows, there is no packet manager, but it's easy to download and install all requires development packets quickly by hand. You'll need:
2015-05-05 00:21:33 +02:00
2017-01-16 22:10:42 +01:00
- [Python ](http://www.python.org/getit/ ) for Windows. When using the official installer, please confirm adding Python to the Windows Path.
- [MSYS2 ](https://msys2.github.io ) is used to provide the bash shell and most standard POSIX command line tools.
2017-01-16 22:19:58 +01:00
- [MinGW64 ](https://mingw-w64.org/doku.php ) GCC for Windows 64 & 32 bits incl. make. To install with MYS2: pacman -S mingw-w64-x86_64-gcc
- [git ](https://git-scm.com ) is used to download BTstack source code. To install with MYS2: pacman -S git
- [winpty ](https://github.com/rprichard/winpty ) a wrapper to allow for console input when running in msys2: To install with MYS2: pacman -S winpty
2015-05-05 00:21:33 +02:00
2015-06-05 14:38:52 +02:00
## Getting BTstack from GitHub
2015-05-05 00:21:33 +02:00
Use git to clone the latest version:
2015-06-18 16:33:34 +02:00
git clone https://github.com/bluekitchen/btstack.git
2015-05-05 00:21:33 +02:00
Alternatively, you can download it as a ZIP archive from
[BTstack’ s page ](https://github.com/bluekitchen/btstack/archive/master.zip ) on
GitHub.
2015-06-05 14:38:52 +02:00
## Compiling the examples and loading firmware
2015-05-05 00:21:33 +02:00
This step is platform specific. To compile and run the examples, you
need to download and install the platform specific toolchain and a flash
tool. For TI’ s CC256x chipsets, you also need the correct init script,
or “Service Pack” in TI nomenclature. Assuming that these are provided,
2016-01-20 14:20:15 +01:00
go to folder [btstack/port/$PLATFORM$]() in command prompt and run make.
2015-05-08 15:09:18 +02:00
If all the paths are correct, it will generate several firmware files. These firmware files
2015-05-05 00:21:33 +02:00
can be loaded onto the device using platform specific flash programmer.
For the PIC32-Harmony platform, a project file for the MPLAB X IDE is
provided, too.
2015-06-05 14:38:52 +02:00
## Run the Example
2015-05-05 00:21:33 +02:00
2015-06-18 16:33:34 +02:00
As a first test, we recommend the [SPP Counter example ](examples/generated/#sec:sppcounterExample ).
During the startup, for TI chipsets, the init
2015-05-05 00:21:33 +02:00
script is transferred, and the Bluetooth stack brought up. After that,
the development board is discoverable as “BTstack SPP Counter” and
provides a single virtual serial port. When you connect to it, you’ ll
receive a counter value as text every second.
2015-06-05 14:38:52 +02:00
## Platform specifics
2015-05-05 00:21:33 +02:00
In the following, we provide more information on specific platform
setups, toolchains, programmers, and init scripts.
2015-06-05 14:38:52 +02:00
### libusb
2015-05-05 00:21:33 +02:00
The quickest way to try BTstack is on a Linux or OS X system with an
2017-01-16 22:10:42 +01:00
additional USB Bluetooth module. The Makefile [port/libusb]() in requires
2015-05-05 00:21:33 +02:00
[pkg-config ](http://www.freedesktop.org/wiki/Software/pkg-config/ )
2015-07-01 12:32:25 +02:00
and [libusb-1.0 ](http://libusb.info ) or higher to be
2015-05-05 00:21:33 +02:00
installed.
On Linux, it’ s usually necessary to run the examples as root as the
kernel needs to detach from the USB module.
On OS X, it’ s necessary to tell the OS to only use the internal
Bluetooth. For this, execute:
sudo nvram bluetoothHostControllerSwitchBehavior=never
2017-01-16 22:10:42 +01:00
## Windows-WinUSB
2015-05-05 00:21:33 +02:00
2017-01-16 22:10:42 +01:00
While libusb basically also works on Windows, we recommend to use the Windows-WinUSB port that uses a native run loop and the native WinUSB API to access the USB Bluetooth dongle.
2015-05-05 00:21:33 +02:00
2017-01-16 22:10:42 +01:00
For libusb or WinUSB, you need to install a special device driver to make the USB dongle accessible to user space. It works like this:
2015-05-05 00:21:33 +02:00
2017-01-16 22:10:42 +01:00
- Start [Zadig ](http://zadig.akeo.ie )
- Select Options -> “List all devices”
- Select USB Bluetooth dongle in the big pull down list
- Select WinUSB (libusb) in the right pull pull down list
- Select “Replace Driver”
2015-05-05 00:21:33 +02:00
2017-01-16 22:19:58 +01:00
When running the examples in the MSYS2, the console input (via btstack_stdin_support) doesn't work. It works in the older MSYS and also the regular
CMD.exe environment. Another option is to install WinPTY and then start the example via WinPTY like this:
$ winpty ./hfp_hf_demo.exe
2015-05-05 00:21:33 +02:00
2015-06-05 14:38:52 +02:00
### Texas Instruments MSP430-based boards
2015-05-05 00:21:33 +02:00
**Compiler Setup.** The MSP430 port of BTstack is developed using the
Long Term Support (LTS) version of mspgcc. General information about it
and installation instructions are provided on the
[MSPGCC Wiki ](http://sourceforge.net/apps/mediawiki/mspgcc/index.php?title=MSPGCC_Wiki ).
On Windows, you need to download and extract
[mspgcc ](http://sourceforge.net/projects/mspgcc/files/Windows/mingw32/ )
2015-05-08 15:09:18 +02:00
to [C:\mspgcc](). Add [C:\mspgcc\bin]() folder to the Windows Path in Environment
2015-06-18 16:33:34 +02:00
variable as explained [here ](#sec:windowsPathQuickStart ).
2015-05-05 00:21:33 +02:00
**Loading Firmware.** To load firmware files onto the MSP430 MCU for the
MSP-EXP430F5438 Experimeneter board, you need a programmer like the
MSP430 MSP-FET430UIF debugger or something similar. The eZ430-RF2560 and
MSP430F5529LP contain a basic debugger. Now, you can use one of
following software tools:
2015-05-08 15:09:18 +02:00
- [MSP430Flasher ](http://processors.wiki.ti.com/index.php/MSP430_Flasher_Command_Line_Programmer )
2015-05-05 00:21:33 +02:00
(windows-only):
2015-05-08 15:09:18 +02:00
- Use the following command, where you need to replace the [BINARY_FILE_NAME.hex]() with
2015-05-05 00:21:33 +02:00
the name of your application:
<!-- -->
2015-06-18 16:33:34 +02:00
MSP430Flasher.exe -n MSP430F5438A -w "BINARY_FILE_NAME.hex" -v -g -z [VCC]
2015-05-05 00:21:33 +02:00
- [MSPDebug ](http://mspdebug.sourceforge.net/ ):
An example session with the MSP-FET430UIF connected on OS X is given
in following listing:
<!-- -->
mspdebug -j -d /dev/tty.FET430UIFfd130 uif
...
prog blink.hex
run
2015-06-05 14:38:52 +02:00
### Texas Instruments CC256x-based chipsets
2015-05-05 00:21:33 +02:00
**CC256x Init Scripts.** In order to use the CC256x chipset on the
PAN13xx modules and others, an initialization script must be obtained.
Due to licensing restrictions, this initialization script must be
obtained separately as follows:
- Download the [BTS file ](http://processors.wiki.ti.com/index.php/CC256x_Downloads )
for your CC256x-based module.
- Copy the included .bts file into
2015-10-15 16:58:46 +02:00
- In [chipset/cc256x](), run the Python script:
2015-05-05 00:21:33 +02:00
<!-- -->
./convert_bts_init_scripts.py
The common code for all CC256x chipsets is provided by
2016-01-22 17:16:06 +01:00
*btstack_chipset_cc256x.c*. During the setup,
*btstack_chipset_cc256x_instance* function is used to get a
*btstack_control_t* instance and passed to *hci_init* function.
2015-05-05 00:21:33 +02:00
**Note:** Depending on the CC256x-based module you’ re using, you’ ll need
to update the reference in the Makefile to match the downloaded file.
**Update:** For the latest revision of the CC256x chipsets, the CC2560B
and CC2564B, TI decided to split the init script into a main part and
the BLE part. The conversion script has been updated to detect
*bluetooth_init_cc256x_1.2.bts* and adds *BLE_init_cc256x_1.2.bts*
if present and merges them into a single .c file.
2015-09-19 21:27:36 +02:00
**Update 2:** In May 2015, TI renamed the init scripts to match
the naming scheme previously used on Linux systems. The conversion
script has been updated to also detect *initscripts_TIInit_6.7.16_bt_spec_4.1.bts*
and integrates *initscripts_TIInit_6.7.16_ble_add-on.bts* if present.
2015-05-08 15:09:18 +02:00
2015-06-18 16:33:34 +02:00
### MSP-EXP430F5438 + CC256x Platform {#sec:platformMSP430QuickStart}
2015-05-05 00:21:33 +02:00
**Hardware Setup.** We assume that a PAN1315, PAN1317, or PAN1323 module
is plugged into RF1 and RF2 of the MSP-EXP430F5438 board and the “RF3
Adapter board” is used or at least simulated. See [User
Guide](http://processors.wiki.ti.com/index.php/PAN1315EMK_User_Guide#RF3_Connector ).
2015-06-05 14:38:52 +02:00
### STM32F103RB Nucleo + CC256x Platform
2015-05-05 00:21:33 +02:00
To try BTstack on this platform, you’ ll need a simple adaptor board. For
2015-05-08 15:09:18 +02:00
details, please read the documentation in [platforms/stm32-f103rb-nucleo/README.md]().
2015-05-05 00:21:33 +02:00
2015-06-05 14:38:52 +02:00
### PIC32 Bluetooth Audio Development Kit
2015-05-05 00:21:33 +02:00
The PIC32 Bluetooth Audio Development Kit comes with the CSR8811-based
BTM805 Bluetooth module. In the port, the UART on the DAC daughter board
was used for the debug output. Please remove the DAC board and connect a
3.3V USB-2-UART converter to GND and TX to get the debug output.
2015-06-18 16:33:34 +02:00
In [platforms/pic32-harmony](), a project file for the MPLAB X IDE
is provided as well as a regular
2015-05-05 00:21:33 +02:00
Makefile. Both assume that the MPLAB XC32 compiler is installed. The
project is set to use -Os optimization which will cause warnings if you
only have the Free version. It will still compile a working example. For
this platform, we only provide the SPP and LE Counter example directly.
2015-06-18 16:33:34 +02:00
Other examples can be run by replacing the *spp_and_le_counter.c* file
2015-05-05 00:21:33 +02:00
with one of the other example files.