chore(radio): remove EEPROM macros and related code (#5461)

This commit is contained in:
philmoz
2024-08-22 10:32:16 +10:00
committed by GitHub
parent 8cfa5b4846
commit e0ec49d84e
83 changed files with 27 additions and 3177 deletions
@@ -32,11 +32,7 @@ enum MemoryType {
MEM_EEPROM
};
#if defined(EEPROM)
#define getBinaryPath(mt) ((mt == MEM_FLASH) ? FIRMWARES_PATH : EEPROMS_PATH)
#else
#define getBinaryPath(mt) (FIRMWARES_PATH)
#endif
#if LCD_H == 480
#define MAX_NAMES_ON_SCREEN 13
@@ -48,7 +48,7 @@
#include "thirdparty/Segger_RTT/RTT/SEGGER_RTT.h"
#endif
#if defined(EEPROM) || defined(SPI_FLASH)
#if defined(SPI_FLASH)
#define MAIN_MENU_LEN 3
#else
#define MAIN_MENU_LEN 2
@@ -79,11 +79,6 @@ uint32_t firmwareSize;
uint32_t firmwareAddress = FIRMWARE_ADDRESS;
uint32_t firmwareWritten = 0;
#if defined(EEPROM)
uint32_t eepromAddress = 0;
uint32_t eepromWritten = 0;
#endif
FlashCheckRes valid;
MemoryType memoryType;
uint32_t unlocked = 0;
@@ -112,14 +107,7 @@ void per10ms()
uint32_t isValidBufferStart(const uint8_t * buffer)
{
#if !defined(SIMU)
#if defined(EEPROM)
if (memoryType == MEM_FLASH)
return isFirmwareStart(buffer);
else
return isEepromStart(buffer);
#else
return isFirmwareStart(buffer);
#endif
#else
return 1;
#endif
@@ -182,14 +170,6 @@ void flashWriteBlock()
#endif // SIMU
}
#if defined(EEPROM)
void writeEepromBlock()
{
eepromWriteBlock(Block_buffer, eepromAddress, BlockCount);
eepromAddress += BlockCount;
}
#endif
#if !defined(SIMU)
typedef void (*fctptr_t)(void);
@@ -249,17 +229,13 @@ void bootloaderInitApp()
TRACE("\nBootloader started :)");
// TODO: move BT & EEPROM into board specifics
// TODO: move BT into board specifics
#if defined(BLUETOOTH)
// we shutdown the bluetooth module now to be sure it will be detected on
// firmware start
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, false);
#endif
#if defined(EEPROM) && defined(EEPROM_RLC)
eepromInit();
#endif
timersInit();
// SD card detect pin
@@ -346,12 +322,7 @@ int bootloaderMain()
memoryType = MEM_FLASH;
state = ST_DIR_CHECK;
break;
#if defined(EEPROM)
case 1:
memoryType = MEM_EEPROM;
state = ST_DIR_CHECK;
break;
#elif defined(SPI_FLASH)
#if defined(SPI_FLASH)
case 1:
state = ST_CLEAR_FLASH_CHECK;
break;
@@ -454,12 +425,6 @@ int bootloaderMain()
firmwareAddress = APP_START_ADDRESS;
firmwareWritten = 0;
}
#if defined(EEPROM)
else {
eepromAddress = 0;
eepromWritten = 0;
}
#endif
state = ST_FLASHING;
}
}
@@ -476,13 +441,6 @@ int bootloaderMain()
firmwareWritten += sizeof(Block_buffer);
progress = (100 * firmwareWritten) / firmwareSize;
}
#if defined(EEPROM)
else {
writeEepromBlock();
eepromWritten += sizeof(Block_buffer);
progress = (100 * eepromWritten) / EEPROM_SIZE;
}
#endif
bootloaderDrawScreen(state, progress);
@@ -493,11 +451,6 @@ int bootloaderMain()
else if (memoryType == MEM_FLASH && firmwareWritten >= FIRMWARE_MAX_LEN) {
state = ST_FLASH_DONE; // Backstop
}
#if defined(EEPROM)
else if (memoryType == MEM_EEPROM && eepromWritten >= EEPROM_SIZE) {
state = ST_FLASH_DONE; // Backstop
}
#endif
#if defined(SPI_FLASH)
} else if (state == ST_CLEAR_FLASH_CHECK) {
bootloaderDrawScreen(state, vpos);
@@ -152,11 +152,7 @@ int8_t STORAGE_GetCapacity_FS(uint8_t lun, uint32_t *block_num, uint16_t *block_
#if defined(FWDRIVE)
if (lun == STORAGE_EEPROM_LUN) {
*block_size = BLOCK_SIZE;
#if defined(EEPROM)
*block_num = RESERVED_SECTORS + EEPROM_SIZE/BLOCK_SIZE + FLASHSIZE/BLOCK_SIZE;
#else
*block_num = RESERVED_SECTORS + FLASHSIZE/BLOCK_SIZE;
#endif
return 0;
}
#endif
@@ -196,11 +192,6 @@ void usbInitLUNs()
*/
int8_t STORAGE_IsReady_FS(uint8_t lun)
{
#if defined(FWDRIVE) && defined(EEPROM)
if (lun == STORAGE_EEPROM_LUN) {
return (lunReady[STORAGE_EEPROM_LUN] != 0) ? 0 : -1;
}
#endif
return (lunReady[STORAGE_SDCARD_LUN] != 0 && storageIsPresent()) ? USBD_OK : USBD_FAIL;
}
@@ -300,11 +291,7 @@ const char firmware_txt[] =
/**
* FAT12 boot sector partition.
*/
#if defined(EEPROM)
#define TOTALSECTORS (RESERVED_SECTORS + (EEPROM_SIZE/BLOCK_SIZE) + (FLASHSIZE/BLOCK_SIZE))
#else
#define TOTALSECTORS (RESERVED_SECTORS + (FLASHSIZE/BLOCK_SIZE))
#endif
#define TOTALSECTORS (RESERVED_SECTORS + (FLASHSIZE/BLOCK_SIZE))
const char g_FATboot[BLOCK_SIZE] =
{
0xeb, 0x3c, 0x90, // Jump instruction.
@@ -443,23 +430,6 @@ const FATDirEntry_t g_DIRroot[] =
0x0003,
FLASHSIZE
},
#if defined(EEPROM)
{
{ 'E', 'E', 'P', 'R', 'O', 'M', ' ', ' '},
{ 'B', 'I', 'N'},
0x20, // Archive
0x00,
0x3E,
0xA301,
0x3D55,
0x3D55,
0x0000,
0xA302,
0x3D55,
0x0003 + (FLASHSIZE/BLOCK_SIZE)/8,
EEPROM_SIZE
},
#endif
// Emty entries are 0x00, omitted here. Up to 16 entries can be defined here
};
@@ -511,13 +481,6 @@ int32_t fat12Read(uint8_t * buffer, uint16_t sector, uint16_t count)
pushCluster (buffer, sector, cluster, rest, cluster+1);
pushCluster (buffer, sector, cluster, rest, (uint16_t) 0xFFF);
#if defined(EEPROM)
// Entry for eeprom.bin
for (int i=0;i<EEPROM_SIZE/BLOCK_SIZE/8 -1;i++)
pushCluster (buffer, sector, cluster, rest, cluster+1);
pushCluster (buffer, sector, cluster, rest, (uint16_t) 0xFFF);
#endif
// Ensure last cluster is written if it is the first half
pushCluster (buffer, sector, cluster, rest, (uint16_t) 0x000);
@@ -540,11 +503,6 @@ int32_t fat12Read(uint8_t * buffer, uint16_t sector, uint16_t count)
address += FIRMWARE_ADDRESS;
memcpy(buffer, (uint8_t *)address, BLOCK_SIZE);
}
#if defined(EEPROM)
else if (sector < RESERVED_SECTORS + (EEPROM_SIZE/BLOCK_SIZE) + (FLASHSIZE/BLOCK_SIZE)) {
eepromReadBlock(buffer, (sector - RESERVED_SECTORS - (FLASHSIZE/BLOCK_SIZE))*BLOCK_SIZE, BLOCK_SIZE);
}
#endif
buffer += BLOCK_SIZE ;
sector++ ;
count-- ;
@@ -602,27 +560,6 @@ int32_t fat12Write(const uint8_t * buffer, uint16_t sector, uint16_t count)
}
#endif
}
#if defined(EEPROM)
else if (sector < RESERVED_SECTORS + (EEPROM_SIZE/BLOCK_SIZE) + (FLASHSIZE/BLOCK_SIZE)) {
// eeprom
while (count) {
if (operation == FATWRITE_NONE && isEepromStart(buffer)) {
TRACE("EEPROM start found in sector %d", sector);
operation = FATWRITE_EEPROM;
}
if (operation == FATWRITE_EEPROM) {
eepromWriteBlock((uint8_t *)buffer, (sector-RESERVED_SECTORS-(FLASHSIZE/BLOCK_SIZE))*BLOCK_SIZE, BLOCK_SIZE);
}
buffer += BLOCK_SIZE;
sector++;
count--;
if (sector-RESERVED_SECTORS >= (EEPROM_SIZE/BLOCK_SIZE)+(FLASHSIZE/BLOCK_SIZE)) {
TRACE("EEPROM end written at sector %d", sector-1);
operation = FATWRITE_NONE;
}
}
}
#endif
return 0 ;
}
#endif