|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
Why the IOmcu last started, named from the registers its boot leaves behind. More...
#include <stdbool.h>#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | reset_regs_t |
| The raw values, as read at boot. More... | |
Macros | |
| #define | RESET_CHIP_HAD_POR 0x00010000u |
| #define | RESET_CHIP_HAD_BOR 0x00020000u |
| #define | RESET_CHIP_HAD_RUN_LOW 0x00040000u |
| #define | RESET_CHIP_HAD_DP_RESET_REQ 0x00080000u |
| #define | RESET_CHIP_HAD_RESCUE 0x00200000u |
| #define | RESET_CHIP_HAD_WATCHDOG_RESET_POWMAN_ASYNC 0x00400000u |
| #define | RESET_CHIP_HAD_WATCHDOG_RESET_POWMAN 0x00800000u |
| #define | RESET_CHIP_HAD_WATCHDOG_RESET_SWCORE 0x01000000u |
| #define | RESET_CHIP_HAD_SWCORE_PD 0x02000000u |
| #define | RESET_CHIP_HAD_GLITCH_DETECT 0x04000000u |
| #define | RESET_CHIP_HAD_HZD_SYS_RESET_REQ 0x08000000u |
| #define | RESET_CHIP_HAD_WATCHDOG_RESET_PSM 0x10000000u |
| #define | RESET_CHIP_HAD_WATCHDOG_ANY |
| Every CHIP_RESET bit that names a watchdog reset. | |
| #define | RESET_WD_REASON_TIMER 0x1u |
| #define | RESET_WD_REASON_FORCE 0x2u |
| #define | RESET_BOOT_TYPE_NORMAL 0x00u |
| #define | RESET_BOOT_TYPE_BOOTSEL 0x02u |
| #define | RESET_BOOT_TYPE_RAM_IMAGE 0x03u |
| #define | RESET_BOOT_TYPE_FLASH_UPDATE 0x04u |
| #define | RESET_BOOT_TYPE_PC_SP 0x0Du |
| #define | RESET_BOOT_TYPE_CHAINED_FLAG 0x80u |
| #define | RESET_PICOTOOL_P0 0xFFFFFFFFu |
| SCRATCH2 and SCRATCH3 after picotool's reboot from BOOTSEL into the application: type NORMAL, p0 = BOOT_PARTITION_NONE (-1), p1 = 0. | |
| #define | RESET_PICOTOOL_P1 0x00000000u |
| SCRATCH3 after that reboot: p1 = 0. | |
| #define | RESET_CAUSE_FULL_MAX 144u |
| Bytes that hold the longest full form with its NUL. | |
Enumerations | |
| enum | reset_cause_t { RESET_CAUSE_UNKNOWN = 0 , RESET_CAUSE_POR , RESET_CAUSE_BOR , RESET_CAUSE_RUN_PIN , RESET_CAUSE_GLITCH , RESET_CAUSE_DEBUGGER , RESET_CAUSE_POWER_DOWN , RESET_CAUSE_FLASH_UPDATE , RESET_CAUSE_RAM_IMAGE , RESET_CAUSE_BOOTSEL_REBOOT , RESET_CAUSE_SW_RESET , RESET_CAUSE_WATCHDOG , RESET_CAUSE_COUNT } |
| The causes reset_cause_decode() names. More... | |
Functions | |
| reset_cause_t | reset_cause_decode (const reset_regs_t *r) |
| Names the cause of the last start. | |
| const char * | reset_cause_word (reset_cause_t c) |
| The fixed word for a cause: POR, BOR, RUN_PIN, GLITCH, DEBUGGER, POWER_DOWN, FLASH_UPDATE, RAM_IMAGE, BOOTSEL_REBOOT, SW_RESET, WATCHDOG or UNKNOWN. | |
| int | reset_cause_boot_type (const reset_regs_t *r) |
| The boot type in the boot word, without the chained flag. | |
| size_t | reset_cause_full (const reset_regs_t *r, char *out, size_t n) |
| The text of the start-up line and the 3s line, every raw value in hex: POR (chip_reset 0x00010000 reason 0x0 boot 0x00000000
params 0x00000000 0x00000000 scratch 0x00000000 0x00000000), with boot none in place of the boot word and the params when rom_get_boot_info() failed. | |
Why the IOmcu last started, named from the registers its boot leaves behind.
Three records survive a restart, and each is cleared by a different reset (RP2350 datasheet, sections 7.3, 7.4, 12.9.4 and 12.9.5):
The boot ROM's boot info (rom_get_boot_info()) gives the type of this boot; a type other than NORMAL comes only from a reboot() vector in the watchdog scratch registers. This file turns these raw values into one fixed word.
Pure C with no pico-sdk: the firmware reads the registers once at boot (firmware/iomcu/src/iomcu_report.c) and holds the bit values below equal to the SDK's with _Static_assert.
Bit names and positions are those of pico-sdk 2.3.0, src/rp2350/hardware_regs/include/hardware/regs/powman.h and watchdog.h, and the boot types of boot/bootrom_constants.h.
SPDX-License-Identifier: MIT
| #define RESET_BOOT_TYPE_BOOTSEL 0x02u |
USB or UART boot
| #define RESET_BOOT_TYPE_CHAINED_FLAG 0x80u |
a bootloader chained in
| #define RESET_BOOT_TYPE_FLASH_UPDATE 0x04u |
after a flash write
| #define RESET_BOOT_TYPE_NORMAL 0x00u |
no one-shot boot type
| #define RESET_BOOT_TYPE_PC_SP 0x0Du |
a vector reboot
| #define RESET_BOOT_TYPE_RAM_IMAGE 0x03u |
an image in SRAM
| #define RESET_CHIP_HAD_BOR 0x00020000u |
bit 17
| #define RESET_CHIP_HAD_DP_RESET_REQ 0x00080000u |
bit 19
| #define RESET_CHIP_HAD_GLITCH_DETECT 0x04000000u |
bit 26
| #define RESET_CHIP_HAD_HZD_SYS_RESET_REQ 0x08000000u |
bit 27
| #define RESET_CHIP_HAD_POR 0x00010000u |
bit 16
| #define RESET_CHIP_HAD_RESCUE 0x00200000u |
bit 21
| #define RESET_CHIP_HAD_RUN_LOW 0x00040000u |
bit 18
| #define RESET_CHIP_HAD_SWCORE_PD 0x02000000u |
bit 25
| #define RESET_CHIP_HAD_WATCHDOG_ANY |
Every CHIP_RESET bit that names a watchdog reset.
| #define RESET_CHIP_HAD_WATCHDOG_RESET_POWMAN 0x00800000u |
bit 23
| #define RESET_CHIP_HAD_WATCHDOG_RESET_POWMAN_ASYNC 0x00400000u |
bit 22
| #define RESET_CHIP_HAD_WATCHDOG_RESET_PSM 0x10000000u |
bit 28
| #define RESET_CHIP_HAD_WATCHDOG_RESET_SWCORE 0x01000000u |
bit 24
| #define RESET_PICOTOOL_P0 0xFFFFFFFFu |
SCRATCH2 and SCRATCH3 after picotool's reboot from BOOTSEL into the application: type NORMAL, p0 = BOOT_PARTITION_NONE (-1), p1 = 0.
picotool 2.x sends this after every command run with -f, and for picotool reboot. This firmware calls reboot() with type FLASH_UPDATE only.
| #define RESET_WD_REASON_FORCE 0x2u |
CTRL.TRIGGER was written
| #define RESET_WD_REASON_TIMER 0x1u |
the watchdog counted down to zero
| enum reset_cause_t |
The causes reset_cause_decode() names.
| int reset_cause_boot_type | ( | const reset_regs_t * | r | ) |
The boot type in the boot word, without the chained flag.
| r | The raw values. |
| reset_cause_t reset_cause_decode | ( | const reset_regs_t * | r | ) |
Names the cause of the last start.
First match wins:
A debugger's warm reset of a core clears REASON (datasheet, WATCHDOG REASON) without a chip-level reset; the start after one reads as the chip-level reset before it.
| r | The raw values; NULL reads as UNKNOWN. |
| size_t reset_cause_full | ( | const reset_regs_t * | r, |
| char * | out, | ||
| size_t | n ) |
The text of the start-up line and the 3s line, every raw value in hex: POR (chip_reset 0x00010000 reason 0x0 boot 0x00000000 params 0x00000000 0x00000000 scratch 0x00000000 0x00000000), with boot none in place of the boot word and the params when rom_get_boot_info() failed.
| r | The raw values. |
| out | Receives the text, NUL-terminated and cut to fit. |
| n | Size of out in bytes; RESET_CAUSE_FULL_MAX holds it. |
| const char * reset_cause_word | ( | reset_cause_t | c | ) |
The fixed word for a cause: POR, BOR, RUN_PIN, GLITCH, DEBUGGER, POWER_DOWN, FLASH_UPDATE, RAM_IMAGE, BOOTSEL_REBOOT, SW_RESET, WATCHDOG or UNKNOWN.
| c | The cause; a value out of range reads as UNKNOWN. |