keep target as L476; minimize RAM usage

pull/3/head
Clyne 4 years ago
parent 1b5ca39ba7
commit 3113d96497

@ -6,6 +6,7 @@
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) ifeq ($(USE_OPT),)
USE_OPT = -Og -ggdb -fomit-frame-pointer -falign-functions=16 -mtune=cortex-m4 USE_OPT = -Og -ggdb -fomit-frame-pointer -falign-functions=16 -mtune=cortex-m4
# USE_OPT = -Os -fomit-frame-pointer -falign-functions=16 -mtune=cortex-m4
endif endif
# C specific options here (added to USE_OPT). # C specific options here (added to USE_OPT).
@ -55,7 +56,7 @@ endif
# Stack size to be allocated to the Cortex-M process stack. This stack is # Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread. # the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),) ifeq ($(USE_PROCESS_STACKSIZE),)
USE_PROCESS_STACKSIZE = 4096 USE_PROCESS_STACKSIZE = 2048
endif endif
# Stack size to the allocated to the Cortex-M main/exceptions stack. This # Stack size to the allocated to the Cortex-M main/exceptions stack. This
@ -100,10 +101,10 @@ include $(CHIBIOS)/os/license/license.mk
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32l4xx.mk include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32l4xx.mk
# HAL-OSAL files (optional). # HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk include $(CHIBIOS)/os/hal/hal.mk
#include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform.mk include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform.mk
#include $(CHIBIOS)/os/hal/boards/ST_STM32L476_DISCOVERY/board.mk include $(CHIBIOS)/os/hal/boards/ST_STM32L476_DISCOVERY/board.mk
include $(CHIBIOS)/os/hal/boards/ST_NUCLEO32_L432KC/board.mk #include $(CHIBIOS)/os/hal/boards/ST_NUCLEO32_L432KC/board.mk
include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform_l432.mk #include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform_l432.mk
include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
# RTOS files (optional). # RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk include $(CHIBIOS)/os/rt/rt.mk
@ -117,7 +118,7 @@ include $(CHIBIOS)/tools/mk/autobuild.mk
# Define linker script file here. # Define linker script file here.
#LDSCRIPT= $(STARTUPLD)/STM32L476xG.ld #LDSCRIPT= $(STARTUPLD)/STM32L476xG.ld
LDSCRIPT= $(STARTUPLD)/STM32L432xC.ld LDSCRIPT= STM32L432xC_stmdsp.ld
# C sources that can be compiled in ARM or THUMB mode depending on the global # C sources that can be compiled in ARM or THUMB mode depending on the global
# setting. # setting.

@ -0,0 +1,85 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
* STM32L432xC memory setup.
*/
MEMORY
{
flash0 (rx) : org = 0x08000000, len = 256k
flash1 (rx) : org = 0x00000000, len = 0
flash2 (rx) : org = 0x00000000, len = 0
flash3 (rx) : org = 0x00000000, len = 0
flash4 (rx) : org = 0x00000000, len = 0
flash5 (rx) : org = 0x00000000, len = 0
flash6 (rx) : org = 0x00000000, len = 0
flash7 (rx) : org = 0x00000000, len = 0
ram0 (wx) : org = 0x20000000, len = 48k /* Save 16k of SRAM2 for loaded ELF */
ram1 (wx) : org = 0x00000000, len = 0
ram2 (wx) : org = 0x00000000, len = 0
ram3 (wx) : org = 0x00000000, len = 0
ram4 (wx) : org = 0x00000000, len = 0
ram5 (wx) : org = 0x00000000, len = 0
ram6 (wx) : org = 0x00000000, len = 0
ram7 (wx) : org = 0x00000000, len = 0
}
/* For each data/text section two region are defined, a virtual region
and a load region (_LMA suffix).*/
/* Flash region to be used for exception vectors.*/
REGION_ALIAS("VECTORS_FLASH", flash0);
REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
/* Flash region to be used for constructors and destructors.*/
REGION_ALIAS("XTORS_FLASH", flash0);
REGION_ALIAS("XTORS_FLASH_LMA", flash0);
/* Flash region to be used for code text.*/
REGION_ALIAS("TEXT_FLASH", flash0);
REGION_ALIAS("TEXT_FLASH_LMA", flash0);
/* Flash region to be used for read only data.*/
REGION_ALIAS("RODATA_FLASH", flash0);
REGION_ALIAS("RODATA_FLASH_LMA", flash0);
/* Flash region to be used for various.*/
REGION_ALIAS("VARIOUS_FLASH", flash0);
REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
/* Flash region to be used for RAM(n) initialization data.*/
REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
/* RAM region to be used for Main stack. This stack accommodates the processing
of all exceptions and interrupts.*/
REGION_ALIAS("MAIN_STACK_RAM", ram0);
/* RAM region to be used for the process stack. This is the stack used by
the main() function.*/
REGION_ALIAS("PROCESS_STACK_RAM", ram0);
/* RAM region to be used for data segment.*/
REGION_ALIAS("DATA_RAM", ram0);
REGION_ALIAS("DATA_RAM_LMA", flash0);
/* RAM region to be used for BSS segment.*/
REGION_ALIAS("BSS_RAM", ram0);
/* RAM region to be used for the default heap.*/
REGION_ALIAS("HEAP_RAM", ram0);
/* Generic rules inclusion.*/
INCLUDE rules.ld

