Adjust stack sizes for tasks, trying to gain RAM. fix some compile faults with particular options

pull/49/head
Pawel Jalocha 2022-05-21 21:11:40 +01:00
rodzic d7e3e08110
commit c7845b9c72
7 zmienionych plików z 55 dodań i 47 usunięć

Wyświetl plik

@ -192,6 +192,7 @@ int BT_SPP_Init(void)
Err = esp_bt_controller_init(&BTconf); if(Err!=ESP_OK) return Err;
Err = esp_bt_controller_enable((esp_bt_mode_t)BTconf.mode); if(Err!=ESP_OK) return Err; // mode must be same as in BTconf
// Err = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT); if(Err!=ESP_OK) return Err;
Err = esp_bt_controller_mem_release(ESP_BT_MODE_BTDM); // this is supposed to release 30kB of RAM
Err = esp_bluedroid_init(); if(Err!=ESP_OK) return Err; // init the BT stack
Err = esp_bluedroid_enable(); if(Err!=ESP_OK) return Err; // enable the BT stack
Err = esp_bt_gap_register_callback(esp_bt_gap_cb); if(Err!=ESP_OK) return Err;

Wyświetl plik

@ -190,10 +190,12 @@ void vTaskDISP(void* pvParameters)
case 5: OLED_DrawBattery (&U8G2_OLED, GPS); break;
case 6: OLED_DrawAltitudeAndSpeed (&U8G2_OLED, GPS); break;
case 7: OLED_DrawRelay (&U8G2_OLED, GPS); break;
case 8: OLED_DrawLookout (&U8G2_OLED, GPS); break;
case 9: OLED_DrawTrafWarn (&U8G2_OLED, GPS); break;
case 10: OLED_DrawFlight (&U8G2_OLED, GPS); break;
case 11: OLED_DrawLoRaWAN (&U8G2_OLED, GPS); break;
case 8: OLED_DrawFlight (&U8G2_OLED, GPS); break;
case 9: OLED_DrawLoRaWAN (&U8G2_OLED, GPS); break;
#ifdef WITH_LOOKOUT
case 10: OLED_DrawLookout (&U8G2_OLED, GPS); break;
case 11: OLED_DrawTrafWarn (&U8G2_OLED, GPS); break;
#endif
}
}
//if ( DISP_Page != 6 )

Wyświetl plik

@ -365,6 +365,7 @@ void OLED_DrawRelay(u8g2_t *OLED, GPS_Position *GPS)
}
}
#ifdef WITH_LOOKOUT
void OLED_DrawLookout(u8g2_t *OLED, GPS_Position *GPS)
{ u8g2_SetFont(OLED, u8g2_font_amstrad_cpc_extended_8r);
uint8_t Len=Format_String(Line, "=> ");
@ -429,6 +430,7 @@ void OLED_DrawTrafWarn(u8g2_t *OLED, GPS_Position *GPS)
Line[Len]=0;
u8g2_DrawStr(OLED, 0, 60, Line);
}
#endif // WITH_LOOKOUT
void OLED_DrawBaro(u8g2_t *OLED, GPS_Position *GPS)
{ u8g2_SetFont(OLED, u8g2_font_7x13_tf); // 5 lines, 12 pixels/line

Wyświetl plik

@ -21,11 +21,12 @@ class SHA256
mbedtls_sha256_context Context;
public:
void Init(void) { mbedtls_sha256_init(&Context); }
void Free(void) { mbedtls_sha256_free(&Context); }
int Start(void) { return mbedtls_sha256_starts_ret(&Context, 0); }
int Update(const uint8_t *Input, size_t Len) { return mbedtls_sha256_update_ret(&Context, Input, Len); }
int Finish(uint8_t CheckSum[32]) { return mbedtls_sha256_finish_ret(&Context, CheckSum); }
void Init(void) { mbedtls_sha256_init(&Context); }
void Free(void) { mbedtls_sha256_free(&Context); }
int Start(void) { return mbedtls_sha256_starts_ret(&Context, 0); }
int Update(const uint8_t *Input, size_t Len) { return mbedtls_sha256_update_ret(&Context, Input, Len); }
void Clone(const SHA256 &Src) { mbedtls_sha256_clone(&Context, &Src.Context); }
int Finish(uint8_t CheckSum[32]) { return mbedtls_sha256_finish_ret(&Context, CheckSum); }
} ;

