Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/fw/board/boards/board_asterix.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,16 @@ void board_early_init(void) {
nrf_gpio_pin_set(15);
nrf_gpio_pin_set(16);

/* TODO: check that LFCLK actually comes up */
nrf_clock_lf_src_set(NRF_CLOCK, NRF_CLOCK_LFCLK_XTAL);
nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_LFCLKSTARTED);
nrf_clock_int_enable(NRF_CLOCK, NRF_CLOCK_INT_LF_STARTED_MASK);
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTART);
/* TODO: Add timeout, report failure if LFCLK does not start. For now,
* WDT should trigger a reboot. Calibrated RC may be used as a fallback,
* provided we can adjust BLE SCA settings at runtime.
*/
while (!nrf_clock_event_check(NRF_CLOCK, NRF_CLOCK_EVENT_LFCLKSTARTED)) {
}
nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_LFCLKSTARTED);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should time out after some time and sadwatch (or TODO for that) if LFXO fails to come up

Copy link
Collaborator Author

@gmarull gmarull Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, even nrfx doesn't time out:

https://github.com/nrfconnect/nrfx/blob/ad604db99489a3cce43620abeb3cf839a2a649b7/drivers/src/nrfx_clock.c#L496-L498

Assuming bootloader will leave WDT on, if this fails the system will reboot anyway. If this fails, we're in trouble as well (e.g. BLE won't work at all). Not sure if BLE SCA can be adjusted at runtime, so we could potentially fall back to a calibrated LF RC.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was on previous Pebbles to mark hardware failure (usually water incursion). Boot cannot proceed but providing the correct error code explicitly (by triggering a sadwatch) can help diagnose the failure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment for now if that's ok

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


void board_init(void) {
Expand Down
Loading