@ -167,7 +167,7 @@
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_CFG_USE_REGISTRY) #if !defined(CH_CFG_USE_REGISTRY)
#define CH_CFG_USE_REGISTRY TRUE #define CH_CFG_USE_REGISTRY FALSE
#endif #endif
/** /**
@ -178,7 +178,7 @@
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_CFG_USE_WAITEXIT) #if !defined(CH_CFG_USE_WAITEXIT)
#define CH_CFG_USE_WAITEXIT TRUE #define CH_CFG_USE_WAITEXIT FALSE
#endif #endif
/** /**
@ -235,7 +235,7 @@
* @note Requires @p CH_CFG_USE_MUTEXES. * @note Requires @p CH_CFG_USE_MUTEXES.
*/ */
#if !defined(CH_CFG_USE_CONDVARS) #if !defined(CH_CFG_USE_CONDVARS)
#define CH_CFG_USE_CONDVARS TRUE #define CH_CFG_USE_CONDVARS FALSE
#endif #endif
/** /**
@ -247,7 +247,7 @@
* @note Requires @p CH_CFG_USE_CONDVARS. * @note Requires @p CH_CFG_USE_CONDVARS.
*/ */
#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT) #if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE #define CH_CFG_USE_CONDVARS_TIMEOUT FALSE
#endif #endif
/** /**
@ -269,7 +269,7 @@
* @note Requires @p CH_CFG_USE_EVENTS. * @note Requires @p CH_CFG_USE_EVENTS.
*/ */
#if !defined(CH_CFG_USE_EVENTS_TIMEOUT) #if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
#define CH_CFG_USE_EVENTS_TIMEOUT TRUE #define CH_CFG_USE_EVENTS_TIMEOUT FALSE
#endif #endif
/** /**
@ -280,7 +280,7 @@
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_CFG_USE_MESSAGES) #if !defined(CH_CFG_USE_MESSAGES)
#define CH_CFG_USE_MESSAGES TRUE #define CH_CFG_USE_MESSAGES FALSE
#endif #endif
/** /**
@ -306,7 +306,7 @@
* @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
*/ */
#if !defined(CH_CFG_USE_DYNAMIC) #if !defined(CH_CFG_USE_DYNAMIC)
#define CH_CFG_USE_DYNAMIC TRUE #define CH_CFG_USE_DYNAMIC FALSE
#endif #endif
/** @} */ /** @} */
@ -353,7 +353,7 @@
* @note Requires @p CH_CFG_USE_MEMCORE. * @note Requires @p CH_CFG_USE_MEMCORE.
*/ */
#if !defined(CH_CFG_MEMCORE_SIZE) #if !defined(CH_CFG_MEMCORE_SIZE)
#define CH_CFG_MEMCORE_SIZE 0 #define CH_CFG_MEMCORE_SIZE (3 * 1024)
#endif #endif
/** /**
@ -389,7 +389,7 @@
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_CFG_USE_OBJ_FIFOS) #if !defined(CH_CFG_USE_OBJ_FIFOS)
#define CH_CFG_USE_OBJ_FIFOS TRUE #define CH_CFG_USE_OBJ_FIFOS FALSE
#endif #endif
/** /**
@ -400,7 +400,7 @@
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_CFG_USE_PIPES) #if !defined(CH_CFG_USE_PIPES)
#define CH_CFG_USE_PIPES TRUE #define CH_CFG_USE_PIPES FALSE
#endif #endif
/** /**
@ -411,7 +411,7 @@
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_CFG_USE_OBJ_CACHES) #if !defined(CH_CFG_USE_OBJ_CACHES)
#define CH_CFG_USE_OBJ_CACHES TRUE #define CH_CFG_USE_OBJ_CACHES FALSE
#endif #endif
/** /**
@ -422,7 +422,7 @@
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_CFG_USE_DELEGATES) #if !defined(CH_CFG_USE_DELEGATES)
#define CH_CFG_USE_DELEGATES TRUE #define CH_CFG_USE_DELEGATES FALSE
#endif #endif
/** /**
@ -433,7 +433,7 @@
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_CFG_USE_JOBS) #if !defined(CH_CFG_USE_JOBS)
#define CH_CFG_USE_JOBS TRUE #define CH_CFG_USE_JOBS FALSE
#endif #endif
/** @} */ /** @} */
@ -453,7 +453,7 @@
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_CFG_USE_FACTORY) #if !defined(CH_CFG_USE_FACTORY)
#define CH_CFG_USE_FACTORY TRUE #define CH_CFG_USE_FACTORY FALSE
#endif #endif
/** /**
@ -469,42 +469,42 @@
* @brief Enables the registry of generic objects. * @brief Enables the registry of generic objects.
*/ */
#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY) #if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE #define CH_CFG_FACTORY_OBJECTS_REGISTRY FALSE
#endif #endif
/** /**
* @brief Enables factory for generic buffers. * @brief Enables factory for generic buffers.
*/ */
#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS) #if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE #define CH_CFG_FACTORY_GENERIC_BUFFERS FALSE
#endif #endif
/** /**
* @brief Enables factory for semaphores. * @brief Enables factory for semaphores.
*/ */
#if !defined(CH_CFG_FACTORY_SEMAPHORES) #if !defined(CH_CFG_FACTORY_SEMAPHORES)
#define CH_CFG_FACTORY_SEMAPHORES TRUE #define CH_CFG_FACTORY_SEMAPHORES FALSE
#endif #endif
/** /**
* @brief Enables factory for mailboxes. * @brief Enables factory for mailboxes.
*/ */
#if !defined(CH_CFG_FACTORY_MAILBOXES) #if !defined(CH_CFG_FACTORY_MAILBOXES)
#define CH_CFG_FACTORY_MAILBOXES TRUE #define CH_CFG_FACTORY_MAILBOXES FALSE
#endif #endif
/** /**
* @brief Enables factory for objects FIFOs. * @brief Enables factory for objects FIFOs.
*/ */
#if !defined(CH_CFG_FACTORY_OBJ_FIFOS) #if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
#define CH_CFG_FACTORY_OBJ_FIFOS TRUE #define CH_CFG_FACTORY_OBJ_FIFOS FALSE
#endif #endif
/** /**
* @brief Enables factory for Pipes. * @brief Enables factory for Pipes.
*/ */
#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__) #if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
#define CH_CFG_FACTORY_PIPES TRUE #define CH_CFG_FACTORY_PIPES FALSE
#endif #endif
/** @} */ /** @} */
@ -556,7 +556,7 @@
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_ENABLE_ASSERTS) #if !defined(CH_DBG_ENABLE_ASSERTS)
#define CH_DBG_ENABLE_ASSERTS TRUE #define CH_DBG_ENABLE_ASSERTS FALSE
#endif #endif
/** /**
@ -752,7 +752,7 @@
/*===========================================================================*/ /*===========================================================================*/
// Enable syscall support // Enable syscall support
#define PORT_USE_SYSCALL TRUE #define PORT_USE_SYSCALL FALSE
#endif /* CHCONF_H */ #endif /* CHCONF_H */

