Update example for FSM-55

This commit is contained in:
NIIBE Yutaka
2015-07-15 12:03:49 +09:00
parent 44b4bf640f
commit d19570954e
4 changed files with 62 additions and 35 deletions

1
example-fsm-55/board.h Symbolic link
View File

@@ -0,0 +1 @@
../board/board-fsm-55.h

View File

@@ -1,26 +1,19 @@
/* /*
* ST32F103 memory setup. * ST32F0 memory setup.
*/ */
__main_stack_size__ = 0x0100; /* Exception handlers */ __main_stack_size__ = 0x0100; /* Exception handlers */
__process0_stack_size__ = 0x0100; /* Main program */ __process0_stack_size__ = 0x0100; /* Main program */
__process1_stack_size__ = 0x0100; /* first thread program */ __process1_stack_size__ = 0x0100; /* first thread program */
__process2_stack_size__ = 0x0100; /* second thread program */ __process2_stack_size__ = 0x0100; /* second thread program */
__process3_stack_size__ = 0x0100; /* third thread program */ __process3_stack_size__ = 0x0100; /* third thread program */
MEMORY MEMORY
{ {
/*
flash0 : org = 0x08000000, len = 4k flash0 : org = 0x08000000, len = 4k
flash : org = 0x08000000+0x1000, len = 60k flash : org = 0x08000000+0x1000, len = 60k
*/
flash0 : org = 0x08000000, len = 1k
flash : org = 0x08000000+0x0400, len = 60k
ram : org = 0x20000000, len = 20k ram : org = 0x20000000, len = 20k
} }
__flash_start__ = 0x08001000;
__flash_end__ = 0x08020000;
__ram_start__ = ORIGIN(ram); __ram_start__ = ORIGIN(ram);
__ram_size__ = 20k; __ram_size__ = 20k;
__ram_end__ = __ram_start__ + __ram_size__; __ram_end__ = __ram_start__ + __ram_size__;
@@ -29,24 +22,20 @@ SECTIONS
{ {
. = 0; . = 0;
.sys : ALIGN(16) SUBALIGN(8) .sys : ALIGN(4) SUBALIGN(4)
{ {
_sys = .; _sys = .;
KEEP(*(.vectors)) KEEP(*(.vectors))
. = ALIGN(16); . = ALIGN(16);
KEEP(*(.sys.version)) KEEP(*(.sys.version))
KEEP(*(.sys.board)) KEEP(*(.sys.board_id))
KEEP(*(.sys.board_name))
build/sys.o(.text) build/sys.o(.text)
build/sys.o(.text.*) build/sys.o(.text.*)
build/sys.o(.rodata) build/sys.o(.rodata)
build/sys.o(.rodata.*) build/sys.o(.rodata.*)
. = ALIGN(1024); . = ALIGN(1024);
/* } > flash0 =0xffffffff
*(.sys.0)
*(.sys.1)
*(.sys.2)
*/
} > flash0
_text = .; _text = .;
@@ -66,6 +55,7 @@ SECTIONS
*(.glue_7t) *(.glue_7t)
*(.glue_7) *(.glue_7)
*(.gcc*) *(.gcc*)
. = ALIGN(8);
} > flash } > flash
.ARM.extab : {*(.ARM.extab* .gnu.linkonce.armextab.*)} > flash .ARM.extab : {*(.ARM.extab* .gnu.linkonce.armextab.*)} > flash
@@ -98,15 +88,15 @@ SECTIONS
__process3_stack_base__ = .; __process3_stack_base__ = .;
. += __process3_stack_size__; . += __process3_stack_size__;
. = ALIGN(8); . = ALIGN(8);
__process_stack3_end__ = .; __process3_stack_end__ = .;
__process2_stack_base__ = .; __process2_stack_base__ = .;
. += __process2_stack_size__; . += __process2_stack_size__;
. = ALIGN(8); . = ALIGN(8);
__process_stack2_end__ = .; __process2_stack_end__ = .;
__process1_stack_base__ = .; __process1_stack_base__ = .;
. += __process1_stack_size__; . += __process1_stack_size__;
. = ALIGN(8); . = ALIGN(8);
__process_stack1_end__ = .; __process1_stack_end__ = .;
__process0_stack_base__ = .; __process0_stack_base__ = .;
. += __process0_stack_size__; . += __process0_stack_size__;
. = ALIGN(8); . = ALIGN(8);

View File

@@ -243,16 +243,25 @@ flash_check_blank (const uint8_t *p_start, size_t size)
return 1; return 1;
} }
extern uint8_t __flash_start__, __flash_end__; #define FLASH_START_ADDR 0x08000000 /* Fixed for all STM32F0/F1. */
#define FLASH_OFFSET 0x1000 /* First pages are not-writable
when protected. */
#if defined(__ARM_ARCH_6M__)
#define FLASH_SIZE_REG ((uint16_t *)0x1ffff7cc)
#define CHIP_ID_REG ((uint32_t *)0x40015800)
#else
#define FLASH_SIZE_REG ((uint16_t *)0x1ffff7e0)
#define CHIP_ID_REG ((uint32_t *)0xe0042000)
#endif
#define FLASH_START (FLASH_START_ADDR+FLASH_OFFSET)
static int static int
flash_write (uint32_t dst_addr, const uint8_t *src, size_t len) flash_write (uint32_t dst_addr, const uint8_t *src, size_t len)
{ {
int status; int status;
uint32_t flash_start = (uint32_t)&__flash_start__; uint32_t flash_end = FLASH_START_ADDR + (*FLASH_SIZE_REG)*1024;
uint32_t flash_end = (uint32_t)&__flash_end__;
if (dst_addr < flash_start || dst_addr + len > flash_end) if (dst_addr < FLASH_START || dst_addr + len > flash_end)
return 0; return 0;
while (len) while (len)
@@ -305,17 +314,21 @@ flash_protect (void)
static void __attribute__((naked)) static void __attribute__((naked))
flash_erase_all_and_exec (void (*entry)(void)) flash_erase_all_and_exec (void (*entry)(void))
{ {
uint32_t addr = (uint32_t)&__flash_start__; uint32_t addr = FLASH_START;
uint32_t end = (uint32_t)&__flash_end__; uint32_t end = FLASH_START_ADDR + (*FLASH_SIZE_REG)*1024;
uint32_t page_size = 1024;
int r; int r;
if (((*CHIP_ID_REG) & 0xfff) == 0x0414)
page_size = 2048;
while (addr < end) while (addr < end)
{ {
r = flash_erase_page (addr); r = flash_erase_page (addr);
if (r != 0) if (r != 0)
break; break;
addr += FLASH_PAGE_SIZE; addr += page_size;
} }
if (addr >= end) if (addr >= end)
@@ -370,8 +383,8 @@ reset (void)
#if defined(__ARM_ARCH_6M__) #if defined(__ARM_ARCH_6M__)
asm volatile ("cpsid i\n\t" /* Mask all interrupts. */ asm volatile ("cpsid i\n\t" /* Mask all interrupts. */
"ldr r0, 1f\n\t" /* r0 = RAM start */ "ldr r0, 1f\n\t" /* r0 = RAM start */
"mov r1, pc\n\t" /* r1 = (PC + 0x0400) & ~0x03ff */ "mov r1, pc\n\t" /* r1 = (PC + 0x1000) & ~0x0fff */
"mov r2, #0x04\n\t" "mov r2, #0x10\n\t"
"lsl r2, #8\n\t" "lsl r2, #8\n\t"
"add r1, r1, r2\n\t" "add r1, r1, r2\n\t"
"sub r2, r2, #1\n\t" "sub r2, r2, #1\n\t"
@@ -436,7 +449,13 @@ handler vector[] __attribute__ ((section(".vectors"))) = {
const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = { const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {
3*2+2, /* bLength */ 3*2+2, /* bLength */
0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE*/ 0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */
/* sys version: "2.0" */ /* sys version: "2.1" */
'2', 0, '.', 0, '0', 0, '2', 0, '.', 0, '1', 0,
}; };
const uint32_t __attribute__((section(".sys.board_id")))
sys_board_id = BOARD_ID;
const uint8_t __attribute__((section(".sys.board_name")))
sys_board_name[] = BOARD_NAME;

View File

@@ -1,4 +1,21 @@
#if defined(__ARM_ARCH_6M__)
#define BOARD_ID_STM32F0_DISCOVERY 0xde4b4bc1
#define BOARD_ID_FSM_55 0x83433c76
#else
#define BOARD_ID_CQ_STARM 0xc5480875
#define BOARD_ID_FST_01_00 0x613870a9
#define BOARD_ID_FST_01 0x696886af
#define BOARD_ID_MAPLE_MINI 0x7a445272
#define BOARD_ID_OLIMEX_STM32_H103 0xf92bb594
#define BOARD_ID_STBEE_MINI 0x1f341961
#define BOARD_ID_STBEE 0x945c37e8
#define BOARD_ID_STM32_PRIMER2 0x21e5798d
#define BOARD_ID_STM8S_DISCOVERY 0x2f0976bb
#endif
extern const uint8_t sys_version[8]; extern const uint8_t sys_version[8];
extern const uint32_t sys_board_id;
extern const uint8_t sys_board_name[];
typedef void (*handler)(void); typedef void (*handler)(void);
extern handler vector[16]; extern handler vector[16];