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

Adds bootloader as a secondary dependency to Photon/P1/Electron system-part2 #1306

Merged
merged 22 commits into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4c1c306
Load DCT functions dynamically in bootloader (P1)
sergeuz Apr 14, 2017
835bcdb
Compilation fixes, renamings
sergeuz Apr 14, 2017
f7ed26b
Panic messages are now logged only in debug builds
sergeuz Apr 14, 2017
09d0351
Disable reading/writing of DCT via DFU if DCT functions cannot be loa…
sergeuz Apr 14, 2017
70c9e2a
Clear module info in DCT before updating modules
sergeuz Apr 14, 2017
66f222e
Load DCT functions on first call; error handling for DCT read operations
sergeuz Apr 16, 2017
cf3ca06
Use backup registers to store system flags (stm32f2xx)
sergeuz Apr 18, 2017
ead398b
Check module dependencies
sergeuz Apr 18, 2017
56c6158
Enable dynamic loading of the DCT functions on Photon
sergeuz Apr 18, 2017
c97d7e0
Check addresses of the dynamically loaded functions
sergeuz Apr 20, 2017
c12d5a6
Check IWDG flag in DCT for compatibility with old bootloaders
sergeuz Apr 20, 2017
3e949ab
Don't clear module info slots in DCT unconditionally to avoid slowing…
sergeuz Apr 20, 2017
c0f1e62
Fix buttons setup in a situation when DCT functions are missing in bo…
sergeuz Apr 21, 2017
57081e2
Fill DFU packet with zeros to make reading errors more apparent
sergeuz Apr 21, 2017
5d91aaf
Minor fixes
sergeuz Apr 21, 2017
403c980
Moves BOOTLOADER_VERSION definition into system_module_version.mk
avtolstoy Apr 23, 2017
a1d5e17
Makes photon/p1 system-part1 and electron system-part3 depend on boot…
avtolstoy Apr 23, 2017
d306841
Adds bootloader module validation
avtolstoy Apr 23, 2017
b2e7a32
Adds a secondary module dependency.
avtolstoy Apr 26, 2017
5a1d198
Fixes unit tests. sizeof(void*) is 8 on 64-bit systems
avtolstoy Apr 26, 2017
86921a6
Add MODULE_DEPENDENCY2 to main/build.mk
avtolstoy Apr 26, 2017
eedde55
Default to invalid in HAL_Core_Validate_Modules
avtolstoy May 10, 2017
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
1 change: 1 addition & 0 deletions bootloader/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GLOBAL_DEFINES += BOOTLOADER_VERSION=$(BOOTLOADER_VERSION)
GLOBAL_DEFINES += MODULE_VERSION=$(BOOTLOADER_VERSION)
GLOBAL_DEFINES += MODULE_FUNCTION=$(MODULE_FUNCTION_BOOTLOADER)
GLOBAL_DEFINES += MODULE_DEPENDENCY=0,0,0
GLOBAL_DEFINES += MODULE_DEPENDENCY2=0,0,0

# select sources from platform

Expand Down
4 changes: 3 additions & 1 deletion bootloader/import.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
BOOTLOADER_MODULE_PATH ?= $(PROJECT_ROOT)/bootloader
BOOTLOADER_VERSION ?= 12
# Bootloader version is defined along with other modules in system_module_version.mk
# BOOTLOADER_VERSION ?= 12
include $(BOOTLOADER_MODULE_PATH)/../modules/shared/system_module_version.mk
BOOTLOADER_BUILD_PATH_EXT = $(BUILD_TARGET_PLATFORM)

# bring in the include folders from inc and src/<platform> is includes
Expand Down
13 changes: 11 additions & 2 deletions bootloader/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@
#include "rgbled.h"
#include "button.h"

#if (PLATFORM_ID == 6) || (PLATFORM_ID == 10) || (PLATFORM_ID == 8)
#include "led_signal.h"
#if PLATFORM_ID == 6 || PLATFORM_ID == 8
#define LOAD_DCT_FUNCTIONS
#include "bootloader_dct.h"
#endif

#if PLATFORM_ID == 6 || PLATFORM_ID == 10 || PLATFORM_ID == 8
#define USE_LED_THEME
#include "led_signal.h"
#endif

