mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
Fix RF Log corrupting overlay apps on launch (issue #583)
This commit is contained in:
1 parent
9d8e082ea2
commit
889813e802
3 files changed
+32
-1
No files matched your search
+14
-1
@@ -131,6 +131,7 @@ static uint16_t gSessionChannel;
|
||||
static uint16_t gSessionTicks500ms;
|
||||
static uint8_t gSessionSMeter;
|
||||
static uint8_t gSessionBattVolt;
|
||||
static bool gSuspended;
|
||||
|
||||
static uint16_t gLogCursor;
|
||||
static uint8_t gLogFilter;
|
||||
@@ -922,7 +923,7 @@ uint32_t RXTX_LOG_SendK5ViewerHistoryPage(uint32_t beforeSeq, void (*send)(const
|
||||
|
||||
static void RXTX_LOG_CaptureSession(uint8_t flags, const VFO_Info_t *vfo)
|
||||
{
|
||||
if (!RXTX_LOG_IsEnabled() || vfo == NULL || gClearActive)
|
||||
if (gSuspended || !RXTX_LOG_IsEnabled() || vfo == NULL || gClearActive)
|
||||
return;
|
||||
|
||||
const uint32_t frequency = (flags & RXTX_LOG_FLAG_TX) ? vfo->pTX->Frequency : vfo->pRX->Frequency;
|
||||
@@ -961,6 +962,7 @@ void RXTX_LOG_Init(void)
|
||||
gLogCursor = 0;
|
||||
gLogFilter = RXTX_LOG_FILTER_ALL;
|
||||
gSessionActive = false;
|
||||
gSuspended = false;
|
||||
gSessionSMeter = RXTX_LOG_SMETER_UNKNOWN;
|
||||
gSessionBattVolt = RXTX_LOG_BATT_UNKNOWN;
|
||||
gClearActive = false;
|
||||
@@ -1060,6 +1062,17 @@ void RXTX_LOG_EndActive(void)
|
||||
RXTX_LOG_ResetActiveSession();
|
||||
}
|
||||
|
||||
void RXTX_LOG_Suspend(void)
|
||||
{
|
||||
RXTX_LOG_EndActive();
|
||||
gSuspended = true;
|
||||
}
|
||||
|
||||
void RXTX_LOG_Resume(void)
|
||||
{
|
||||
gSuspended = false;
|
||||
}
|
||||
|
||||
void RXTX_LOG_Tick500ms(void)
|
||||
{
|
||||
if (gSessionActive) {
|
||||
|
||||
@@ -76,6 +76,8 @@ bool RXTX_LOG_IsEnabled(void);
|
||||
void RXTX_LOG_BeginRx(const VFO_Info_t *vfo, FUNCTION_Type_t function);
|
||||
void RXTX_LOG_BeginTx(const VFO_Info_t *vfo);
|
||||
void RXTX_LOG_EndActive(void);
|
||||
void RXTX_LOG_Suspend(void);
|
||||
void RXTX_LOG_Resume(void);
|
||||
void RXTX_LOG_Task10ms(void);
|
||||
void RXTX_LOG_Tick500ms(void);
|
||||
const char *RXTX_LOG_GetFilterName(void);
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
#include "k5viewer.h"
|
||||
#endif
|
||||
#include "app/app.h"
|
||||
#ifdef ENABLE_FEAT_F4HWN_RXTX_LOG
|
||||
#include "app/rxtx_log.h"
|
||||
#endif
|
||||
#include "ui/helper.h"
|
||||
#include "ui/main.h"
|
||||
#include "ui/status.h"
|
||||
@@ -1105,6 +1108,13 @@ uint8_t APP_LaunchOverlay(uint8_t slot)
|
||||
if (h.link_vma != (uint32_t)ws)
|
||||
return APP_ERR_VMA;
|
||||
|
||||
/* Flush and suspend RF logging before the sector cache becomes executable
|
||||
* app code. Both a pending RX and an app-owned TX could otherwise write a
|
||||
* log entry through the same 4 KiB buffer and overwrite the running app. */
|
||||
#ifdef ENABLE_FEAT_F4HWN_RXTX_LOG
|
||||
RXTX_LOG_Suspend();
|
||||
#endif
|
||||
|
||||
/* Repurpose the sector cache: drop any cached config sector, load the code
|
||||
* straight in (ReadBuffer bypasses the cache), and verify it in RAM before
|
||||
* trusting it. Zeroing first leaves the app's .bss clean. */
|
||||
@@ -1114,6 +1124,9 @@ uint8_t APP_LaunchOverlay(uint8_t slot)
|
||||
|
||||
if (MB_Crc32Bytes(ws, h.code_size) != h.code_crc32) {
|
||||
PY25Q16_InvalidateCache();
|
||||
#ifdef ENABLE_FEAT_F4HWN_RXTX_LOG
|
||||
RXTX_LOG_Resume();
|
||||
#endif
|
||||
return APP_ERR_CRC;
|
||||
}
|
||||
|
||||
@@ -1210,6 +1223,9 @@ uint8_t APP_LaunchOverlay(uint8_t slot)
|
||||
SETTINGS_SaveFM();
|
||||
PY25Q16_InvalidateCache();
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_FEAT_F4HWN_RXTX_LOG
|
||||
RXTX_LOG_Resume();
|
||||
#endif
|
||||
return APP_OK;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user