Add shared emulator services, waveform generation and STM32 USB boot ports
This commit is contained in:
34
c/set-protocol/ports/stm32f407-usb-boot/test_boot_image.c
Normal file
34
c/set-protocol/ports/stm32f407-usb-boot/test_boot_image.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user