mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-28 04:40:47 +00:00
system/nxinit: Add subreason for sys.boot.reason
init.rc
on init && property:sys.boot.reason=watchdog,4
...
on init && property:sys.boot.reason=bootloader|recovery|thermal
...
Test
cause->cause = BOARDIOC_RESETCAUSE_CPU_RWDT;
cause->flag = 4
init_main: setprop key:sys.boot.reason value:watchdog,4
cause->cause = BOARDIOC_RESETCAUSE_CPU_SOFT;
cause->flag = BOARDIOC_SOFTRESETCAUSE_ENTER_BOOTLOADER;
init_main: setprop key:sys.boot.reason value:bootloader
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
parent
fd35a05249
commit
ee32ebda06
1 changed files with 15 additions and 5 deletions
|
|
@ -27,7 +27,9 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <poll.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/boardctl.h>
|
||||
#include <sys/param.h>
|
||||
|
|
@ -118,12 +120,10 @@ static int init_boot_reason(FAR struct action_manager_s *am)
|
|||
[BOARDIOC_RESETCAUSE_SYS_CHIPPOR] = "cold",
|
||||
[BOARDIOC_RESETCAUSE_SYS_RWDT] = "watchdog",
|
||||
[BOARDIOC_RESETCAUSE_SYS_BOR] = "undervoltage",
|
||||
[BOARDIOC_RESETCAUSE_CORE_SOFT] = "warm",
|
||||
[BOARDIOC_RESETCAUSE_CORE_DPSP] = "warm",
|
||||
[BOARDIOC_RESETCAUSE_CORE_MWDT] = "watchdog",
|
||||
[BOARDIOC_RESETCAUSE_CORE_RWDT] = "watchdog",
|
||||
[BOARDIOC_RESETCAUSE_CPU_MWDT] = "watchdog",
|
||||
[BOARDIOC_RESETCAUSE_CPU_SOFT] = "warm",
|
||||
[BOARDIOC_RESETCAUSE_CPU_RWDT] = "watchdog",
|
||||
[BOARDIOC_RESETCAUSE_PIN] = "powerkey",
|
||||
[BOARDIOC_RESETCAUSE_LOWPOWER] = "lowpower",
|
||||
|
|
@ -142,7 +142,9 @@ static int init_boot_reason(FAR struct action_manager_s *am)
|
|||
[BOARDIOC_SOFTRESETCAUSE_THERMAL] = "thermal",
|
||||
};
|
||||
|
||||
char buf[CONFIG_SYSTEM_NXINIT_RC_LINE_MAX];
|
||||
struct boardioc_reset_cause_s reset;
|
||||
FAR const char *value;
|
||||
int ret;
|
||||
|
||||
memset(&reset, 0, sizeof(reset));
|
||||
|
|
@ -163,9 +165,17 @@ static int init_boot_reason(FAR struct action_manager_s *am)
|
|||
reset.flag = nitems(resetflag) - 1;
|
||||
}
|
||||
|
||||
return init_property_set(am->prop, "sys.boot.reason",
|
||||
reset.cause != BOARDIOC_RESETCAUSE_CPU_SOFT ?
|
||||
resetcause[reset.cause] : resetflag[reset.flag]);
|
||||
if (resetcause[reset.cause])
|
||||
{
|
||||
sprintf(buf, "%s,%" PRIu32 "", resetcause[reset.cause], reset.flag);
|
||||
value = buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = resetflag[reset.flag];
|
||||
}
|
||||
|
||||
return init_property_set(am->prop, "sys.boot.reason", value);
|
||||
}
|
||||
#else
|
||||
# define init_boot_reason(am) (0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue