- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19
Add support for NRF53 and DPPI #18
Conversation
| @cvinayak FYI | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DPPI model can be simplified slightly. Added some other comments as well
        
          
                CMakeLists.txt
              
                Outdated
          
        
      | # CMake file to compile this BabbleSim component as a west module in Zephyr | ||
|  | ||
| if(CONFIG_BOARD_NRF52_BSIM) | ||
| if(CONFIG_BOARD_NRF52_BSIM OR CONFIG_BOARD_NRF53_BSIM) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add a configuration CONFIG_BOARD_BSIM_COMPATIBLE in upstream zephyr so that it becomes easier to support other boards in the future?
| zephyr_library_compile_definitions(NO_POSIX_CHEATS) | ||
|  | ||
| file(GLOB_RECURSE HW_MODEL_SRCS . src/*.c) | ||
| if (CONFIG_BOARD_NRF52_BSIM) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can replace CONFIG_BOARD_NRF52_BSIM with CONFIG_HAS_HW_NRF_DPPIC
        
          
                src/HW_models/NRF_DPPI.h
              
                Outdated
          
        
      | #endif | ||
|  | ||
| extern NRF_DPPIC_Type NRF_DPPI_regs; | ||
| #define NUMBER_DPPI_CHANNELS 32 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may use DPPI_CH_NUM instead. It is defined in nrf5340_network_peripherals.h
| @@ -0,0 +1,49 @@ | |||
| /* | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should extract out a common file? We can make core_cmxx.h and let core_cm33.h and core_cm4.h include this file?
        
          
                src/nrfx/hal/nrf_ccm.c
              
                Outdated
          
        
      | case NRF_CCM_TASK_STOP: | ||
| nrf_dppi_subscriber_add(channel, nrf_ccm_TASK_STOP); | ||
| break; | ||
| #if defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos) || defined(__NRFX_DOXYGEN__) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add  || defined(__NRFX_DOXYGEN__) here. Similar in other places
| /* | ||
| * Redefine the base addresses. | ||
| */ | ||
|  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider splitting this file. @aescolar , what do you think?
        
          
                src/HW_models/NRF_DPPI.c
              
                Outdated
          
        
      | static subscr_list_elem_t* dppi_subscriber_list[NUMBER_DPPI_CHANNELS]; | ||
|  | ||
| //Function for checking if an element is in the subscriber linked list | ||
| static bool subscriber_list_check(dest_f_t task_function, subscr_list_elem_t ** pp_head) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use pointer to pointer in this function. You may use
subscriber_in_list(dest_f_t task_function, subscr_list_elem_t * p_head)?
        
          
                src/HW_models/NRF_DPPI.c
              
                Outdated
          
        
      | { | ||
| if (!subscriber_list_check(task_function, pp_head)) | ||
| { | ||
| struct subscr_list_elem* p_elem = (struct subscr_list_elem*) malloc(sizeof(struct subscr_list_elem)); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly speaking, you should check the return code of the malloc
        
          
                src/HW_models/NRF_DPPI.c
              
                Outdated
          
        
      | { | ||
| if(subscriber_list_check(task_function, pp_head)) | ||
| { | ||
| struct subscr_list_elem* temp = (struct subscr_list_elem*) malloc(sizeof(struct subscr_list_elem)); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this malloc and the free's below. The temp variable is assigned in the line below, so the new memory is never used. There are some similar cases in functions below.
        
          
                src/HW_models/NRF_DPPI.c
              
                Outdated
          
        
      | /** | ||
| * Initialize the DPPI model | ||
| */ | ||
| void nrf_dppi_init() | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function signature should be explicit to indicate that the function takes no parameters
| void nrf_dppi_init() | |
| void nrf_dppi_init(void) | 
| @wopu-ot FYI | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of general comments before anything else:
- It is a risky choice to throw yourselves into a mayor change, without agreeing the direction first. (Meaning you risk spending a lot of time writing code which will be scrapped).
- For mayor PRs, or mayor rework, it would be very nice if you gave a heads up, so we knew what is coming.
Before dwelling into details:
- It would be good to talk and understand what you want to do overall, and agree the general direction.
- That code does not account compiling without Zephyr (it does not compile without it)
(I just browsed very fast thru the code. The 4 things I pointed are in the only function I read carefully)
        
          
                src/HW_models/NRF_DPPI.c
              
                Outdated
          
        
      | */ | ||
| void nrf_dppi_publish(uint8_t channel) | ||
| { | ||
| struct subscr_list_elem* temp = (struct subscr_list_elem*) malloc(sizeof(struct subscr_list_elem)); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a memory leak :) (that malloc is not needed)
        
          
                src/HW_models/NRF_DPPI.c
              
                Outdated
          
        
      | temp = temp->p_next; | ||
| } | ||
|  | ||
| free(temp); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this free is not needed (nor safe)
        
          
                src/HW_models/NRF_DPPI.c
              
                Outdated
          
        
      | while (temp != NULL) | ||
| { | ||
| temp->task_function(); | ||
| prev = temp; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
        
          
                src/HW_models/NRF_DPPI.c
              
                Outdated
          
        
      | { | ||
| struct subscr_list_elem* temp = (struct subscr_list_elem*) malloc(sizeof(struct subscr_list_elem)); | ||
| temp = dppi_subscriber_list[channel]; | ||
| subscr_list_elem_t *prev; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
| The goal of providing nrf53_bsim is to be able run tests in a simulator with the nrf53 HAL layer. This is currently not possible. We have had some bugs that would like have been uncovered if we had used nrf53_bsim | 
| 
 Thanks :) | 
Add DPPI in order to be able to model the NRF53 HW. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Changes in CMakeLists, NRF_HW_model_top.c, nrfx_common.c and nrf_bsim_redef.h in order for the model to support both the NRF52 and the NRF53 series. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
NRF53 runs on cm33. Add this core in order for the model to support NRF53. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Add irq sources for NRF53. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Add use of DPPI to AAR if DPPI is defined. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Add use of DPPI to CCM if DPPI is defined. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Add use of DPPI to ECB if DPPI is defined. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Add use of DPPI to CLOCK if DPPI is defined. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Add use of DPPI to RADIO if DPPI is defined. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Add use of DPPI to RNG if DPPI is defined. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Add use of DPPI to TIMER if DPPI is defined. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Add use of DPPI to RTC if DPPI is defined. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
Add a common core-file for easier maintenance. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
| @auroraslb Do you still want to proceed with this PR or should I close it? | 
| 
 @wopu-ot , we can close this PR for now and reopen later if needed. | 
The goal of providing HW models for the nrf53 network core is to be able run tests in a simulator with the nrf53 HAL layer.
This will make it easier to find bugs and regressions in the hal layer of a Bluetooth Controller.
The models share the same source code as the models for the nrf52 series, as most HW peripherals are identical.
The same approach can also be used to create models for nrf51 series and similar.
@aescolar, I would like to get some input on how to adapt the makefiles to be able to build a 53-series model in a standalone build environment.
To build for the nrf53-series in zephyr is done here: zephyrproject-rtos/zephyr#30734