System Reboot and Reason Acquisition


1. Overview

This document introduces how to use the SigmaStar platform to reboot the system and obtain the interface and command for the reboot reason. The platform SoC contains an ARM CPU and a RISCV CPU, and supports rebooting the entire SoC, rebooting the ARM separately, and rebooting the RISCV separately.

This platform runs U-Boot/Linux on ARM and FreeRTOS on RISCV. The following describes U-Boot/Linux/FreeRTOS respectively.

2. U-Boot API Reference

API name Function
drv_reboot_read_rtc_io1 Read the level status of RTC IO1.
drv_reboot_read_rtc_io3 Read the level status of RTC IO3.
drv_reboot_get_wakeup_source Get the system's wakeup source.
drv_reboot_get_reason Get the reason for the reboot.
drv_reboot_read_kernel_panic_flag Read the kernel panic flag.
drv_reboot_clear_kernel_panic_flag Clear the kernel panic flag.
drv_reboot_reset Reboot the entire SoC.
drv_reboot_poweroff Power off the SoC.
drv_riscv_reset Stop RISCV FreeRTOS.
drv_riscv_start Start RISCV FreeRTOS.
reboot reason enumeration type definition
REBOOT_HW_RESET Indicates Hardware Reset.
REBOOT_WDT_RESET Indicates Watchdog Reset.
REBOOT_SW_RESET Indicates Software Reset.
REBOOT_ARM_CORE_RESET Indicates ARM Core Reset.
wakeup source enumeration type definition
RTC_IO1_WAKEUP Indicates the wakeup source is RTC IO1.
RTC_IO3_WAKEUP Indicates the wakeup source is RTC IO3.
RTC_ALARM_WAKEUP Indicates that the wakeup source is RTC ALARM.

2.1. drv_reboot_read_rtc_io1

  • Function

    Read the current level status of RTC IO1.

  • Syntax

    status = drv_reboot_read_rtc_io1();
    
  • Parameters

    none

  • Return value

    • 0: Indicates that RTC IO1 is currently at a low level.

    • 1: Indicates that RTC IO1 is currently at a high level.

  • Dependency

    • Header file: drivers/sstar/reboot/drv_reboot.h
  • Note

    none

2.2. drv_reboot_read_rtc_io3

  • Function

    Read the current level status of RTC IO3.

  • Syntax

    status = drv_reboot_read_rtc_io3();
    
  • Parameters

    none

  • Return value

    • 0: Indicates that RTC IO3 is currently at a low level.

    • 1: Indicates that RTC IO3 is currently at a high level.

  • Dependency

    • Header file: drivers/sstar/reboot/drv_reboot.h
  • Note

    none

2.3. drv_reboot_get_wakeup_source

  • Function

    Gets the system's wakeup source.

  • Syntax

    wakeup_source = drv_reboot_get_wakeup_source();
    
  • Parameters

    none

  • Return value

    • RTC_IO1_WAKEUP: Indicates that the wakeup source is RTC IO1.

    • RTC_IO3_WAKEUP: Indicates that the wakeup source is RTC IO3.

    • RTC_ALARM_WAKEUP: Indicates that the wakeup source is RTC ALARM.

  • Dependency

    • Header file: drivers/sstar/reboot/drv_reboot.h
  • Note

    none

2.4. drv_reboot_get_reason

  • Function

    Get the reason for the system boot/reboot.

  • Syntax

    reason = drv_reboot_get_reason();
    
  • Parameters

    none

  • Return value

    • REBOOT_HW_RESET: Indicates that this is a hardware power-on boot.

    • REBOOT_WDT_RESET: Indicates that this is a reboot triggered by Watchdog.

    • REBOOT_SW_RESET: Indicates that this is a software-triggered reboot.

    • REBOOT_ARM_CORE_RESET: Indicates that this is a reboot triggered by rebooting ARM alone.

  • Dependency

    • Header file: drivers/sstar/reboot/drv_reboot.h
  • Note

    none

