From f54ae2597e6a9a81f69356b417da8604182de35d Mon Sep 17 00:00:00 2001 From: hedger Date: Tue, 7 Dec 2021 17:17:08 +0300 Subject: [PATCH] Bootloader size optimizations (#873) --- .../targets/f6/furi-hal/furi-hal-version.c | 22 ------------------- bootloader/targets/f6/target.c | 4 +++- .../targets/f7/furi-hal/furi-hal-version.c | 22 ------------------- bootloader/targets/f7/target.c | 4 +++- firmware/targets/f6/target.mk | 4 ++-- firmware/targets/f7/target.mk | 4 ++-- make/toolchain.mk | 2 +- 7 files changed, 11 insertions(+), 51 deletions(-) diff --git a/bootloader/targets/f6/furi-hal/furi-hal-version.c b/bootloader/targets/f6/furi-hal/furi-hal-version.c index df6d61b0d..1425cd6d2 100644 --- a/bootloader/targets/f6/furi-hal/furi-hal-version.c +++ b/bootloader/targets/f6/furi-hal/furi-hal-version.c @@ -87,29 +87,7 @@ typedef struct { static FuriHalVersion furi_hal_version = {0}; static void furi_hal_version_set_name(const char* name) { - if(name != NULL) { - strlcpy(furi_hal_version.name, name, FURI_HAL_VERSION_ARRAY_NAME_LENGTH); - snprintf( - furi_hal_version.device_name, - FURI_HAL_VERSION_DEVICE_NAME_LENGTH, - "xFlipper %s", - furi_hal_version.name); - } else { - snprintf(furi_hal_version.device_name, FURI_HAL_VERSION_DEVICE_NAME_LENGTH, "xFlipper"); - } - furi_hal_version.device_name[0] = 0; - - // BLE Mac address - uint32_t udn = LL_FLASH_GetUDN(); - uint32_t company_id = LL_FLASH_GetSTCompanyID(); - uint32_t device_id = LL_FLASH_GetDeviceID(); - furi_hal_version.ble_mac[0] = (uint8_t)(udn & 0x000000FF); - furi_hal_version.ble_mac[1] = (uint8_t)((udn & 0x0000FF00) >> 8); - furi_hal_version.ble_mac[2] = (uint8_t)((udn & 0x00FF0000) >> 16); - furi_hal_version.ble_mac[3] = (uint8_t)device_id; - furi_hal_version.ble_mac[4] = (uint8_t)(company_id & 0x000000FF); - furi_hal_version.ble_mac[5] = (uint8_t)((company_id & 0x0000FF00) >> 8); } static void furi_hal_version_load_otp_default() { diff --git a/bootloader/targets/f6/target.c b/bootloader/targets/f6/target.c index df694edd5..0240204c0 100644 --- a/bootloader/targets/f6/target.c +++ b/bootloader/targets/f6/target.c @@ -194,10 +194,12 @@ void target_display_init() { // Create payload u8g2_ClearBuffer(&fb); u8g2_SetDrawColor(&fb, 0x01); - u8g2_SetFont(&fb, u8g2_font_helvB08_tf); u8g2_DrawXBM(&fb, 0, 64 - 50, 128, 50, I_DFU_128x50); +#ifndef SLIM_BOOTLOADER + u8g2_SetFont(&fb, u8g2_font_helvB08_tf); u8g2_DrawStr(&fb, 2, 8, "Update & Recovery Mode"); u8g2_DrawStr(&fb, 2, 21, "DFU started"); +#endif // Send buffer u8g2_SetPowerSave(&fb, 0); u8g2_SendBuffer(&fb); diff --git a/bootloader/targets/f7/furi-hal/furi-hal-version.c b/bootloader/targets/f7/furi-hal/furi-hal-version.c index df6d61b0d..1425cd6d2 100644 --- a/bootloader/targets/f7/furi-hal/furi-hal-version.c +++ b/bootloader/targets/f7/furi-hal/furi-hal-version.c @@ -87,29 +87,7 @@ typedef struct { static FuriHalVersion furi_hal_version = {0}; static void furi_hal_version_set_name(const char* name) { - if(name != NULL) { - strlcpy(furi_hal_version.name, name, FURI_HAL_VERSION_ARRAY_NAME_LENGTH); - snprintf( - furi_hal_version.device_name, - FURI_HAL_VERSION_DEVICE_NAME_LENGTH, - "xFlipper %s", - furi_hal_version.name); - } else { - snprintf(furi_hal_version.device_name, FURI_HAL_VERSION_DEVICE_NAME_LENGTH, "xFlipper"); - } - furi_hal_version.device_name[0] = 0; - - // BLE Mac address - uint32_t udn = LL_FLASH_GetUDN(); - uint32_t company_id = LL_FLASH_GetSTCompanyID(); - uint32_t device_id = LL_FLASH_GetDeviceID(); - furi_hal_version.ble_mac[0] = (uint8_t)(udn & 0x000000FF); - furi_hal_version.ble_mac[1] = (uint8_t)((udn & 0x0000FF00) >> 8); - furi_hal_version.ble_mac[2] = (uint8_t)((udn & 0x00FF0000) >> 16); - furi_hal_version.ble_mac[3] = (uint8_t)device_id; - furi_hal_version.ble_mac[4] = (uint8_t)(company_id & 0x000000FF); - furi_hal_version.ble_mac[5] = (uint8_t)((company_id & 0x0000FF00) >> 8); } static void furi_hal_version_load_otp_default() { diff --git a/bootloader/targets/f7/target.c b/bootloader/targets/f7/target.c index df694edd5..0240204c0 100644 --- a/bootloader/targets/f7/target.c +++ b/bootloader/targets/f7/target.c @@ -194,10 +194,12 @@ void target_display_init() { // Create payload u8g2_ClearBuffer(&fb); u8g2_SetDrawColor(&fb, 0x01); - u8g2_SetFont(&fb, u8g2_font_helvB08_tf); u8g2_DrawXBM(&fb, 0, 64 - 50, 128, 50, I_DFU_128x50); +#ifndef SLIM_BOOTLOADER + u8g2_SetFont(&fb, u8g2_font_helvB08_tf); u8g2_DrawStr(&fb, 2, 8, "Update & Recovery Mode"); u8g2_DrawStr(&fb, 2, 21, "DFU started"); +#endif // Send buffer u8g2_SetPowerSave(&fb, 0); u8g2_SendBuffer(&fb); diff --git a/firmware/targets/f6/target.mk b/firmware/targets/f6/target.mk index 85669e8d6..cad7d33fd 100644 --- a/firmware/targets/f6/target.mk +++ b/firmware/targets/f6/target.mk @@ -19,9 +19,9 @@ BOOT_CFLAGS = -DBOOT_ADDRESS=$(BOOT_ADDRESS) -DFW_ADDRESS=$(FW_ADDRESS) -DOS_OF MCU_FLAGS = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard CFLAGS += $(MCU_FLAGS) $(BOOT_CFLAGS) -DSTM32WB55xx -Wall -fdata-sections -ffunction-sections -LDFLAGS += $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs +LDFLAGS += $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs -u _printf_float -CPPFLAGS += -fno-rtti -fno-use-cxa-atexit -fno-exceptions +CPPFLAGS += -fno-rtti -fno-use-cxa-atexit -fno-exceptions LDFLAGS += -Wl,--start-group -lstdc++ -lsupc++ -Wl,--end-group HARDWARE_TARGET = 6 diff --git a/firmware/targets/f7/target.mk b/firmware/targets/f7/target.mk index d6b8cbfa9..f54f3f25e 100644 --- a/firmware/targets/f7/target.mk +++ b/firmware/targets/f7/target.mk @@ -19,9 +19,9 @@ BOOT_CFLAGS = -DBOOT_ADDRESS=$(BOOT_ADDRESS) -DFW_ADDRESS=$(FW_ADDRESS) -DOS_OF MCU_FLAGS = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard CFLAGS += $(MCU_FLAGS) $(BOOT_CFLAGS) -DSTM32WB55xx -Wall -fdata-sections -ffunction-sections -LDFLAGS += $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs +LDFLAGS += $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs -u _printf_float -CPPFLAGS += -fno-rtti -fno-use-cxa-atexit -fno-exceptions +CPPFLAGS += -fno-rtti -fno-use-cxa-atexit -fno-exceptions LDFLAGS += -Wl,--start-group -lstdc++ -lsupc++ -Wl,--end-group HARDWARE_TARGET = 7 diff --git a/make/toolchain.mk b/make/toolchain.mk index 3b3babf4d..75d0c370c 100644 --- a/make/toolchain.mk +++ b/make/toolchain.mk @@ -27,4 +27,4 @@ endif CFLAGS += -fdata-sections -ffunction-sections -fno-math-errno -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" CPPFLAGS += -fno-threadsafe-statics -fno-use-cxa-atexit -fno-exceptions -fno-rtti -LDFLAGS += -Wl,-Map=$(OBJ_DIR)/$(PROJECT).map,--cref -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority -u _printf_float -n \ No newline at end of file +LDFLAGS += -Wl,-Map=$(OBJ_DIR)/$(PROJECT).map,--cref -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority -n \ No newline at end of file