void platform_startup();
Expand Down Expand Up @@ -386,6 +391,10 @@ int main(void)
* Currently FLASH_UPDATE_MODULES support is enabled only on BM-09 bootloader
*/
FLASH_UpdateModules(flashModulesCallback);
#ifdef LOAD_DCT_FUNCTIONS
// DCT functions may need to be reloaded after updating a system module
load_dct_functions();
#endif
#else
if (REFLASH_FROM_BACKUP == 1)
{
Expand Down
95 changes: 95 additions & 0 deletions bootloader/src/photon/bootloader_dct.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#include "bootloader_dct.h"

#include "flash_mal.h"

#include <stdint.h>
#include <stddef.h>

#define MODULAR_FIRMWARE 1
#include "../../../hal/src/photon/ota_module_bounds.c"

#define SYSTEM_PART2_MIN_MODULE_VERSION 107 // 0.7.0-rc.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v0.7.0-rc.1 will start at module version 200

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ca75375

#define DYNALIB_HAL_CORE_INDEX 7
#define HAL_DCT_READ_APP_DATA_INDEX 33
#define HAL_DCT_WRITE_APP_DATA_INDEX 34

static const void*(*HAL_DCT_Read_App_Data)(uint32_t, void*) = NULL;
static int(*HAL_DCT_Write_App_Data)(const void*, uint32_t, uint32_t, void*) = NULL;
static uint8_t dct_funcs_inited = 0;

static const module_info_t* get_module_info(const module_bounds_t* bounds, uint16_t min_version) {
const module_info_t* module = FLASH_ModuleInfo(FLASH_INTERNAL, bounds->start_address);
// Check primary module info
if (!module || module->platform_id != PLATFORM_ID || module->module_function != bounds->module_function ||
module->module_index != bounds->module_index || module->module_version < min_version) {
return NULL;
}
// Check module boundaries
const uintptr_t startAddr = (uintptr_t)module->module_start_address;
const uintptr_t endAddr = (uintptr_t)module->module_end_address;
if (endAddr < startAddr || startAddr != bounds->start_address || endAddr > bounds->end_address) {
return NULL;
}
// Verify checksum
if (!FLASH_VerifyCRC32(FLASH_INTERNAL, startAddr, endAddr - startAddr)) {
return NULL;
}
return module;
}

static inline bool check_module_addr(void* ptr, const module_info_t* module) {
return (ptr >= module->module_start_address && ptr < module->module_end_address);
}

static void init_dct_functions() {
HAL_DCT_Read_App_Data = NULL;
HAL_DCT_Write_App_Data = NULL;
const module_info_t* part2 = get_module_info(&module_system_part2, SYSTEM_PART2_MIN_MODULE_VERSION);
if (!part2) {
return;
}
// Part2 should contain complete DCT implementation, but it's easy to introduce an additional
// dependency during development, so we require part1 to be consistent as well
const module_info_t* part1 = get_module_info(&module_system_part1, part2->dependency.module_version);
if (!part1 || part1->dependency.module_function != MODULE_FUNCTION_NONE) {
return;
}
// Get hal_core's dynalib table
void*** dynalib = (void***)((const char*)part2 + sizeof(module_info_t));
void** dynalib_hal_core = dynalib[DYNALIB_HAL_CORE_INDEX];
// Get addresses of the DCT functions
void* hal_dct_read_app_data_ptr = dynalib_hal_core[HAL_DCT_READ_APP_DATA_INDEX];
void* hal_dct_write_app_data_ptr = dynalib_hal_core[HAL_DCT_WRITE_APP_DATA_INDEX];
if (!check_module_addr(hal_dct_read_app_data_ptr, part2) ||
!check_module_addr(hal_dct_write_app_data_ptr, part2)) {
return;
}
HAL_DCT_Read_App_Data = hal_dct_read_app_data_ptr;
HAL_DCT_Write_App_Data = hal_dct_write_app_data_ptr;
}

void load_dct_functions() {
dct_funcs_inited = 0;
}

const void* dct_read_app_data(uint32_t offset) {
if (!dct_funcs_inited) {
init_dct_functions();
dct_funcs_inited = 1;
}
if (HAL_DCT_Read_App_Data) {
return HAL_DCT_Read_App_Data(offset, NULL /* reserved */);
}
return NULL;
}

int dct_write_app_data(const void* data, uint32_t offset, uint32_t size) {
if (!dct_funcs_inited) {
init_dct_functions();
dct_funcs_inited = 1;
}
if (HAL_DCT_Write_App_Data) {
return HAL_DCT_Write_App_Data(data, offset, size, NULL /* reserved */);
}
return -1;
}
6 changes: 6 additions & 0 deletions bootloader/src/photon/bootloader_dct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef BOOTLOADER_DCT_H
#define BOOTLOADER_DCT_H

void load_dct_functions();

#endif // BOOTLOADER_DCT_H
11 changes: 0 additions & 11 deletions bootloader/src/photon/dct_hal.c

This file was deleted.

2 changes: 1 addition & 1 deletion bootloader/src/stm32f2xx/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int BUTTON_Debounce() {
void BUTTON_Init_Ext() {
const button_config_t* conf = (const button_config_t*)dct_read_app_data(DCT_MODE_BUTTON_MIRROR_OFFSET);

if (conf->active == 0xAA && conf->debounce_time == 0xBBCC) {
if (conf && conf->active == 0xAA && conf->debounce_time == 0xBBCC) {
//int32_t state = HAL_disable_irq();
memcpy((void*)&HAL_Buttons[BUTTON1_MIRROR], (void*)conf, sizeof(button_config_t));
HAL_Buttons[BUTTON1_MIRROR].active = 0;
Expand Down
5 changes: 3 additions & 2 deletions dynalib/inc/module_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef struct module_info_t {
uint8_t module_function; /* The module function */
uint8_t module_index;
module_dependency_t dependency;
uint32_t reserved3;
module_dependency_t dependency2;
} module_info_t;

#define STATIC_ASSERT_MODULE_INFO_OFFSET(field, expected) STATIC_ASSERT( module_info_##field, offsetof(module_info_t, field)==expected || sizeof(void*)!=4)
Expand All @@ -65,8 +65,9 @@ STATIC_ASSERT_MODULE_INFO_OFFSET(platform_id, 12);
STATIC_ASSERT_MODULE_INFO_OFFSET(module_function, 14);
STATIC_ASSERT_MODULE_INFO_OFFSET(module_index, 15);
STATIC_ASSERT_MODULE_INFO_OFFSET(dependency, 16);
STATIC_ASSERT_MODULE_INFO_OFFSET(reserved3, 20);
STATIC_ASSERT_MODULE_INFO_OFFSET(dependency2, 20);

STATIC_ASSERT(module_info_size, sizeof(module_info_t) == 24 || sizeof(void*) != 4);

/**
* Define the module function enum also as preprocessor symbols so we can
Expand Down
6 changes: 4 additions & 2 deletions dynalib/inc/module_info.inc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ extern char link_module_end;
#error MODULE_DEPENDENCY not defined
#endif

#define MODULE_DEPENDENCY2 0,0,0
#ifndef MODULE_DEPENDENCY2
#error MODULE_DEPENDENCY2 not defined
#endif

#if PLATFORM_ID!=3
__attribute__((externally_visible _ARM_SECTION(section(".modinfo.module_info"))))
Expand All @@ -119,7 +121,7 @@ const module_info_t module_info = {
(uint8_t)(MODULE_FUNCTION), /* module function */
(uint8_t)(MODULE_INDEX), /* module index (part1 part2 etc..) */
{ MODULE_DEPENDENCY },
0
{ MODULE_DEPENDENCY2 }
};


Expand Down
1 change: 1 addition & 0 deletions hal/inc/core_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ extern "C" {
void HAL_Core_Init(void);
void HAL_Core_Config(void);
bool HAL_Core_Validate_User_Module(void);
bool HAL_Core_Validate_Modules(uint32_t flags, void* reserved);
bool HAL_Core_Mode_Button_Pressed(uint16_t pressedMillisDuration);
void HAL_Core_Mode_Button_Reset(uint16_t button);
void HAL_Core_System_Reset(void);
Expand Down
4 changes: 4 additions & 0 deletions hal/inc/hal_dynalib_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "core_hal.h"
#include "deviceid_hal.h"
#include "syshealth_hal.h"
#include "dct_hal.h"
#endif

// WARNING
Expand Down Expand Up @@ -77,6 +78,9 @@ DYNALIB_FN(31, hal_core, HAL_Core_Led_Mirror_Pin_Disable, void(uint8_t, uint8_t,

DYNALIB_FN(32, hal_core, HAL_Set_Event_Callback, void(HAL_Event_Callback, void*))

DYNALIB_FN(33, hal_core, HAL_DCT_Read_App_Data, const void*(uint32_t, void*))
DYNALIB_FN(34, hal_core, HAL_DCT_Write_App_Data, int(const void*, uint32_t, uint32_t, void*))

DYNALIB_END(hal_core)

#endif /* HAL_DYNALIB_CORE_H */
1 change: 1 addition & 0 deletions hal/src/electron/dct_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
#pragma once

#include "dct_hal_stm32f2xx.h"
#include "dcd_flash.h"
#include "dct.h"

24 changes: 0 additions & 24 deletions hal/src/electron/ota_flash_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,6 @@
#include "cellular_hal.h"
#include "core_hal.h"

// Electron!

#if MODULAR_FIRMWARE
const module_bounds_t module_bootloader = { 0x4000, 0x8000000, 0x8004000, MODULE_FUNCTION_BOOTLOADER, 0, MODULE_STORE_MAIN };
const module_bounds_t module_system_part1 = { 0x20000, 0x8020000, 0x8040000, MODULE_FUNCTION_SYSTEM_PART, 1, MODULE_STORE_MAIN };
const module_bounds_t module_system_part2 = { 0x20000, 0x8040000, 0x8060000, MODULE_FUNCTION_SYSTEM_PART, 2, MODULE_STORE_MAIN };
const module_bounds_t module_system_part3 = { 0x20000, 0x8060000, 0x8080000, MODULE_FUNCTION_SYSTEM_PART, 3, MODULE_STORE_MAIN };
const module_bounds_t module_user = { 0x20000, 0x8080000, 0x80A0000, MODULE_FUNCTION_USER_PART, 1, MODULE_STORE_MAIN};
const module_bounds_t module_factory = { 0x20000, 0x80A0000, 0x80C0000, MODULE_FUNCTION_USER_PART, 1, MODULE_STORE_FACTORY};
const module_bounds_t* module_bounds[] = { &module_bootloader, &module_system_part1, &module_system_part2, &module_system_part3, &module_user, &module_factory };

const module_bounds_t module_ota = { 0x20000, 0x80C0000, 0x80E0000, MODULE_FUNCTION_NONE, 0, MODULE_STORE_SCRATCHPAD};
#else
const module_bounds_t module_bootloader = { 0x4000, 0x8000000, 0x8004000, MODULE_FUNCTION_BOOTLOADER, 0, MODULE_STORE_MAIN};
const module_bounds_t module_user = { 0x60000, 0x8020000, 0x8080000, MODULE_FUNCTION_MONO_FIRMWARE, 0, MODULE_STORE_MAIN};
const module_bounds_t module_factory = { 0x60000, 0x8080000, 0x80E0000, MODULE_FUNCTION_MONO_FIRMWARE, 0, MODULE_STORE_FACTORY};
const module_bounds_t* module_bounds[] = { &module_bootloader, &module_user, &module_factory };

const module_bounds_t module_ota = { 0x60000, 0x8080000, 0x80E0000, MODULE_FUNCTION_NONE, 0, MODULE_STORE_SCRATCHPAD};
#endif

const unsigned module_bounds_length = arraySize(module_bounds);


void HAL_OTA_Add_System_Info(hal_system_info_t* info, bool create, void* reserved)
{
if (create) {
Expand Down
23 changes: 23 additions & 0 deletions hal/src/electron/ota_module_bounds.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "ota_flash_hal.h"
#include "spark_macros.h"

#if MODULAR_FIRMWARE
const module_bounds_t module_bootloader = { 0x4000, 0x8000000, 0x8004000, MODULE_FUNCTION_BOOTLOADER, 0, MODULE_STORE_MAIN };
const module_bounds_t module_system_part1 = { 0x20000, 0x8020000, 0x8040000, MODULE_FUNCTION_SYSTEM_PART, 1, MODULE_STORE_MAIN };
const module_bounds_t module_system_part2 = { 0x20000, 0x8040000, 0x8060000, MODULE_FUNCTION_SYSTEM_PART, 2, MODULE_STORE_MAIN };
const module_bounds_t module_system_part3 = { 0x20000, 0x8060000, 0x8080000, MODULE_FUNCTION_SYSTEM_PART, 3, MODULE_STORE_MAIN };
const module_bounds_t module_user = { 0x20000, 0x8080000, 0x80A0000, MODULE_FUNCTION_USER_PART, 1, MODULE_STORE_MAIN};
const module_bounds_t module_factory = { 0x20000, 0x80A0000, 0x80C0000, MODULE_FUNCTION_USER_PART, 1, MODULE_STORE_FACTORY};
const module_bounds_t* module_bounds[] = { &module_bootloader, &module_system_part1, &module_system_part2, &module_system_part3, &module_user, &module_factory };

const module_bounds_t module_ota = { 0x20000, 0x80C0000, 0x80E0000, MODULE_FUNCTION_NONE, 0, MODULE_STORE_SCRATCHPAD};
#else
const module_bounds_t module_bootloader = { 0x4000, 0x8000000, 0x8004000, MODULE_FUNCTION_BOOTLOADER, 0, MODULE_STORE_MAIN};
const module_bounds_t module_user = { 0x60000, 0x8020000, 0x8080000, MODULE_FUNCTION_MONO_FIRMWARE, 0, MODULE_STORE_MAIN};
const module_bounds_t module_factory = { 0x60000, 0x8080000, 0x80E0000, MODULE_FUNCTION_MONO_FIRMWARE, 0, MODULE_STORE_FACTORY};
const module_bounds_t* module_bounds[] = { &module_bootloader, &module_user, &module_factory };

const module_bounds_t module_ota = { 0x60000, 0x8080000, 0x80E0000, MODULE_FUNCTION_NONE, 0, MODULE_STORE_SCRATCHPAD};
#endif

const unsigned module_bounds_length = arraySize(module_bounds);
1 change: 1 addition & 0 deletions hal/src/photon/dct_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
extern "C" {
#endif

#include "dct_hal_stm32f2xx.h"
#include "platform_dct.h"
#include "platform_system_flags.h"
#include "dct.h"
Expand Down
20 changes: 0 additions & 20 deletions hal/src/photon/ota_flash_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,6 @@
#include "core_hal.h"
#include "dct.h"

#if MODULAR_FIRMWARE
const module_bounds_t module_bootloader = { 0x4000, 0x8000000, 0x8004000, MODULE_FUNCTION_BOOTLOADER, 0, MODULE_STORE_MAIN };
const module_bounds_t module_system_part1 = { 0x40000, 0x8020000, 0x8060000, MODULE_FUNCTION_SYSTEM_PART, 1, MODULE_STORE_MAIN };
const module_bounds_t module_system_part2 = { 0x40000, 0x8060000, 0x80A0000, MODULE_FUNCTION_SYSTEM_PART, 2, MODULE_STORE_MAIN};
const module_bounds_t module_user = { 0x20000, 0x80A0000, 0x80C0000, MODULE_FUNCTION_USER_PART, 1, MODULE_STORE_MAIN};
const module_bounds_t module_factory = { 0x20000, 0x80E0000, 0x8100000, MODULE_FUNCTION_USER_PART, 1, MODULE_STORE_FACTORY};
const module_bounds_t* module_bounds[] = { &module_bootloader, &module_system_part1, &module_system_part2, &module_user, &module_factory };

const module_bounds_t module_ota = { 0x40000, 0x80C0000, 0x8100000, MODULE_FUNCTION_NONE, 0, MODULE_STORE_SCRATCHPAD};
#else
const module_bounds_t module_bootloader = { 0x4000, 0x8000000, 0x8004000, MODULE_FUNCTION_BOOTLOADER, 0, MODULE_STORE_MAIN};
const module_bounds_t module_user = { 0x60000, 0x8020000, 0x8080000, MODULE_FUNCTION_MONO_FIRMWARE, 0, MODULE_STORE_MAIN};
const module_bounds_t module_factory = { 0x60000, 0x8080000, 0x80E0000, MODULE_FUNCTION_MONO_FIRMWARE, 0, MODULE_STORE_FACTORY};
const module_bounds_t* module_bounds[] = { &module_bootloader, &module_user, &module_factory };

const module_bounds_t module_ota = { 0x60000, 0x8080000, 0x80E0000, MODULE_FUNCTION_NONE, 0, MODULE_STORE_SCRATCHPAD};
#endif

const unsigned module_bounds_length = arraySize(module_bounds);

void HAL_OTA_Add_System_Info(hal_system_info_t* info, bool create, void* reserved)
{
// presently no additional key/value pairs to send back
Expand Down
22 changes: 22 additions & 0 deletions hal/src/photon/ota_module_bounds.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "ota_flash_hal.h"
#include "spark_macros.h"

#if MODULAR_FIRMWARE
const module_bounds_t module_bootloader = { 0x4000, 0x8000000, 0x8004000, MODULE_FUNCTION_BOOTLOADER, 0, MODULE_STORE_MAIN };
const module_bounds_t module_system_part1 = { 0x40000, 0x8020000, 0x8060000, MODULE_FUNCTION_SYSTEM_PART, 1, MODULE_STORE_MAIN };
const module_bounds_t module_system_part2 = { 0x40000, 0x8060000, 0x80A0000, MODULE_FUNCTION_SYSTEM_PART, 2, MODULE_STORE_MAIN};
const module_bounds_t module_user = { 0x20000, 0x80A0000, 0x80C0000, MODULE_FUNCTION_USER_PART, 1, MODULE_STORE_MAIN};
const module_bounds_t module_factory = { 0x20000, 0x80E0000, 0x8100000, MODULE_FUNCTION_USER_PART, 1, MODULE_STORE_FACTORY};
const module_bounds_t* module_bounds[] = { &module_bootloader, &module_system_part1, &module_system_part2, &module_user, &module_factory };

const module_bounds_t module_ota = { 0x40000, 0x80C0000, 0x8100000, MODULE_FUNCTION_NONE, 0, MODULE_STORE_SCRATCHPAD};
#else
const module_bounds_t module_bootloader = { 0x4000, 0x8000000, 0x8004000, MODULE_FUNCTION_BOOTLOADER, 0, MODULE_STORE_MAIN};
const module_bounds_t module_user = { 0x60000, 0x8020000, 0x8080000, MODULE_FUNCTION_MONO_FIRMWARE, 0, MODULE_STORE_MAIN};
const module_bounds_t module_factory = { 0x60000, 0x8080000, 0x80E0000, MODULE_FUNCTION_MONO_FIRMWARE, 0, MODULE_STORE_FACTORY};
const module_bounds_t* module_bounds[] = { &module_bootloader, &module_user, &module_factory };

const module_bounds_t module_ota = { 0x60000, 0x8080000, 0x80E0000, MODULE_FUNCTION_NONE, 0, MODULE_STORE_SCRATCHPAD};
#endif

const unsigned module_bounds_length = arraySize(module_bounds);
12 changes: 10 additions & 2 deletions hal/src/stm32/ota_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@

#include "ota_flash_hal.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* Checks if the minimum required dependencies for the given module are satisfied.
* @param bounds The bounds of the module to check.
* @return {@code true} if the dependencies are satisfied, {@code false} otherwise.
*/
bool validate_module_dependencies(const module_bounds_t* bounds, bool userPartOptional, bool fullDeps);
const module_bounds_t* find_module_bounds(uint8_t module_function, uint8_t module_index);
bool fetch_module(hal_module_t* target, const module_bounds_t* bounds, bool userDepsOptional, uint16_t check_flags=0);
const module_info_t* locate_module(const module_bounds_t* bounds);
bool fetch_module(hal_module_t* target, const module_bounds_t* bounds, bool userDepsOptional, uint16_t check_flags);
const module_info_t* locate_module(const module_bounds_t* bounds);

#ifdef __cplusplus
}
#endif
Loading