Fixing up TS80P Build (#1429)
* Silence wchart warning + go back to simple size limiter Going from smart linker file to basic #defines to make things just easier to debug * 2 deg c increments for NTC table * Update cmsis_gcc.h * Drop special linker * Update portmacro.h * Update Makefile
This commit is contained in:
@@ -10,14 +10,15 @@
|
|||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
static uint16_t settings_page[512] __attribute__((section(".settings_page")));
|
#define SETTINGS_START_PAGE (0x08000000 + (127 * 1024))
|
||||||
|
|
||||||
|
|
||||||
uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
||||||
FLASH_EraseInitTypeDef pEraseInit;
|
FLASH_EraseInitTypeDef pEraseInit;
|
||||||
pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
|
pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||||
pEraseInit.Banks = FLASH_BANK_1;
|
pEraseInit.Banks = FLASH_BANK_1;
|
||||||
pEraseInit.NbPages = 1;
|
pEraseInit.NbPages = 1;
|
||||||
pEraseInit.PageAddress = (uint32_t)settings_page;
|
pEraseInit.PageAddress = (uint32_t)SETTINGS_START_PAGE;
|
||||||
uint32_t failingAddress = 0;
|
uint32_t failingAddress = 0;
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
|
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
|
||||||
@@ -32,13 +33,10 @@ uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
|||||||
HAL_FLASH_Unlock();
|
HAL_FLASH_Unlock();
|
||||||
for (uint16_t i = 0; i < (length / 2); i++) {
|
for (uint16_t i = 0; i < (length / 2); i++) {
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, (uint32_t)&settings_page[i], data[i]);
|
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, SETTINGS_START_PAGE+ (i*sizeof(uint32_t)), data[i]);
|
||||||
}
|
}
|
||||||
HAL_FLASH_Lock();
|
HAL_FLASH_Lock();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void flash_read_buffer(uint8_t *buffer, const uint16_t length) {
|
void flash_read_buffer(uint8_t *buffer, const uint16_t length) { memcpy(buffer, (uint8_t*)SETTINGS_START_PAGE, length); }
|
||||||
memset(buffer, 0, length);
|
|
||||||
memcpy(buffer, settings_page, length);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -116,17 +116,6 @@ SECTIONS
|
|||||||
_edata = .; /* define a global symbol at data end */
|
_edata = .; /* define a global symbol at data end */
|
||||||
} >RAM AT> ROM
|
} >RAM AT> ROM
|
||||||
|
|
||||||
.logo_page (NOLOAD) :
|
|
||||||
{
|
|
||||||
. = ABSOLUTE(__FLASH_END_ADDR__ - 2048);
|
|
||||||
KEEP (*(.logo_page*))
|
|
||||||
} > ROM
|
|
||||||
|
|
||||||
.settings_page (NOLOAD) :
|
|
||||||
{
|
|
||||||
. = ABSOLUTE(__FLASH_END_ADDR__ - 1024);
|
|
||||||
KEEP (*(.settings_page*))
|
|
||||||
} > ROM
|
|
||||||
|
|
||||||
.bss :
|
.bss :
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,66 +29,29 @@ void resetWatchdog() { HAL_IWDG_Refresh(&hiwdg); }
|
|||||||
static const uint16_t NTCHandleLookup[] = {
|
static const uint16_t NTCHandleLookup[] = {
|
||||||
// ADC Reading , Temp in C
|
// ADC Reading , Temp in C
|
||||||
29189, 0, //
|
29189, 0, //
|
||||||
29014, 1, //
|
|
||||||
28832, 2, //
|
28832, 2, //
|
||||||
28644, 3, //
|
|
||||||
28450, 4, //
|
28450, 4, //
|
||||||
28249, 5, //
|
|
||||||
28042, 6, //
|
28042, 6, //
|
||||||
27828, 7, //
|
|
||||||
27607, 8, //
|
27607, 8, //
|
||||||
27380, 9, //
|
|
||||||
27146, 10, //
|
27146, 10, //
|
||||||
26906, 11, //
|
|
||||||
26660, 12, //
|
26660, 12, //
|
||||||
26407, 13, //
|
|
||||||
26147, 14, //
|
26147, 14, //
|
||||||
25882, 15, //
|
|
||||||
25610, 16, //
|
25610, 16, //
|
||||||
25332, 17, //
|
|
||||||
25049, 18, //
|
25049, 18, //
|
||||||
24759, 19, //
|
|
||||||
24465, 20, //
|
24465, 20, //
|
||||||
24164, 21, //
|
|
||||||
23859, 22, //
|
23859, 22, //
|
||||||
23549, 23, //
|
|
||||||
23234, 24, //
|
23234, 24, //
|
||||||
22915, 25, //
|
|
||||||
22591, 26, //
|
22591, 26, //
|
||||||
22264, 27, //
|
|
||||||
21933, 28, //
|
21933, 28, //
|
||||||
21599, 29, //
|
|
||||||
21261, 30, //
|
21261, 30, //
|
||||||
20921, 31, //
|
|
||||||
20579, 32, //
|
20579, 32, //
|
||||||
20234, 33, //
|
|
||||||
19888, 34, //
|
19888, 34, //
|
||||||
19541, 35, //
|
|
||||||
19192, 36, //
|
19192, 36, //
|
||||||
18843, 37, //
|
|
||||||
18493, 38, //
|
18493, 38, //
|
||||||
18143, 39, //
|
|
||||||
17793, 40, //
|
17793, 40, //
|
||||||
17444, 41, //
|
|
||||||
17096, 42, //
|
17096, 42, //
|
||||||
16750, 43, //
|
|
||||||
16404, 44, //
|
16404, 44, //
|
||||||
16061, 45, //
|
16061, 45, //
|
||||||
// 15719, 46, //
|
|
||||||
// 15380, 47, //
|
|
||||||
// 15044, 48, //
|
|
||||||
// 14710, 49, //
|
|
||||||
// 14380, 50, //
|
|
||||||
// 14053, 51, //
|
|
||||||
// 13729, 52, //
|
|
||||||
// 13410, 53, //
|
|
||||||
// 13094, 54, //
|
|
||||||
// 12782, 55, //
|
|
||||||
// 12475, 56, //
|
|
||||||
// 12172, 57, //
|
|
||||||
// 11874, 58, //
|
|
||||||
// 11580, 59, //
|
|
||||||
// 11292, 60, //
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void) {
|
|||||||
\return PSP Register value
|
\return PSP Register value
|
||||||
*/
|
*/
|
||||||
__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void) {
|
__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void) {
|
||||||
register uint32_t result;
|
uint32_t result;
|
||||||
|
|
||||||
__ASM volatile("MRS %0, psp\n" : "=r"(result));
|
__ASM volatile("MRS %0, psp\n" : "=r"(result));
|
||||||
return (result);
|
return (result);
|
||||||
@@ -143,7 +143,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProc
|
|||||||
\return MSP Register value
|
\return MSP Register value
|
||||||
*/
|
*/
|
||||||
__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void) {
|
__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void) {
|
||||||
register uint32_t result;
|
uint32_t result;
|
||||||
|
|
||||||
__ASM volatile("MRS %0, msp\n" : "=r"(result));
|
__ASM volatile("MRS %0, msp\n" : "=r"(result));
|
||||||
return (result);
|
return (result);
|
||||||
|
|||||||
@@ -10,14 +10,14 @@
|
|||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
static uint16_t settings_page[512] __attribute__((section(".settings_page")));
|
#define SETTINGS_START_PAGE (0x08000000 + (63 * 1024))
|
||||||
|
|
||||||
uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
||||||
FLASH_EraseInitTypeDef pEraseInit;
|
FLASH_EraseInitTypeDef pEraseInit;
|
||||||
pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
|
pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||||
pEraseInit.Banks = FLASH_BANK_1;
|
pEraseInit.Banks = FLASH_BANK_1;
|
||||||
pEraseInit.NbPages = 1;
|
pEraseInit.NbPages = 1;
|
||||||
pEraseInit.PageAddress = (uint32_t)settings_page;
|
pEraseInit.PageAddress = (uint32_t)SETTINGS_START_PAGE;
|
||||||
uint32_t failingAddress = 0;
|
uint32_t failingAddress = 0;
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
|
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
|
||||||
@@ -32,10 +32,10 @@ uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
|||||||
HAL_FLASH_Unlock();
|
HAL_FLASH_Unlock();
|
||||||
for (uint16_t i = 0; i < (length / 2); i++) {
|
for (uint16_t i = 0; i < (length / 2); i++) {
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, (uint32_t)&settings_page[i], data[i]);
|
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, SETTINGS_START_PAGE+ (i*sizeof(uint32_t)), data[i]);
|
||||||
}
|
}
|
||||||
HAL_FLASH_Lock();
|
HAL_FLASH_Lock();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void flash_read_buffer(uint8_t *buffer, const uint16_t length) { memcpy(buffer, settings_page, length); }
|
void flash_read_buffer(uint8_t *buffer, const uint16_t length) { memcpy(buffer, (uint8_t*)SETTINGS_START_PAGE, length); }
|
||||||
|
|||||||
@@ -116,17 +116,6 @@ SECTIONS
|
|||||||
_edata = .; /* define a global symbol at data end */
|
_edata = .; /* define a global symbol at data end */
|
||||||
} >RAM AT> ROM
|
} >RAM AT> ROM
|
||||||
|
|
||||||
.logo_page (NOLOAD) :
|
|
||||||
{
|
|
||||||
. = ABSOLUTE(__FLASH_END_ADDR__ - 2048);
|
|
||||||
KEEP (*(.logo_page*))
|
|
||||||
} > ROM
|
|
||||||
|
|
||||||
.settings_page (NOLOAD) :
|
|
||||||
{
|
|
||||||
. = ABSOLUTE(__FLASH_END_ADDR__ - 1024);
|
|
||||||
KEEP (*(.settings_page*))
|
|
||||||
} > ROM
|
|
||||||
|
|
||||||
.bss :
|
.bss :
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
#include "gd32vf103_libopt.h"
|
#include "gd32vf103_libopt.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#define FMC_PAGE_SIZE ((uint16_t)0x400U)
|
#define FMC_PAGE_SIZE ((uint16_t)0x400U)
|
||||||
// static uint16_t settings_page[FMC_PAGE_SIZE] __attribute__ ((section (".settings_page")));
|
|
||||||
// Linker script doesnt want to play, so for now its hard coded
|
|
||||||
#define SETTINGS_START_PAGE (0x08000000 + (127 * 1024))
|
#define SETTINGS_START_PAGE (0x08000000 + (127 * 1024))
|
||||||
uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ extern "C" {
|
|||||||
* These settings should not be altered.
|
* These settings should not be altered.
|
||||||
*-----------------------------------------------------------
|
*-----------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
#include "FreeRTOSConfig.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|||||||
@@ -152,15 +152,15 @@ S_SRCS := $(shell find $(MINIWARE_STARTUP_DIR) -type f -name '*.S')
|
|||||||
LDSCRIPT=$(MINIWARE_LD_FILE)
|
LDSCRIPT=$(MINIWARE_LD_FILE)
|
||||||
DEV_GLOBAL_DEFS= -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D GCC_ARMCM3 \
|
DEV_GLOBAL_DEFS= -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D GCC_ARMCM3 \
|
||||||
-D ARM_MATH_CM3 \
|
-D ARM_MATH_CM3 \
|
||||||
-D STM32F10X_MD
|
-D STM32F10X_MD
|
||||||
DEV_LDFLAGS=
|
DEV_LDFLAGS= -Wl,--wrap=printf -Wl,--no-wchar-size-warning
|
||||||
DEV_AFLAGS=
|
DEV_AFLAGS=
|
||||||
DEV_CFLAGS= -D VECT_TAB_OFFSET=$(bootldr_size)U
|
DEV_CFLAGS= -D VECT_TAB_OFFSET=$(bootldr_size)U
|
||||||
DEV_CXXFLAGS=
|
DEV_CXXFLAGS=
|
||||||
CPUFLAGS= -mcpu=cortex-m3 \
|
CPUFLAGS= -mcpu=cortex-m3 \
|
||||||
-mthumb \
|
-mthumb \
|
||||||
-mfloat-abi=soft
|
-mfloat-abi=soft
|
||||||
flash_size=64k
|
flash_size=62k
|
||||||
bootldr_size=0x4000
|
bootldr_size=0x4000
|
||||||
DEVICE_DFU_ADDRESS=0x08004000
|
DEVICE_DFU_ADDRESS=0x08004000
|
||||||
DEVICE_DFU_VID_PID=0x1209:0xDB42
|
DEVICE_DFU_VID_PID=0x1209:0xDB42
|
||||||
@@ -186,7 +186,7 @@ DEV_CXXFLAGS=
|
|||||||
CPUFLAGS= -mcpu=cortex-m3 \
|
CPUFLAGS= -mcpu=cortex-m3 \
|
||||||
-mthumb \
|
-mthumb \
|
||||||
-mfloat-abi=soft
|
-mfloat-abi=soft
|
||||||
flash_size=128k
|
flash_size=126k
|
||||||
bootldr_size=32k
|
bootldr_size=32k
|
||||||
DEVICE_DFU_ADDRESS=0x08008000
|
DEVICE_DFU_ADDRESS=0x08008000
|
||||||
DEVICE_DFU_VID_PID=0x1209:0xDB42
|
DEVICE_DFU_VID_PID=0x1209:0xDB42
|
||||||
@@ -313,7 +313,7 @@ $(shell find $(DEVICE_BSP_DIR) -type d \( $(EXCLUDED_DIRS) \) -prune -false -o
|
|||||||
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
|
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
|
||||||
|
|
||||||
# code optimisation ------------------------------------------------------------
|
# code optimisation ------------------------------------------------------------
|
||||||
OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common
|
OPTIM=-Os -fshort-wchar -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common
|
||||||
|
|
||||||
# global defines ---------------------------------------------------------------
|
# global defines ---------------------------------------------------------------
|
||||||
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U -fshort-wchar
|
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U -fshort-wchar
|
||||||
@@ -343,6 +343,7 @@ endif
|
|||||||
CC=$(COMPILER_PREFIX)-gcc
|
CC=$(COMPILER_PREFIX)-gcc
|
||||||
CPP=$(COMPILER_PREFIX)-g++
|
CPP=$(COMPILER_PREFIX)-g++
|
||||||
OBJCOPY=$(COMPILER_PREFIX)-objcopy
|
OBJCOPY=$(COMPILER_PREFIX)-objcopy
|
||||||
|
SIZE=$(COMPILER_PREFIX)-size
|
||||||
OBJDUMP=$(COMPILER_PREFIX)-objdump
|
OBJDUMP=$(COMPILER_PREFIX)-objdump
|
||||||
# use gcc in assembler mode so we can use defines etc in assembly
|
# use gcc in assembler mode so we can use defines etc in assembly
|
||||||
AS=$(COMPILER_PREFIX)-gcc -x assembler-with-cpp
|
AS=$(COMPILER_PREFIX)-gcc -x assembler-with-cpp
|
||||||
@@ -405,7 +406,7 @@ CXXFLAGS=$(DEV_CXXFLAGS) \
|
|||||||
-D${COMPILER} \
|
-D${COMPILER} \
|
||||||
-MMD \
|
-MMD \
|
||||||
$(CHECKOPTIONS) \
|
$(CHECKOPTIONS) \
|
||||||
-std=c++14 \
|
-std=c++17 \
|
||||||
$(OPTIM) \
|
$(OPTIM) \
|
||||||
-fno-rtti \
|
-fno-rtti \
|
||||||
-fno-exceptions \
|
-fno-exceptions \
|
||||||
@@ -469,6 +470,7 @@ firmware-%: $(HEXFILE_DIR)/$(model)_%.hex $(HEXFILE_DIR)/$(model)_%.bin $(HEXFIL
|
|||||||
|
|
||||||
%.bin : %.elf Makefile
|
%.bin : %.elf Makefile
|
||||||
$(OBJCOPY) $< -O binary $@
|
$(OBJCOPY) $< -O binary $@
|
||||||
|
$(SIZE) $<
|
||||||
|
|
||||||
%.dfu : %.bin Makefile
|
%.dfu : %.bin Makefile
|
||||||
python3 dfuse-pack.py -b $(DEVICE_DFU_ADDRESS)@0:$< -D $(DEVICE_DFU_VID_PID) $@
|
python3 dfuse-pack.py -b $(DEVICE_DFU_ADDRESS)@0:$< -D $(DEVICE_DFU_VID_PID) $@
|
||||||
|
|||||||
Reference in New Issue
Block a user