8000 Merge pull request #54 from bcmi-labs/gen_libbootutil · arduino/mcuboot-arduino-stm32h7@c27e9da · GitHub
[go: up one dir, main page]

Skip to content

Commit c27e9da

Browse files
authored
Merge pull request #54 from bcmi-labs/gen_libbootutil
Improve generate_lib script and libbootutil library size
2 parents c7b7308 + 2e6e828 commit c27e9da

File tree

8 files changed

+83
-10
lines changed

8 files changed

+83
-10
lines changed

app/bootutil/bootutil_extra.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright (c) 2022 Arduino SA. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#include "bootutil_extra.h"
20+
#include "rtc.h"
21+
22+
int boot_set_debug(int enable) {
23+
RTCInit();
24+
unsigned int rtc_reg = RTCGetBKPRegister(RTC_BKP_DR7);
25+
26+
if(enable) {
27+
rtc_reg |= 0x00000001;
28+
} else {
29+
rtc_reg &= ~0x00000001;
30+
}
31+
32+
return RTCSetBKPRegister(RTC_BKP_DR7, rtc_reg);
33+
}

app/bootutil/bootutil_extra.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright (c) 2022 Arduino SA. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#ifndef __BOOTUTIL_EXTRA_H
20+
#define __BOOTUTIL_EXTRA_H
21+
22+
int boot_set_debug(int enable);
23+
24+
#endif //__BOOTUTIL_EXTRA_H
File renamed without changes.

app/rtc/rtc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@
2323
#include "stm32h7xx_hal.h"
2424
#include "stm32h7xx_hal_rtc.h"
2525

26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
2630
void RTCInit();
2731
uint32_t RTCGetBKPRegister(uint32_t BackupRegister);
2832
uint32_t RTCSetBKPRegister(uint32_t BackupRegister, uint32_t Data);
2933

34+
#ifdef __cplusplus
35+
}
36+
#endif
37+
3038
#endif //__RTC_H

app/target.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ int target_init(void) {
243243
HAL_FLASH_Lock();
244244
if(valid_application() && empty_keys()) {
245245
BOOT_LOG_INF("MCUboot not configured, but valid image found.");
246-
BOOT_LOG_INF("Booting firmware image at 0x%x\n", USBD_DFU_APP_DEFAULT_ADD);
247-
mbed_start_application(USBD_DFU_APP_DEFAULT_ADD);
246+
BOOT_LOG_INF("Booting firmware image at 0x%x\n", APP_DEFAULT_ADD);
247+
mbed_start_application(APP_DEFAULT_ADD);
248248
}
249249
swap_ticker.attach(&swap_feedback, 250ms);
250250
return 0;

app/target.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
#include "usbd_dfu_flash.h"
3030
#endif
3131

32+
#if MCUBOOT_APPLICATION_DFU
33+
#define APP_DEFAULT_ADD USBD_DFU_APP_DEFAULT_ADD
34+
#else
35+
#define APP_DEFAULT_ADD 0x08040000
36+
#endif
37+
3238
#define BOOTLOADER_CONFIG_MAGIC 0xA0
3339
#define BOOTLOADER_VERSION 2
3440

generate_lib.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
2-
rm -rf BUILD/PORTENTA_H7_M7/GCC_ARM/
3-
mbed compile -m PORTENTA_H7_M7 -t GCC_ARM --app=mbed_app_log_off.json
4-
cd BUILD/PORTENTA_H7_M7/GCC_ARM/
5-
rm -rf mbed-os/
6-
find . -name "*.o" | xargs arm-none-eabi-ar -csr libbootutil.a
2+
mbed compile -c -m PORTENTA_H7_M7 -t GCC_ARM --app=mbed_app_bootutil.json
3+
echo
4+
echo Generating library
5+
find ./BUILD/PORTENTA_H7_M7/GCC_ARM/ \( -name "FileBlockDevice.o" -o -name "rtc.o" -o -name "ota.o" -o -name "bootutil_extra.o" -o -name "flash_map_backend.o" -o -name "bootutil_public.o" \) | xargs arm-none-eabi-ar -csr libbootutil.a
6+
echo -n "Library: "
7+
find ./ -name "libbootutil.a"
8+
echo

mbed_app_log_off.json renamed to mbed_app_bootutil.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"target_overrides": {
1111
"*": {
12-
"target.restrict_size": "0x20000",
12+
"target.restrict_size": "0x40000",
1313
"target.c_lib": "small",
1414
"mcuboot.log-level": "MCUBOOT_LOG_LEVEL_OFF",
1515
"mbed-trace.enable": false,
@@ -70,9 +70,9 @@
7070
"mcuboot.max-align": 32,
7171
"mcuboot.bootstrap": true,
7272
"mcuboot.application-hooks": true,
73-
"mcuboot.application-littlefs": true,
73+
"mcuboot.application-littlefs": null,
7474
"mcuboot.application-sdcard": null,
75-
"mcuboot.application-dfu": true,
75+
"mcuboot.application-dfu": null,
7676
"mcuboot.signature-algorithm": "SIGNATURE_TYPE_EC256",
7777
"mcuboot.encrypt-ec256": true,
7878
"mcuboot.include-keys": null

0 commit comments

Comments
 (0)
0