Skip to content
README.md 5.41 KiB
Newer Older
Yoan Picchi's avatar
Yoan Picchi committed

# babblesim PoC

## Dependencies

1. Gcc for arm

    [developer.arm.com](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads)<br>
    Download, install and add the binary directory to your path 

2. FVP

    Download and install the FVP at /opt/arm/VHT_Corstone_SSE-300_Ethos-U55.<br>
    Alternatively, if you have the FVP already installed at another path, make sure it's added to your `$PATH`. If it is installed in `/opt/arm/` for instance:

    ```sh
    command -v VHT_Corstone_SSE-300_Ethos-U55 >/dev/null 2>&1 || export PATH=$PATH:/opt/arm/
    ```

3. Python 3.8+ and tools

    It'll be needed for the Zephyr bluetooth controler build tool:

    ```sh
    sudo apt-get install python3 python3-venv python3-pip
    ```

## Build

There are 4 components to build:
1. Babblesim (the phy simulation)
2. Zephyr bluetooth controller (running on the Linux host and connected to babblesim)
3. NimBLE bluetooth host stack (built with Open IoT SDK running in the FVP)
4. HCI bridge (Linux application that connects the NimBLE Bluetooth Stack in the FVP to Linux's BlueZ)

The Zephyr controller requires babblesim to be built first.

### Using the top level build script

If your git environement is setup with a global name and address, you may use the top level build script directly:

```sh
. build.sh
```

If it isn't, you may set your git name and email globally with:

```sh
git config --global user.name "first_name last_name"
git config --global user.email "someone@something.com"
```

If you prefer not to set it, you'll need to run the config script in `babblesim/` manually first and then run the build script

```sh
cd babblesim
. config.sh
cd ..
. build.sh
```

### Manual build

If the build script fails, you'll need to clean then build each component individually to figure out the issue:
#### Install west

[zephyrproject.org](https://docs.zephyrproject.org/latest/develop/west/install.html)
```sh
python3 -m venv venv
source ./venv/bin/activate
pip3 install west pyelftools
```
#### Babblesim

The config script needs to be run as source because it sets a pair of environment variables that will be needed both to build zephyr and at runtime.<br>
You will have a missing include `fftw3.h` for one of the babblesim component. You may ignore it, we don't use that component and the build will skip it and build the others.
```sh
cd babblesim
. clean.sh
. config.sh
. build.sh
cd ..
```
#### Zephyr

```sh
cd zephyr_controller
. clean.sh
. build.sh
cd ..
```
#### NimBLE/IOT SDK

You need to be connected to the VPN to pull and build the IOT SDK
```sh
cd iot_sdk
. clean.sh
. config.sh
. build.sh
cd ..
```
#### HCI bridge

```sh
cd linux-side_bridge
. clean.sh
. build.sh
cd ..
```

## Run

You'll need 4 consoles:
1. Babblesim

    The console running babblesim needs environment variables to be setup. If this is a new console, rerun the config script before running the simulation.

    ```sh
    cd babblesim
    . config.sh
    . run.sh
    ```
    This will run the Zephyr bluetooth controller alongside the babblesim simulation.<br>
    Take note of the pseudotty used:

    eg: `UART_0 connected to pseudotty: /dev/pts/5`

    Please ignore the missing files during the initial cleanup
2. btattach

    Use the pseudotty you got from babblesim

    ```sh
    sudo btattach -P h4 -B /dev/pts/5 -S 1000000
    ```
    Take note of the device ID:

    eg: `Device index 1 attached`

    Wait a few seconds before continuing until it attaches to the zephyr bluetooth controller application.<br>
    If you want to be sure the `btattach` is complete you may monitor the traffic in another terminal with:

    ```sh
    sudo btmon
    ```
3. HCI bridge

    After waiting for btattach to finish, use as parameter the device ID you previously obtained

    ```sh
    cd linux-side_bridge
    sudo __build/bridge 1
    ```
4. NimBLE/IOT SDK

    ```sh
    cd iot_sdk
    . run.sh
    ```

You should first see some traffic in the terminal with the HCI bridge.
Eventually the terminal with babblesim should show a message (device address will vary):

`Device found: 2D:71:8F:C2:E4:6E (random) (RSSI -35)`

This is the Nimble device running in the FVP being detected by the observer device running in babblesim.


Terminate the programs in the reverse order they were started:

- NimBLE Host stack
- HCI bridge
- btattach
- Babblesim

Failure to do so may create zombie interfaces that will only be cleaned after a reboot.
This means in particular that your pts and device number may be different for each run.



# License and contributions

The software is provided under the Apache-2.0 license. All contributions to software and documents are licensed by contributors under the same license model as the software/document itself (ie. inbound == outbound licensing). Open IoT SDK may reuse software already licensed under another license, provided the license is permissive in nature and compatible with Apache v2.0.

Folders containing files under different permissive license than Apache 2.0 are listed in the LICENSE file.

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information.

## Security issues reporting

If you find any security vulnerabilities, please do not report it in the GitLab issue tracker. Instead, send an email to the security team at arm-security@arm.com stating that you may have found a security vulnerability in the Open IoT SDK.

More details can be found at [Arm Developer website](https://developer.arm.com/support/arm-security-updates/report-security-vulnerabilities).