Skip to content

Commit 3a45538

Browse files
committed
STM32F4 Test application: modified to turn a led on early at boot to measure
boot time.
1 parent e14efd6 commit 3a45538

7 files changed

Lines changed: 67 additions & 34 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ AS:=$(CROSS_COMPILE)gcc
77
OBJCOPY:=$(CROSS_COMPILE)objcopy
88
SIZE:=$(CROSS_COMPILE)size
99
BOOT_IMG?=test-app/image.bin
10-
BOOT0_OFFSET?=0x10000
10+
BOOT0_OFFSET?=0x20000
1111
SIGN?=ED25519
1212
TARGET?=stm32f4
1313
DEBUG?=0

include/target.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
* Ensure that your firmware entry point is
77
* at FLASH_AREA_IMAGE_0_OFFSET + 0x100
88
*/
9-
#define WOLFBOOT_SECTOR_SIZE 0x1000
10-
#define WOLFBOOT_PARTITION_SIZE 0x10000
9+
#define WOLFBOOT_SECTOR_SIZE 0x20000
10+
#define WOLFBOOT_PARTITION_SIZE 0x20000
1111

12-
#define WOLFBOOT_PARTITION_BOOT_ADDRESS 0x10000
13-
#define WOLFBOOT_PARTITION_UPDATE_ADDRESS 0x20000
14-
#define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x30000
12+
#define WOLFBOOT_PARTITION_BOOT_ADDRESS 0x20000
13+
#define WOLFBOOT_PARTITION_UPDATE_ADDRESS 0x40000
14+
#define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x60000
1515

1616
#endif

test-app/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ CC:=$(CROSS_COMPILE)gcc
33
LD:=$(CROSS_COMPILE)gcc
44
OBJS:=startup.o main.o timer.o led.o system.o
55
TARGET?=none
6-
76
LSCRIPT:=app.ld
8-
97
OBJCOPY:=$(CROSS_COMPILE)objcopy
10-
11-
128
CFLAGS:=-mcpu=cortex-m3 -mthumb -g -ggdb -Wall -Wno-main -Wstack-usage=200 -ffreestanding -Wno-unused -nostdlib -DPLATFORM_$(TARGET)
139
LDFLAGS:=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=image.map -nostdlib
1410

@@ -18,6 +14,12 @@ image.bin: image.elf
1814

1915
image.elf: $(OBJS) $(LSCRIPT)
2016
$(LD) $(LDFLAGS) $(OBJS) -o $@
17+
18+
standalone:CFLAGS+=-DPLATFORM_stm32f4
19+
standalone:LDFLAGS:=-T standalone.ld -Wl,-gc-sections -Wl,-Map=image.map -nostdlib
20+
21+
22+
standalone: image.bin
2123

2224
startup.o: startup.c
2325

test-app/led.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,12 @@
3232
#define GPIOD_OSPD (*(volatile uint32_t *)(GPIOD_BASE + 0x08))
3333
#define GPIOD_PUPD (*(volatile uint32_t *)(GPIOD_BASE + 0x0c))
3434
#define GPIOD_ODR (*(volatile uint32_t *)(GPIOD_BASE + 0x14))
35+
#define GPIOD_BSRR (*(volatile uint32_t *)(GPIOD_BASE + 0x18))
3536
#define GPIOD_AFL (*(volatile uint32_t *)(GPIOD_BASE + 0x20))
3637
#define GPIOD_AFH (*(volatile uint32_t *)(GPIOD_BASE + 0x24))
3738
#define LED_PIN (15)
38-
39+
#define LED_BOOT_PIN (14)
3940
#define GPIO_OSPEED_100MHZ (0x03)
40-
41-
42-
void led_setup(void)
43-
{
44-
uint32_t reg;
45-
AHB1_CLOCK_ER |= GPIOD_AHB1_CLOCK_ER;
46-
reg = GPIOD_MODE & ~ (0x03 << (LED_PIN * 2));
47-
GPIOD_MODE = reg | (1 << (LED_PIN * 2));
48-
49-
reg = GPIOD_PUPD & (0x03 << (LED_PIN * 2));
50-
GPIOD_PUPD = reg | (0x02 << (LED_PIN * 2));
51-
}
52-
5341
void led_pwm_setup(void)
5442
{
5543
uint32_t reg;
@@ -66,6 +54,16 @@ void led_pwm_setup(void)
6654
/* Alternate function: use high pin */
6755
reg = GPIOD_AFH & ~(0xf << ((LED_PIN - 8) * 4));
6856
GPIOD_AFH = reg | (0x2 << ((LED_PIN - 8) * 4));
57+
}
6958

59+
void boot_led_on(void)
60+
{
61+
uint32_t reg;
62+
AHB1_CLOCK_ER |= GPIOD_AHB1_CLOCK_ER;
63+
reg = GPIOD_MODE & ~(0x03 << (LED_BOOT_PIN * 2));
64+
GPIOD_MODE = reg | (1 << (LED_BOOT_PIN * 2));
65+
reg = GPIOD_PUPD & ~(0x03 << (LED_BOOT_PIN * 2));
66+
GPIOD_PUPD = reg | (1 << (LED_BOOT_PIN * 2));
67+
GPIOD_BSRR |= (1 << LED_BOOT_PIN);
7068
}
7169

test-app/led.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ void led_on(void);
55
void led_off(void);
66
void led_toggle(void);
77
void led_pwm_setup(void);
8+
void boot_led_on(void);
89
#endif

test-app/main.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#ifdef PLATFORM_stm32f4
3131

3232
void main(void) {
33+
boot_led_on();
3334
flash_set_waitstates();
3435
clock_config();
3536
led_pwm_setup();
@@ -76,8 +77,6 @@ void main(void)
7677

7778
#endif
7879

79-
80-
8180
#ifdef PLATFORM_samr21
8281
void main(void) {
8382
asm volatile ("cpsie i");
@@ -86,11 +85,3 @@ void main(void) {
8685
}
8786
#endif
8887

89-
#ifdef PLATFORM_lm3s
90-
void main(void) {
91-
asm volatile ("cpsie i");
92-
while(1)
93-
WFI();
94-
}
95-
#endif
96-

test-app/standalone.ld

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
MEMORY
2+
{
3+
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x001FF00
4+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000
5+
}
6+
7+
SECTIONS
8+
{
9+
.text :
10+
{
11+
_start_text = .;
12+
KEEP(*(.isr_vector))
13+
*(.text*)
14+
*(.rodata*)
15+
. = ALIGN(4);
16+
_end_text = .;
17+
} > FLASH
18+
19+
_stored_data = .;
20+
21+
.data : AT (_stored_data)
22+
{
23+
_start_data = .;
24+
KEEP(*(.data*))
25+
. = ALIGN(4);
26+
_end_data = .;
27+
} > RAM
28+
29+
.bss :
30+
{
31+
_start_bss = .;
32+
*(.bss*)
33+
*(COMMON)
34+
. = ALIGN(4);
35+
_end_bss = .;
36+
_end = .;
37+
} > RAM
38+
}
39+
40+
PROVIDE(_start_heap = _end);
41+
PROVIDE(_end_stack = ORIGIN(RAM) + LENGTH(RAM));

0 commit comments

Comments
 (0)