aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2015-07-14 16:10:07 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2015-07-14 16:10:07 +0900
commit27f71ff5c093f740c78a28644e3be2843c660b7d (patch)
tree45a580a5e2a5702aa557585f65f80c41ce136397
parent3ba8234cecde90467fb75d72055fa0c226ed16df (diff)
New sys.c
-rw-r--r--ChangeLog11
-rw-r--r--board/board-cq-starm.h1
-rw-r--r--board/board-fst-01-00.h1
-rw-r--r--board/board-fst-01.h2
-rw-r--r--board/board-maple-mini.h1
-rw-r--r--board/board-olimex-stm32-h103.h1
-rw-r--r--board/board-stbee-mini.h1
-rw-r--r--board/board-stbee.h1
-rw-r--r--board/board-stm32-primer2.h1
-rw-r--r--board/board-stm8s-discovery.h1
-rw-r--r--entry.c12
-rw-r--r--example-cdc/sample.ld8
-rw-r--r--example-cdc/sys.c32
13 files changed, 51 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 9c95a47..dab0e12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-07-14 Niibe Yutaka <gniibe@fsij.org>
+
+ * board/board-*.h (BOARD_ID): New.
+ * example-cdc/sys.c (sys_board_id): New.
+ * example-cdc/sample.ld (.sys.board_id): New.
+ (__flash_start__, __flash_end__): Remove.
+ * entry.c [HAVE_SYS_H] (vector_table): By undefining STM32F10X_MD,
+ prepare for high density device even compiled for MD device.
+
2015-07-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* board/board-stm32-primer2.h: Update.
@@ -9,7 +18,7 @@
(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/sys.c (sys_board_name): New.
* example-cdc/sample.ld: Update.
2015-07-08 Niibe Yutaka <gniibe@fsij.org>
diff --git a/board/board-cq-starm.h b/board/board-cq-starm.h
index 54c53ff..b771230 100644
--- a/board/board-cq-starm.h
+++ b/board/board-cq-starm.h
@@ -1,4 +1,5 @@
#define BOARD_NAME "CQ STARM"
+#define BOARD_ID 0xc5480875
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
diff --git a/board/board-fst-01-00.h b/board/board-fst-01-00.h
index 30a9311..8bfccc3 100644
--- a/board/board-fst-01-00.h
+++ b/board/board-fst-01-00.h
@@ -1,4 +1,5 @@
#define BOARD_NAME "FST-01-00"
+#define BOARD_ID 0x613870a9
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
diff --git a/board/board-fst-01.h b/board/board-fst-01.h
index aecb9db..c062133 100644
--- a/board/board-fst-01.h
+++ b/board/board-fst-01.h
@@ -1,4 +1,6 @@
#define BOARD_NAME "FST-01"
+#define BOARD_ID 0x696886af
+/* echo -n "FST-01" | sha256sum | sed -e 's/^.*\(........\) -$/\1/' */
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
diff --git a/board/board-maple-mini.h b/board/board-maple-mini.h
index 5e19dee..b8e1726 100644
--- a/board/board-maple-mini.h
+++ b/board/board-maple-mini.h
@@ -1,4 +1,5 @@
#define BOARD_NAME "Maple Mini"
+#define BOARD_ID 0x7a445272
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
diff --git a/board/board-olimex-stm32-h103.h b/board/board-olimex-stm32-h103.h
index 26c3dd3..9bd011f 100644
--- a/board/board-olimex-stm32-h103.h
+++ b/board/board-olimex-stm32-h103.h
@@ -1,4 +1,5 @@
#define BOARD_NAME "Olimex STM32-H103"
+#define BOARD_ID 0xf92bb594
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
diff --git a/board/board-stbee-mini.h b/board/board-stbee-mini.h
index 51aee57..b69863e 100644
--- a/board/board-stbee-mini.h
+++ b/board/board-stbee-mini.h
@@ -1,4 +1,5 @@
#define BOARD_NAME "STBee Mini"
+#define BOARD_ID 0x1f341961
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
diff --git a/board/board-stbee.h b/board/board-stbee.h
index c7835a0..3ffc160 100644
--- a/board/board-stbee.h
+++ b/board/board-stbee.h
@@ -1,4 +1,5 @@
#define BOARD_NAME "STBee"
+#define BOARD_ID 0x945c37e8
#define FLASH_PAGE_SIZE 2048
diff --git a/board/board-stm32-primer2.h b/board/board-stm32-primer2.h
index 2d56f90..700f4ea 100644
--- a/board/board-stm32-primer2.h
+++ b/board/board-stm32-primer2.h
@@ -1,4 +1,5 @@
#define BOARD_NAME "STM32 Primer2"
+#define BOARD_ID 0x21e5798d
#define FLASH_PAGE_SIZE 2048
diff --git a/board/board-stm8s-discovery.h b/board/board-stm8s-discovery.h
index 08942ef..4e28662 100644
--- a/board/board-stm8s-discovery.h
+++ b/board/board-stm8s-discovery.h
@@ -1,4 +1,5 @@
#define BOARD_NAME "STM8S Discovery"
+#define BOARD_ID 0x2f0976bb
#define FLASH_PAGE_SIZE 1024
#define STM32F10X_MD /* Medium-density device */
diff --git a/entry.c b/entry.c
index a55a1d5..f79a207 100644
--- a/entry.c
+++ b/entry.c
@@ -34,6 +34,7 @@
#define INLINE __attribute__ ((used))
#include "sys.h"
#include "board.h"
+#undef STM32F10X_MD /* Prepare for high density device, too. */
#else
#include "board.h"
#include "clk_gpio_init.c"
@@ -192,17 +193,18 @@ handler vector_table[] __attribute__ ((section(".startup.vectors"))) = {
chx_handle_intr /* DMA1 CH6 */, chx_handle_intr /* DMA1 CH7 */,
chx_handle_intr /* ADC1_2 */, chx_handle_intr /* USB HP */,
/* 0x90 */
- chx_handle_intr, /* USB LP */
- /* ... and more. CAN, EXT9_5, TIMx, I2C, SPI, USART, EXT15_10 */
+ chx_handle_intr /* USB LP */, chx_handle_intr /* CAN */,
+ /* ... and more. EXT9_5, TIMx, I2C, SPI, USART, EXT15_10 */
+ chx_handle_intr, chx_handle_intr,
+ /* 0xA0 */
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,
+ /* 0xc0 */
#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,
+ chx_handle_intr, chx_handle_intr, chx_handle_intr,
#endif
#if !defined(STM32F10X_MD)
/* High-density chips have more; RTCAlarm, USBWakeup, ... , DMA2_Channel4_5 */
diff --git a/example-cdc/sample.ld b/example-cdc/sample.ld
index 55ad7aa..322165b 100644
--- a/example-cdc/sample.ld
+++ b/example-cdc/sample.ld
@@ -14,9 +14,6 @@ MEMORY
ram : org = 0x20000000, len = 20k
}
-__flash_start__ = 0x08001000;
-__flash_end__ = 0x08020000;
-
__ram_start__ = ORIGIN(ram);
__ram_size__ = 20k;
__ram_end__ = __ram_start__ + __ram_size__;
@@ -25,13 +22,14 @@ SECTIONS
{
. = 0;
- .sys : ALIGN(16) SUBALIGN(8)
+ .sys : ALIGN(4) SUBALIGN(4)
{
_sys = .;
KEEP(*(.vectors))
. = ALIGN(16);
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(.rodata)
diff --git a/example-cdc/sys.c b/example-cdc/sys.c
index 19c31b1..968b133 100644
--- a/example-cdc/sys.c
+++ b/example-cdc/sys.c
@@ -243,16 +243,19 @@ flash_check_blank (const uint8_t *p_start, size_t size)
return 1;
}
-extern uint8_t __flash_start__, __flash_end__;
+#define FLASH_START_ADDR 0x08000000 /* Fixed for all STM32F1. */
+#define FLASH_OFFSET 0x1000 /* First pages are not-writable. */
+#define FLASH_START (FLASH_START_ADDR+FLASH_OFFSET)
+#define CHIP_ID_REG ((uint32_t *)0xe0042000)
+#define FLASH_SIZE_REG ((uint16_t *)0x1ffff7e0)
static int
flash_write (uint32_t dst_addr, const uint8_t *src, size_t len)
{
int status;
- uint32_t flash_start = (uint32_t)&__flash_start__;
- uint32_t flash_end = (uint32_t)&__flash_end__;
+ uint32_t flash_end = FLASH_START + (*FLASH_SIZE_REG)*1024;
- if (dst_addr < flash_start || dst_addr + len > flash_end)
+ if (dst_addr < FLASH_START || dst_addr + len > flash_end)
return 0;
while (len)
@@ -305,17 +308,21 @@ flash_protect (void)
static void __attribute__((naked))
flash_erase_all_and_exec (void (*entry)(void))
{
- uint32_t addr = (uint32_t)&__flash_start__;
- uint32_t end = (uint32_t)&__flash_end__;
+ uint32_t addr = FLASH_START;
+ uint32_t end = FLASH_START + (*FLASH_SIZE_REG)*1024;
+ uint32_t page_size = 1024;
int r;
+ if (((*CHIP_ID_REG) & 0xfff) == 0x0414)
+ page_size = 2048;
+
while (addr < end)
{
r = flash_erase_page (addr);
if (r != 0)
break;
- addr += FLASH_PAGE_SIZE;
+ addr += page_size;
}
if (addr >= end)
@@ -416,9 +423,12 @@ 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 */
- /* sys version: "2.0" */
- '2', 0, '.', 0, '0', 0,
+ /* sys version: "2.1" */
+ '2', 0, '.', 0, '1', 0,
};
-const uint8_t __attribute__((section(".sys.board")))
-sys_board[] = BOARD_NAME;
+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;