mirror of https://github.com/wolfSSL/wolfBoot.git
STM32F4 Test application: modified to turn a led on early at boot to measure
boot time.pull/3/head
parent
e14efd641a
commit
3a455383a1
2
Makefile
2
Makefile
|
@ -7,7 +7,7 @@ AS:=$(CROSS_COMPILE)gcc
|
|||
OBJCOPY:=$(CROSS_COMPILE)objcopy
|
||||
SIZE:=$(CROSS_COMPILE)size
|
||||
BOOT_IMG?=test-app/image.bin
|
||||
BOOT0_OFFSET?=0x10000
|
||||
BOOT0_OFFSET?=0x20000
|
||||
SIGN?=ED25519
|
||||
TARGET?=stm32f4
|
||||
DEBUG?=0
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
* Ensure that your firmware entry point is
|
||||
* at FLASH_AREA_IMAGE_0_OFFSET + 0x100
|
||||
*/
|
||||
#define WOLFBOOT_SECTOR_SIZE 0x1000
|
||||
#define WOLFBOOT_PARTITION_SIZE 0x10000
|
||||
#define WOLFBOOT_SECTOR_SIZE 0x20000
|
||||
#define WOLFBOOT_PARTITION_SIZE 0x20000
|
||||
|
||||
#define WOLFBOOT_PARTITION_BOOT_ADDRESS 0x10000
|
||||
#define WOLFBOOT_PARTITION_UPDATE_ADDRESS 0x20000
|
||||
#define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x30000
|
||||
#define WOLFBOOT_PARTITION_BOOT_ADDRESS 0x20000
|
||||
#define WOLFBOOT_PARTITION_UPDATE_ADDRESS 0x40000
|
||||
#define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x60000
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,12 +3,8 @@ CC:=$(CROSS_COMPILE)gcc
|
|||
LD:=$(CROSS_COMPILE)gcc
|
||||
OBJS:=startup.o main.o timer.o led.o system.o
|
||||
TARGET?=none
|
||||
|
||||
LSCRIPT:=app.ld
|
||||
|
||||
OBJCOPY:=$(CROSS_COMPILE)objcopy
|
||||
|
||||
|
||||
CFLAGS:=-mcpu=cortex-m3 -mthumb -g -ggdb -Wall -Wno-main -Wstack-usage=200 -ffreestanding -Wno-unused -nostdlib -DPLATFORM_$(TARGET)
|
||||
LDFLAGS:=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=image.map -nostdlib
|
||||
|
||||
|
@ -18,6 +14,12 @@ image.bin: image.elf
|
|||
|
||||
image.elf: $(OBJS) $(LSCRIPT)
|
||||
$(LD) $(LDFLAGS) $(OBJS) -o $@
|
||||
|
||||
standalone:CFLAGS+=-DPLATFORM_stm32f4
|
||||
standalone:LDFLAGS:=-T standalone.ld -Wl,-gc-sections -Wl,-Map=image.map -nostdlib
|
||||
|
||||
|
||||
standalone: image.bin
|
||||
|
||||
startup.o: startup.c
|
||||
|
||||
|
|
|
@ -32,24 +32,12 @@
|
|||
#define GPIOD_OSPD (*(volatile uint32_t *)(GPIOD_BASE + 0x08))
|
||||
#define GPIOD_PUPD (*(volatile uint32_t *)(GPIOD_BASE + 0x0c))
|
||||
#define GPIOD_ODR (*(volatile uint32_t *)(GPIOD_BASE + 0x14))
|
||||
#define GPIOD_BSRR (*(volatile uint32_t *)(GPIOD_BASE + 0x18))
|
||||
#define GPIOD_AFL (*(volatile uint32_t *)(GPIOD_BASE + 0x20))
|
||||
#define GPIOD_AFH (*(volatile uint32_t *)(GPIOD_BASE + 0x24))
|
||||
#define LED_PIN (15)
|
||||
|
||||
#define LED_BOOT_PIN (14)
|
||||
#define GPIO_OSPEED_100MHZ (0x03)
|
||||
|
||||
|
||||
void led_setup(void)
|
||||
{
|
||||
uint32_t reg;
|
||||
AHB1_CLOCK_ER |= GPIOD_AHB1_CLOCK_ER;
|
||||
reg = GPIOD_MODE & ~ (0x03 << (LED_PIN * 2));
|
||||
GPIOD_MODE = reg | (1 << (LED_PIN * 2));
|
||||
|
||||
reg = GPIOD_PUPD & (0x03 << (LED_PIN * 2));
|
||||
GPIOD_PUPD = reg | (0x02 << (LED_PIN * 2));
|
||||
}
|
||||
|
||||
void led_pwm_setup(void)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
@ -66,6 +54,16 @@ void led_pwm_setup(void)
|
|||
/* Alternate function: use high pin */
|
||||
reg = GPIOD_AFH & ~(0xf << ((LED_PIN - 8) * 4));
|
||||
GPIOD_AFH = reg | (0x2 << ((LED_PIN - 8) * 4));
|
||||
|
||||
}
|
||||
|
||||
void boot_led_on(void)
|
||||
{
|
||||
uint32_t reg;
|
||||
AHB1_CLOCK_ER |= GPIOD_AHB1_CLOCK_ER;
|
||||
reg = GPIOD_MODE & ~(0x03 << (LED_BOOT_PIN * 2));
|
||||
GPIOD_MODE = reg | (1 << (LED_BOOT_PIN * 2));
|
||||
reg = GPIOD_PUPD & ~(0x03 << (LED_BOOT_PIN * 2));
|
||||
GPIOD_PUPD = reg | (1 << (LED_BOOT_PIN * 2));
|
||||
GPIOD_BSRR |= (1 << LED_BOOT_PIN);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,4 +5,5 @@ void led_on(void);
|
|||
void led_off(void);
|
||||
void led_toggle(void);
|
||||
void led_pwm_setup(void);
|
||||
void boot_led_on(void);
|
||||
#endif
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#ifdef PLATFORM_stm32f4
|
||||
|
||||
void main(void) {
|
||||
boot_led_on();
|
||||
flash_set_waitstates();
|
||||
clock_config();
|
||||
led_pwm_setup();
|
||||
|
@ -76,8 +77,6 @@ void main(void)
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef PLATFORM_samr21
|
||||
void main(void) {
|
||||
asm volatile ("cpsie i");
|
||||
|
@ -86,11 +85,3 @@ void main(void) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_lm3s
|
||||
void main(void) {
|
||||
asm volatile ("cpsie i");
|
||||
while(1)
|
||||
WFI();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x001FF00
|
||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
_start_text = .;
|
||||
KEEP(*(.isr_vector))
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
. = ALIGN(4);
|
||||
_end_text = .;
|
||||
} > FLASH
|
||||
|
||||
_stored_data = .;
|
||||
|
||||
.data : AT (_stored_data)
|
||||
{
|
||||
_start_data = .;
|
||||
KEEP(*(.data*))
|
||||
. = ALIGN(4);
|
||||
_end_data = .;
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
_start_bss = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_end_bss = .;
|
||||
_end = .;
|
||||
} > RAM
|
||||
}
|
||||
|
||||
PROVIDE(_start_heap = _end);
|
||||
PROVIDE(_end_stack = ORIGIN(RAM) + LENGTH(RAM));
|
Loading…
Reference in New Issue