1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

OSX Simulation: Start populating the board and fw information

This will allow testing the tablet to know what type of UAVOs to
expect.
This commit is contained in:
James Cotton 2012-10-07 09:42:20 -05:00
parent 8a2f6f7398
commit 4b35cdf0ef
12 changed files with 452 additions and 215 deletions

View File

@ -0,0 +1,46 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_BOOTLOADER Functions
* @brief HAL code to interface to the OpenPilot AHRS module
* @{
*
* @file pios_bl_helper.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Bootloader Helper Functions
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* 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, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_BL_HELPER_H_
#define PIOS_BL_HELPER_H_
extern uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress);
extern uint8_t PIOS_BL_HELPER_FLASH_Ini();
extern uint32_t PIOS_BL_HELPER_CRC_Memory_Calc();
extern void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size);
extern uint8_t PIOS_BL_HELPER_FLASH_Start();
extern void PIOS_BL_HELPER_CRC_Ini();
#endif /* PIOS_BL_HELPER_H_ */

View File

@ -0,0 +1,5 @@
#ifndef PIOS_BOARD_H_
#define PIOS_BOARD_H_
#endif /* PIOS_BOARD_H_ */

View File

@ -0,0 +1,24 @@
#ifndef PIOS_BOARD_INFO_H
#define PIOS_BOARD_INFO_H
#include <stdint.h> /* uint* */
#define PIOS_BOARD_INFO_BLOB_MAGIC 0xBDBDBDBD
struct pios_board_info {
uint32_t magic;
uint8_t board_type;
uint8_t board_rev;
uint8_t bl_rev;
uint8_t hw_type;
uint32_t fw_base;
uint32_t fw_size;
uint32_t desc_base;
uint32_t desc_size;
uint32_t ee_base;
uint32_t ee_size;
} __attribute__((packed));
extern const struct pios_board_info pios_board_info_blob;
#endif /* PIOS_BOARD_INFO_H */

View File

@ -0,0 +1,45 @@
/*!
* @File iap.h
* @Brief Header file for the In-Application-Programming Module
*
* Created on: Sep 6, 2010
* Author: joe
*/
#ifndef PIOS_IAP_H_
#define PIOS_IAP_H_
/****************************************************************************************
* Header files
****************************************************************************************/
/*****************************************************************************************
* Public Definitions/Macros
****************************************************************************************/
#if defined(STM32F4XX)
#define MAGIC_REG_1 RTC_BKP_DR1
#define MAGIC_REG_2 RTC_BKP_DR2
#define IAP_BOOTCOUNT RTC_BKP_DR3
#else
#define MAGIC_REG_1 BKP_DR1
#define MAGIC_REG_2 BKP_DR2
#define IAP_BOOTCOUNT BKP_DR3
#endif
/****************************************************************************************
* Public Functions
****************************************************************************************/
void PIOS_IAP_Init(void);
uint32_t PIOS_IAP_CheckRequest( void );
void PIOS_IAP_SetRequest1(void);
void PIOS_IAP_SetRequest2(void);
void PIOS_IAP_ClearRequest(void);
uint16_t PIOS_IAP_ReadBootCount(void);
void PIOS_IAP_WriteBootCount(uint16_t);
/****************************************************************************************
* Public Data
****************************************************************************************/
#endif /* PIOS_IAP_H_ */

View File

@ -1,35 +1,50 @@
/**
******************************************************************************
*
* @file pios_sys.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Thorsten Klose (tk@midibox.org)
* @brief System and hardware Init functions header.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* 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, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_SYS_H
#define PIOS_SYS_H
/* Public Functions */
extern void PIOS_SYS_Init(void);
extern int32_t PIOS_SYS_Reset(void);
extern int32_t PIOS_SYS_SerialNumberGet(char *str);
#endif /* PIOS_SYS_H */
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_SYS System Functions
* @brief PIOS System Initialization code
* @{
*
* @file pios_sys.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Thorsten Klose (tk@midibox.org)
* @brief System and hardware Init functions header.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* 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, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_SYS_H
#define PIOS_SYS_H
#define PIOS_SYS_SERIAL_NUM_BINARY_LEN 12
#define PIOS_SYS_SERIAL_NUM_ASCII_LEN (PIOS_SYS_SERIAL_NUM_BINARY_LEN * 2)
/* Public Functions */
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[PIOS_SYS_SERIAL_NUM_BINARY_LEN]);
extern int32_t PIOS_SYS_SerialNumberGet(char str[PIOS_SYS_SERIAL_NUM_ASCII_LEN+1]);
#endif /* PIOS_SYS_H */
/**
* @}
* @}
*/

