<commit_before>
.. _nrf52_bsim:

NRF52 simulated board (BabbleSim)
#################################

.. contents::
   :depth: 1
   :backlinks: entry
   :local:


Overview
********

This is a simulated NRF52 board which uses `BabbleSim`_ to simulate the radio
activity.
This board models some of the NRF52 SOC peripherals:

* Radio
* Timers
* Real time counter
* Random number generator
* AES CCM & AES ECB encryption HW
* Accelerated address resolver
* Clock control
* PPI (Programmable Peripheral Interconnect)

The nrf52_bsim board definition uses the POSIX architecture to
run applications natively on the development system.  As with
the ``native_posix`` board, this has the benefit of providing
native code execution performance and easy debugging using
native tools, but has the same drawbacks.  Please refer to
:ref:`Native Posix's important limitations <native_important_limitations>`
for more details.

.. _BabbleSim:
   https://BabbleSim.github.io

.. _nrf52bsim_build_and_run:

Building and running
**********************

.. note::

   You must have the 32-bit C library installed in your system
   (in Ubuntu 16.04 install the gcc-multilib package)

.. note::

   This will **not** work in Windows Subsystem for Linux (WSL) because WSL
   does not support native 32-bit binaries.

To target this board you need to have `BabbleSim`_ compiled in your system.
If you do not have it yet, you can fetch and build it in this way:

.. code-block:: console

   mkdir -p ${HOME}/bsim && cd ${HOME}/bsim
   repo init -u <EMAIL>:BabbleSim/manifest.git -m everything.xml \
     -b master
   repo sync
   make everything -j 8

Define two environment variables to point to your BabbleSim
installation, ``BSIM_OUT_PATH`` and ``BSIM_COMPONENTS_PATH``.
If you followed the previous steps, you can just do:

.. code-block:: console

   export BSIM_OUT_PATH=${HOME}/bsim/
   export BSIM_COMPONENTS_PATH=${HOME}/bsim/components/

You're now ready to build applications targeting this board, for example:

.. zephyr-app-commands::
   :zephyr-app: samples/hello_world<commit_msg>nrf52_bsim: doc: Clarify how to fetch and compile BabbleSim<commit_after>
.. _nrf52_bsim:

NRF52 simulated board (BabbleSim)
#################################

.. contents::
   :depth: 1
   :backlinks: entry
   :local:


Overview
********

This is a simulated NRF52 board which uses `BabbleSim`_ to simulate the radio
activity.
This board models some of the NRF52 SOC peripherals:

* Radio
* Timers
* Real time counter
* Random number generator
* AES CCM & AES ECB encryption HW
* Accelerated address resolver
* Clock control
* PPI (Programmable Peripheral Interconnect)

The nrf52_bsim board definition uses the POSIX architecture to
run applications natively on the development system.  As with
the ``native_posix`` board, this has the benefit of providing
native code execution performance and easy debugging using
native tools, but has the same drawbacks.  Please refer to
:ref:`Native Posix's important limitations <native_important_limitations>`
for more details.

.. _BabbleSim:
   https://BabbleSim.github.io

.. _nrf52bsim_build_and_run:

Building and running
**********************

.. note::

   You must have the 32-bit C library installed in your system
   (in Ubuntu 16.04 install the gcc-multilib package)

.. note::

   This will **not** work in Windows Subsystem for Linux (WSL) because WSL
   does not support native 32-bit binaries.

To target this board you need to have `BabbleSim`_ compiled in your system.
If you do not have it yet, in `its webpage <https://BabbleSim.github.io>`_
you can find instructions on how to
`fetch <https://babblesim.github.io/fetching.html>`_ and
`build <https://babblesim.github.io/building.html>`_ it.
In short, you can do:

.. code-block:: console

   mkdir -p ${HOME}/bsim && cd ${HOME}/bsim
   curl https://storage.googleapis.com/git-repo-downloads/repo > ./repo  && chmod a+x ./repo
   ./repo init -u <EMAIL>:BabbleSim/manifest.git -m everything.xml -b master
   ./repo sync
   make everything -j 8

Define two environment variables to point to your BabbleSim
installation, ``BSIM_OUT_PATH`` and ``BSIM_COMPONENTS_PATH``.
If you followed the previous steps, you can just do:

.. code-block:: console

   export BSIM_OUT_PATH=${HOME}/bsim/
   export BSIM_COMPONENTS_PATH=${HOME}/bsim/components/

.. note::

   You can add these two lines to your ``~/.zephyrrc`` file, or to your shell
   initialization script (``~/.bashrc``), so you won't need to rerun them
   manually for each new shell.

You're now ready to build applications targeting this board, for example:

.. zephyr-app-commands::
   :zephyr-app: samples/hello_world
{'fraction_non_alphanumeric': 0.1110872367855608, 'fraction_numerical': 0.009883970777825527, 'mean_word_length': 4.121012101210121, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5030175', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1368, 'n_words': 554}