2.5. drv_reboot_read_kernel_panic_flag

  • Function

    Read the kernel panic flag.

  • Syntax

    status = drv_reboot_read_kernel_panic_flag();
    
  • Parameters

    none

  • Return value

    • 0: Indicates that no kernel panic occurred before this reboot.

    • 1: Indicates that a kernel panic occurred before this reboot.

  • Dependency

    • Header file: drivers/sstar/reboot/drv_reboot.h
  • Note

    none

2.6. drv_reboot_clear_kernel_panic_flag

  • Function

    Clear the kernel panic flag.

  • Syntax

    drv_reboot_clear_kernel_panic_flag();
    
  • Parameters

    none

  • Return value

    none

  • Dependency

    • Header file: drivers/sstar/reboot/drv_reboot.h
  • Note

    none

2.7. drv_reboot_reset

  • Function

    Reboot the entire SoC.

  • Syntax

    drv_reboot_reset();
    
  • Parameters

    none

  • Return value

    none

  • Dependency

    • Header file: drivers/sstar/reboot/drv_reboot.h
  • Note

    none

2.8. drv_reboot_poweroff

  • Function

    Power off the SoC.

  • Syntax

    drv_reboot_poweroff();
    
  • Parameters

    none

  • Return value

    none

  • Dependency

    • Header file: drivers/sstar/reboot/drv_reboot.h
  • Note

    none

2.9. drv_riscv_reset

  • Function

    Stop RISCV FreeRTOS.

  • Syntax

    drv_riscv_reset();
    
  • Parameters

    none

  • Return value

    none

  • Dependency

    • Header file: drivers/sstar/riscv/drv_riscv.h
  • Note

    • After calling drv_riscv_reset() to stop RISCV FreeRTOS, you can call drv_riscv_start() to start RISCV FreeRTOS.

2.10. drv_riscv_start

  • Function

    Start RISCV FreeRTOS.

  • Syntax

    drv_riscv_start();
    
  • Parameters

    none

  • Return value

    none

  • Dependency

    • Header file: drivers/sstar/riscv/drv_riscv.h
  • Note

    • You need to call drv_riscv_reset() to stop RISCV FreeRTOS first, and then call drv_riscv_start() to start RISCV FreeRTOS.

3. U-Boot command line reference

Command Function
reboot io1 Read the level status of RTC IO1.
reboot io3 Read the level status of RTC IO3.
reboot wakeup_source Get the system's wakeup source.
reboot reason Get the reboot reason.
reboot kernel_panic Read the kernel panic flag.
reboot clear_kernel_panic Clear the kernel panic flag.
reboot reset Reboot the entire SoC.
reboot poweroff Power off the SoC.
riscv stop Stop RISCV FreeRTOS.
riscv start Start RISCV FreeRTOS.

3.1. Read the level status of RTC IO1

  • Command

    reboot io1
    
  • Log

    • "io1: 0" means RTC IO1 is currently at a low level.

    • "io1: 1" means RTC IO1 is currently at a high level.

  • Note

    none

3.2. Read the level status of RTC IO3

  • Command

    reboot io3
    
  • Log

    • "io3: 0" means RTC IO3 is currently at a low level.

    • "io3: 1" means RTC IO3 is currently at a high level.

  • Note

    none

3.3. Get the system wake-up source

  • Command

    reboot wakeup_source
    
  • Log

    • "wakeup source: io1" means the wakeup source is RTC IO1.

    • "wakeup source: io3" means the wakeup source is RTC IO3.

    • "wakeup source: alarm" means the wakeup source is RTC ALARM.

  • Note

    none

3.4. Get the reason for the system boot/reboot

  • Command

    reboot reason
    
  • Log

    • "reason: hw reset" means this is a hardware power-on reboot.

    • "reason: wdt reset" means this is a reboot triggered by Watchdog.

    • "reason: sw reset" indicates that this is a software-triggered reboot.

    • "reason: arm core reset" means this is a reboot triggered by rebooting ARM alone.

  • Note

    none

