Skip to content

Commit 413a349

Browse files
aescolarcarlescufi
authored andcommitted
nrf_bsim: Only connect once to Bsim Phy
Each MCU initialization hooks will attempt to call into the API to connect to the bsim phy and, if the user requested it thru command line, delay its boot. Doing this for all MCUs is best to ensure it is done even if there is no image for the other MCU, but results in the calls being done twice if there is 2 MCUs images, which results in the simulator API giving a warning about it being likely an error in the app. To avoid this problem, let's have this be called only once. Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent f64d123 commit 413a349

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

boards/posix/nrf_bsim/common/phy_sync_ctrl.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ NSI_TASK(phy_sync_ctrl_register_args, PRE_BOOT_1, 10);
214214

215215
void phy_sync_ctrl_connect_to_2G4_phy(void)
216216
{
217+
static bool ever_run;
218+
219+
if (ever_run) {
220+
return;
221+
}
222+
ever_run = true;
223+
217224
bs_trace_raw(9, "%s: Connecting to phy...\n", __func__);
218225
hwll_connect_to_phy(bsim_args_get_2G4_device_nbr(),
219226
bsim_args_get_simid(),
@@ -223,6 +230,13 @@ void phy_sync_ctrl_connect_to_2G4_phy(void)
223230

224231
void phy_sync_ctrl_pre_boot2(void)
225232
{
233+
static bool ever_run;
234+
235+
if (ever_run) {
236+
return;
237+
}
238+
ever_run = true;
239+
226240
if (((sync_args.start_offset > 0) && (sync_args.delay_init))
227241
|| sync_args.sync_preinit) {
228242
/* Delay the next steps until the simulation time has
@@ -235,6 +249,13 @@ void phy_sync_ctrl_pre_boot2(void)
235249

236250
void phy_sync_ctrl_pre_boot3(void)
237251
{
252+
static bool ever_run;
253+
254+
if (ever_run) {
255+
return;
256+
}
257+
ever_run = true;
258+
238259
/*
239260
* If sync_preboot was set, we sync with the phy
240261
* right before booting the CPU

0 commit comments

Comments
 (0)