@ -142,7 +142,7 @@
* @brief Enables the SERIAL subsystem. * @brief Enables the SERIAL subsystem.
*/ */
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL TRUE #define HAL_USE_SERIAL FALSE
#endif #endif
/** /**
@ -230,7 +230,7 @@
* @note Disabling this option saves both code and data space. * @note Disabling this option saves both code and data space.
*/ */
#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) #if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
#define ADC_USE_WAIT TRUE #define ADC_USE_WAIT FALSE
#endif #endif
/** /**
@ -238,7 +238,7 @@
* @note Disabling this option saves both code and data space. * @note Disabling this option saves both code and data space.
*/ */
#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
#define ADC_USE_MUTUAL_EXCLUSION TRUE #define ADC_USE_MUTUAL_EXCLUSION FALSE
#endif #endif
/*===========================================================================*/ /*===========================================================================*/
@ -290,7 +290,7 @@
* @note Disabling this option saves both code and data space. * @note Disabling this option saves both code and data space.
*/ */
#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__) #if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
#define DAC_USE_WAIT TRUE #define DAC_USE_WAIT FALSE
#endif #endif
/** /**
@ -298,7 +298,7 @@
* @note Disabling this option saves both code and data space. * @note Disabling this option saves both code and data space.
*/ */
#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) #if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
#define DAC_USE_MUTUAL_EXCLUSION TRUE #define DAC_USE_MUTUAL_EXCLUSION FALSE
#endif #endif
/*===========================================================================*/ /*===========================================================================*/

