sys_board and stm32 primer2

This commit is contained in:
NIIBE Yutaka
2015-07-13 16:45:32 +09:00
parent 2bb0e0de5d
commit 3ba8234cec
17 changed files with 82 additions and 21 deletions

View File

@@ -1,3 +1,17 @@
2015-07-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* board/board-stm32-primer2.h: Update.
* entry.c (vector_table): Less or more.
2015-07-13 Niibe Yutaka <gniibe@fsij.org>
* board/board-*.h (BOARD_NAME): New.
(STM32F10X_MD): Define for medium-density devices.
* example-led/sys.c, sample.ld: Update.
* example-fsm-55/sys.c, hacker-emblem.ld: Update.
* example-cdc/sys.c (sys_board): New.
* example-cdc/sample.ld: Update.
2015-07-08 Niibe Yutaka <gniibe@fsij.org>
* VERSION: 0.06.

View File

@@ -1,4 +1,7 @@
#define BOARD_NAME "CQ STARM"
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE 9

View File

@@ -1,4 +1,7 @@
#define BOARD_NAME "FST-01-00"
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE 9

View File

@@ -1,4 +1,7 @@
#define BOARD_NAME "FST-01"
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE 6

View File

@@ -1,4 +1,7 @@
#define BOARD_NAME "Maple Mini"
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE 9

View File

@@ -1,4 +1,7 @@
#define BOARD_NAME "Olimex STM32-H103"
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE 9

View File

@@ -1,4 +1,7 @@
#define BOARD_NAME "STBee Mini"
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE 6

View File

@@ -1,3 +1,5 @@
#define BOARD_NAME "STBee"
#define FLASH_PAGE_SIZE 2048
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1

View File

@@ -1,3 +1,5 @@
#define BOARD_NAME "STM32 Primer2"
#define FLASH_PAGE_SIZE 2048
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
@@ -5,7 +7,7 @@
#define STM32_HSECLK 12000000
#define GPIO_LED_BASE GPIOE_BASE
#define GPIO_LED_CLEAR_TO_EMIT 0
#define GPIO_LED_SET_TO_EMIT 0
#define GPIO_USB_BASE GPIOD_BASE
#define GPIO_USB_CLEAR_TO_ENABLE 3
#define GPIO_OTHER_BASE GPIOA_BASE
@@ -14,12 +16,13 @@
* Port A setup.
* PA0 - input with pull-up. AN0
* PA1 - input with pull-up. AN1
* PA8 - Input with pull-down (PBUTTON).
* PA11 - Push Pull output 10MHz 0 default (until USB enabled) (USBDM)
* PA12 - Push Pull output 10MHz 0 default (until USB enabled) (USBDP)
* ------------------------ Default
* PAx - input with pull-up
*/
#define VAL_GPIO_OTHER_ODR 0xFFFFE7FF
#define VAL_GPIO_OTHER_ODR 0xFFFFE6FF
#define VAL_GPIO_OTHER_CRL 0x88888888 /* PA7...PA0 */
#define VAL_GPIO_OTHER_CRH 0x88811888 /* PA15...PA8 */
@@ -37,10 +40,14 @@
* Port E setup.
* PE0 - Push pull output (LED 1:ON 0:OFF)
* PE1 - Push pull output (LED 1:ON 0:OFF)
* PE3 - Input with pull-down (JOYSTICK L).
* PE4 - Input with pull-down (JOYSTICK R).
* PE5 - Input with pull-down (JOYSTICK U).
* PE6 - Input with pull-down (JOYSTICK D).
* ------------------------ Default
* PEx - input with pull-up
*/
#define VAL_GPIO_LED_ODR 0xFFFFFFFF
#define VAL_GPIO_LED_ODR 0xFFFFFF87
#define VAL_GPIO_LED_CRL 0x88888833 /* PE7...PE0 */
#define VAL_GPIO_LED_CRH 0x88888888 /* PE15...PE8 */

View File

@@ -1,4 +1,7 @@
#define BOARD_NAME "STM8S Discovery"
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE 9

14
entry.c
View File