View File

@ -0,0 +1,53 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_BOOTLOADER Functions
* @brief HAL code to interface to the OpenPilot AHRS module
* @{
*
* @file pios_bl_helper.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief Bootloader Helper Functions
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* 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, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Project Includes */
#include "pios.h"
#if defined(PIOS_INCLUDE_BL_HELPER)
#include <pios_board_info.h>
uint32_t PIOS_BL_HELPER_CRC_Memory_Calc()
{
return 0;
}
extern const struct fw_version_info fw_version_blob;
void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size)
{
uint8_t * desc = (uint8_t *) &fw_version_blob;
for (uint32_t i = 0; i < size; i++) {
array[i] = desc[i];
}
}
void PIOS_BL_HELPER_CRC_Ini()
{
}
#endif

View File

@ -0,0 +1,20 @@
#include <pios.h>
#include <pios_board.h>
#include "pios_board_info.h"
const struct pios_board_info pios_board_info_blob = {
.magic = PIOS_BOARD_INFO_BLOB_MAGIC,
.board_type = BOARD_TYPE,
.board_rev = BOARD_REVISION,
.bl_rev = BOOTLOADER_VERSION,
.hw_type = HW_TYPE,
.fw_base = FW_BANK_BASE,
.fw_size = FW_BANK_SIZE - FW_DESC_SIZE,
.desc_base = FW_BANK_BASE + FW_BANK_SIZE - FW_DESC_SIZE,
.desc_size = FW_DESC_SIZE,
#ifdef EE_BANK_BASE
.ee_base = EE_BANK_BASE,
.ee_size = EE_BANK_SIZE,
#endif
};

View File

@ -0,0 +1,69 @@
/*!
* @File iap.c
* @Brief
*
* Created on: Sep 6, 2010
* Author: joe
*/
/****************************************************************************************
* Header files
****************************************************************************************/
#include <pios.h>
/*!
* \brief PIOS_IAP_Init - performs required initializations for iap module.
* \param none.
* \return none.
* \retval none.
*
* Created: Sep 8, 2010 10:10:48 PM by joe
*/
void PIOS_IAP_Init( void )
{
}
/*!
* \brief Determines if an In-Application-Programming request has been made.
* \param *comm - Which communication stream to use for the IAP (USB, Telemetry, I2C, SPI, etc)
* \return TRUE - if correct sequence found, along with 'comm' updated.
* FALSE - Note that 'comm' will have an invalid comm identifier.
* \retval
*
*/
uint32_t PIOS_IAP_CheckRequest( void )
{
return false;
}
/*!
* \brief Sets the 1st word of the request sequence.
* \param n/a
* \return n/a
* \retval
*/
void PIOS_IAP_SetRequest1(void)
{
}
void PIOS_IAP_SetRequest2(void)
{
}
void PIOS_IAP_ClearRequest(void)
{
}
uint16_t PIOS_IAP_ReadBootCount(void)
{
return 0;
}
void PIOS_IAP_WriteBootCount (uint16_t boot_count)
{
}

View File

@ -1,165 +1,111 @@
/**
******************************************************************************
*
* @file pios_sys.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org)
* @brief Sets up basic system hardware, functions are called from Main.
* @see The GNU Public License (GPL) Version 3
* @defgroup PIOS_SYS System Functions
* @{
*
*****************************************************************************/
/*
* 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, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Project Includes */
#include "pios.h"
#if defined(PIOS_INCLUDE_SYS)
/* Private Function Prototypes */
void NVIC_Configuration(void);
void SysTick_Handler(void);
/* Local Macros */
#define MEM8(addr) (*((volatile uint8_t *)(addr)))
/**
* Initialises all system peripherals
*/
void PIOS_SYS_Init(void)
{
/**
* stub
*/
printf("PIOS_SYS_Init\n");
/* Initialise Basic NVIC */
NVIC_Configuration();
#if defined(PIOS_INCLUDE_LED)
/* Initialise LEDs */
PIOS_LED_Init();
#endif
}
/**
* Shutdown PIOS and reset the microcontroller:<BR>
* <UL>
* <LI>Disable all RTOS tasks
* <LI>Disable all interrupts
* <LI>Turn off all board LEDs
* <LI>Reset STM32
* </UL>
* \return < 0 if reset failed
*/
int32_t PIOS_SYS_Reset(void)
{
/**
* stub
*/
printf("PIOS_SYS_Reset\n");
/* Disable all RTOS tasks */
#if defined(PIOS_INCLUDE_FREERTOS)
/* port specific FreeRTOS function to disable tasks (nested) */
portENTER_CRITICAL();
#endif
while(1);
/* We will never reach this point */
return -1;
}
/**
* 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_SerialNumberGet(char *str)
{
int i;
/* Stored in the so called "electronic signature" */
for(i=0; i<24; ++i) {
//uint8_t b = MEM8(0x1ffff7e8 + (i/2));
//if( !(i & 1) )
//b >>= 4;
//b &= 0x0f;
//str[i] = ((b > 9) ? ('A'-10) : '0') + b;
str[i]='6';
}
str[i] = 0;
/* No error */
return 0;
}
/**
* Configures Vector Table base location and SysTick
*/
void NVIC_Configuration(void)
{
/**
* stub
*/
printf("NVIC_Configuration\n");
/* Set the Vector Table base address as specified in .ld file */
//NVIC_SetVectorTable(PIOS_NVIC_VECTTAB_FLASH, 0x0);
/* 4 bits for Interrupt priorities so no sub priorities */
//NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
/* Configure HCLK clock as SysTick clock source. */
//SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
}
#ifdef USE_FULL_ASSERT
/**
* Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* \param[in] file pointer to the source file name
* \param[in] line assert_param error line source number
* \retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* When serial debugging is implemented, use something like this. */
/* printf("Wrong parameters value: file %s on line %d\r\n", file, line); */
printf("Wrong parameters value: file %s on line %d\r\n", file, line);
/* Setup the LEDs to Alternate */
PIOS_LED_On(LED1);
PIOS_LED_Off(LED2);
/* Infinite loop */
while (1)
{
PIOS_LED_Toggle(LED1);
PIOS_LED_Toggle(LED2);
for(int i = 0; i < 1000000; i++);
}
}
#endif
#endif
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_SYS System Functions
* @brief PIOS System Initialization code
* @{
*
* @file pios_sys.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org)
* @brief Sets up basic STM32 system hardware, functions are called from Main.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* 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, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Project Includes */
#include "pios.h"
#if defined(PIOS_INCLUDE_SYS)
/**
* Initialises all system peripherals
*/
void PIOS_SYS_Init(void)
{
}
/**
* Shutdown PIOS and reset the microcontroller:<BR>
* <UL>
* <LI>Disable all RTOS tasks
* <LI>Disable all interrupts
* <LI>Turn off all board LEDs
* <LI>Reset STM32
* </UL>
* \return < 0 if reset failed
*/
int32_t PIOS_SYS_Reset(void)
{
/* We will never reach this point */
return -1;
}
/**
* Returns the CPU's flash size (in bytes)
*/
uint32_t PIOS_SYS_getCPUFlashSize(void)
{
return 1024000;
}
/**
* Returns the serial number as a string
* param[out] uint8_t pointer to a string which can store at least 12 bytes
* (12 bytes returned for STM32)
* return < 0 if feature not supported
*/
int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t *array)
{
/* Stored in the so called "electronic signature" */
for (int i = 0; i < PIOS_SYS_SERIAL_NUM_BINARY_LEN; ++i) {
array[i] = 0xff;
}
/* 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!
* (24 digits returned for STM32)
* return < 0 if feature not supported
*/
int32_t PIOS_SYS_SerialNumberGet(char *str)
{
/* Stored in the so called "electronic signature" */
int i;
for (i = 0; i < PIOS_SYS_SERIAL_NUM_ASCII_LEN; ++i) {
str[i] = 'F';
}
str[i] = '\0';
/* No error */
return 0;
}
#endif
/**
* @}
* @}
*/

View File

@ -72,6 +72,13 @@
#include <pios_irq.h>
#include <pios_sim.h>
#if defined(PIOS_INCLUDE_IAP)
#include <pios_iap.h>
#endif
#if defined(PIOS_INCLUDE_BL_HELPER)
#include <pios_bl_helper.h>
#endif
#define NELEMENTS(x) (sizeof(x) / sizeof(*(x)))
#endif /* PIOS_H */

View File

@ -22,6 +22,11 @@
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#####
BOARD_NAME=revolution
WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST)))
TOP := $(realpath $(WHEREAMI)/../../)
include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk
# Set developer code and compile options
# Set to YES to compile for debugging
@ -53,6 +58,7 @@ USE_THUMB_MODE = YES
MODULES += Actuator ManualControl Stabilization
MODULES += AltitudeHold VtolPathFollower FixedWingPathFollower PathPlanner
MODULES += Attitude/revolution
MODULES += FirmwareIAP
#MODULES += OveroSync/simulated
# To run simulation instead of connect to SITL
@ -60,20 +66,17 @@ MODULES += Sensors/simulated
MODULES += Telemetry
# MCU name, submodel and board
# - MCU used for compiler-option (-mtune)
# - MODEL used for linker-script name (-T) and passed as define
# - BOARD just passed as define (optional)
MCU = i686
#CHIP = STM32F103RET
#BOARD = STM3210E_OP
MODEL = HD
ifeq ($(USE_BOOTLOADER), YES)
BOOT_MODEL = $(MODEL)_BL
BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE)
BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION)
BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE)
BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)
BLONLY_CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE)
BLONLY_CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE)
BLONLY_CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE)
else
BOOT_MODEL = $(MODEL)_NB
endif
# Since we are simulating all this firmware the code needs to know what the BL would
# normally contain
CFLAGS += $(BLONLY_CDEFS)
# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.)
OUTDIR = ../../build/sim_osx
@ -177,6 +180,9 @@ SRC += $(PIOSPOSIX)/pios_com.c
SRC += $(PIOSPOSIX)/pios_servo.c
SRC += $(PIOSPOSIX)/pios_wdg.c
SRC += $(PIOSPOSIX)/pios_debug.c
SRC += $(PIOSPOSIX)/pios_bl_helper.c
SRC += $(PIOSPOSIX)/pios_iap.c
SRC += $(PIOSPOSIX)/pios_board_info.c
SRC += $(PIOSPOSIX)/pios_rcvr.c
SRC += $(PIOSPOSIX)/pios_gcsrcvr.c
@ -311,7 +317,7 @@ CSTANDARD = -std=gnu99
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
ifeq ($(DEBUG),YES)
CFLAGS = -g$(DEBUGF) -DDEBUG
CFLAGS += -g$(DEBUGF) -DDEBUG
endif
CFLAGS += -DDIAGNOSTICS
@ -320,7 +326,6 @@ CFLAGS += -DDIAG_TASKS
CFLAGS += $(CFLAGS_UAVOBJECTS)
CFLAGS += -DARCH_POSIX
CFLAGS += -O$(OPT)
CFLAGS += -mtune=$(MCU)
CFLAGS += $(CDEFS)
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.

View File

@ -44,6 +44,8 @@
#define PIOS_INCLUDE_SERVO
#define PIOS_INCLUDE_RCVR
#define PIOS_INCLUDE_GCSRCVR
#define PIOS_INCLUDE_IAP
#define PIOS_INCLUDE_BL_HELPER
#define PIOS_RCVR_MAX_CHANNELS 12
#define PIOS_RCVR_MAX_DEVS 3