From 8aee4432a9aa517deb5b9851949a0d5f405e1ed4 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Tue, 21 Jun 2016 09:15:38 +0200 Subject: [PATCH] px4io: set safety on before going into bootloader (#4860) Sometimes when flashing new firmware, the IO update fails because safety is off. In this case, we should set safety on first before putting the IO board into bootloader mode. --- src/drivers/px4io/px4io.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index e3c1b1e6d3..66ea188244 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -699,6 +699,12 @@ PX4IO::init() // be due to mismatched firmware versions and we want // the startup script to be able to load a new IO // firmware + + // If IO has already safety off it won't accept going into bootloader mode, + // therefore we need to set safety on first. + io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_FORCE_SAFETY_ON, PX4IO_FORCE_SAFETY_MAGIC); + + // Now the reboot into bootloader mode should succeed. io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_REBOOT_BL, PX4IO_REBOOT_BL_MAGIC); return -1; }