Hi,
I have a PCF8523 RTC on a I2C bus connected on a custom board with a NRF9160 Dev board runing it (Acctinius Iccarus Dev board to be exact). Communicating with it over I2C works perfectly however when trying to communicate with it using the RTC driver present in zephyr for it (only present in V2.5.0-rc1 at the moment) I get a very hard to figure out error. Upon calling any of the API functions I get thrown to here and the board resets:
void C_SecureFault_Handler(void) { /* A SecureFault may indicate corruption of secure state, so it is essential * that Non-secure code does not regain control after one is raised. * Returning from this exception could allow a pending NS exception to be * taken, so the current solution is to panic. */ tfm_core_panic(); } __attribute__((naked)) void SecureFault_Handler(void) { EXCEPTION_INFO(EXCEPTION_TYPE_SECUREFAULT); __ASM volatile( "bl C_SecureFault_Handler \n" "b . \n" ); }
(Listed under tf-m/trusted-firmware-m/platform/ext/common/faults.c)
The RTC is defined like this under the device tree:
&i2c2 { compatible = "nordic,nrf-twim"; status = "okay"; clock-frequency = <I2C_BITRATE_FAST>; pinctrl-0 = <&i2c2_default>; pinctrl-1 = <&i2c2_sleep>; pinctrl-names = "default", "sleep"; lis2dh12_accel: lis2dh12-accel@19 { compatible = "st,lis2dh12", "st,lis2dh"; reg = <0x19>; irq-gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>, <&gpio0 29 GPIO_ACTIVE_HIGH>; }; pcf8523: pcf8523@40 { compatible = "nxp,pcf8523"; battery-switch-over = "standard"; alarms-count = <1>; reg = <0x40 >; }; };
And I'm calling the api function through a c++ as show here:
int system_utils::boardRTC::getCurrentTime( time_t *buffer){ rtc_time rtcBuffer; int rslt = rtc_get_time(this->RTCdevice, &rtcBuffer); //if ( rslt != 0){ //Error case, propagate up // return rslt; //} //*buffer = timeutil_timegm(rtc_time_to_tm(&rtcBuffer)); return 0; }
(Note that I've commented out code to narrow it down)
Tracing through with the debug functon and a jtag probe the program jumps immediatly after the call to rtc_get_time to the fault.
Can anyone help me figure out what is happening here?