Bsim for central_hr example

Hey guys,

for testing purposes on nrf52833 and SDK 2.8.0 I want to use a simulation and stumbled upon bsim.

I followed the instructions there and can build and run the hello world for the hardware and for the simulation.
But the step with the central_hr does not work for me. Building for hardware is ok but not simulation, because if I run:

export BSIM_OUT_PATH=${ZEPHYR_BASE}/../tools/bsim/
export BSIM_COMPONENTS_PATH=${BSIM_OUT_PATH}/components
rm -rf build_sim && west build -b nrf52_bsim -d build_sim


I get

  This combination of SoC and floating point ABI is notsupported by the
  SoftDevice Controller lib.

 
From here I have to use zephyr BLE controller instead of the Softdevice. So in prj.conf I add:

CONFIG_BT_LL_SW_SPLIT=y


and again with

export BSIM_OUT_PATH=${ZEPHYR_BASE}/../tools/bsim/
export BSIM_COMPONENTS_PATH=${BSIM_OUT_PATH}/components
rm -rf build_sim && west build -b nrf52_bsim -d build_sim

I get:

FAILED: zephyr/CMakeFiles/native_runner_executable zephyr/zephyr.exe ~/nordic/central_hr/build_sim/central_hr/zephyr/CMakeFiles/native_runner_executable ~/nordic/central_hr/build_sim/central_hr/zephyr/zephyr.exe
cd ~/nordic/central_hr/build_sim/central_hr/zephyr && /usr/bin/make -f ~/ncs/v2.8.0/zephyr/scripts/native_simulator/Makefile all --warn-undefined-variables -r NSI_CONFIG_FILE=~/nordic/central_hr/build_sim/central_hr/zephyr/NSI/nsi_config
/usr/bin/ld: ~/nordic/central_hr/build_sim/central_hr/zephyr/NSI~/nordic/central_hr/build_sim/central_hr/zephyr/zephyr.elf.loc_cpusw.o:(.data.bt_dev+0x158): undefined reference to `__device_dts_ord_86'
collect2: error: ld returned 1 exit status
make: *** [~/ncs/v2.8.0/zephyr/scripts/native_simulator/Makefile:131: ~/nordic/central_hr/build_sim/central_hr/zephyr/zephyr.exe] Error 1
ninja: build stopped: subcommand failed.

This seems to be related to the device tree, but I am not sure how.

With this video starting at ~20mins I could track it down to

struct bt_dev bt_dev = {
 .init = { .handler = (init_work), },
 .hci = (&__device_dts_ord_86),
};

in

build_sim/central_hr/zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/hci_core.c.i

Parents
  • Hi,

    The way to change Bluetooth controller implementation has changed, and that is now done in the devicetree instaed of using Kconfig. See this post for details.

  • Hi, thank you, it looks good:

    ~/nordic/central_hr$ d_00: @00:00:00.000000  *** Booting nRF Connect SDK v2.8.0-a2386bfc8401 ***
    d_00: @00:00:00.000000  *** Using Zephyr OS v3.7.99-0bc3393fb112 ***
    d_00: @00:00:00.000000  [00:00:00.000,000] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    d_00: @00:00:00.000000  [00:00:00.000,000] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
    d_00: @00:00:00.000000  [00:00:00.000,000] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 3.7 Build 99
    d_00: @00:00:00.000000  [00:00:00.000,000] <wrn> bt_id: No static addresses stored in controller
    d_00: @00:00:00.002648  [00:00:00.002,624] <inf> bt_hci_core: Identity: FD:9E:B2:48:47:39 (random)
    d_00: @00:00:00.002648  [00:00:00.002,624] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x0000, manufacturer 0x0059
    d_00: @00:00:00.002648  [00:00:00.002,624] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0xffff
    d_00: @00:00:00.002648  Bluetooth initialized
    d_00: @00:00:00.003368  Scanning successfully started

    Now I would like to do the same for my actual application instead of central_hr. My app is based on the NUS example and uses UART. I run into following error:

    d_00: @00:00:00.000000  *** Booting My Application v2.7.0-7937ab1b0b19 ***
    d_00: @00:00:00.000000  *** Using nRF Connect SDK v2.8.0-a2386bfc8401 ***
    d_00: @00:00:00.000000  *** Using Zephyr OS v3.7.99-0bc3393fb112 ***
    d_00: @00:00:00.000000  [00:00:00.000,000] <err> UART_DRIVER: Cannot initialize UART callback
    d_00: @00:00:00.000000  [00:00:00.000,000] <err> BLE: Uart init failed (err -88)

    which comes from here:

        /* Register UART Callback */
        err = uart_callback_set(uart, uart_cb, NULL);
        if (err) {
            k_free(rx);
            LOG_ERR("Cannot initialize UART callback");
            return err;
        }

    while -88 is

    #define ENOSYS 88		/* Function not implemented */

    and zephyr.dts:

    8508.zephyr.dts

    Probably also something with the device tree. Do you have an idea?

  • Hi,

    I have not been able to test today, but I see the UARTE peripheral should be emulated by the nrf52_bsim board, so I would expect it should be possible to get it to work with the proiper configuration. I suggest you refer to the nrf52_bsim board files for reference. I should add though that this is added by the Zephyr community and not supported by Nordic (that may change, though).

    Also, please note that bsim has its clear uses for instance in reproducing bugs that can take a long time to reproduce, etc as you can simulate much faster than in real life. But the models are far from perfect, so you riskm issing real issues, and also getting false positives. So it is not a test tool I would recommend for most projects. (There is also a limitation in that currently you have to use Zephyr LL and not the SoftDegvice Controller which is what you should use in the real procuct, adding even more to the difference between the simulated device and the real product.)

Reply
  • Hi,

    I have not been able to test today, but I see the UARTE peripheral should be emulated by the nrf52_bsim board, so I would expect it should be possible to get it to work with the proiper configuration. I suggest you refer to the nrf52_bsim board files for reference. I should add though that this is added by the Zephyr community and not supported by Nordic (that may change, though).

    Also, please note that bsim has its clear uses for instance in reproducing bugs that can take a long time to reproduce, etc as you can simulate much faster than in real life. But the models are far from perfect, so you riskm issing real issues, and also getting false positives. So it is not a test tool I would recommend for most projects. (There is also a limitation in that currently you have to use Zephyr LL and not the SoftDegvice Controller which is what you should use in the real procuct, adding even more to the difference between the simulated device and the real product.)

Children
No Data
Related