docs: Miscelaneous improvements

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-07-21 11:14:22 +02:00
parent 7a5b67d9ee
commit 46a3f44403
21 changed files with 249 additions and 174 deletions

View File

@ -1,27 +0,0 @@
Current limitations and pending things to do:
(T): To do
(N): Nice to have
(L): Low priority
(VL): Very low priority (not used in current controller SW)
* Proper testing: All currently implemented models have only been tested lightly
* RADIO:
* (L) Only BLE 1/2Mbps (no LR) and 802.15.4 packet format supported
* (L) Only default freq. map supported
* (VL) Only 1st logical address is supported
* (VL) More limitation listed in NRF_RADIO.c
* ECB:
* AAR:
* AES-CCM:
* FICR:
* Just empty registers by now
* (N) Would be nice to have a programmable BT-Addr from command line
* RNG:
* (N) Delay is always the same and constant (with or without bias correction)
* TIMER:
* (VL) Counter mode is not fully supported
Not implemented, and no plans to implement:
* WDT, QDEC, LPCOMP, COMP, PWM, PDM, ACL, NVMC, MWU, SPIM/S, I2S, FPU, USB,
UART, UARTE, QSPI, GPIO, CRYPTOCELL, UICR

View File

@ -1,12 +1,15 @@
# Models of some of the HW present in a NRF52xxx
# Models of the nRF52xxx HW peripherals
Where relevant differences exist, these models try to align with a NRF52833.
This repo contains both models of the NRF52 HW as well as some replacement nrfx
This repo contains models of the nRF52 HW peripherals and some replacement nrfx
HAL functions. When used in combination with the real nrfx, these should enable code
meant for the nrfx to run without needing further changes.
This includes Zephyr SW.
Where relevant
[differences](https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_nrf52%2Fstruct%2Fnrf52.html&cp=5)
exist, these models try to align with an
[nRF52833](https://infocenter.nordicsemi.com/topic/struct_nrf52/struct/nrf52833.html?cp=5_1).
When compiling this component using the provided Makefile (not with Zephyr's build system),
the environment variable `NRFX_BASE` must be set to the path where a nrfx has been cloned.
The nrfx must be at least version 2.3.0.
@ -33,11 +36,22 @@ for the radio environment simulation.
For more information about the HW models, or how to use them without the
nrf52_bsim please refer to [README_HW_models.md](./README_HW_models.md)
## Faithfullness of these models
## What these models include
Not all SOC peripherals are modelled yet, and for some of the included peripherals
not all features or options are modelled. This is typically the case for HW functionality
which is not used by the Zephyr drivers/OS.
You can find what features of which peripherals are included so far, and with what approximations in
[README_impl_status.md](./README_impl_status.md).
It is certainly possible to expand these models to include the missing peripherals or functionality.
### Faithfullness of these models
These models are accurate enough to allow the current Zephyr to run, and
its BLE stack to function. For more details please see the notes on the source
its BLE and 15.4 stacks to function. For more details please see the notes on the source
files for each peripheral model.
In general, functionality is modelled only to the necessary degree as to enable the SW to run,
in a manner that is comparable to the real HW.
These models are based solely on
[the public SOC specifications](https://infocenter.nordicsemi.com/topic/struct_nrf52/struct/nrf52833.html)
@ -45,12 +59,6 @@ These models are based solely on
They have been developed without any other knowledge and probably contain
inacuracies, and defects.
Several of the peripherals which are not necessary for typical BLE applications
are not modelled. Moreover, in the modelled peripherals, functionality which is
not used in the Zephyr drivers is normally not modelled either.
The [TODO](../TODO.txt) file list some mayor omissions.
It is certainly possible to expand these models to include the rest.
### About the ARM processor peripherals
These models do not include the ARM processor peripherals (for ex. the SCB)

View File

@ -2,7 +2,7 @@ For general information about these models refer to [README.md](README.md)
You will only need to continue reading if you are curious about how these
models are built, or if you want to use them for some other purpose than
with the nrf52_bsim.
with Zephyr's nrf52_bsim.
## Requirements

View File

@ -0,0 +1,84 @@
# Current implementation status
Currently these models aim at modelling the peripherals of a nRF52833 SOC at varying degrees:
* &#x2713; **NVMC** — Non-volatile memory controller
* See [NRF_NVMC.c](../src/HW_models/NRF_NVMC.c)
* &#x2713; **FICR** — Factory information configuration registers
* See [NRF_FICR.c](../src/HW_models/NRF_FICR.c)
* &#x2713; **UICR** — User information configuration registers
* See [NRF_NVMC.c](../src/HW_models/NRF_NVMC.c)
* &#x10102; **POWER** — Power supply
* Only register stubs
* &#x2713; **CLOCK** — Clock control
* See [NRF_CLOCK.c](../src/HW_models/NRF_CLOCK.c)
* &#x2713; **AAR** — Accelerated address resolver
* See [NRF_AAR.c](../src/HW_models/NRF_AAR.c)
* &#x10102; **ACL** — Access control lists
* Not modelled yet
* &#x2713; **CCM** — AES CCM mode encryption
* See [NRF_AES_CCM.c](../src/HW_models/NRF_AES_CCM.c)
* &#x10102; **COMP** — Comparator
* Not modelled yet
* &#x2714; **ECB** — AES electronic codebook mode encryption
* Complete
* &#x2714; **EGU** — Event generator unit
* Complete
* &#x2713; **GPIO** — General purpose input/output
* See [NRF_GPIO.c](../src/HW_models/NRF_GPIO.c)
* &#x2714; **GPIOTE** — GPIO tasks and events
* Complete with very minor differences
* See [NRF_GPIOTE.c](../src/HW_models/NRF_GPIOTE.c)
* &#x10102; **I2S** — Inter-IC sound interface
* Not modelled yet
* &#x10102; **LPCOMP** — Low-power comparator
* Not modelled yet
* &#x10102; **MWU** — Memory watch unit
* Not modelled yet
* &#x10102; **NFCT** — Near field communication tag
* Not modelled yet
* &#x10102; **PDM** — Pulse density modulation interface
* Not modelled yet
* &#x2714; **PPI** — Programmable peripheral interconnect
* Complete but some peripheral connections are missing
* &#x10102; **PWM** — Pulse width modulation
* Not modelled yet
* &#x10102; **QDEC** — Quadrature decoder
* Not modelled yet
* &#x2713; **RADIO** — 2.4 GHz radio
* See [NRF_RADIO.c](../src/HW_models/NRF_RADIO.c)
* &#x2713; **RNG** — Random number generator
* See [NRF_RNG.c](../src/HW_models/NRF_RNG.c)
* &#x2713; **RTC** — Real-time counter
* See [NRF_RTC.c](../src/HW_models/NRF_RTC.c)
* &#x10102; **SAADC** — Successive approximation analog-to-digital converter
* Not modelled yet
* &#x10102; **SPI** — Serial peripheral interface master
* Not modelled yet
* &#x10102; **SPIM** — Serial peripheral interface master with EasyDMA
* Not modelled yet
* &#x10102; **SPIS** — Serial peripheral interface slave with EasyDMA
* Not modelled yet
* &#x2714; **SWI** — Software interrupts
* See EGU
* &#x2713; **TEMP** — Temperature sensor
* See [NRF_TEMP.c](../src/HW_models/NRF_TEMP.c)
* &#x10102; **TWI** — I2C compatible two-wire interface
* Not modelled yet
* &#x2713; **TIMER** — Timer/counter
* See [NRF_TIMER.c](../src/HW_models/NRF_TIMER.c)
* &#x10102; **TWIM** — I2C compatible two-wire interface master with EasyDMA
* Not modelled yet
* &#x10102; **TWIS** — I2C compatible two-wire interface slave with EasyDMA
* Not modelled yet
* &#x10102; **UART** — Universal asynchronous receiver/transmitter
* Not modelled yet
* &#x10102; **UARTE** — Universal asynchronous receiver/transmitter with EasyDMA
* Not modelled yet
* &#x10102; **USBD** — Universal serial bus device
* Not modelled yet
* &#x10102; **WDT** — Watchdog timer
* Not modelled yet
ARM processor peripherals or the AHB interconnect are not part of these models

View File

@ -3,10 +3,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* AR Accelerated address resolver
* AAR Accelerated address resolver
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/aar.html?cp=4_1_0_5_1
*/
#include "NRF_AAR.h"
#include <string.h>
#include <stdbool.h>

View File

@ -3,6 +3,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* AES electronic codebook mode encryption
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/ecb.html?cp=4_1_0_5_5
*/
#include "NRF_AES_ECB.h"
#include "NRF_PPI.h"
#include <string.h>
@ -14,11 +20,6 @@
#include "bs_tracing.h"
#include "BLECrypt_if.h"
/*
* AES electronic codebook mode encryption
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/ecb.html?cp=4_1_0_5_5
*/
bs_time_t Timer_ECB = TIME_NEVER; /* Time when the ECB will finish */
NRF_ECB_Type NRF_ECB_regs;

View File

@ -4,16 +4,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "NRF_CLOCK.h"
#include <string.h>
#include <stdint.h>
#include "time_machine_if.h"
#include "NRF_HW_model_top.h"
#include "NRF_PPI.h"
#include "NRF_RTC.h"
#include "irq_ctrl.h"
#include "bs_tracing.h"
#include "bs_utils.h"
/*
* CLOCK Clock control
@ -47,6 +37,17 @@
* After TASK_CTSTOP EVENTS_CTSTOPPED is raised immediately.
*/
#include "NRF_CLOCK.h"
#include <string.h>
#include <stdint.h>
#include "time_machine_if.h"
#include "NRF_HW_model_top.h"
#include "NRF_PPI.h"
#include "NRF_RTC.h"
#include "irq_ctrl.h"
#include "bs_tracing.h"
#include "bs_utils.h"
NRF_CLOCK_Type NRF_CLOCK_regs;
static uint32_t CLOCK_INTEN = 0; //interrupt enable

View File

@ -4,17 +4,17 @@
* SPDX-License-Identifier: Apache-2.0
*/
/*
* EGU Event generator unit
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/egu.html?cp=4_1_0_5_6
*/
#include <string.h>
#include "bs_tracing.h"
#include "irq_ctrl.h"
#include "NRF_EGU.h"
#include "NRF_PPI.h"
/*
* EGU Event generator unit
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/egu.html?cp=4_1_0_5_6
*/
#define N_EGU 6
#define N_EGU_EVENTS 16
NRF_EGU_Type NRF_EGU_regs[N_EGU];

View File

@ -3,11 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "NRF_FICR.h"
#include "NRF_NVMC.h"
#include <string.h>
#include "bs_rand_main.h"
#include "weak_stubs.h"
/*
* Factory information configuration registers
@ -21,6 +16,12 @@
* with command line options; something like -deviceaddr=<bt_address>
*/
#include "NRF_FICR.h"
#include "NRF_NVMC.h"
#include <string.h>
#include "bs_rand_main.h"
#include "weak_stubs.h"
NRF_FICR_Type NRF_FICR_regs;
void nrf_ficr_init(){

View File

@ -4,12 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <stdbool.h>
#include "NRF_GPIO.h"
#include "NRF_GPIOTE.h"
#include "bs_tracing.h"
/*
* GPIO General purpose input/output
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/gpio.html?cp=5_1_0_5_7
@ -40,6 +34,12 @@
* is sent instantaneously to the GPIOTE
*/
#include <stdint.h>
#include <stdbool.h>
#include "NRF_GPIO.h"
#include "NRF_GPIOTE.h"
#include "bs_tracing.h"
NRF_GPIO_Type NRF_GPIO_regs[NRF_GPIOS];
/* Number of pins per port: */

View File

@ -4,14 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <string.h>
#include "NRF_GPIOTE.h"
#include "NRF_GPIO.h"
#include "NRF_PPI.h"
#include "irq_ctrl.h"
#include "bs_tracing.h"
/*
* GPIOTE GPIO tasks and events
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/gpiote.html?cp=5_1_0_5_8
@ -22,6 +14,14 @@
* so task priority is not accounted for
*/
#include <stdint.h>
#include <string.h>
#include "NRF_GPIOTE.h"
#include "NRF_GPIO.h"
#include "NRF_PPI.h"
#include "irq_ctrl.h"
#include "bs_tracing.h"
NRF_GPIOTE_Type NRF_GPIOTE_regs = {0};
static uint32_t GPIOTE_ITEN;

View File

@ -4,23 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "bs_tracing.h"
#include "bs_cmd_line.h"
#include "bs_oswrap.h"
#include "NRF_NVMC.h"
#include "NRF_HW_model_top.h"
#include "time_machine_if.h"
#include "weak_stubs.h"
/*
* NVMC Non-volatile memory controller
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/nvmc.html?cp=5_1_0_3_2
@ -60,6 +43,23 @@
* * Warn users if an address is written more than n_write between erases
*/
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "bs_tracing.h"
#include "bs_cmd_line.h"
#include "bs_oswrap.h"
#include "NRF_NVMC.h"
#include "NRF_HW_model_top.h"
#include "time_machine_if.h"
#include "weak_stubs.h"
NRF_UICR_Type *NRF_UICR_regs_p;
NRF_NVMC_Type NRF_NVMC_regs = {0};
bs_time_t Timer_NVMC = TIME_NEVER; //Time when the next flash operation will be completed

View File

@ -3,11 +3,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "NRF_POWER.h"
/*
* This is only a stub of the register interface with no functionality behind
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/power.html?cp=4_1_0_4_2
*/
#include "NRF_POWER.h"
NRF_POWER_Type NRF_POWER_regs = {0};

View File

@ -3,6 +3,13 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* PPI Programmable peripheral interconnect
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/ppi.html?cp=4_1_0_5_14
*
*/
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
@ -20,12 +27,6 @@
#include "NRF_EGU.h"
#include "bs_tracing.h"
/*
* PPI Programmable peripheral interconnect
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/ppi.html?cp=4_1_0_5_14
*
*/
NRF_PPI_Type NRF_PPI_regs; ///< The PPI registers
/**

View File

@ -4,31 +4,10 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include "bs_types.h"
#include "bs_tracing.h"
#include "bs_utils.h"
#include "bs_pc_2G4.h"
#include "bs_pc_2G4_utils.h"
#include "time_machine_if.h"
#include "NRF_RADIO.h"
#include "NRF_HW_model_top.h"
#include "NRF_PPI.h"
#include "NRF_AES_CCM.h"
#include "irq_ctrl.h"
#include "NRF_HWLowL.h"
#include "crc.h"
#include "NRF_RADIO_signals.h"
#include "NRF_RADIO_utils.h"
#include "NRF_RADIO_timings.h"
#include "NRF_RADIO_bitcounter.h"
#include "NRF_RADIO_priv.h"
/**
* RADIO 2.4 GHz Radio
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/radio.html?cp=4_1_0_5_17
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/radio.html?cp=5_1_0_5_17
*
* Note: as of now, only 1&2Mbps BLE & 15.4 packet formats are supported, there is quite many notes around in the code
* where changes would be required to support other formats
@ -158,6 +137,28 @@
* most of the same CCA_ED code, and the same CCA procedure to the Phy.
*/
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include "bs_types.h"
#include "bs_tracing.h"
#include "bs_utils.h"
#include "bs_pc_2G4.h"
#include "bs_pc_2G4_utils.h"
#include "time_machine_if.h"
#include "NRF_RADIO.h"
#include "NRF_HW_model_top.h"
#include "NRF_PPI.h"
#include "NRF_AES_CCM.h"
#include "irq_ctrl.h"
#include "NRF_HWLowL.h"
#include "crc.h"
#include "NRF_RADIO_signals.h"
#include "NRF_RADIO_utils.h"
#include "NRF_RADIO_timings.h"
#include "NRF_RADIO_bitcounter.h"
#include "NRF_RADIO_priv.h"
NRF_RADIO_Type NRF_RADIO_regs;
uint32_t NRF_RADIO_INTEN = 0; //interrupt enable (global for RADIO_signals.c)

View File

@ -83,7 +83,7 @@ void nrf_radio_signal_DISABLED(){
NRF_RADIO_regs.EVENTS_DISABLED = 1;
nrf_ppi_event(RADIO_EVENTS_DISABLED);
//These 2 are fake shortcuts meant to start a HW timer for the TIFS
//These 2 are fake tasks meant to start a HW timer for the TIFS
if ( NRF_RADIO_regs.SHORTS & RADIO_SHORTS_DISABLED_TXEN_Msk ) {
nrf_radio_fake_task_TRXEN_TIFS();
}

View File

@ -4,6 +4,16 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* RNG Random number generator
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/rng.html?cp=4_1_0_5_18
*
* Very rough model
*
* The delay is constant
*/
#include "NRF_RNG.h"
#include <string.h>
#include <stdbool.h>
@ -13,13 +23,6 @@
#include "irq_ctrl.h"
#include "bs_rand_main.h"
/*
* RNG Random number generator
* https://infocenter.nordicsemi.com/topic/ps_nrf52833/rng.html?cp=4_1_0_5_18
*
* Very rough model
*/
NRF_RNG_Type NRF_RNG_regs;
bs_time_t Timer_RNG = TIME_NEVER; //Time when the next random number will be ready

View File

@ -3,16 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include "NRF_PPI.h"
#include "NRF_CLOCK.h"
#include "NRF_HW_model_top.h"
#include "irq_ctrl.h"
#include "bs_tracing.h"
#include "time_machine_if.h"
/*
* RTC Real-time counter
@ -33,6 +23,17 @@
* * Note: RTC2 cannot be used (it does not have an assigned interrupt)
*/
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include "NRF_PPI.h"
#include "NRF_CLOCK.h"
#include "NRF_HW_model_top.h"
#include "irq_ctrl.h"
#include "bs_tracing.h"
#include "time_machine_if.h"
#define N_RTC 3
#define N_CC 4

View File

@ -3,14 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "NRF_TEMP.h"
#include <string.h>
#include <stdbool.h>
#include "time_machine_if.h"
#include "NRF_HW_model_top.h"
#include "NRF_PPI.h"
#include "irq_ctrl.h"
#include "bs_rand_main.h"
/*
* TEMP Temperature sensor
@ -25,6 +17,15 @@
* * There is no modeling of possible calibration errors or inaccuracies due to no non-linearities compensation
*/
#include "NRF_TEMP.h"
#include <string.h>
#include <stdbool.h>
#include "time_machine_if.h"
#include "NRF_HW_model_top.h"
#include "NRF_PPI.h"
#include "irq_ctrl.h"
#include "bs_rand_main.h"
NRF_TEMP_Type NRF_TEMP_regs;
bs_time_t Timer_TEMP = TIME_NEVER; //Time when the next temperature measurement will be ready

View File

@ -3,14 +3,6 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include <stdbool.h>
#include "time_machine_if.h"
#include "NRF_TIMER.h"
#include "NRF_HW_model_top.h"
#include "NRF_PPI.h"
#include "irq_ctrl.h"
#include "bs_tracing.h"
/*
* TIMER Timer/counter
@ -25,6 +17,15 @@
* * The functionality of TASK_SHUTDOWN is a bit of a guess
*/
#include <string.h>
#include <stdbool.h>
#include "time_machine_if.h"
#include "NRF_TIMER.h"
#include "NRF_HW_model_top.h"
#include "NRF_PPI.h"
#include "irq_ctrl.h"
#include "bs_tracing.h"
#define N_TIMERS 5
#define N_CC 6
NRF_TIMER_Type NRF_TIMER_regs[N_TIMERS];

View File

@ -1,7 +1,7 @@
## nRFx HAL
The HAL source files provided with these models implement
some modifications to the HAL interface [real nRFx HAL](https://github.com/NordicSemiconductor/nrfx/)
some modifications to [the real nRFx HAL](https://github.com/NordicSemiconductor/nrfx/)
needed due to the HW models peculiarities.
Its main purpose is to allow unmodified embedded code to run directly
using this repository HW models.
@ -15,7 +15,7 @@ There is two main differences in this HAL compared to the real one:
registers
* When a HW register with sideeffects is written, the appropriate
HW model function is called to trigger that sideeffect.<br><br>
HW model function is called to trigger that sideeffect.<br>
A sideeffect should be understood as some activity beyond the modification
of the register itself. For example, in real HW, writting a `1` to
`NRF_RNG->TASKS_START` will start the random number generation.
@ -24,17 +24,13 @@ There is two main differences in this HAL compared to the real one:
function `nrf_rng_regw_sideeffects_TASK_START()` needs to be called.
This replacement HAL functions take care of that.
The original implementation of the HAL APIs from the real nrfx is included in `nrf_hal_originals.c`.
All these functions are labelled as weak, so they can be replaced as needed with new definition in `src/nrfx/hal/`
This removes the need for duplicating code.
The original implementation of the HAL APIs from the real nrfx is included in
`nrf_hal_originals.c`.
All these functions are labelled as weak, so they can be replaced as needed with content
of `src/nrfx/hal/`. This removes the need for duplicating code.
Note that this HAL version should be, wherever possible, a copy of the
official nRFx HAL, with only minor differences due to what is described above.
And normally most differences between the official version and this one will be
simply due to this not having been updated yet.
Note that, so far, this replacement HAL only provides a subset of the
whole nRFx API: Mostly the functions and types used by the current Zephyr
BLE controller and necessary drivers, and only for the peripherals which are
part of these models.
Note that this replacement HAL only provides the necessary replacements for the subset of the
nRFx API corresponding to the peripherals included in these models.
Note also that for these, not necessarily all nRFx functions which could need replacing are
included. Though those used by Zephyr should be included.
It is certainly possible to expand it to cover the whole API.