mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
Merge branch 'master' into OP-438_os_Windows-installer
This commit is contained in:
commit
207e6f93b1
@ -121,6 +121,7 @@ SRC += $(PIOSCOMMON)/pios_com.c
|
||||
SRC += $(PIOSCOMMON)/pios_hmc5843.c
|
||||
SRC += $(PIOSCOMMON)/printf-stdarg.c
|
||||
SRC += $(PIOSCOMMON)/pios_iap.c
|
||||
SRC += $(PIOSCOMMON)/pios_bl_helper.c
|
||||
|
||||
## CMSIS for STM32
|
||||
SRC += $(CMSISDIR)/core_cm3.c
|
||||
|
@ -99,8 +99,6 @@ void affine_rotate(float scale[3][4], float rotation[3]);
|
||||
void calibration(float result[3], float scale[3][4], float arg[3]);
|
||||
|
||||
/* Bootloader related functions and var*/
|
||||
static uint32_t iap_calc_crc(void);
|
||||
static void read_description(uint8_t *);
|
||||
void firmwareiapobj_callback(AhrsObjHandle obj);
|
||||
volatile uint8_t reset_count=0;
|
||||
|
||||
@ -1249,36 +1247,15 @@ void firmwareiapobj_callback(AhrsObjHandle obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(firmwareIAPObj.BoardType==BOARD_TYPE && firmwareIAPObj.crc!=iap_calc_crc())
|
||||
else if(firmwareIAPObj.BoardType==BOARD_TYPE && firmwareIAPObj.crc!=PIOS_BL_HELPER_CRC_Memory_Calc())
|
||||
{
|
||||
read_description(firmwareIAPObj.Description);
|
||||
firmwareIAPObj.crc=iap_calc_crc();
|
||||
PIOS_BL_HELPER_FLASH_Read_Description(firmwareIAPObj.Description,SIZE_OF_DESCRIPTION);
|
||||
firmwareIAPObj.crc=PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
firmwareIAPObj.BoardRevision=BOARD_REVISION;
|
||||
FirmwareIAPObjSet(&firmwareIAPObj);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t iap_calc_crc(void)
|
||||
{
|
||||
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);
|
||||
CRC_ResetDR();
|
||||
CRC_CalcBlockCRC((uint32_t *) START_OF_USER_CODE, (SIZE_OF_CODE) >> 2);
|
||||
return CRC_GetCRC();
|
||||
}
|
||||
static uint8_t *FLASH_If_Read(uint32_t SectorAddress)
|
||||
{
|
||||
return (uint8_t *) (SectorAddress);
|
||||
}
|
||||
static void read_description(uint8_t * array)
|
||||
{
|
||||
uint8_t x = 0;
|
||||
for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + SIZE_OF_DESCRIPTION; ++i) {
|
||||
array[x] = *FLASH_If_Read(i);
|
||||
++x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -40,5 +40,6 @@
|
||||
#define PIOS_INCLUDE_HMC5843
|
||||
#define PIOS_INCLUDE_GPIO
|
||||
#define PIOS_INCLUDE_EXTI
|
||||
#define PIOS_INCLUDE_BL_HELPER
|
||||
|
||||
#endif /* PIOS_CONFIG_H */
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define PIOS_INCLUDE_SPI
|
||||
#define PIOS_INCLUDE_SYS
|
||||
#define PIOS_INCLUDE_BL_HELPER
|
||||
#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT
|
||||
#define PIOS_INCLUDE_GPIO
|
||||
|
||||
#endif /* PIOS_CONFIG_H */
|
||||
|
@ -96,7 +96,7 @@ int main() {
|
||||
}
|
||||
PIOS_Board_Init();
|
||||
boot_status = idle;
|
||||
Fw_crc = crc_memory_calc();
|
||||
Fw_crc = PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
PIOS_LED_On(LED1);
|
||||
while (1) {
|
||||
process_spi_request();
|
||||
@ -146,7 +146,7 @@ void process_spi_request(void) {
|
||||
|
||||
case OPAHRS_MSG_V0_REQ_FWUP_VERIFY:
|
||||
opahrs_msg_v0_init_user_tx(&user_tx_v0, OPAHRS_MSG_V0_RSP_FWUP_STATUS);
|
||||
Fw_crc = crc_memory_calc();
|
||||
Fw_crc = PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
lfsm_user_set_tx_v0(&user_tx_v0);
|
||||
boot_status = idle;
|
||||
PIOS_LED_Off(LED1);
|
||||
@ -216,7 +216,7 @@ void process_spi_request(void) {
|
||||
uint32_t adr=user_rx_v0.payload.user.v.req.fwdn_data.adress;
|
||||
for(uint8_t x=0;x<4;++x)
|
||||
{
|
||||
user_tx_v0.payload.user.v.rsp.fw_dn.data[x]=*FLASH_If_Read(adr+x);
|
||||
user_tx_v0.payload.user.v.rsp.fw_dn.data[x]=*PIOS_BL_HELPER_FLASH_If_Read(adr+x);
|
||||
}
|
||||
lfsm_user_set_tx_v0(&user_tx_v0);
|
||||
break;
|
||||
@ -226,7 +226,7 @@ void process_spi_request(void) {
|
||||
user_tx_v0.payload.user.v.rsp.fwup_status.status = boot_status;
|
||||
lfsm_user_set_tx_v0(&user_tx_v0);
|
||||
PIOS_LED_On(LED1);
|
||||
if (FLASH_Start() == TRUE) {
|
||||
if (PIOS_BL_HELPER_FLASH_Start() == TRUE) {
|
||||
boot_status = started;
|
||||
PIOS_LED_Off(LED1);
|
||||
} else {
|
||||
|
@ -31,6 +31,7 @@
|
||||
#ifndef PIOS_CONFIG_H
|
||||
#define PIOS_CONFIG_H
|
||||
#define PIOS_INCLUDE_BL_HELPER
|
||||
#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT
|
||||
#define USB_HID
|
||||
/* Enable/Disable PiOS Modules */
|
||||
#define PIOS_INCLUDE_DELAY
|
||||
@ -61,4 +62,4 @@
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
@ -116,10 +116,10 @@ void DataDownload(DownloadAction action) {
|
||||
}
|
||||
break;
|
||||
case Self_flash:
|
||||
SendBuffer[6 + (x * 4)] = *FLASH_If_Read(offset);
|
||||
SendBuffer[7 + (x * 4)] = *FLASH_If_Read(offset + 1);
|
||||
SendBuffer[8 + (x * 4)] = *FLASH_If_Read(offset + 2);
|
||||
SendBuffer[9 + (x * 4)] = *FLASH_If_Read(offset + 3);
|
||||
SendBuffer[6 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset);
|
||||
SendBuffer[7 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 1);
|
||||
SendBuffer[8 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 2);
|
||||
SendBuffer[9 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 3);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
@ -178,7 +178,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
uint8_t result = 0;
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Ini();
|
||||
result = PIOS_BL_HELPER_FLASH_Ini();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
result = TRUE;
|
||||
@ -214,7 +214,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
if (TransferType == FW) {
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Start();
|
||||
result = PIOS_BL_HELPER_FLASH_Start();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
result = FALSE;
|
||||
@ -459,7 +459,7 @@ uint8_t isBiggerThanAvailable(DFUTransfer type, uint32_t size) {
|
||||
uint32_t CalcFirmCRC() {
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
return crc_memory_calc();
|
||||
return PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
return 0;
|
||||
@ -484,7 +484,7 @@ bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) {
|
||||
break;
|
||||
case Self_flash:
|
||||
for (uint8_t x = 0; x < 4; ++x) {
|
||||
buffer[x] = *FLASH_If_Read(adr + x);
|
||||
buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x);
|
||||
}
|
||||
return TRUE;
|
||||
break;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#ifndef PIOS_CONFIG_H
|
||||
#define PIOS_CONFIG_H
|
||||
#define PIOS_INCLUDE_BL_HELPER
|
||||
#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT
|
||||
#define USB_HID
|
||||
/* Enable/Disable PiOS Modules */
|
||||
#define PIOS_INCLUDE_DELAY
|
||||
@ -64,4 +65,4 @@
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
@ -158,7 +158,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
uint8_t result = 0;
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Ini();
|
||||
result = PIOS_BL_HELPER_FLASH_Ini();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
result = TRUE;
|
||||
@ -195,7 +195,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
if (TransferType == FW) {
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Start();
|
||||
result = PIOS_BL_HELPER_FLASH_Start();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
PIOS_OPAHRS_bl_FwupStart(&rsp);
|
||||
@ -525,7 +525,7 @@ uint32_t CalcFirmCRC() {
|
||||
struct opahrs_msg_v0 rsp;
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
return crc_memory_calc();
|
||||
return PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
PIOS_OPAHRS_bl_FwupVerify(&rsp);
|
||||
@ -574,7 +574,7 @@ bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) {
|
||||
break;
|
||||
case Self_flash:
|
||||
for (uint8_t x = 0; x < 4; ++x) {
|
||||
buffer[x] = *FLASH_If_Read(adr + x);
|
||||
buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x);
|
||||
}
|
||||
return TRUE;
|
||||
break;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#ifndef PIOS_CONFIG_H
|
||||
#define PIOS_CONFIG_H
|
||||
#define PIOS_INCLUDE_BL_HELPER
|
||||
#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT
|
||||
#define USB_HID
|
||||
/* Enable/Disable PiOS Modules */
|
||||
#define PIOS_INCLUDE_DELAY
|
||||
@ -61,4 +62,4 @@
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
@ -116,10 +116,10 @@ void DataDownload(DownloadAction action) {
|
||||
}
|
||||
break;
|
||||
case Self_flash:
|
||||
SendBuffer[6 + (x * 4)] = *FLASH_If_Read(offset);
|
||||
SendBuffer[7 + (x * 4)] = *FLASH_If_Read(offset + 1);
|
||||
SendBuffer[8 + (x * 4)] = *FLASH_If_Read(offset + 2);
|
||||
SendBuffer[9 + (x * 4)] = *FLASH_If_Read(offset + 3);
|
||||
SendBuffer[6 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset);
|
||||
SendBuffer[7 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 1);
|
||||
SendBuffer[8 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 2);
|
||||
SendBuffer[9 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 3);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
@ -178,7 +178,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
uint8_t result = 0;
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Ini();
|
||||
result = PIOS_BL_HELPER_FLASH_Ini();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
result = TRUE;
|
||||
@ -214,7 +214,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
if (TransferType == FW) {
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Start();
|
||||
result = PIOS_BL_HELPER_FLASH_Start();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
result = FALSE;
|
||||
@ -459,7 +459,7 @@ uint8_t isBiggerThanAvailable(DFUTransfer type, uint32_t size) {
|
||||
uint32_t CalcFirmCRC() {
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
return crc_memory_calc();
|
||||
return PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
return 0;
|
||||
@ -484,7 +484,7 @@ bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) {
|
||||
break;
|
||||
case Self_flash:
|
||||
for (uint8_t x = 0; x < 4; ++x) {
|
||||
buffer[x] = *FLASH_If_Read(adr + x);
|
||||
buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x);
|
||||
}
|
||||
return TRUE;
|
||||
break;
|
||||
|
@ -216,6 +216,7 @@ SRC += $(PIOSCOMMON)/pios_adxl345.c
|
||||
SRC += $(PIOSCOMMON)/pios_com.c
|
||||
SRC += $(PIOSCOMMON)/pios_i2c_esc.c
|
||||
SRC += $(PIOSCOMMON)/pios_iap.c
|
||||
SRC += $(PIOSCOMMON)/pios_bl_helper.c
|
||||
SRC += $(PIOSCOMMON)/printf-stdarg.c
|
||||
## Libraries for flight calculations
|
||||
SRC += $(FLIGHTLIB)/fifo_buffer.c
|
||||
|
@ -65,6 +65,7 @@
|
||||
#define PIOS_INCLUDE_GPIO
|
||||
#define PIOS_INCLUDE_EXTI
|
||||
#define PIOS_INCLUDE_WDG
|
||||
#define PIOS_INCLUDE_BL_HELPER
|
||||
|
||||
#define PIOS_INCLUDE_ADXL345
|
||||
#define PIOS_INCLUDE_FLASH
|
||||
|
@ -47,7 +47,6 @@
|
||||
|
||||
#define RESET_DELAY 500 /* delay between sending reset ot INS */
|
||||
|
||||
|
||||
#define TICKS2MS(t) ((t)/portTICK_RATE_MS)
|
||||
#define MS2TICKS(m) ((m)*portTICK_RATE_MS)
|
||||
|
||||
@ -59,18 +58,12 @@ const uint32_t iap_time_3_high_end = 5000;
|
||||
// Private types
|
||||
|
||||
// Private variables
|
||||
const static uint8_t version[] = { 0, 0, 1 };
|
||||
const static uint16_t SVN = 12345;
|
||||
static uint8_t reset_count = 0;
|
||||
static portTickType lastResetSysTime;
|
||||
|
||||
// Private functions
|
||||
static void FirmwareIAPCallback(UAVObjEvent* ev);
|
||||
|
||||
static uint32_t iap_calc_crc(void);
|
||||
|
||||
static void read_description(uint8_t *);
|
||||
|
||||
FirmwareIAPObjData data;
|
||||
|
||||
static uint32_t get_time(void);
|
||||
@ -97,7 +90,8 @@ static void resetTask(UAVObjEvent *);
|
||||
int32_t FirmwareIAPInitialize()
|
||||
{
|
||||
data.BoardType= BOARD_TYPE;
|
||||
read_description(data.Description);
|
||||
PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM);
|
||||
PIOS_SYS_SerialNumberGetBinary(data.CPUSerial);
|
||||
data.BoardRevision= BOARD_REVISION;
|
||||
data.ArmReset=0;
|
||||
data.crc = 0;
|
||||
@ -130,11 +124,12 @@ static void FirmwareIAPCallback(UAVObjEvent* ev)
|
||||
this_time = get_time();
|
||||
delta = this_time - last_time;
|
||||
last_time = this_time;
|
||||
if((data.BoardType==BOARD_TYPE)&&(data.crc != iap_calc_crc()))
|
||||
if((data.BoardType==BOARD_TYPE)&&(data.crc != PIOS_BL_HELPER_CRC_Memory_Calc()))
|
||||
{
|
||||
read_description(data.Description);
|
||||
PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM);
|
||||
PIOS_SYS_SerialNumberGetBinary(data.CPUSerial);
|
||||
data.BoardRevision=BOARD_REVISION;
|
||||
data.crc = iap_calc_crc();
|
||||
data.crc = PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
FirmwareIAPObjSet( &data );
|
||||
}
|
||||
if((data.ArmReset==1)&&(iap_state!=IAP_STATE_RESETTING))
|
||||
@ -213,41 +208,6 @@ static uint32_t get_time(void)
|
||||
return TICKS2MS(ticks);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Calculate the CRC value of the code in flash.
|
||||
* \param None
|
||||
* \return calculated CRC value using STM32's builtin CRC hardware
|
||||
*
|
||||
* \note
|
||||
* I copied this function as the function crc calc function in pios_bl_helper.c
|
||||
* is only included when the PIOS_BL_HELPER is defined, but this also includes
|
||||
* the flash unlock and erase functions. It is safer to only have the flash
|
||||
* functions in the bootloader.
|
||||
*
|
||||
*/
|
||||
|
||||
static uint32_t iap_calc_crc(void)
|
||||
{
|
||||
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);
|
||||
CRC_ResetDR();
|
||||
CRC_CalcBlockCRC((uint32_t *) START_OF_USER_CODE, (SIZE_OF_CODE) >> 2);
|
||||
return CRC_GetCRC();
|
||||
}
|
||||
static uint8_t *FLASH_If_Read(uint32_t SectorAddress)
|
||||
{
|
||||
return (uint8_t *) (SectorAddress);
|
||||
}
|
||||
static void read_description(uint8_t * array)
|
||||
{
|
||||
uint8_t x = 0;
|
||||
for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + SIZE_OF_DESCRIPTION; ++i) {
|
||||
array[x] = *FLASH_If_Read(i);
|
||||
++x;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executed by event dispatcher callback to reset INS before resetting OP
|
||||
*/
|
||||
|
@ -53,8 +53,11 @@
|
||||
// Private functions
|
||||
|
||||
static void gpsTask(void *parameters);
|
||||
|
||||
#ifdef PIOS_GPS_SETS_HOMELOCATION
|
||||
static void setHomeLocation(GPSPositionData * gpsData);
|
||||
static float GravityAccel(float latitude, float longitude, float altitude);
|
||||
#endif
|
||||
|
||||
// ****************
|
||||
// Private constants
|
||||
@ -65,11 +68,19 @@ static float GravityAccel(float latitude, float longitude, float altitude);
|
||||
#define GPS_TIMEOUT_MS 500
|
||||
#define GPS_COMMAND_RESEND_TIMEOUT_MS 2000
|
||||
|
||||
#ifdef PIOS_GPS_SETS_HOMELOCATION
|
||||
// Unfortunately need a good size stack for the WMM calculation
|
||||
#ifdef ENABLE_GPS_BINARY_GTOP
|
||||
#define STACK_SIZE_BYTES 800
|
||||
#ifdef ENABLE_GPS_BINARY_GTOP
|
||||
#define STACK_SIZE_BYTES 800
|
||||
#else
|
||||
#define STACK_SIZE_BYTES 800
|
||||
#endif
|
||||
#else
|
||||
#define STACK_SIZE_BYTES 800
|
||||
#ifdef ENABLE_GPS_BINARY_GTOP
|
||||
#define STACK_SIZE_BYTES 440
|
||||
#else
|
||||
#define STACK_SIZE_BYTES 440
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define TASK_PRIORITY (tskIDLE_PRIORITY + 1)
|
||||
@ -311,12 +322,14 @@ static void gpsTask(void *parameters)
|
||||
else
|
||||
{ // we appear to be receiving GPS sentences OK, we've had an update
|
||||
|
||||
#ifdef PIOS_GPS_SETS_HOMELOCATION
|
||||
HomeLocationData home;
|
||||
HomeLocationGet(&home);
|
||||
|
||||
GPSPositionGet(&GpsData);
|
||||
if ((GpsData.Status == GPSPOSITION_STATUS_FIX3D) && (home.Set == HOMELOCATION_SET_FALSE))
|
||||
setHomeLocation(&GpsData);
|
||||
#endif
|
||||
|
||||
//criteria for GPS-OK taken from this post...
|
||||
//http://forums.openpilot.org/topic/1523-professors-insgps-in-svn/page__view__findpost__p__5220
|
||||
@ -334,6 +347,7 @@ static void gpsTask(void *parameters)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PIOS_GPS_SETS_HOMELOCATION
|
||||
/*
|
||||
* Estimate the acceleration due to gravity for a particular location in LLA
|
||||
*/
|
||||
@ -389,6 +403,7 @@ static void setHomeLocation(GPSPositionData * gpsData)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// ****************
|
||||
|
||||
|
@ -208,6 +208,7 @@ SRC += $(PIOSCOMMON)/pios_bmp085.c
|
||||
SRC += $(PIOSCOMMON)/pios_hcsr04.c
|
||||
SRC += $(PIOSCOMMON)/pios_i2c_esc.c
|
||||
SRC += $(PIOSCOMMON)/pios_iap.c
|
||||
SRC += $(PIOSCOMMON)/pios_bl_helper.c
|
||||
SRC += $(PIOSCOMMON)/printf-stdarg.c
|
||||
SRC += $(FLIGHTLIB)/ahrs_spi_comm.c
|
||||
SRC += $(FLIGHTLIB)/ahrs_comm_objects.c
|
||||
|
@ -66,6 +66,7 @@
|
||||
#define PIOS_INCLUDE_RTC
|
||||
#define PIOS_INCLUDE_WDG
|
||||
#define PIOS_INCLUDE_I2C_ESC
|
||||
#define PIOS_INCLUDE_BL_HELPER
|
||||
|
||||
/* Defaults for Logging */
|
||||
#define LOG_FILENAME "PIOS.LOG"
|
||||
@ -89,6 +90,9 @@
|
||||
/* Stabilization options */
|
||||
#define PIOS_QUATERNION_STABILIZATION
|
||||
|
||||
/* GPS options */
|
||||
#define PIOS_GPS_SETS_HOMELOCATION
|
||||
|
||||
|
||||
#endif /* PIOS_CONFIG_H */
|
||||
/**
|
||||
|
@ -33,18 +33,19 @@
|
||||
#if defined(PIOS_INCLUDE_BL_HELPER)
|
||||
#include "stm32f10x_flash.h"
|
||||
|
||||
uint8_t *FLASH_If_Read(uint32_t SectorAddress)
|
||||
uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress)
|
||||
{
|
||||
return (uint8_t *) (SectorAddress);
|
||||
}
|
||||
|
||||
uint8_t FLASH_Ini()
|
||||
#if defined(PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT)
|
||||
uint8_t PIOS_BL_HELPER_FLASH_Ini()
|
||||
{
|
||||
FLASH_Unlock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t FLASH_Start()
|
||||
uint8_t PIOS_BL_HELPER_FLASH_Start()
|
||||
{
|
||||
uint32_t pageAdress;
|
||||
pageAdress = START_OF_USER_CODE;
|
||||
@ -70,24 +71,27 @@ uint8_t FLASH_Start()
|
||||
|
||||
return (fail == TRUE) ? 0 : 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t crc_memory_calc()
|
||||
uint32_t PIOS_BL_HELPER_CRC_Memory_Calc()
|
||||
{
|
||||
PIOS_BL_HELPER_CRC_Ini();
|
||||
CRC_ResetDR();
|
||||
CRC_CalcBlockCRC((uint32_t *) START_OF_USER_CODE, (SIZE_OF_CODE) >> 2);
|
||||
return CRC_GetCRC();
|
||||
}
|
||||
|
||||
void read_description(uint8_t * array)
|
||||
void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size)
|
||||
{
|
||||
uint8_t x = 0;
|
||||
for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + SIZE_OF_DESCRIPTION; ++i) {
|
||||
array[x] = *FLASH_If_Read(i);
|
||||
if (size>SIZE_OF_DESCRIPTION) size = SIZE_OF_DESCRIPTION;
|
||||
for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + size; ++i) {
|
||||
array[x] = *PIOS_BL_HELPER_FLASH_If_Read(i);
|
||||
++x;
|
||||
}
|
||||
}
|
||||
|
||||
void CRC_Ini()
|
||||
void PIOS_BL_HELPER_CRC_Ini()
|
||||
{
|
||||
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);
|
||||
}
|
||||
|
@ -134,6 +134,27 @@ uint32_t PIOS_SYS_getCPUFlashSize(void)
|
||||
return ((uint32_t) MEM16(0x1FFFF7E0) * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the serial number as a string
|
||||
* param[out] str pointer to a string which can store at least 32 digits + zero terminator!
|
||||
* (24 digits returned for STM32)
|
||||
* return < 0 if feature not supported
|
||||
*/
|
||||
int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t *array)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Stored in the so called "electronic signature" */
|
||||
for (i = 0; i < 12; ++i) {
|
||||
uint8_t b = MEM8(0x1ffff7e8 + i);
|
||||
|
||||
array[i] = b;
|
||||
}
|
||||
|
||||
/* No error */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the serial number as a string
|
||||
* param[out] str pointer to a string which can store at least 32 digits + zero terminator!
|
||||
|
@ -31,16 +31,16 @@
|
||||
#ifndef PIOS_BL_HELPER_H_
|
||||
#define PIOS_BL_HELPER_H_
|
||||
|
||||
extern uint8_t *FLASH_If_Read(uint32_t SectorAddress);
|
||||
extern uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress);
|
||||
|
||||
extern uint8_t FLASH_Ini();
|
||||
extern uint8_t PIOS_BL_HELPER_FLASH_Ini();
|
||||
|
||||
extern uint32_t crc_memory_calc();
|
||||
extern uint32_t PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
|
||||
extern void read_description(uint8_t * array);
|
||||
extern void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size);
|
||||
|
||||
extern uint8_t FLASH_Start();
|
||||
extern uint8_t PIOS_BL_HELPER_FLASH_Start();
|
||||
|
||||
extern void CRC_Ini();
|
||||
extern void PIOS_BL_HELPER_CRC_Ini();
|
||||
|
||||
#endif /* PIOS_BL_HELPER_H_ */
|
||||
|
@ -36,6 +36,7 @@
|
||||
extern void PIOS_SYS_Init(void);
|
||||
extern int32_t PIOS_SYS_Reset(void);
|
||||
extern uint32_t PIOS_SYS_getCPUFlashSize(void);
|
||||
extern int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t *array);
|
||||
extern int32_t PIOS_SYS_SerialNumberGet(char *str);
|
||||
|
||||
#endif /* PIOS_SYS_H */
|
||||
|
@ -1,8 +1,9 @@
|
||||
<xml>
|
||||
<object name="FirmwareIAPObj" singleinstance="true" settings="false">
|
||||
<description>Firmware IAP</description>
|
||||
<description>Queries board for SN, model, revision, and sends reset command</description>
|
||||
<field name="Command" units="" type="uint16" elements="1"/>
|
||||
<field name="Description" units="" type="uint8" elements="100"/>
|
||||
<field name="Description" units="" type="uint8" elements="40"/>
|
||||
<field name="CPUSerial" units="" type="uint8" elements="12" />
|
||||
<field name="BoardRevision" units="" type="uint16" elements="1"/>
|
||||
<field name="BoardType" units="" type="uint8" elements="1"/>
|
||||
<field name="ArmReset" units="" type="uint8" elements="1"/>
|
||||
|
Loading…
Reference in New Issue
Block a user