Wyświetl plik

@ -234,7 +234,7 @@ class LookOut
NMEA[Len++]=',';
if(Tgt) // ID
#ifdef WITH_SKYDEMON
{ Len+=Format_Hex(NMEA+Len, Tgt->ID & 0x00FFFFFF); }
{ Len+=Format_Hex(NMEA+Len, Tgt->ID & 0x00FFFFFF); } // maybe just 6 digits should be produced ?
#else
{ Len+=Format_Hex(NMEA+Len, Tgt->ID); }
#endif

Wyświetl plik

@ -101,11 +101,11 @@ void app_main(void)
#ifdef WITH_SDLOG
Log_Mutex = xSemaphoreCreateMutex();
xTaskCreate(vTaskSDLOG, "SDLOG", 4000, 0, tskIDLE_PRIORITY+1, 0);
xTaskCreate(vTaskSDLOG, "SDLOG", 3000, 0, tskIDLE_PRIORITY+1, 0);
#endif
#ifdef WITH_LOG
xTaskCreate(vTaskLOG , "LOG", 5000, 0, tskIDLE_PRIORITY+1, 0);
xTaskCreate(vTaskLOG , "LOG", 4500, 0, tskIDLE_PRIORITY+1, 0);
#endif
xTaskCreate(vTaskRF, "RF", 2000, 0, tskIDLE_PRIORITY+5, 0);
@ -136,7 +136,7 @@ void app_main(void)
bool StartAP = Parameters.APname[0]; // start WiFi AP when APname non-empty
#endif
if(StartAP)
xTaskCreate(vTaskAP, "AP", 4000, 0, tskIDLE_PRIORITY+3, 0);
xTaskCreate(vTaskAP, "AP", 3000, 0, tskIDLE_PRIORITY+3, 0);
#else // WITH_AP
const bool StartAP=0;
#endif // WITH_AP
@ -145,7 +145,7 @@ void app_main(void)
xTaskCreate(vTaskAPRS, "APRS", 4000, 0, tskIDLE_PRIORITY+2, 0);
#endif
#if defined(WITH_OLED) || defined(WITH_U8G2_OLED) || defined(WITH_ST7789) || defined(WITH_ILI9341)
xTaskCreate(vTaskDISP, "DISP", 3000, 0, tskIDLE_PRIORITY+2, 0);
xTaskCreate(vTaskDISP, "DISP", 2000, 0, tskIDLE_PRIORITY+2, 0);
#endif
#ifdef WITH_SOUND
xTaskCreate(vTaskSOUND, "SOUND", 2000, 0, tskIDLE_PRIORITY+3, 0);

Wyświetl plik

