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

Enable bootloader OTA updates on Electron #1002

Merged
merged 2 commits into from
Jun 10, 2016
Merged
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
- `millis()`/`micros()` are now atomic to ensure monotonic values. Fixes [#916](https://github.com/spark/firmware/issues/916) and [#925](https://github.com/spark/firmware/issues/925)
- availableForWrite() was reporting bytes available instead of bytes available for write [#1020](https://github.com/spark/firmware/pull/1020) and [#1017](https://github.com/spark/firmware/issues/1017)
- `digitalRead()` interferes with `analogRead()` [#993](https://github.com/spark/firmware/issues/993)

- [electron] reinstated OTA bootloader updates [#1002](https://github.com/spark/firmware/pull/1002)


## v0.5.1 (same as v0.5.1-rc.2)
Expand Down
37 changes: 20 additions & 17 deletions hal/src/stm32f2xx/bootloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,28 @@
#if PLATFORM_ID==6 || PLATFORM_ID==8
#define HAL_REPLACE_BOOTLOADER
#endif
#if PLATFORM_ID==6 || PLATFORM_ID==8 || PLATFORM_ID==10
#define HAL_REPLACE_BOOTLOADER_OTA
#endif
#endif

#ifdef HAL_REPLACE_BOOTLOADER_OTA
bool bootloader_update(const void* bootloader_image, unsigned length)
{
HAL_Bootloader_Lock(false);
bool result = (FLASH_CopyMemory(FLASH_INTERNAL, (uint32_t)bootloader_image,
FLASH_INTERNAL, 0x8000000, length, MODULE_FUNCTION_BOOTLOADER,
MODULE_VERIFY_DESTINATION_IS_START_ADDRESS|MODULE_VERIFY_CRC|MODULE_VERIFY_FUNCTION));
HAL_Bootloader_Lock(true);
return result;
}
#else
bool bootloader_update(const void*, unsigned)
{
return false;
}
#endif // HAL_REPLACE_BOOTLOADER_OTA

#ifdef HAL_REPLACE_BOOTLOADER

/**
Expand All @@ -37,16 +57,6 @@ bool bootloader_requires_update()
return requires_update;
}

bool bootloader_update(const void* bootloader_image, unsigned length)
{
HAL_Bootloader_Lock(false);
bool result = (FLASH_CopyMemory(FLASH_INTERNAL, (uint32_t)bootloader_image,
FLASH_INTERNAL, 0x8000000, length, MODULE_FUNCTION_BOOTLOADER,
MODULE_VERIFY_DESTINATION_IS_START_ADDRESS|MODULE_VERIFY_CRC|MODULE_VERIFY_FUNCTION));
HAL_Bootloader_Lock(true);
return result;
}

bool bootloader_update_if_needed()
{
bool updated = false;
Expand All @@ -56,20 +66,13 @@ bool bootloader_update_if_needed()
return updated;
}



#else

bool bootloader_requires_update()
{
return false;
}

bool bootloader_update(const void*, unsigned)
{
return false;
}

bool bootloader_update_if_needed()
{
return false;
Expand Down