Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / fc / firmware_update_common.h
blob4ae34450999fb0d6ccbd390c9503436ec1fc2fff
1 /*
2 * This file is part of INAV.
4 * INAV is free software. You can redistribute this software
5 * and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * INAV is distributed in the hope that they will be
11 * useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #include <stdint.h>
23 #include "platform.h"
25 #define FIRMWARE_UPDATE_FIRMWARE_FILENAME "firmware.upt"
26 #define FIRMWARE_UPDATE_BACKUP_FILENAME "firmware.bak"
27 #define FIRMWARE_UPDATE_META_FILENAME "update.mta"
29 #define FIRMWARE_UPDATE_METADATA_MAGIC 0xAABBCCDD
31 #undef FLASH_END
33 #define FIRMWARE_START_ADDRESS ((uint32_t)&__firmware_start)
34 #define FLASH_START_ADDRESS 0x08000000UL
35 #define FLASH_END (FLASH_START_ADDRESS + MCU_FLASH_SIZE * 1024)
36 #define CONFIG_START_ADDRESS ((uint32_t)&__config_start)
37 #define CONFIG_END_ADDRESS ((uint32_t)&__config_end)
39 #define AVAILABLE_FIRMWARE_SPACE (FLASH_END - FIRMWARE_START_ADDRESS)
41 extern uint8_t __firmware_start; // set via linker
43 #if defined(CONFIG_IN_FLASH)
44 extern uint8_t __config_start;
45 extern uint8_t __config_end;
46 #endif
48 typedef struct {
49 uint32_t magic;
50 #ifdef USE_FLASHFS
51 uint32_t firmwareSize;
52 bool dataFlashErased;
53 #endif
54 uint8_t backupCRC;
55 } firmwareUpdateMetadata_t;
57 bool firmwareUpdateMetadataRead(firmwareUpdateMetadata_t *updateMetadata);
58 bool firmwareUpdateMetadataWrite(firmwareUpdateMetadata_t *updateMetadata);