3.5. Reading kernel panic flags

  • Command

    reboot kernel_panic
    
  • Log

    • "kernel_panic: 0" means that no kernel panic occurred before this reboot.

    • "kernel_panic: 1" means kernel panic occurred before this reboot.

  • Note

    none

3.6. Clear kernel panic flag

  • Command

    reboot clear_kernel_panic
    
  • Log

    none

  • Note

    none

3.7. Reboot the entire SoC

  • Command

    reboot reset
    
  • Log

    none

  • Note

    none

3.8. Power off the SoC

  • Command

    reboot poweroff
    
  • Log

    none

  • Note

    none

3.9. Stop RISCV FreeRTOS

  • Command

    riscv stop
    
  • Log

    none

  • Note

    • After executing riscv stop to stop RISCV FreeRTOS, you can execute riscv start to start RISCV FreeRTOS.

3.10. Booting RISCV FreeRTOS

  • Command

    riscv start
    
  • Log

    none

  • Note

    • You need to execute riscv stop to stop RISCV FreeRTOS first, and then execute riscv start to start RISCV FreeRTOS.

4. Linux command line reference

Command Function
reboot Reboot the entire SoC.
poweroff Powers off the SoC.
cat /sys/class/sstar/msys/REBOOT_TYPE Get the reboot reason.
cat /sys/class/sstar/msys/KERNEL_PANIC Read the kernel panic flag.
echo 2 > /sys/class/sstar/riscv/reset Stop RISCV FreeRTOS.
echo 1 > /sys/class/sstar/riscv/reset Reboot RISCV FreeRTOS.

4.1. reboot the entire SoC

  • Command

    reboot
    
  • Log

    none

  • Note

    none

4.2. Power off the SoC

  • Command

    poweroff
    
  • Log

    none

  • Note

    none

4.3. Get the reason for reboot

  • Command

    cat /sys/class/sstar/msys/REBOOT_TYPE
    
  • Log

    • "Reboot_Type: hard" indicates this is a hardware power-on reboot.

    • "Reboot_Type: watchdog" indicates that this is a reboot triggered by Watchdog.

    • "Reboot_Type: reboot" indicates that this is a software-triggered reboot.

    • "Reboot_Type: arm_core" indicates this is a reboot triggered by rebooting ARM alone.

  • Note

    none

4.4. Reading kernel panic flags

  • Command

    cat /sys/class/sstar/msys/KERNEL_PANIC
    
  • Log

    • "Kernel_Panic: 0" means that there was no kernel panic before this reboot.

    • "Kernel_Panic: 1" means kernel panic occurred before this reboot.

  • Note

    none

4.5. Stop RISCV FreeRTOS

  • Command

    echo 2 > /sys/class/sstar/riscv/reset
    
  • Log

    none

  • Note

    • After executing echo 2 > /sys/class/sstar/riscv/reset to stop RISCV FreeRTOS, you can execute echo 1 > /sys/class/sstar/riscv/reset to reboot RISCV FreeRTOS.

4.6. reboot RISCV FreeRTOS

  • Command

    echo 1 > /sys/class/sstar/riscv/reset
    
  • Log

    none

  • Note

    • Directly executing echo 1 > /sys/class/sstar/riscv/reset will reboot RISCV FreeRTOS.

    • You can first execute echo 2 > /sys/class/sstar/riscv/reset to stop RISCV FreeRTOS, and then execute echo 1 > /sys/class/sstar/riscv/reset to reboot RISCV FreeRTOS.

5. FreeRTOS API Reference

