Author Topic: memory corruption RP2040  (Read 1414 times)

0 Members and 1 Guest are viewing this topic.

Offline PinGNUTopic starter

  • Newbie
  • Posts: 1
  • Country: gb
    • carlparsons
memory corruption RP2040
« on: March 13, 2023, 12:18:00 pm »
Hi

How can I implement a power-loss detection mechanism to detect when power is lost and take appropriate actions to prevent memory corruption. This mechanism could include a hardware watchdog timer, software timer, or interrupt service routine that can trigger a graceful shutdown of the RP2040. I am actually using a PGA2040 a cut-down version of PiPico

Carl
 

Offline shapirus

  • Super Contributor
  • ***
  • Posts: 1806
  • Country: ua
Re: memory corruption RP2040
« Reply #1 on: March 13, 2023, 01:58:27 pm »
If power is already lost, then it's too late to shut down.
Does your question imply that you use a backup power device that takes over when the primary power source fails?
 

Offline dobsonr741

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: us
Re: memory corruption RP2040
« Reply #2 on: March 13, 2023, 02:22:59 pm »
Not clear which memory we talk about. RAM? That’s a high bar never intended to be achieved on the Pico. Flash memory writes? Perhaps frequent and alternating atomic A/B writes can survive power loss without corruption for a price of loosing the latest but not the one before. Same applies to a flash alternative ext memory, like an FRAM, if internal flash endurance is a concern.

One example of this atomic flash update is https://github.com/olegv142/stm32-config, though not RP2040 adopted. Or https://github.com/littlefs-project/littlefs
« Last Edit: March 13, 2023, 03:03:25 pm by dobsonr741 »
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1732
  • Country: 00
Re: memory corruption RP2040
« Reply #3 on: March 13, 2023, 07:23:32 pm »
A classic strategy is a large cap on your MCU VDD, and monitor the power source and trigger if it's drop below a certain threshold. E.g. a hardware comparator that flips, which could trigger an IRQ. Then dump contents to non-volatile ASAP and halt other write operations that could corrupt the state.
Sometimes you can also use the ADC for this, through some hardware monitor configuration, or manually on a certain polling interval.
 
I don't think the other internal peripherals are of much use. Perhaps make sure that the brownout voltage threshold is also set accordingly, or use an external reset monitor.
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 416
  • Country: zm
Re: memory corruption RP2040
« Reply #4 on: March 14, 2023, 05:53:05 am »
Hi

How can I implement a power-loss detection mechanism to detect when power is lost and take appropriate actions to prevent memory corruption. This mechanism could include a hardware watchdog timer, software timer, or interrupt service routine that can trigger a graceful shutdown of the RP2040. I am actually using a PGA2040 a cut-down version of PiPico

Carl
I Had this same issue with some power monitoring tech, when the power fails so did the monitors and that in turn ment that the data collection system would re-use last known value. to get around this i got a Geekpi UPS for PI pico(look for the model with power management serial chip) , it has a on board 18650 with serial feedback of current power input. when input power fails then the battery pmc send a signal and the device is able to update the host server and go into power save mode with a IRQ on the serial for when the power returns.

The Only issue with this device is it does now like input power via the pico's USB power when the 18650 is flat, it heats up the chips a lot and i've yet to figure out why (black soldermask is hell for tracing a pcb trace)

so power is applied via the UPS board and in turn does not allow access to the pico for programming, We switched to picow to get around this fact and use OTA updates instead.

darkspr1te



 

Offline barshatriplee

  • Regular Contributor
  • *
  • !
  • Posts: 130
  • Country: bd
Re: memory corruption RP2040
« Reply #5 on: March 26, 2023, 02:31:43 pm »
Configuring the watchdog timer seems to be the easiest option.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf