kopia lustrzana https://github.com/OpenRTX/OpenRTX
Implemented activation of external flash backup and restore via menu entries
rodzic
a1c26b2898
commit
ab3d148449
|
@ -31,7 +31,6 @@ openrtx_src = ['openrtx/src/core/state.c',
|
|||
'openrtx/src/core/dsp.cpp',
|
||||
'openrtx/src/core/cps.c',
|
||||
'openrtx/src/core/crc.c',
|
||||
'openrtx/src/core/xmodem.c',
|
||||
'openrtx/src/core/memory_profiling.cpp',
|
||||
'openrtx/src/ui/ui.c',
|
||||
'openrtx/src/ui/ui_main.c',
|
||||
|
@ -124,7 +123,9 @@ def = def + {'GIT_VERSION': git_version}
|
|||
## TYT MDx family
|
||||
##
|
||||
|
||||
mdx_src = ['platform/drivers/ADC/ADC1_MDx.c',
|
||||
mdx_src = ['openrtx/src/core/xmodem.c',
|
||||
'openrtx/src/core/backup.c',
|
||||
'platform/drivers/ADC/ADC1_MDx.c',
|
||||
'platform/drivers/GPS/GPS_MDx.cpp',
|
||||
'platform/drivers/NVM/W25Qx.c',
|
||||
'platform/drivers/NVM/nvmem_settings_MDx.c',
|
||||
|
@ -140,7 +141,9 @@ mdx_src = ['platform/drivers/ADC/ADC1_MDx.c',
|
|||
## GDx family: Radioddity GD-77 and Baofeng DM-1801
|
||||
##
|
||||
|
||||
gdx_src = ['platform/drivers/NVM/W25Qx.c',
|
||||
gdx_src = ['openrtx/src/core/xmodem.c',
|
||||
'openrtx/src/core/backup.c',
|
||||
'platform/drivers/NVM/W25Qx.c',
|
||||
'platform/drivers/NVM/AT24Cx_GDx.c',
|
||||
'platform/drivers/NVM/spiFlash_GDx.c',
|
||||
'platform/drivers/NVM/nvmem_GDx.c',
|
||||
|
|
|
@ -97,6 +97,7 @@ typedef struct
|
|||
bool zone_enabled;
|
||||
zone_t zone;
|
||||
uint8_t rtxStatus;
|
||||
bool rtxShutdown;
|
||||
|
||||
bool emergency;
|
||||
settings_t settings;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef XMODEM_H
|
||||
#define XMODEM_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ void state_init()
|
|||
state.channel_index = 1; // Set default channel index (it is 1-based)
|
||||
state.zone_enabled = false;
|
||||
state.rtxStatus = RTX_OFF;
|
||||
state.rtxShutdown = false;
|
||||
state.emergency = false;
|
||||
|
||||
// Force brightness field to be in range 0 - 100
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <interfaces/graphics.h>
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/delays.h>
|
||||
#include <interfaces/radio.h>
|
||||
#include <event.h>
|
||||
#include <rtx.h>
|
||||
#include <queue.h>
|
||||
|
@ -251,7 +252,18 @@ void *rtx_task(void *arg)
|
|||
while(1)
|
||||
{
|
||||
rtx_taskFunc();
|
||||
|
||||
// TODO: implement a cleaner shutdown procedure
|
||||
if(state.rtxShutdown == true)
|
||||
{
|
||||
radio_disableRtx();
|
||||
platform_ledOff(RED);
|
||||
platform_ledOff(GREEN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(HAS_GPS) && !defined(MD3x0_ENABLE_DBG)
|
||||
|
|
|
@ -118,7 +118,7 @@ size_t xmodem_receivePacket(void* data, uint8_t expectedBlockNum)
|
|||
return blockSize;
|
||||
}
|
||||
|
||||
ssize_t xmodem_sendData(size_t size, ssize_t (*callback)(uint8_t *, size_t))
|
||||
ssize_t xmodem_sendData(size_t size, int (*callback)(uint8_t *, size_t))
|
||||
{
|
||||
// Wait for the start command from the receiver, only CRC mode is supported.
|
||||
uint8_t cmd = 0;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <backup.h>
|
||||
#include <ui.h>
|
||||
#include <interfaces/nvmem.h>
|
||||
#include <interfaces/platform.h>
|
||||
|
@ -443,30 +444,68 @@ void _ui_drawMenuBackupRestore(ui_state_t* ui_state)
|
|||
|
||||
void _ui_drawMenuBackup(ui_state_t* ui_state)
|
||||
{
|
||||
(void) ui_state;
|
||||
|
||||
gfx_clearScreen();
|
||||
// Print "Flash Backup" on top bar
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "Flash Backup");
|
||||
// Print backup message
|
||||
gfx_print(layout.line2_pos, layout.line2_font, TEXT_ALIGN_CENTER,
|
||||
point_t line = layout.line2_pos;
|
||||
gfx_print(line, FONT_SIZE_8PT, TEXT_ALIGN_CENTER,
|
||||
color_white, "Connect to RTXTool");
|
||||
gfx_print(layout.line3_pos, layout.line2_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "to backup flash.");
|
||||
// TODO: Add call to xmodem send function
|
||||
line.y += 18;
|
||||
gfx_print(line, FONT_SIZE_8PT, TEXT_ALIGN_CENTER,
|
||||
color_white, "to backup flash and");
|
||||
line.y += 18;
|
||||
gfx_print(line, FONT_SIZE_8PT, TEXT_ALIGN_CENTER,
|
||||
color_white, "press PTT to start.");
|
||||
|
||||
// Shutdown RF stage
|
||||
state.rtxShutdown = true;
|
||||
|
||||
#ifndef PLATFORM_LINUX
|
||||
if(platform_getPttStatus() == 1)
|
||||
{
|
||||
platform_ledOn(GREEN);
|
||||
eflash_dump();
|
||||
platform_terminate();
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void _ui_drawMenuRestore(ui_state_t* ui_state)
|
||||
{
|
||||
(void) ui_state;
|
||||
|
||||
gfx_clearScreen();
|
||||
// Print "Flash Backup" on top bar
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "Flash Restore");
|
||||
// Print backup message
|
||||
gfx_print(layout.line2_pos, layout.line2_font, TEXT_ALIGN_CENTER,
|
||||
point_t line = layout.line2_pos;
|
||||
gfx_print(line, FONT_SIZE_8PT, TEXT_ALIGN_CENTER,
|
||||
color_white, "Connect to RTXTool");
|
||||
gfx_print(layout.line3_pos, layout.line2_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "to restore flash.");
|
||||
// TODO: Add call to xmodem receive function
|
||||
line.y += 18;
|
||||
gfx_print(line, FONT_SIZE_8PT, TEXT_ALIGN_CENTER,
|
||||
color_white, "to restore flash and");
|
||||
line.y += 18;
|
||||
gfx_print(line, FONT_SIZE_8PT, TEXT_ALIGN_CENTER,
|
||||
color_white, "press PTT to start.");
|
||||
|
||||
// Shutdown RF stage
|
||||
state.rtxShutdown = true;
|
||||
|
||||
#ifndef PLATFORM_LINUX
|
||||
if(platform_getPttStatus() == 1)
|
||||
{
|
||||
platform_ledOn(GREEN);
|
||||
eflash_restore();
|
||||
platform_terminate();
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void _ui_drawMenuInfo(ui_state_t* ui_state)
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2022 by Federico Amedeo Izzo IU2NUO, *
|
||||
* Niccolò Izzo IU2KIN, *
|
||||
* Frederik Saraci IU2NRO, *
|
||||
* Silvano Seva IU2KWO *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <xmodem.h>
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/delays.h>
|
||||
#include "W25Qx.h"
|
||||
|
||||
static const size_t FLASH_SIZE = 16*1024*1024; /* 16MB */
|
||||
size_t addr = 0;
|
||||
|
||||
int callback(uint8_t *ptr, size_t size)
|
||||
{
|
||||
if((addr + size) > FLASH_SIZE) return -1;
|
||||
W25Qx_readData(addr, ptr, size);
|
||||
addr += size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
platform_init();
|
||||
W25Qx_init();
|
||||
W25Qx_wakeup();
|
||||
|
||||
xmodem_sendData(FLASH_SIZE, callback);
|
||||
|
||||
while(1)
|
||||
{
|
||||
platform_ledOn(GREEN);
|
||||
sleepFor(1,0);
|
||||
platform_ledOff(GREEN);
|
||||
sleepFor(1,0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Ładowanie…
Reference in New Issue