diff --git a/bootloader/main.c b/bootloader/main.c index 85ad2edb2098a883996c3cb9fef1a55e6be2d258..c1f0a87d75e4b9fef45112cd4e87c12757cd3c17 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -2,6 +2,7 @@ #include "card10-version.h" #include "card10.h" +#include "card10-platform.h" #include "led.h" #include "pb.h" #include "pmic.h" @@ -30,9 +31,6 @@ #define PARTITION_END (0x10000000 + 1024 * 1024 - 1) #define MSC_MAGIC 0x6E697807 -/* TODO: Make this address part of the linker script */ -void* API_CALL_MEM = (void*)0x20080000; - DIR dir; FATFS FatFs; @@ -75,7 +73,7 @@ int mount(void) int get_msc_flag(void) { // We use the API call memory to store a magic value there. - uint32_t* flag = (uint32_t*)API_CALL_MEM; + uint32_t* flag = API_CALL_MEM_ADDRESS; if (*flag == MSC_MAGIC) { *flag = 0; return 1; diff --git a/bootloader/meson.build b/bootloader/meson.build index 9a680aca75f5bbb7dcb51055d752d355b2afc593..3278010569543f2836718758afebb661be3eddae 100644 --- a/bootloader/meson.build +++ b/bootloader/meson.build @@ -24,6 +24,7 @@ elf = executable( version_hdr, dependencies: [ libcard10, + libcard10_platform, max32665_startup_boot, libff13, maxusb, diff --git a/epicardium/api/common.h b/epicardium/api/common.h index ff0c9f3abf4da6822ca89c890c3a6bb55fab7ce6..5e8a1e0cd6bce52a3b0e6869353419bc0fec3461 100644 --- a/epicardium/api/common.h +++ b/epicardium/api/common.h @@ -1,5 +1,6 @@ #pragma once #include "epicardium.h" +#include "card10-platform.h" #include <stdint.h> #include <stdbool.h> @@ -49,6 +50,4 @@ struct api_call_mem { uint8_t buffer[1]; }; -/* TODO: Make this address part of the linker script */ -static __attribute__((unused)) struct api_call_mem* API_CALL_MEM = - (struct api_call_mem*)0x20080000; +static __attribute__((unused)) struct api_call_mem* API_CALL_MEM = API_CALL_MEM_ADDRESS; diff --git a/epicardium/meson.build b/epicardium/meson.build index 1aa5556010941d2267f8b10aafcaf9ec7683c8a2..f594b4ef508671f3ad17138434773e546cefe118 100644 --- a/epicardium/meson.build +++ b/epicardium/meson.build @@ -24,13 +24,13 @@ api_caller_lib = static_library( 'api/caller.c', 'api/interrupt-receiver.c', api[0], # Caller - dependencies: periphdriver, + dependencies: [periphdriver, libcard10_platform], ) api_caller = declare_dependency( include_directories: include_directories('.'), link_with: api_caller_lib, - dependencies: periphdriver, + dependencies: [periphdriver, libcard10_platform], ) api_dispatcher_lib = static_library( @@ -39,7 +39,7 @@ api_dispatcher_lib = static_library( 'api/interrupt-sender.c', 'api/control.c', api[1], # Dispatcher - dependencies: [libcard10, periphdriver], + dependencies: [libcard10, libcard10_platform, periphdriver], ) ########################################################################## @@ -88,7 +88,7 @@ elf = executable( l0der_sources, ble_sources, version_hdr, - dependencies: [libcard10, max32665_startup_core0, maxusb, libff13, ble, bhy1], + dependencies: [libcard10, libcard10_platform, max32665_startup_core0, maxusb, libff13, ble, bhy1], link_with: [api_dispatcher_lib, freertos], link_whole: [max32665_startup_core0_lib, board_card10_lib, newlib_heap_lib], include_directories: [freertos_includes], diff --git a/epicardium/modules/lifecycle.c b/epicardium/modules/lifecycle.c index 214fe4a7ceda62066aadbfaec2cc3b7520f20127..fcadfcc88b1e8c67787990b495e7e10b54b02ea6 100644 --- a/epicardium/modules/lifecycle.c +++ b/epicardium/modules/lifecycle.c @@ -6,6 +6,7 @@ #include "l0der/l0der.h" #include "card10.h" +#include "card10-platform.h" #include "FreeRTOS.h" #include "task.h" @@ -17,7 +18,6 @@ #define PYCARDIUM_IVT (void *)0x10080000 #define BLOCK_WAIT pdMS_TO_TICKS(1000) -#define MSC_MAGIC 0x6E697807 /* * Loading an empty filename into Pycardium will drop straight into the @@ -287,7 +287,7 @@ static void load_menu(bool reset) void epic_system_reset(int to_bootloader) { // Set a flag for the bootloader. - uint32_t* flag = (uint32_t*)API_CALL_MEM; + uint32_t* flag = API_CALL_MEM_ADDRESS; *flag = to_bootloader ? MSC_MAGIC : 0; card10_reset(); diff --git a/lib/card10-platform/card10-platform.h b/lib/card10-platform/card10-platform.h new file mode 100644 index 0000000000000000000000000000000000000000..138a701339aba54f3baf91c3dae6a88cb551ba97 --- /dev/null +++ b/lib/card10-platform/card10-platform.h @@ -0,0 +1,8 @@ +#ifndef CARD10_PLATFORM_H + +#define MSC_MAGIC 0x6E697807 + +/* TODO: Make this address part of the linker script */ +#define API_CALL_MEM_ADDRESS ((void*)0x20080000) + +#endif diff --git a/lib/card10-platform/meson.build b/lib/card10-platform/meson.build new file mode 100644 index 0000000000000000000000000000000000000000..8cc8a03c0bce9a2617607f7d3960beaf87b46f57 --- /dev/null +++ b/lib/card10-platform/meson.build @@ -0,0 +1,8 @@ +includes = include_directories( + './', +) + +libcard10_platform = declare_dependency( + include_directories: includes, +) + diff --git a/lib/meson.build b/lib/meson.build index e43c62dbd5ab9b144d6189318973f4db212cb9eb..ddcb1d138e50853fa21dcc2dd68789f753b659a7 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -12,5 +12,6 @@ subdir('./FreeRTOS-Plus/') subdir('./micropython/') subdir('./card10/') +subdir('./card10-platform/') subdir('./mx25lba/') subdir('./ff13/')