some memory savings

sipo
Ondřej Hruška 7 years ago
parent 26934a0984
commit c58787c95d
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 8
      cortex_handlers.c
  2. 18
      freertos.c
  3. 4
      gex.mk
  4. 16
      platform/plat_compat.h

@ -37,7 +37,7 @@ void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName)
// && (__CORTEX_M >= 3)
#if VERBOSE_HARDFAULT
void prvGetRegistersFromStack( uint32_t *origStack, uint32_t lr_value)
void __attribute__((used)) HardFault_DumpRegisters( uint32_t *origStack, uint32_t lr_value)
{
/* These are volatile to try and prevent the compiler/linker optimising them
away as the variables never actually get used. If the debugger won't show the
@ -179,7 +179,7 @@ void __attribute__((naked)) HardFault_Handler(void)
// " mov r2, lr \n"
// " ldr r3, handler2_address_const \n"
// " bx r3 \n"
// " handler2_address_const: .word prvGetRegistersFromStack \n"
// " handler2_address_const: .word HardFault_DumpRegisters \n"
// );
//
__asm volatile( ".syntax unified\n"
@ -188,10 +188,10 @@ void __attribute__((naked)) HardFault_Handler(void)
"TST R0, R1 \n"
"BEQ _MSP \n"
"MRS R0, PSP \n"
"B prvGetRegistersFromStack \n"
"B HardFault_DumpRegisters \n"
"_MSP: \n"
"MRS R0, MSP \n"
"B prvGetRegistersFromStack \n"
"B HardFault_DumpRegisters \n"
".syntax divided\n") ;
#endif

@ -59,15 +59,15 @@
/* Variables -----------------------------------------------------------------*/
osThreadId tskMainHandle;
uint32_t mainTaskBuffer[ TSK_STACK_MAIN ];
uint32_t mainTaskStack[ TSK_STACK_MAIN ];
osStaticThreadDef_t mainTaskControlBlock;
osThreadId tskMsgHandle;
uint32_t msgTaskBuffer[ TSK_STACK_MSG ];
uint32_t msgTaskStack[ TSK_STACK_MSG ];
osStaticThreadDef_t msgTaskControlBlock;
osThreadId tskJobRunnerHandle;
uint32_t jobRunnerBuffer[ TSK_STACK_JOBRUNNER ];
uint32_t jobRunnerStack[ TSK_STACK_JOBRUNNER ];
osStaticThreadDef_t jobRunnerControlBlock;
osMessageQId queSchedHandle;
@ -135,9 +135,9 @@ void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackTy
void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN Init */
stackmon_register("Main", mainTaskBuffer, sizeof(mainTaskBuffer));
stackmon_register("JobRunner", jobRunnerBuffer, sizeof(jobRunnerBuffer));
stackmon_register("Messaging", msgTaskBuffer, sizeof(msgTaskBuffer));
stackmon_register("Main", mainTaskStack, sizeof(mainTaskStack));
stackmon_register("JobRunner", jobRunnerStack, sizeof(jobRunnerStack));
stackmon_register("Messaging", msgTaskStack, sizeof(msgTaskStack));
/* USER CODE END Init */
/* Create the mutex(es) */
@ -168,15 +168,15 @@ void MX_FREERTOS_Init(void) {
/* Create the thread(s) */
/* definition and creation of tskMain */
osThreadStaticDef(tskMain, TaskMain, osPriorityHigh, 0, TSK_STACK_MAIN, mainTaskBuffer, &mainTaskControlBlock);
osThreadStaticDef(tskMain, TaskMain, osPriorityHigh, 0, TSK_STACK_MAIN, mainTaskStack, &mainTaskControlBlock);
tskMainHandle = osThreadCreate(osThread(tskMain), NULL);
/* definition and creation of tskJobRunner */
osThreadStaticDef(tskJobRunner, TaskJobQueue, osPriorityAboveNormal, 0, TSK_STACK_JOBRUNNER, jobRunnerBuffer, &jobRunnerControlBlock);
osThreadStaticDef(tskJobRunner, TaskJobQueue, osPriorityAboveNormal, 0, TSK_STACK_JOBRUNNER, jobRunnerStack, &jobRunnerControlBlock);
tskJobRunnerHandle = osThreadCreate(osThread(tskJobRunner), NULL);
/* definition and creation of TaskMessaging */
osThreadStaticDef(tskMsg, TaskMessaging, osPriorityNormal, 0, TSK_STACK_MSG, msgTaskBuffer, &msgTaskControlBlock);
osThreadStaticDef(tskMsg, TaskMessaging, osPriorityNormal, 0, TSK_STACK_MSG, msgTaskStack, &msgTaskControlBlock);
tskMsgHandle = osThreadCreate(osThread(tskMsg), NULL);
/* USER CODE BEGIN RTOS_THREADS */

@ -83,8 +83,8 @@ GEX_CDEFS = $(GEX_CDEFS_BASE) \
-DVERBOSE_ASSERT=1 \
-DDEBUG_VFS=0 \
-DDEBUG_FLASH_WRITE=0 \
-DVERBOSE_HARDFAULT=0 \
-DUSE_STACK_MONITOR=0 \
-DVERBOSE_HARDFAULT=1 \
-DUSE_STACK_MONITOR=1 \
-DUSE_DEBUG_UART=1
endif

@ -8,17 +8,23 @@
#define VFS_DRIVE_NAME "GEX"
// -------- Static buffers ---------
#define TSK_STACK_MAIN 220 // USB / VFS task stack size
#define TSK_STACK_MSG 220 // TF message handler task stack size
#define TSK_STACK_JOBRUNNER 80 // Job runner task stack size
// USB / VFS task stack size
#if DISABLE_MSC
#define TSK_STACK_MAIN 100 // without MSC the stack usage is significantly lower
#else
#define TSK_STACK_MAIN 160
#endif
#define TSK_STACK_MSG 220 // TF message handler task stack size (all unit commands run on this thread)
#define TSK_STACK_JOBRUNNER 80 // Job runner task stack size (for async execution of events caught in interrupt)
#define BULK_READ_BUF_LEN 256 // Buffer for TF bulk reads
#define UNIT_TMP_LEN 512 // Buffer for bulk read and varions internal unit operations
#define FLASH_SAVE_BUF_LEN 256 // Static buffer for saving to flash
#define FLASH_SAVE_BUF_LEN 128 // Static buffer for saving to flash
#define JOB_QUEUE_CAPACITY 4 // Job runner queue size (16 bytes each)
#define RX_QUE_CAPACITY 10 // TinyFrame rx queue size (64 bytes each)
#define RX_QUE_CAPACITY 6 // TinyFrame rx queue size (64 bytes each)
#define TF_MAX_PAYLOAD_RX 512 // TF max Rx payload
#define TF_SENDBUF_LEN 64 // TF transmit buffer (can be less than a full frame)

Loading…
Cancel
Save