mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 10:46:33 +08:00
Remove reboot() API, replace with a prototype for up_systemreset() which is portable.
This commit is contained in:
@@ -138,7 +138,7 @@ int do_state_update(int status_pub, struct vehicle_status_s *current_status, con
|
|||||||
current_status->flag_system_armed = false;
|
current_status->flag_system_armed = false;
|
||||||
mavlink_log_critical(mavlink_fd, "[commander] REBOOTING SYSTEM");
|
mavlink_log_critical(mavlink_fd, "[commander] REBOOTING SYSTEM");
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
reboot();
|
up_systemreset();
|
||||||
/* SPECIAL CASE: NEVER RETURNS FROM THIS FUNCTION CALL */
|
/* SPECIAL CASE: NEVER RETURNS FROM THIS FUNCTION CALL */
|
||||||
} else {
|
} else {
|
||||||
invalid_state = true;
|
invalid_state = true;
|
||||||
|
|||||||
@@ -47,7 +47,11 @@
|
|||||||
#include <nuttx/compiler.h>
|
#include <nuttx/compiler.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "stm32_internal.h"
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
/* these headers are not C++ safe */
|
||||||
|
#include <stm32_internal.h>
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************************************
|
||||||
* Definitions
|
* Definitions
|
||||||
@@ -153,3 +157,5 @@
|
|||||||
extern void stm32_spiinitialize(void);
|
extern void stm32_spiinitialize(void);
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
|
|||||||
@@ -59,13 +59,13 @@
|
|||||||
#include <drivers/drv_gpio.h>
|
#include <drivers/drv_gpio.h>
|
||||||
#include <drivers/boards/px4fmu/px4fmu_internal.h>
|
#include <drivers/boards/px4fmu/px4fmu_internal.h>
|
||||||
|
|
||||||
|
#include <systemlib/systemlib.h>
|
||||||
#include <systemlib/mixer/mixer.h>
|
#include <systemlib/mixer/mixer.h>
|
||||||
#include <drivers/drv_mixer.h>
|
#include <drivers/drv_mixer.h>
|
||||||
|
|
||||||
#include <uORB/topics/actuator_controls.h>
|
#include <uORB/topics/actuator_controls.h>
|
||||||
#include <uORB/topics/actuator_outputs.h>
|
#include <uORB/topics/actuator_outputs.h>
|
||||||
|
|
||||||
#include <systemlib/systemlib.h>
|
|
||||||
#include <systemlib/err.h>
|
#include <systemlib/err.h>
|
||||||
|
|
||||||
class PX4FMU : public device::CDev
|
class PX4FMU : public device::CDev
|
||||||
|
|||||||
@@ -41,14 +41,13 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "systemlib/systemlib.h"
|
#include <systemlib/systemlib.h>
|
||||||
|
|
||||||
__EXPORT int reboot_main(int argc, char *argv[]);
|
__EXPORT int reboot_main(int argc, char *argv[]);
|
||||||
|
|
||||||
int reboot_main(int argc, char *argv[])
|
int reboot_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
reboot();
|
up_systemreset();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -73,41 +73,6 @@ const struct __multiport_info multiport_info = {
|
|||||||
|
|
||||||
static void kill_task(FAR _TCB *tcb, FAR void *arg);
|
static void kill_task(FAR _TCB *tcb, FAR void *arg);
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* user_start
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int reboot(void)
|
|
||||||
{
|
|
||||||
sched_lock();
|
|
||||||
// print text
|
|
||||||
printf("\r\nRebooting system - ending tasks and performing hard reset\r\n\r\n");
|
|
||||||
fflush(stdout);
|
|
||||||
//usleep(5000);
|
|
||||||
|
|
||||||
/* Sending kill signal to other tasks */
|
|
||||||
//killall();
|
|
||||||
|
|
||||||
/* Waiting maximum time for all to exit */
|
|
||||||
//usleep(5000);
|
|
||||||
//sched_lock();
|
|
||||||
|
|
||||||
/* Resetting CPU */
|
|
||||||
// FIXME Need check for ARM architecture here
|
|
||||||
#ifndef NVIC_AIRCR
|
|
||||||
#define NVIC_AIRCR (*((uint32_t*)0xE000ED0C))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set the SYSRESETREQ bit to force a reset */
|
|
||||||
NVIC_AIRCR = 0x05fa0004;
|
|
||||||
|
|
||||||
/* Spinning until the board is really reset */
|
|
||||||
while (true);
|
|
||||||
|
|
||||||
/* Should never reach here */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void killall()
|
void killall()
|
||||||
{
|
{
|
||||||
// printf("Sending SIGUSR1 to all processes now\n");
|
// printf("Sending SIGUSR1 to all processes now\n");
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
/** Reboots the board */
|
/** Reboots the board */
|
||||||
__EXPORT int reboot(void);
|
extern void up_systemreset(void) noreturn_function;
|
||||||
|
|
||||||
/** Sends SIGUSR1 to all processes */
|
/** Sends SIGUSR1 to all processes */
|
||||||
__EXPORT void killall(void);
|
__EXPORT void killall(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user