@@ -196,8 +196,20 @@ handler vector_table[] __attribute__ ((section(".startup.vectors"))) = {
/* ... and more. CAN, EXT9_5, TIMx, I2C, SPI, USART, EXT15_10 */
chx_handle_intr, chx_handle_intr, chx_handle_intr, chx_handle_intr,
chx_handle_intr, chx_handle_intr, chx_handle_intr, chx_handle_intr,
chx_handle_intr, chx_handle_intr, chx_handle_intr, chx_handle_intr,
chx_handle_intr, chx_handle_intr,
#if !defined(__ARM_ARCH_6M__)
/* STM32F0 doesn't have more. */
chx_handle_intr, chx_handle_intr,
chx_handle_intr, chx_handle_intr, chx_handle_intr, chx_handle_intr,
chx_handle_intr, chx_handle_intr, chx_handle_intr, chx_handle_intr,
chx_handle_intr, chx_handle_intr,
#endif
#if !defined(STM32F10X_MD)
/* High-density chips have more; RTCAlarm, USBWakeup, ... , DMA2_Channel4_5 */
chx_handle_intr, chx_handle_intr, chx_handle_intr, chx_handle_intr,
chx_handle_intr, chx_handle_intr, chx_handle_intr, chx_handle_intr,
chx_handle_intr, chx_handle_intr, chx_handle_intr, chx_handle_intr,
chx_handle_intr, chx_handle_intr, chx_handle_intr, chx_handle_intr,
chx_handle_intr, chx_handle_intr, chx_handle_intr,
#endif
};

View File

@@ -25,15 +25,16 @@ SECTIONS
{
. = 0;
.sys : ALIGN(16) SUBALIGN(16)
.sys : ALIGN(16) SUBALIGN(8)
{
_sys = .;
KEEP(*(.vectors))
_sys = .;
KEEP(*(.vectors))
. = ALIGN(16);
*(.sys.version)
KEEP(*(.sys.version))
KEEP(*(.sys.board))
build/sys.o(.text)
build/sys.o(.text.*)
build/sys.o(.rodata)
build/sys.o(.rodata)
build/sys.o(.rodata.*)
. = ALIGN(1024);
*(.sys.0)
@@ -59,6 +60,7 @@ SECTIONS
*(.glue_7t)
*(.glue_7)
*(.gcc*)
. = ALIGN(8);
} > flash
.ARM.extab : {*(.ARM.extab* .gnu.linkonce.armextab.*)} > flash

View File

@@ -415,7 +415,10 @@ handler vector[] __attribute__ ((section(".vectors"))) = {
const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {
3*2+2, /* bLength */
0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE*/
0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */
/* sys version: "2.0" */
'2', 0, '.', 0, '0', 0,
};
const uint8_t __attribute__((section(".sys.board")))
sys_board[] = BOARD_NAME;

View File

@@ -29,12 +29,13 @@ SECTIONS
{
. = 0;
.sys : ALIGN(16) SUBALIGN(16)
.sys : ALIGN(16) SUBALIGN(8)
{
_sys = .;
KEEP(*(.vectors))
. = ALIGN(16);
*(.sys.version)
KEEP(*(.sys.version))
KEEP(*(.sys.board))
build/sys.o(.text)
build/sys.o(.text.*)
build/sys.o(.rodata)

View File

@@ -364,10 +364,10 @@ static void __attribute__ ((naked))
reset (void)
{
/*
* This code may not be at start of flash ROM, because of DFU.
* This code may not be at the start of flash ROM, because of DFU.
* So, we take the address from PC.
*/
#if __ARM_ARCH_6M__
#if defined(__ARM_ARCH_6M__)
asm volatile ("cpsid i\n\t" /* Mask all interrupts. */
"ldr r0, 1f\n\t" /* r0 = RAM start */
"mov r1, pc\n\t" /* r1 = (PC + 0x0400) & ~0x03ff */

View File

@@ -29,12 +29,13 @@ SECTIONS
{
. = 0;
.sys : ALIGN(16) SUBALIGN(16)
.sys : ALIGN(16) SUBALIGN(8)
{
_sys = .;
KEEP(*(.vectors))
. = ALIGN(16);
*(.sys.version)
KEEP(*(.sys.version))
KEEP(*(.sys.board))
build/sys.o(.text)
build/sys.o(.text.*)
build/sys.o(.rodata)

View File

@@ -363,8 +363,6 @@ nvic_system_reset (void)
static void __attribute__ ((naked))
reset (void)
{
extern const unsigned long *FT0, *FT1, *FT2;
/*
* This code may not be at the start of flash ROM, because of DFU.
* So, we take the address from PC.
@@ -391,6 +389,7 @@ reset (void)
"1: .word 0x20000000"
: /* no output */ : /* no input */ : "memory");
#else
extern const unsigned long *FT0, *FT1, *FT2;
asm volatile ("cpsid i\n\t" /* Mask all interrupts. */
"ldr r0, 1f\n\t" /* r0 = SCR */
"mov r1, pc\n\t" /* r1 = (PC + 0x1000) & ~0x0fff */
@@ -406,12 +405,11 @@ reset (void)
".align 2\n"
"1: .word 0xe000ed00"
: /* no output */ : /* no input */ : "memory");
#endif
/* Never reach here. */
/* Artificial entry to refer FT0, FT1, and FT2. */
asm volatile (""
: : "r" (FT0), "r" (FT1), "r" (FT2));
#endif
/* Never reach here. */
}
typedef void (*handler)(void);