Does anyone know how to attach an user call back function to Photon PVD_irq?

I want to save data to EEPROM when main power lose.
I find out Photon API does not support attach user functions to PVD IRQ Handdle
I have try to modify the hal/src/photon/core_hal.c

When I am try to CC my APP:

/firmware-0.6.1/user/applications/air/main.cpp:66: undefined reference to `Attach_LMP_Irq'

Did I make any mistakes?

//hal/src/photon/core_hal.c
void (*Lose_Main_Power)(void) = NULL;

void Attach_LMP_Irq(void (*LMP)(void))
{
Lose_Main_Power = LMP;
}

static void PVD_irq(void)
{
EXTI_ClearITPendingBit(EXTI_Line16);
if (PWR_GetFlagStatus(PWR_FLAG_PVDO)) {
if (NULL != Lose_Main_Power) {
Lose_Main_Power();
}
}
}

void HAL_Core_Setup_override_interrupts(void) {
memcpy(&link_ram_interrupt_vectors_location, &link_interrupt_vectors_location, &link_ram_interrupt_vectors_location_end-&link_ram_interrupt_vectors_location);
uint32_t* isrs = (uint32_t*)&link_ram_interrupt_vectors_location;
isrs[HardFaultIndex] = (uint32_t)HardFault_Handler;
isrs[MemManageIndex] = (uint32_t)MemManage_Handler;
isrs[BusFaultIndex] = (uint32_t)BusFault_Handler;
isrs[UsageFaultIndex] = (uint32_t)UsageFault_Handler;
isrs[SysTickIndex] = (uint32_t)SysTickOverride;
isrs[USART1Index] = (uint32_t)HAL_USART1_Handler;
isrs[USART2Index] = (uint32_t)HAL_USART2_Handler;
isrs[ButtonExtiIndex] = (uint32_t)Mode_Button_EXTI_irq;
isrs[TIM7Index] = (uint32_t)TIM7_override;  // WICED uses this for a JTAG watchdog handler
isrs[DMA2Stream2Index] = (uint32_t)DMA2_Stream2_irq_override;
isrs[CAN2_TX_IRQHandler_Idx]            = (uint32_t)CAN2_TX_irq;
isrs[CAN2_RX0_IRQHandler_Idx]           = (uint32_t)CAN2_RX0_irq;
isrs[CAN2_RX1_IRQHandler_Idx]           = (uint32_t)CAN2_RX1_irq;
isrs[CAN2_SCE_IRQHandler_Idx]           = (uint32_t)CAN2_SCE_irq;

//--------------------PVD--------------------------------
isrs[PVD_Index] = (uint32_t)PVD_irq;

SCB->VTOR = (unsigned long)isrs;

}

/hal/inc/core_hal.h
extern void Attach_LMP_Irq(void (*LMP)(void));

I’m not convinced it’ll be a good idea to write to EEPROM when your system detects a power loss.
The EEPROM write will demand some extra power that will most likely prevent the write action from finishing successfully and hence might even pose the risk to corrupt the firmware region.

What was your build statement from what directory?
Was it a make clean all from ./firmware/modules?

A large bulk capactitance can work as a backup power
Call EEPROM.performPendingErase() in setup(),When lose main power call EEPROM.put().

cd ./firmware/modules
make clean PLATFORM=photon
make all PLATFORM=photon

cd ./firmware/main
make APP=myapp PLATFORM=photon

A large bulk capactitance can work as a backup power
Call EEPROM.performPendingErase() in setup(),When lose main power call EEPROM.put().

cd ./firmware/modules
make clean PLATFORM=photon
make all PLATFORM=photon

cd ./firmware/main
make APP=myapp PLATFORM=photon

Would not the cap keep the interrupt from firing since it’ll hold Vdd up till it’s also discharged below the threshold and consequently close to brownout?
So I’d still see possible issues.
But maybe @tylercpeacock could loop in Brett (or any other Particle engineer) for that question.