Skip to content

gh #212 New API and enum last reboot reason - #213

Open
thanushreevani wants to merge 4 commits into
developfrom
feature/issue212_api_lastrebootreason
Open

gh #212 New API and enum last reboot reason#213
thanushreevani wants to merge 4 commits into
developfrom
feature/issue212_api_lastrebootreason

Conversation

@thanushreevani

@thanushreevani thanushreevani commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Normalization mapping (raw hardware token → dsRebootReason_t):

DS_REBOOT_REASON_POWER_ON
POWER_ON, POWER_ON_RESET, POWER_ON_REBOOT, HARDWARE, COLD_BOOT
(BRCM: POWER_ON/HARDWARE RTK: POWER_ON/HARDWARE
AMLOGIC: code 0 MTK: 0x00)

DS_REBOOT_REASON_SOFTWARE_RESET
SOFTWARE_MASTER_RESET, SOFTWARE_RESET, SW_RESET,
SOFTWARE_REBOOT, NORMAL_BOOT
(BRCM: SOFTWARE_MASTER_RESET/SW_RESET/SOFTWARE_RESET/SOFTWARE
RTK: same AMLOGIC: code 1 MTK: 0xD1)

DS_REBOOT_REASON_KERNEL_PANIC
KERNEL_PANIC, KERNEL_PANIC_RESET, CRASH_DUMP, CRASH_REBOOT
(BRCM: KERNEL_PANIC/KERNEL_PANIC_RESET
RTK: same AMLOGIC: code 11 (CRASH_REBOOT), code 12 (KERNEL_PANIC)
MTK: 0xEF)

DS_REBOOT_REASON_WATCHDOG
WATCHDOG, WATCHDOG_RESET, WATCHDOG_TIMER_RESET, WATCH_DOG,
GEN_WATCHDOG_RESET, GEN_WATCHDOG_1_RESET, WATCHDOG_REBOOT
(BRCM: WATCHDOG, GEN_WATCHDOG_1_RESET/GEN_WATCHDOG_RESET
RTK: WATCHDOG, GEN_WATCHDOG_1_RESET/GEN_WATCHDOG_RESET
AMLOGIC: code 13 MTK: 0xE0)

DS_REBOOT_REASON_THERMAL
OVERTEMP, OVERHEAT, THERMAL, THERMAL_REBOOT
(BRCM: OVERTEMP/OVERHEAT RTK: OVERTEMP/OVERHEAT
AMLOGIC: code 10 MTK: 0xE4)

DS_REBOOT_REASON_VOLTAGE
OVERVOLTAGE, UNDERVOLTAGE, OVERVOLTAGE_RESET,
UNDERVOLTAGE_RESET, UNDERVOLTAGE_0_RESET, UNDERVOLTAGE_1_RESET
(BRCM: OVERVOLTAGE, UNDERVOLTAGE/UNDERVOLTAGE_0_RESET/UNDERVOLTAGE_1_RESET
RTK: same)

DS_REBOOT_REASON_FACTORY_RESET
FACTORY_RESET, FACTORY_RESET_REBOOT
(AMLOGIC: code 2)

DS_REBOOT_REASON_STANDBY_WAKEUP
S3_WAKEUP_RESET, SUSPEND_REBOOT, SUSPEND_BOOT,
HIBERNATE_REBOOT, HIBERNATE_BOOT
(BRCM: S3_WAKEUP_RESET RTK: S3_WAKEUP_RESET
AMLOGIC: code 5 (SUSPEND_BOOT), code 6 (HIBERNATE_BOOT))

DS_REBOOT_REASON_SECURITY_RESET
SECURITY_MASTER_RESET, STR_AUTH_FAIL, AMLOGIC_DDR_SHA2_REBOOT
(BRCM: SECURITY_MASTER_RESET RTK: SECURITY_MASTER_RESET
AMLOGIC: code 14)

DS_REBOOT_REASON_UPDATE
UPGRADE_SYSTEM_REBOOT, UPDATE_BOOT
(AMLOGIC: code 3)

DS_REBOOT_REASON_UNKNOWN
Everything else, including:
CPU_EJTAG_RESET, SCPU_EJTAG_RESET, MAIN_CHIP_INPUT_RESET,
MAIN_CHIP_RESET_INPUT, SMARTCARD_INSERT_RESET, PCIE_HOT_BOOT_RESET,
AUX_CHIP_EDGE_RESET, AUX_CHIP_LEVEL_RESET, MPM_RESET,
RPMPB (AMLOGIC code 9), FFV (AMLOGIC code 15),
BOOTLOADER_REBOOT / FASTBOOT_BOOTLOADER (AMLOGIC code 7),
SHUTDOWN_REBOOT (AMLOGIC code 8), FASTBOOT_REBOOT / FAST_BOOT (AMLOGIC code 4),
FRONT_PANEL_4SEC_RESET / FRONT_PANEL_RESET, TAP_IN_SYSTEM_RESET,
HARD_POWER, absent / unmatched raw values

@thanushreevani
thanushreevani requested a review from kanjoe24 August 4, 2026 06:11
@thanushreevani thanushreevani self-assigned this Aug 4, 2026
@thanushreevani
thanushreevani requested a review from a team as a code owner August 4, 2026 06:11
Copilot AI review requested due to automatic review settings August 4, 2026 06:11
@thanushreevani thanushreevani added the enhancement New feature or request label Aug 4, 2026
@thanushreevani thanushreevani linked an issue Aug 4, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Host HAL API and data model for reporting the device’s last reboot reason in a platform-agnostic way, enabling middleware to consume a normalized enum plus vendor-specific diagnostic strings.