@ -32,9 +32,8 @@
#define MCUCONF_H #define MCUCONF_H
#define STM32L4xx_MCUCONF #define STM32L4xx_MCUCONF
//#define STM32L476_MCUCONF #define STM32L476_MCUCONF
#define STM32L432_MCUCONF //#define STM32L432_MCUCONF
//#define STM32L433_MCUCONF
/* /*
* HAL driver system settings. * HAL driver system settings.

@ -21,7 +21,8 @@
constexpr unsigned int MAX_ELF_FILE_SIZE = 8 * 1024; constexpr unsigned int MAX_ELF_FILE_SIZE = 8 * 1024;
constexpr unsigned int MAX_ERROR_QUEUE_SIZE = 8; constexpr unsigned int MAX_ERROR_QUEUE_SIZE = 8;
constexpr unsigned int MAX_SAMPLE_BUFFER_SIZE = 8000; constexpr unsigned int MAX_SAMPLE_BUFFER_SIZE = 6000;
constexpr unsigned int MAX_SIGGEN_BUFFER_SIZE = 3000;
enum class RunStatus : char enum class RunStatus : char
{ {
@ -61,7 +62,7 @@ static Error error_queue_pop()
static msg_t conversionMBBuffer[4]; static msg_t conversionMBBuffer[4];
static MAILBOX_DECL(conversionMB, conversionMBBuffer, 4); static MAILBOX_DECL(conversionMB, conversionMBBuffer, 4);
static THD_WORKING_AREA(conversionThreadWA, 1024); static THD_WORKING_AREA(conversionThreadWA, 2048);
static THD_FUNCTION(conversionThread, arg); static THD_FUNCTION(conversionThread, arg);
static time_measurement_t conversion_time_measurement; static time_measurement_t conversion_time_measurement;
@ -80,7 +81,7 @@ static std::array<dacsample_t, CACHE_SIZE_ALIGN(dacsample_t, MAX_SAMPLE_BUFFER_S
#if CACHE_LINE_SIZE > 0 #if CACHE_LINE_SIZE > 0
CC_ALIGN(CACHE_LINE_SIZE) CC_ALIGN(CACHE_LINE_SIZE)
#endif #endif
static std::array<dacsample_t, CACHE_SIZE_ALIGN(dacsample_t, MAX_SAMPLE_BUFFER_SIZE)> dac2_samples; static std::array<dacsample_t, CACHE_SIZE_ALIGN(dacsample_t, MAX_SIGGEN_BUFFER_SIZE)> dac2_samples;
static uint8_t elf_file_store[MAX_ELF_FILE_SIZE]; static uint8_t elf_file_store[MAX_ELF_FILE_SIZE];
static elf::entry_t elf_entry = nullptr; static elf::entry_t elf_entry = nullptr;
@ -116,7 +117,7 @@ int main()
} }
static unsigned int dac_sample_count = MAX_SAMPLE_BUFFER_SIZE; static unsigned int dac_sample_count = MAX_SAMPLE_BUFFER_SIZE;
static unsigned int dac2_sample_count = MAX_SAMPLE_BUFFER_SIZE; static unsigned int dac2_sample_count = MAX_SIGGEN_BUFFER_SIZE;
static unsigned int adc_sample_count = MAX_SAMPLE_BUFFER_SIZE; static unsigned int adc_sample_count = MAX_SAMPLE_BUFFER_SIZE;
void main_loop() void main_loop()
@ -160,7 +161,7 @@ void main_loop()
case 'D': case 'D':
if (usbserial::read(&cmd[1], 2) == 2) { if (usbserial::read(&cmd[1], 2) == 2) {
unsigned int count = cmd[1] | (cmd[2] << 8); unsigned int count = cmd[1] | (cmd[2] << 8);
if (count <= MAX_SAMPLE_BUFFER_SIZE / 2) { if (count <= MAX_SIGGEN_BUFFER_SIZE) {
dac2_sample_count = count; dac2_sample_count = count;
usbserial::read(&dac2_samples[0], dac2_sample_count * sizeof(dacsample_t)); usbserial::read(&dac2_samples[0], dac2_sample_count * sizeof(dacsample_t));
} else { } else {

Loading…
Cancel
Save