API Name Function
drv_reboot_read_rtc_io1 Read the level status of RTC IO1.
drv_reboot_read_rtc_io3 Read the level status of RTC IO3.
drv_reboot_get_wakeup_source Get the system's wakeup source.
drv_reboot_get_reason Get the reboot reason.
drv_reboot_reset Reboot the entire SoC.
drv_reboot_reset_riscv Reboot RISCV FreeRTOS.
drv_reboot_stop_arm Stop ARM Linux.
drv_reboot_reset_arm Reboot ARM Linux.
drv_reboot_poweroff Power off the SoC.
reboot reason enumeration type definition
REBOOT_HW_RESET Indicates Hardware Reset.
REBOOT_WDT_RESET Indicates Watchdog Reset.
REBOOT_SW_RESET Indicates Software Reset.
REBOOT_RISCV_CORE_ACTIVE_RESET Indicates that RISCV Core is actively reset.
REBOOT_RISCV_CORE_PASSIVE_RESET Indicates that RISCV Core is passively reset.
wakeup source enumeration type definition
RTC_IO1_WAKEUP Indicates the wakeup source is RTC IO1.
RTC_IO3_WAKEUP Indicates the wakeup source is RTC IO3.
RTC_ALARM_WAKEUP Indicates that the wakeup source is RTC ALARM.

5.1. drv_reboot_read_rtc_io1

  • Function

    Read the current level status of RTC IO1.

  • Syntax

    status = drv_reboot_read_rtc_io1();
    
  • Parameters

    none

  • Return value

    • 0: Indicates that RTC IO1 is currently at a low level.

    • 1: Indicates that RTC IO1 is currently at a high level.

  • Dependency

    • Header file: sc/driver/sysdriver/reboot/drv/pub/drv_reboot.h
  • Note

    none

5.2. drv_reboot_read_rtc_io3

  • Function

    Read the current level status of RTC IO3.

  • Syntax

    status = drv_reboot_read_rtc_io3();
    
  • Parameters

    none

  • Return value

    • 0: Indicates that RTC IO3 is currently at a low level.

    • 1: Indicates that RTC IO3 is currently at a high level.

  • Dependency

    • Header file: sc/driver/sysdriver/reboot/drv/pub/drv_reboot.h
  • Note

    none

5.3. drv_reboot_get_wakeup_source

  • Function

    Gets the system's wakeup source.

  • Syntax

    wakeup_source = drv_reboot_get_wakeup_source();
    
  • Parameters

    none

  • Return value

    • RTC_IO1_WAKEUP: Indicates that the wakeup source is RTC IO1.

    • RTC_IO3_WAKEUP: Indicates that the wakeup source is RTC IO3.

    • RTC_ALARM_WAKEUP: Indicates that the wakeup source is RTC ALARM.

  • Dependency

    • Header file: sc/driver/sysdriver/reboot/drv/pub/drv_reboot.h
  • Note

    none

5.4. drv_reboot_get_reason

  • Function

    Get the reason for the system boot/reboot.

  • Syntax

    reason = drv_reboot_get_reason();
    
  • Parameters

    none

  • Return value

    • REBOOT_HW_RESET: Indicates that this is a hardware power-on boot.

    • REBOOT_WDT_RESET: Indicates that this is a reboot triggered by Watchdog.

    • REBOOT_SW_RESET: Indicates that this is a software-triggered reboot.

    • REBOOT_RISCV_CORE_ACTIVE_RESET: Indicates that this is a reboot triggered by a separate reboot of RISCV, and the initiator is RISCV FreeRTOS.

    • REBOOT_RISCV_CORE_PASSIVE_RESET: Indicates that this is a reboot triggered by a separate reboot of RISCV, and the initiator is ARM Linux.

  • Dependency

    • Header file: sc/driver/sysdriver/reboot/drv/pub/drv_reboot.h
  • Note

    none

5.5. drv_reboot_reset

  • Function

    Reboot the entire SoC.

  • Syntax

    drv_reboot_reset();
    
  • Parameters

    none

  • Return value

    none

  • Dependency

    • Header file: sc/driver/sysdriver/reboot/drv/pub/drv_reboot.h
  • Note

    none

5.6. drv_reboot_reset_riscv

  • Function

    Reboot RISCV FreeRTOS.

  • Syntax

    drv_reboot_reset_riscv();
    
  • Parameters

    none

  • Return value

    none

  • Dependency

    • Header file: sc/driver/sysdriver/reboot/drv/pub/drv_reboot.h
  • Note

    none

