Skip to content

Conversation

stnolting
Copy link
Owner

This PR adds a function to perform a "soft restart" of a CPU core. For example, this can be used to "park" the secondary CPU core (core1) again so it can be launched again:

int main_core1(void) {

  // setup NEORV32 runtime-environment (RTE) for this core (core1)
  neorv32_rte_setup();

  // do some useful stuff
  stuff();

  // park core1 again in crt0 boot code
  neorv32_cpu_soft_restart();

  // return to crt0 and halt; will never be reached
  return 0;
}

Warning

This is just a "software reset" that uses the in-code reset/boot/entry address linked at compile time.

After this core can be re-booted using neorv32_smp_launch();.


A real hardware reset of the entire processor can be triggered via the watchdog (WDT) module by the new new neorv32_wdt_force_hwreset(); function:

void neorv32_wdt_force_hwreset(void) {

  // enable strict mode; if strict mode is already enabled and the WDT
  // is locked this will already trigger a hardware reset
  NEORV32_WDT->CTRL |= (uint32_t)(1 << WDT_CTRL_STRICT);

  // try to reset the WDT using an incorrect password;
  // this will finally trigger a hardware reset
  NEORV32_WDT->RESET = 0;
}

@stnolting stnolting added the SW Software-related label Apr 7, 2025
@stnolting stnolting self-assigned this Apr 7, 2025
@stnolting stnolting marked this pull request as ready for review April 7, 2025 16:55
@stnolting stnolting merged commit e1283bc into main Apr 7, 2025
4 checks passed
@stnolting stnolting deleted the restart_functions branch April 7, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SW Software-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant