1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-23 00:05:13 +03:00

Code moved

This commit is contained in:
bsongis 2014-04-08 18:00:44 +02:00
parent 896ff1e386
commit 96aa54ac77
3 changed files with 21 additions and 38 deletions

View file

@ -356,7 +356,7 @@ int menuFlashFile(uint32_t index, uint8_t event)
fr = openFirmwareFile(index);
fr = f_close(&FlashFile);
Valid = 1;
if (isFirmwareStart(Block_buffer) == 0) {
if (!isFirmwareStart(Block_buffer)) {
Valid = 2;
}
}
@ -648,6 +648,13 @@ int main()
// Commit to flashing
uint32_t blockOffset = 0;
lcd_putsLeft(4*FH, "\032Loading...");
if (firmwareAddress == FIRMWARE_ADDRESS + BOOTLOADER_SIZE) {
if (!isFirmwareStart(Block_buffer)) {
state = ST_FLASH_DONE;
}
}
while (BlockCount) {
writeFlash((uint32_t *)firmwareAddress, &Block_buffer[blockOffset]);
blockOffset += FLASH_PAGESIZE/4; // 32-bit words
@ -659,6 +666,7 @@ int main()
BlockCount = 0;
}
}
firmwareWritten += 4; // 4K blocks
lcd_rect( 3, 6*FH+4, 204, 7);

View file

@ -7,18 +7,6 @@ void writeFlash(uint32_t *address, uint32_t *buffer) // size is 256 bytes
uint32_t FlashSectorNum;
uint32_t flash_cmd = 0;
/* Initialize the function pointer (retrieve function address from NMI vector) */
if ((uint32_t) address == FIRMWARE_START+BOOTLOADER_SIZE) {
if (isFirmwareStart(buffer))
FlashBlocked = 0;
else
FlashBlocked = 1;
}
if (FlashBlocked) {
return;
}
// Always initialise this here, setting a default doesn't seem to work
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008);
FlashSectorNum = (uint32_t) address;

View file

@ -43,47 +43,34 @@ void eraseSector(uint32_t sector)
FLASH->CR &= SECTOR_MASK;
}
void writeFlash(uint32_t *address, uint32_t *buffer) // size is 256 bytes
void writeFlash(uint32_t *address, uint32_t *buffer) // page size is 256 bytes
{
static uint8_t FlashBlocked = 1;
uint32_t i;
if ((uint32_t) address == 0x08008000) {
if (isFirmwareStart(buffer)) {
FlashBlocked = 0;
if ((uint32_t) address == 0x08000000) {
eraseSector(0);
}
else {
FlashBlocked = 1;
else if ((uint32_t) address == 0x08004000) {
eraseSector(1);
}
}
if (FlashBlocked) {
return;
}
if ((uint32_t) address == 0x08008000) {
else if ((uint32_t) address == 0x08008000) {
eraseSector(2);
}
if ((uint32_t) address == 0x0800C000) {
else if ((uint32_t) address == 0x0800C000) {
eraseSector(3);
}
if ((uint32_t) address == 0x08010000) {
else if ((uint32_t) address == 0x08010000) {
eraseSector(4);
}
if ((uint32_t) address == 0x08020000) {
else if ((uint32_t) address == 0x08020000) {
eraseSector(5);
}
if ((uint32_t) address == 0x08040000) {
else if ((uint32_t) address == 0x08040000) {
eraseSector(6);
}
if ((uint32_t) address == 0x08060000) {
else if ((uint32_t) address == 0x08060000) {
eraseSector(7);
}
// Now program the 256 bytes
for (i = 0; i < 64; i += 1) {
for (uint32_t i=0; i<FLASH_PAGESIZE/4; i++) {
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
be done by word */