-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflash_check.c
More file actions
executable file
·40 lines (30 loc) · 1.19 KB
/
flash_check.c
File metadata and controls
executable file
·40 lines (30 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*!\file flash_check.c
** \author SMFSW
** \copyright MIT (c) 2017-2026, SMFSW
** \brief Function to check flash CRC
*/
/****************************************************************/
#include "sarmfsw.h"
#include "CRC_stm32.h"
#include "flash_check.h"
/****************************************************************/
__WEAK uint32_t Get_app_start_address(void) {
return FLASH_BASE; }
__WEAK uint32_t Get_app_size(void) {
return FLASH_SIZE; }
FctERR flash_crc_check(void)
{
const uint32_t base = Get_app_start_address();
const size_t sz = Get_app_size();
// Deepsource would raise possible misaligned pointer access, keeping it quiet with 'skipcq'
const uint32_t crc_ref = *(uint32_t *) (base + sz - sizeof(uint32_t)); // skipcq: CXX-S1014
const size_t len = sz - sizeof(uint32_t);
return crc_check(crc_ref, CRC_Feed_DWORD, base, len);
}
FctERR flash_full_crc_check(void)
{
// Deepsource would raise possible misaligned pointer access, keeping it quiet with 'skipcq'
const uint32_t crc_ref = *(uint32_t *) (FLASH_BASE + FLASH_SIZE - sizeof(uint32_t)); // skipcq: CXX-S1014
const size_t len = (size_t) FLASH_SIZE - sizeof(uint32_t);
return crc_check(crc_ref, CRC_Feed_DWORD, FLASH_BASE, len);
}