5.7. drv_reboot_stop_arm

  • Function

    Stop ARM Linux.

  • Syntax

    drv_reboot_stop_arm();
    
  • Parameters

    none

  • Return value

    none

  • Dependency

    • Header file: sc/driver/sysdriver/reboot/drv/pub/drv_reboot.h
  • Note

    • After calling drv_reboot_stop_arm() to stop ARM Linux, you can call drv_reboot_reset_arm() to reboot ARM Linux.

5.8. drv_reboot_reset_arm

  • Function

    Reboot ARM Linux.

  • Syntax

    drv_reboot_reset_arm();
    
  • Parameters

    none

  • Return value

    none

  • Dependency

    • Header file: drivers/sstar/riscv/drv_riscv.h
  • Note

    • The effect of calling drv_reboot_reset_arm() directly is to reboot ARM Linux.

    • You can first call drv_reboot_stop_arm() to stop ARM Linux, and then call drv_reboot_reset_arm() to reboot ARM Linux.

5.9. drv_reboot_poweroff

  • Function

    Power off the SoC.

  • Syntax

    drv_reboot_poweroff();
    
  • Parameters

    none

  • Return value

    none

  • Dependency

    • Header file: sc/driver/sysdriver/reboot/drv/pub/drv_reboot.h
  • Note

    none

6. FreeRTOS Command Line Reference

Command Function
reboot io1 Read the level status of RTC IO1.
reboot io3 Read the level status of RTC IO3.
reboot wakeup_source Get the system wakeup source.
reboot reason Get the reboot reason.
reboot reset Reboot the entire SoC.
reboot reset_riscv Reboot RISCV FreeRTOS.
reboot stop_arm Stop ARM Linux.
reboot reset_arm Reboot ARM Linux.
reboot poweroff Power off the SoC.

6.1. Read the level status of RTC IO1

  • Command

    reboot io1
    
  • Log

    • "io1: 0" means RTC IO1 is currently at a low level.

    • "io1: 1" means RTC IO1 is currently at a high level.

  • Note

    none

6.2. Read the level status of RTC IO3

  • Command

    reboot io3
    
  • Log

    • "io3: 0" means RTC IO3 is currently at a low level.

    • "io3: 1" means RTC IO3 is currently at a high level.

  • Note

    none

6.3. Get the system wakeup source

  • Command

    reboot wakeup_source
    
  • Log

    • "wakeup source: io1" means the wakeup source is RTC IO1.

    • "wakeup source: io3" means the wakeup source is RTC IO3.

    • "wakeup source: alarm" means the wakeup source is RTC ALARM.

  • Note

    none

6.4. Get the reason for the system boot/reboot

  • Command

    reboot reason
    
  • Log

    • "reason: hw reset" means this is a hardware power-on reboot.

    • "reason: wdt reset" means this is a reboot triggered by Watchdog.

    • "reason: sw reset" means this is a software-triggered reboot.

    • "reason: riscv core active reset" means this is a reboot triggered by a separate reboot of RISCV, and the initiator is RISCV FreeRTOS.

    • "reason: riscv core passive reset" means that this is a reboot triggered by a separate reboot of RISCV, and the initiator is ARM Linux.

  • Note

    none

6.5. Reboot the entire SoC

  • Command

    reboot reset
    
  • Log

    none

  • Note

    none

6.6. reboot RISCV FreeRTOS

  • Command

    reboot reset_riscv
    
  • Log

    none

  • Note

    none

6.7. Stop ARM Linux

  • Command

    reboot stop_arm
    
  • Log

    none

  • Note

    • After executing reboot stop_arm to stop ARM Linux, you can execute reboot reset_arm to reboot ARM Linux.

6.8. reboot ARM Linux

  • Command

    reboot reset_arm
    
  • Log

    none

  • Note

    • The effect of directly executing reboot reset_arm is to reboot ARM Linux.

    • You can first execute reboot stop_arm to stop ARM Linux, and then execute reboot reset_arm to reboot ARM Linux.

6.9. Power off the SoC

  • Command

    reboot poweroff
    
  • Log

    none

  • Note

    none