Changes:

  • Introduces dsRebootReasonType_t normalized reboot-reason enum and dsRebootReason_t descriptor struct.
  • Adds new public API dsGetLastRebootReason(dsRebootReason_t *rebootReason) to retrieve the last reboot reason.
Suppressed comments (2)

include/dsHost.h:183

  • The comment contains a split word ("classifica tion"), which is a spelling/formatting error in this public header and will show up in generated docs.
     *  Mapped to RebootInfo.source in the middleware classifica    tion pipeline. */

include/dsHost.h:312

  • The new API doxygen block uses inconsistent leading "*" indentation compared to the rest of this header (which uses " *"), and it also has a spacing typo in one @retval ("-Not"). Aligning this block improves readability and keeps the generated docs consistent.
/**
* @brief Retrieves the last reboot reason from the platform.
*
* This API returns a normalized reboot reason along with
* vendor-specific diagnostic information.
*
* Platform implementations are responsible for translating
* hardware-specific reboot causes into the common
* dsRebootReasonType_t enumeration.
*
* @param[out] rebootReason    -    Reboot reason information.
*
* @return dsError_t
* @retval dsERR_NONE                     - Success
* @retval dsERR_NOT_INITIALIZED          - Module not initialized
* @retval dsERR_INVALID_PARAM            - Invalid parameter
* @retval dsERR_OPERATION_NOT_SUPPORTED  -Not supported on platform
* @retval dsERR_GENERAL                  - Platform-specific failure
*/

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/dsHost.h Outdated
Comment thread include/dsHost.h Outdated
Copilot AI review requested due to automatic review settings August 4, 2026 07:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (3)

include/dsHost.h:183

  • There’s an unintended word break in this doc comment ("classifica tion"), which reads like a typo in the public API documentation.
    /** @brief Camel-case human-readable source, e.g. "KernelPanic", "WatchDog".
     *  Mapped to RebootInfo.source in the middleware classifica    tion pipeline. */

include/dsHost.h:298

  • This new Doxygen block doesn’t follow the spacing/indentation used throughout this header (lines should be prefixed with " *"). Also, one @retval entry is missing a space after the dash ("-Not").
/**
* @brief Retrieves the last reboot reason from the platform.
*
* This API returns a normalized reboot reason along with
* vendor-specific diagnostic information.

include/dsHost.h:94

  • There’s trailing whitespace at the end of this comment separator line; if whitespace checks are enabled, this can cause lint failures and creates noisy diffs in the future.

This issue also appears in the following locations of the same file:

  • line 182
  • line 294
 * ---------------------------------------------------------------------- 

Comment thread include/dsHost.h Outdated

/** @brief Camel-case human-readable source, e.g. "KernelPanic", "WatchDog".
* Mapped to RebootInfo.source in the middleware classifica tion pipeline. */
char rebootInitiatedBy[DS_REBOOT_REASON_STR_LEN];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need these many reboot reason string? I think one reason string should be enough

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This many variables where read from the structure and logged in MW API, so added all the strings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copilot AI review requested due to automatic review settings August 4, 2026 10:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (2)

include/dsHost.h:273

  • This Doxygen block is formatted inconsistently with the rest of the file (missing leading space before '*', inconsistent @param spacing, and @return line format). Keeping the comment style consistent improves generated docs readability.
/**
* @brief Retrieves the last reboot reason from the platform.
*
* This API returns a normalized reboot reason along with
* vendor-specific diagnostic information.

include/dsHost.h:133

  • The enum documentation refers to "logString", but the struct field is named rebootReasonString. This mismatch makes the API contract unclear for implementers/consumers.
    DS_REBOOT_REASON_UNKNOWN,            /**< Reason could not be determined or
                                          *   does not match any defined category.
                                          *   Consult logString for vendor detail. */

Comment thread include/dsHost.h
* applicable. Must not be used for programmatic decision-making. */
char rebootReasonString[DS_REBOOT_REASON_STR_LEN];

} dsRebootReason_t;

@kanjoe24 kanjoe24 Aug 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the behaviour of the repo and interface files, isn't it better to move enum to other header files say dsUtls.h or dsTypes.h ?
Just a thought, we can discuss if needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is only one enum and a struct and that is related only to reboot reason api, added it in the same file

Comment thread include/dsHost.h
* @retval dsERR_INVALID_PARAM - Invalid parameter
* @retval dsERR_OPERATION_NOT_SUPPORTED - Not supported on platform
* @retval dsERR_GENERAL - Platform-specific failure
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, as this api is part of dshost, we would need to call init before this api gets called, as done in all other apis here. So good to add below line

* @pre dsHostInit() must be called before this function

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copilot AI review requested due to automatic review settings August 7, 2026 08:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (2)

include/dsHost.h:259

  • The Doxygen block for dsGetLastRebootReason is formatted inconsistently with the rest of this header (missing leading space before *), and it introduces inconsistent spelling ("initialized" vs the existing "initialised"). This can degrade generated API docs readability/searchability.
/**
* @brief Retrieves the last reboot reason from the platform.
*
* This API returns a normalized reboot reason along with
* vendor-specific diagnostic information.

include/dsHost.h:133

  • The enum documentation references logString, but the struct field is named rebootReasonString. This looks like a stale/incorrect identifier and will confuse implementers reading the generated docs.

This issue also appears on line 255 of the same file.

    DS_REBOOT_REASON_UNKNOWN,            /**< Reason could not be determined or
                                          *   does not match any defined category.
                                          *   Consult logString for vendor detail. */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Feature: API to get the last reboot reason

4 participants