20 lines
547 B
C
20 lines
547 B
C
#ifndef F407_BOOT_IMAGE_H
|
|
#define F407_BOOT_IMAGE_H
|
|
#include "boot_port.h"
|
|
#include <string.h>
|
|
|
|
static inline bool f407_vectors_valid(const uint8_t *image, uint32_t size)
|
|
{
|
|
uint32_t sp, pc;
|
|
if (size < 8 || size > F407_APP_SIZE) return false;
|
|
memcpy(&sp, image, 4);
|
|
memcpy(&pc, image + 4, 4);
|
|
return !(sp & 7) &&
|
|
((sp > 0x20000000UL && sp <= 0x20020000UL) ||
|
|
(sp > 0x10000000UL && sp <= 0x10010000UL)) &&
|
|
(pc & 1) && (pc & ~1UL) >= F407_APP_BASE &&
|
|
(pc & ~1UL) < F407_APP_BASE + size;
|
|
}
|
|
|
|
#endif
|