Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for updating firmware after every reboot #345

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 optiboot/bootloaders/optiboot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ else
BAUD_RATE_CMD = -DBAUD_RATE=115200
endif

ifdef ALWAYS_USE_BOOTLOADER
ALWAYS_USE_BOOTLOADER_CMD = -DALWAYS_USE_BOOTLOADER=$(ALWAYS_USE_BOOTLOADER)
else
ALWAYS_USE_BOOTLOADER_CMD =
endif

HELPTEXT += "Option LED=B3 - set LED pin to particular port/bit\n"
ifdef LED
LED_CMD = -DLED=$(LED)
Expand Down Expand Up @@ -299,7 +305,7 @@ COMMON_OPTIONS = $(BAUD_RATE_CMD) $(LED_START_FLASHES_CMD) $(BIGBOOT_CMD)
COMMON_OPTIONS += $(SOFT_UART_CMD) $(LED_DATA_FLASH_CMD) $(LED_CMD) $(SS_CMD)
COMMON_OPTIONS += $(SUPPORT_EEPROM_CMD) $(LED_START_ON_CMD) $(APPSPM_CMD)
COMMON_OPTIONS += $(OSCCAL_VALUE_CMD) $(VERSION_CMD) $(TIMEOUT_CMD)
COMMON_OPTIONS += $(POR_CMD) $(EXTR_CMD) $(RS485_CMD)
COMMON_OPTIONS += $(POR_CMD) $(EXTR_CMD) $(RS485_CMD) $(ALWAYS_USE_BOOTLOADER_CMD)

#UART is handled separately and only passed for devices with more than one.
HELPTEXT += "Option UART=n - use UARTn for communications\n"
Expand Down
11 changes: 10 additions & 1 deletion optiboot/bootloaders/optiboot/optiboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,12 +781,21 @@ int main(void) {
# warning "START_APP_ON_EXTR is defined and NO_START_APP_ON_POR isn't"
# define APP_START_REASONS 1 /* Always start rge App. */
# define WDRF_CLR_REASONS 0 /* Never clear WDRF */
#endif

#if ALWAYS_USE_BOOTLOADER
#define _ALWAYS_USE_BOOTLOADR 1
#else
#define _ALWAYS_USE_BOOTLOADR 0
#endif

ch = MCUSR;

// Skip all logic and run bootloader if MCUSR is cleared (application request)
if (ch != 0) {
if (_ALWAYS_USE_BOOTLOADR || ch != 0) {

#undef _ALWAYS_USE_BOOTLOADR

/*
* To run the boot loader, External Reset Flag must be set.
* If not, we could make shortcut and jump directly to application code.
Expand Down