Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion comm/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,13 @@ void commands_process_packet(unsigned char *data, unsigned int len,
if (nrf_driver_ext_nrf_running()) {
nrf_driver_pause(6000);
}
uint16_t flash_res = flash_helper_erase_new_app(buffer_get_uint32(data, &ind));
uint16_t flash_res = 100;
if (!REJECT_FLASH_LOADING) {
flash_res = flash_helper_erase_new_app(buffer_get_uint32(data, &ind));
}
else {
commands_printf("Firmware loading rejected by the controller.");
}

ind = 0;
uint8_t send_buffer[50];
Expand Down
10 changes: 10 additions & 0 deletions hwconf/Ubox/100v/hw_ubox_100_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ static enPOWER_KEY_TYPE power_key_type = power_key_type_undecided;
static uint32_t power_key_pressed_ms = 0;
static bool power_key_pressed_when_power_on = false;

bool hw_reject_flash_loading(void)
{
bool do_reject = power_key_type == power_key_type_momentary;
if (do_reject)
commands_printf("%s: Momentary button detected, firmware loading is not permitted!", HW_NAME);

// Don't allow loading firmware if the power button behaves like a momentary one
return do_reject;
}

static THD_FUNCTION(shutdown_thread, arg) {
(void)arg;
chRegSetThreadName("Shutdown_ubox");
Expand Down
3 changes: 3 additions & 0 deletions hwconf/Ubox/100v/hw_ubox_100_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#error "Must define hardware type"
#endif

#define REJECT_FLASH_LOADING hw_reject_flash_loading()

// HW properties
#define HW_HAS_3_SHUNTS
#define INVERTED_SHUNT_POLARITY
Expand Down Expand Up @@ -295,5 +297,6 @@

// HW-specific functions
float hw100_250_get_temp(void);
bool hw_reject_flash_loading(void);

#endif /* HW_UBOX_V2_100_CORE_H_ */
10 changes: 10 additions & 0 deletions hwconf/Ubox/126v/hw_ubox_126_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ static enPOWER_KEY_TYPE power_key_type = power_key_type_undecided;
static uint32_t power_key_pressed_ms = 0;
static bool power_key_pressed_when_power_on = false;

bool hw_reject_flash_loading(void)
{
bool do_reject = power_key_type == power_key_type_momentary;
if (do_reject)
commands_printf("%s: Momentary button detected, firmware loading is not permitted!", HW_NAME);

// Don't allow loading firmware if the power button behaves like a momentary one
return do_reject;
}

static THD_FUNCTION(shutdown_thread, arg) {
(void)arg;
chRegSetThreadName("Shutdown_ubox");
Expand Down
3 changes: 3 additions & 0 deletions hwconf/Ubox/126v/hw_ubox_126_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#error "Must define hardware type"
#endif

#define REJECT_FLASH_LOADING hw_reject_flash_loading()

// HW properties
#define HW_HAS_3_SHUNTS
#define INVERTED_SHUNT_POLARITY
Expand Down Expand Up @@ -280,5 +282,6 @@

// HW-specific functions
float hw100_250_get_temp(void);
bool hw_reject_flash_loading(void);

#endif /* HW_UBOX_126_CORE_H_ */
4 changes: 4 additions & 0 deletions hwconf/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@
#define HW_PERMANENT_NRF_FAILED_HOOK()
#endif

#ifndef REJECT_FLASH_LOADING
#define REJECT_FLASH_LOADING false
#endif

#ifndef HW_EARLY_INIT
#define HW_EARLY_INIT()
#endif
Expand Down