New sys.c
This commit is contained in:
11
ChangeLog
11
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>
|
2015-07-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
|
||||||
|
|
||||||
* board/board-stm32-primer2.h: Update.
|
* board/board-stm32-primer2.h: Update.
|
||||||
@@ -9,7 +18,7 @@
|
|||||||
(STM32F10X_MD): Define for medium-density devices.
|
(STM32F10X_MD): Define for medium-density devices.
|
||||||
* example-led/sys.c, sample.ld: Update.
|
* example-led/sys.c, sample.ld: Update.
|
||||||
* example-fsm-55/sys.c, hacker-emblem.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.
|
* example-cdc/sample.ld: Update.
|
||||||
|
|
||||||
2015-07-08 Niibe Yutaka <gniibe@fsij.org>
|
2015-07-08 Niibe Yutaka <gniibe@fsij.org>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#define BOARD_NAME "CQ STARM"
|
#define BOARD_NAME "CQ STARM"
|
||||||
|
#define BOARD_ID 0xc5480875
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 1024
|
#define FLASH_PAGE_SIZE 1024
|
||||||
#define STM32F10X_MD /* Medium-density device */
|
#define STM32F10X_MD /* Medium-density device */
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#define BOARD_NAME "FST-01-00"
|
#define BOARD_NAME "FST-01-00"
|
||||||
|
#define BOARD_ID 0x613870a9
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 1024
|
#define FLASH_PAGE_SIZE 1024
|
||||||
#define STM32F10X_MD /* Medium-density device */
|
#define STM32F10X_MD /* Medium-density device */
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#define BOARD_NAME "FST-01"
|
#define BOARD_NAME "FST-01"
|
||||||
|
#define BOARD_ID 0x696886af
|
||||||
|
/* echo -n "FST-01" | sha256sum | sed -e 's/^.*\(........\) -$/\1/' */
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 1024
|
#define FLASH_PAGE_SIZE 1024
|
||||||
#define STM32F10X_MD /* Medium-density device */
|
#define STM32F10X_MD /* Medium-density device */
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#define BOARD_NAME "Maple Mini"
|
#define BOARD_NAME "Maple Mini"
|
||||||
|
#define BOARD_ID 0x7a445272
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 1024
|
#define FLASH_PAGE_SIZE 1024
|
||||||
#define STM32F10X_MD /* Medium-density device */
|
#define STM32F10X_MD /* Medium-density device */
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#define BOARD_NAME "Olimex STM32-H103"
|
#define BOARD_NAME "Olimex STM32-H103"
|
||||||
|
#define BOARD_ID 0xf92bb594
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 1024
|
#define FLASH_PAGE_SIZE 1024
|
||||||
#define STM32F10X_MD /* Medium-density device */
|
#define STM32F10X_MD /* Medium-density device */
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#define BOARD_NAME "STBee Mini"
|
#define BOARD_NAME "STBee Mini"
|
||||||
|
#define BOARD_ID 0x1f341961
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 1024
|
#define FLASH_PAGE_SIZE 1024
|
||||||
#define STM32F10X_MD /* Medium-density device */
|
#define STM32F10X_MD /* Medium-density device */
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#define BOARD_NAME "STBee"
|
#define BOARD_NAME "STBee"
|
||||||
|
#define BOARD_ID 0x945c37e8
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 2048
|
#define FLASH_PAGE_SIZE 2048
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#define BOARD_NAME "STM32 Primer2"
|
#define BOARD_NAME "STM32 Primer2"
|
||||||
|
#define BOARD_ID 0x21e5798d
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 2048
|
#define FLASH_PAGE_SIZE 2048
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#define BOARD_NAME "STM8S Discovery"
|
#define BOARD_NAME "STM8S Discovery"
|
||||||
|
#define BOARD_ID 0x2f0976bb
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 1024
|
#define FLASH_PAGE_SIZE 1024
|
||||||
#define STM32F10X_MD /* Medium-density device */
|
#define STM32F10X_MD /* Medium-density device */
|
||||||
|
|||||||
14
entry.c
14
entry.c
@@ -34,6 +34,7 @@
|
|||||||
#define INLINE __attribute__ ((used))
|
#define INLINE __attribute__ ((used))
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
#undef STM32F10X_MD /* Prepare for high density device, too. */
|
||||||
#else
|
#else
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "clk_gpio_init.c"
|
#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 /* DMA1 CH6 */, chx_handle_intr /* DMA1 CH7 */,
|
||||||
chx_handle_intr /* ADC1_2 */, chx_handle_intr /* USB HP */,
|
chx_handle_intr /* ADC1_2 */, chx_handle_intr /* USB HP */,
|
||||||
/* 0x90 */
|
/* 0x90 */
|
||||||
chx_handle_intr, /* USB LP */
|
chx_handle_intr /* USB LP */, chx_handle_intr /* CAN */,
|
||||||
/* ... and more. CAN, EXT9_5, TIMx, I2C, SPI, USART, EXT15_10 */
|
/* ... and more. 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,
|
||||||
|
/* 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,
|
||||||
|
/* 0xc0 */
|
||||||
#if !defined(__ARM_ARCH_6M__)
|
#if !defined(__ARM_ARCH_6M__)
|
||||||
/* STM32F0 doesn't have more. */
|
/* 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, 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
|
#endif
|
||||||
#if !defined(STM32F10X_MD)
|
#if !defined(STM32F10X_MD)
|
||||||
/* High-density chips have more; RTCAlarm, USBWakeup, ... , DMA2_Channel4_5 */
|
/* High-density chips have more; RTCAlarm, USBWakeup, ... , DMA2_Channel4_5 */
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ MEMORY
|
|||||||
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__;
|
||||||
@@ -25,13 +22,14 @@ 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)
|
||||||
|
|||||||
@@ -243,16 +243,19 @@ 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 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
|
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 + (*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 +308,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 + (*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)
|
||||||
@@ -416,9 +423,12 @@ 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 uint8_t __attribute__((section(".sys.board")))
|
const uint32_t __attribute__((section(".sys.board_id")))
|
||||||
sys_board[] = BOARD_NAME;
|
sys_board_id = BOARD_ID;
|
||||||
|
|
||||||
|
const uint8_t __attribute__((section(".sys.board_name")))
|
||||||
|
sys_board_name[] = BOARD_NAME;
|
||||||
|
|||||||
Reference in New Issue
Block a user