35 lines
1.4 KiB
C
35 lines
1.4 KiB
C
#include "boot_image.h"
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
|
|
int main(void)
|
|
{
|
|
uint32_t words[32] = {0x20020000, F407_APP_BASE + 9};
|
|
uint8_t *image = (uint8_t *)words;
|
|
/* A Keil image needs no metadata. Replacing its body must still boot. */
|
|
assert(f407_vectors_valid(image, F407_APP_SIZE));
|
|
words[10] ^= 1;
|
|
assert(f407_vectors_valid(image, F407_APP_SIZE));
|
|
words[0] = words[1] = 0xffffffff;
|
|
assert(!f407_vectors_valid(image, F407_APP_SIZE));
|
|
words[0] = 0x20020000; words[1] = 0x08000101;
|
|
assert(!f407_vectors_valid(image, F407_APP_SIZE));
|
|
words[1] = F407_APP_BASE + 8;
|
|
assert(!f407_vectors_valid(image, F407_APP_SIZE));
|
|
words[1] = F407_APP_BASE + 9; words[0] = 0x20020001;
|
|
assert(!f407_vectors_valid(image, F407_APP_SIZE));
|
|
words[0] = 0x10010000;
|
|
assert(f407_vectors_valid(image, F407_APP_SIZE));
|
|
assert(!f407_vectors_valid(image, 8));
|
|
assert(!f407_vectors_valid(image, 7));
|
|
assert(!f407_vectors_valid(image, F407_APP_SIZE + 1));
|
|
words[1] = F407_APP_BASE + F407_APP_SIZE + 1;
|
|
assert(!f407_vectors_valid(image, F407_APP_SIZE));
|
|
words[1] = F407_APP_BASE + 9;
|
|
/* Like climate, vectors alone cannot establish image completeness. */
|
|
memset(image + 8, 0xff, sizeof(words) - 8);
|
|
assert(f407_vectors_valid(image, F407_APP_SIZE));
|
|
puts("F407 boot: Keil image replacement and vector checks passed");
|
|
return 0;
|
|
}
|