@ -582,7 +582,7 @@ void vTaskPROC(void* pvParameters)
Format_UnsDec(CONS_UART_Write, TimeSync_msTime(), 3);
Format_String(CONS_UART_Write, " -> Sent\n");
xSemaphoreGive(CONS_Mutex);
#endif
#endif // DEBUG_PRINT
PosTime=Position->getUnixTime();
PosPacket.Packet.HeaderWord=0;
PosPacket.Packet.Header.Address = Parameters.Address; // set address
@ -590,7 +590,7 @@ void vTaskPROC(void* pvParameters)
#ifdef WITH_ENCRYPT
if(Parameters.Encrypt) // if position encryption is requested
{ PosPacket.Packet.Header.Encrypted = 1; } // then set the flg in the header
#endif
#endif // WITH_ENCRYPT
PosPacket.Packet.calcAddrParity(); // parity of (part of) the header
if(BestResid==0) Position->Encode(PosPacket.Packet); // encode position/altitude/speed/etc. from GPS position
else // extrapolate the position when if not at an exact UTC second
@ -603,16 +603,16 @@ void vTaskPROC(void* pvParameters)
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
Format_String(CONS_UART_Write, Line, 0, Len);
xSemaphoreGive(CONS_Mutex); }
#endif
#endif // DEBUG_PRINT
OGN_TxPacket<OGN_Packet> *TxPacket = RF_TxFIFO.getWrite();
TxPacket->Packet = PosPacket.Packet; // copy the position packet to the TxFIFO
#ifdef WITH_ENCRYPT
if(Parameters.Encrypt) TxPacket->Packet.Encrypt(Parameters.EncryptKey); // if encryption is requested then encrypt
else TxPacket->Packet.Whiten(); // otherwise only whiten
#else
#else // WITH_ENCRYPT
TxPacket->Packet.Whiten(); // just whiten if there is no encryption
#endif
#endif // WITH_ENCRYPT
TxPacket->calcFEC(); // calculate FEC code
#ifdef DEBUG_PRINT
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
@ -624,7 +624,7 @@ void vTaskPROC(void* pvParameters)
Format_Hex(CONS_UART_Write, TxPacket->Packet.HeaderWord);
CONS_UART_Write('\r'); CONS_UART_Write('\n');
xSemaphoreGive(CONS_Mutex);
#endif
#endif // WITH_ENCRYPT
XorShift32(RX_Random);
static uint8_t TxBackOff=0;
if(TxBackOff) TxBackOff--;
@ -645,33 +645,33 @@ void vTaskPROC(void* pvParameters)
XorShift32(RX_Random);
FNT_TxFIFO.Write();
FNTbackOff = 8+(RX_Random&0x1); } // every 9 or 10sec
#endif
#endif // WITH_FANET
#ifdef WITH_LOOKOUT
const LookOut_Target *Tgt=Look.ProcessOwn(PosPacket.Packet); // process own position, get the most dangerous target
const LookOut_Target *Tgt=Look.ProcessOwn(PosPacket.Packet); // process own position, get the most dangerous target
#ifdef WITH_PFLAA
if(Parameters.Verbose)
{ xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
Look.WritePFLA(CONS_UART_Write); // produce PFLAU and PFLAA for all tracked targets
xSemaphoreGive(CONS_Mutex);
if(Parameters.Verbose)
{ xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
Look.WritePFLA(CONS_UART_Write); // produce PFLAU and PFLAA for all tracked targets
xSemaphoreGive(CONS_Mutex);
#ifdef WITH_SDLOG
if(Log_Free()>=512)
{ xSemaphoreTake(Log_Mutex, portMAX_DELAY);
Look.WritePFLA(Log_Write);
xSemaphoreGive(Log_Mutex); }
#endif
if(Log_Free()>=512)
{ xSemaphoreTake(Log_Mutex, portMAX_DELAY);
Look.WritePFLA(Log_Write);
xSemaphoreGive(Log_Mutex); }
#endif // WITH_SDLOG
}
#else
#else // WITH_PFLAA
if(Parameters.Verbose)
{ uint8_t Len=Look.WritePFLAU(Line); // $PFLAU, overall status
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
Format_String(CONS_UART_Write, Line, 0, Len);
xSemaphoreGive(CONS_Mutex);
#ifdef WITH_SDLOG
if(Log_Free()>=128)
{ xSemaphoreTake(Log_Mutex, portMAX_DELAY);
Format_String(Log_Write, Line, 0, Len); // send the NMEA out to the log file
xSemaphoreGive(Log_Mutex); }
#endif
if(Log_Free()>=128)
{ xSemaphoreTake(Log_Mutex, portMAX_DELAY);
Format_String(Log_Write, Line, 0, Len); // send the NMEA out to the log file
xSemaphoreGive(Log_Mutex); }
#endif // WITH_SDLOG
}
#endif // WITH_PFLAA
uint8_t Warn = 0;
@ -699,9 +699,10 @@ void vTaskPROC(void* pvParameters)
#endif // WITH_BEEPER
#ifdef WITH_SOUND
Sound_TrafficWarn(Tgt);
#endif
#endif // WITH_SOUND
}
#else // WITH_LOOKOUT
#ifdef WITH_PFLAA
if(Parameters.Verbose)
{ uint8_t Len=Look.WritePFLAU(Line); // $PFLAU, overall status
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
@ -712,8 +713,9 @@ void vTaskPROC(void* pvParameters)
{ xSemaphoreTake(Log_Mutex, portMAX_DELAY);
Format_String(Log_Write, Line, 0, Len); // send the NMEA out to the log file
xSemaphoreGive(Log_Mutex); }
#endif
#endif // WITH_SDLOG
}
#endif // WITH_PFLAA
#endif // WITH_LOOKOUT
#ifdef WITH_FLASHLOG
bool Written=FlashLog_Process(PosPacket.Packet, PosTime);
@ -729,10 +731,10 @@ void vTaskPROC(void* pvParameters)
{
#ifdef WITH_APRS
APRStx_FIFO.Write(PosPacket);
#endif
#endif // WITH_APRS
#ifdef WITH_LOG
FlashLog(&PosPacket, PosTime);
#endif
#endif // WITH_APRS
PrevLoggedPacket = PosPacket.Packet;
}
} else // if GPS position is not complete, contains no valid position, etc.
@ -747,7 +749,7 @@ void vTaskPROC(void* pvParameters)
Format_Hex(CONS_UART_Write, TxPacket->Packet.HeaderWord);
CONS_UART_Write('\r'); CONS_UART_Write('\n');
xSemaphoreGive(CONS_Mutex);
#endif
#endif // DEBUG_PRINT
XorShift32(RX_Random);
if(PosTime && ((RX_Random&0x7)==0) ) // send if some position in the packet and at 1/8 normal rate
RF_TxFIFO.Write(); // complete the write into the TxFIFO
@ -760,7 +762,7 @@ void vTaskPROC(void* pvParameters)
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
Format_String(CONS_UART_Write, Line);
xSemaphoreGive(CONS_Mutex);
#endif
#endif // DEBUG_PRINT
#ifdef WITH_FANET
if(Parameters.Pilot[0] && (SlotTime&0xFF)==(RX_Random&0xFF) ) // every 256sec
@ -769,7 +771,7 @@ void vTaskPROC(void* pvParameters)
FNTpkt->setName(Parameters.Pilot);
XorShift32(RX_Random);
FNT_TxFIFO.Write(); }
#endif
#endif // WITH_FANET
StatPacket.Packet.HeaderWord=0;
StatPacket.Packet.Header.Address = Parameters.Address; // set address
@ -791,10 +793,10 @@ void vTaskPROC(void* pvParameters)
{ StatTxBackOff=16+(RX_Random%15);
#ifdef WITH_APRS
APRStx_FIFO.Write(StatPacket);
#endif
#endif // WITH_APRS
#ifdef WITH_LOG
FlashLog(&StatPacket, PosTime); // log the status packet
#endif
#endif // WITH_LOG
*StatusPacket = StatPacket; // copy status packet into the Tx queue
StatusPacket->Packet.Whiten(); // whiten for transmission
StatusPacket->calcFEC(); // calc. the FEC code
@ -817,7 +819,7 @@ void vTaskPROC(void* pvParameters)
Format_Hex(CONS_UART_Write, RelayPacket->Packet.HeaderWord);
CONS_UART_Write('\r'); CONS_UART_Write('\n');
xSemaphoreGive(CONS_Mutex);
#endif
#endif // DEBUG_PRINT
RF_TxFIFO.Write();
}
CleanRelayQueue(SlotTime);