1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 06:15:16 +03:00

Fix SITL on Cygwin + minor cleanup

This commit is contained in:
Petr Ledvina 2017-05-22 13:25:45 +02:00
parent 00bd8d91d5
commit 919f0caa6b
5 changed files with 29 additions and 29 deletions

View file

@ -1008,6 +1008,11 @@ SITLEXCLUDES = \
drivers/system.c \ drivers/system.c \
drivers/rcc.c \ drivers/rcc.c \
drivers/serial_uart.c \ drivers/serial_uart.c \
drivers/rx_xn297.c \
drivers/display_ug2864hsweg01.c \
telemetry/crsf.c \
telemetry/srxl.c \
io/displayport_oled.c
# check if target.mk supplied # check if target.mk supplied
@ -1143,7 +1148,7 @@ CC_SPEED_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED)
CC_SIZE_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SIZE) CC_SIZE_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SIZE)
else #DEBUG else #DEBUG
OPTIMISE_DEFAULT := -O0 OPTIMISE_DEFAULT := -Og
CC_DEBUG_OPTIMISATION := $(OPTIMISE_DEFAULT) CC_DEBUG_OPTIMISATION := $(OPTIMISE_DEFAULT)

View file

@ -25,8 +25,7 @@ INSERT AFTER .text;
__FLASH_CONFIG_Size = 0x2000; /* 8kB */ __FLASH_CONFIG_Size = 0x2000; /* 8kB */
SECTIONS { SECTIONS {
/* .FLASH_CONFIG BLOCK( DEFINED(__section_alignment__) ? __section_alignment__ : 4 ) : SUBALIGN(4)*/ .FLASH_CONFIG BLOCK( DEFINED(__section_alignment__) ? __section_alignment__ : 4 ) :
.FLASH_CONFIG :
{ {
PROVIDE_HIDDEN (__config_start = . ); PROVIDE_HIDDEN (__config_start = . );
. = . + __FLASH_CONFIG_Size; . = . + __FLASH_CONFIG_Size;

View file

@ -436,9 +436,7 @@ char _Min_Stack_Size;
// fake EEPROM // fake EEPROM
extern uint8_t __config_start; extern uint8_t __config_start;
extern uint8_t __config_end; extern uint8_t __config_end;
extern uint32_t __FLASH_CONFIG_Size;
static FILE *eepromFd = NULL; static FILE *eepromFd = NULL;
const char *EEPROM_FILE = EEPROM_FILENAME;
void FLASH_Unlock(void) { void FLASH_Unlock(void) {
uint8_t * const eeprom = &__config_start; uint8_t * const eeprom = &__config_start;
@ -449,50 +447,47 @@ void FLASH_Unlock(void) {
} }
// open or create // open or create
eepromFd = fopen(EEPROM_FILE,"r+"); eepromFd = fopen(EEPROM_FILENAME,"r+");
if (eepromFd != NULL) { if (eepromFd != NULL) {
long lSize;
int c;
// obtain file size: // obtain file size:
fseek(eepromFd , 0 , SEEK_END); fseek(eepromFd , 0 , SEEK_END);
lSize = ftell(eepromFd); long lSize = ftell(eepromFd);
rewind(eepromFd); rewind(eepromFd);
printf("[FLASH_Unlock]size = %ld, %ld\n", lSize, (uintptr_t)(&__config_end - &__config_start)); printf("[FLASH_Unlock]size = %ld, %ld\n", lSize, (uintptr_t)(&__config_end - &__config_start));
for(unsigned int i=0; i<(uintptr_t)(&__config_end - &__config_start); i++){ for (unsigned i = 0; i < (uintptr_t)(&__config_end - &__config_start); i++) {
c = fgetc(eepromFd); int c = fgetc(eepromFd);
if(c == EOF) break; if(c == EOF) break;
eeprom[i] = (uint8_t)c; eeprom[i] = (uint8_t)c;
} }
} else { } else {
eepromFd = fopen(EEPROM_FILE, "w+"); eepromFd = fopen(EEPROM_FILENAME, "w+");
fwrite(eeprom, sizeof(uint8_t), (size_t)&__FLASH_CONFIG_Size, eepromFd); fwrite(eeprom, sizeof(uint8_t), &__config_end - &__config_start, eepromFd);
} }
} }
void FLASH_Lock(void) { void FLASH_Lock(void) {
// flush & close // flush & close
if (eepromFd != NULL) { if (eepromFd != NULL) {
const uint8_t *eeprom = &__config_start; const uint8_t *eeprom = &__config_start;
fseek(eepromFd, 0, SEEK_SET); fseek(eepromFd, 0, SEEK_SET);
fwrite(eeprom, sizeof(uint8_t), (size_t)&__FLASH_CONFIG_Size, eepromFd); fwrite(eeprom, 1, &__config_end - &__config_start, eepromFd);
fflush(eepromFd);
fclose(eepromFd); fclose(eepromFd);
eepromFd = NULL; eepromFd = NULL;
} }
} }
FLASH_Status FLASH_ErasePage(uint32_t Page_Address) { FLASH_Status FLASH_ErasePage(uintptr_t Page_Address) {
UNUSED(Page_Address); UNUSED(Page_Address);
// printf("[FLASH_ErasePage]%x\n", Page_Address); // printf("[FLASH_ErasePage]%x\n", Page_Address);
return FLASH_COMPLETE; return FLASH_COMPLETE;
} }
FLASH_Status FLASH_ProgramWord(uint32_t addr, uint32_t Data) { FLASH_Status FLASH_ProgramWord(uintptr_t addr, uint32_t Data) {
if ((addr >= (uintptr_t)&__config_start)&&(addr < (uintptr_t)&__config_end)) { if ((addr >= (uintptr_t)&__config_start)&&(addr < (uintptr_t)&__config_end)) {
*((uint32_t*)(uintptr_t)addr) = Data; *((uint32_t*)addr) = Data;
// printf("[FLASH_ProgramWord]0x%x = %x\n", addr, *((uint32_t*)(uintptr_t)addr)); printf("[FLASH_ProgramWord]0x%p = %x\n", (void*)addr, *((uint32_t*)addr));
} else { } else {
printf("[FLASH_ProgramWord]Out of Range!! 0x%x = %x\n", addr, *((uint32_t*)(uintptr_t)addr)); printf("[FLASH_ProgramWord]Out of Range! 0x%p\n", (void*)addr);
} }
return FLASH_COMPLETE; return FLASH_COMPLETE;
} }

View file

@ -233,8 +233,8 @@ typedef struct {
void FLASH_Unlock(void); void FLASH_Unlock(void);
void FLASH_Lock(void); void FLASH_Lock(void);
FLASH_Status FLASH_ErasePage(uint32_t Page_Address); FLASH_Status FLASH_ErasePage(uintptr_t Page_Address);
FLASH_Status FLASH_ProgramWord(uint32_t addr, uint32_t Data); FLASH_Status FLASH_ProgramWord(uintptr_t addr, uint32_t Data);
uint64_t nanos64_real(); uint64_t nanos64_real();
uint64_t micros64_real(); uint64_t micros64_real();

View file

@ -8,6 +8,7 @@
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/socket.h>
#include "udplink.h" #include "udplink.h"