From 8ba2d76cd64e0718f3605e0eb5cfab1f4a0550b3 Mon Sep 17 00:00:00 2001 From: gussy Date: Sat, 13 Mar 2010 20:46:46 +0000 Subject: [PATCH] OP-21: Cleaning up a few things. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@302 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/Bootloaders/OpenPilot/bootloader.c | 16 ++++++++-------- flight/Bootloaders/OpenPilot/inc/bootloader.h | 2 +- flight/Bootloaders/OpenPilot/inc/pios_board.h | 4 ++-- flight/Bootloaders/OpenPilot/inc/pios_config.h | 10 ---------- flight/Bootloaders/OpenPilot/inc/ymodem.h | 3 --- flight/Bootloaders/OpenPilot/ymodem.c | 1 - flight/OpenPilot/Makefile | 2 +- flight/OpenPilot/System/inc/pios_board.h | 2 +- flight/PiOS/Common/pios_com.c | 8 ++++++++ flight/PiOS/STM32F10x/link_stm32f10x_HD_BL.ld | 2 +- 10 files changed, 22 insertions(+), 28 deletions(-) diff --git a/flight/Bootloaders/OpenPilot/bootloader.c b/flight/Bootloaders/OpenPilot/bootloader.c index 4297b8e8f..912cc358a 100644 --- a/flight/Bootloaders/OpenPilot/bootloader.c +++ b/flight/Bootloaders/OpenPilot/bootloader.c @@ -36,9 +36,9 @@ extern uint32_t FlashDestination; extern uint8_t file_name[FILE_NAME_LENGTH]; /* Local variables */ -uint32_t BlockNbr = 0, UserMemoryMask = 0; -bool FlashProtection = FALSE; -uint8_t tab_1024[1024] = { 0 }; +static uint32_t BlockNbr = 0, UserMemoryMask = 0; +static bool FlashProtection = FALSE; +static uint8_t tab_1024[1024] = { 0 }; /** * Main bootloader function @@ -60,13 +60,13 @@ void StartBootloader(void) /* Test if any page of Flash memory where program user will be loaded is write protected */ if((FLASH_GetWriteProtectionOptionByte() & UserMemoryMask) != UserMemoryMask) { FlashProtection = TRUE; - SerialPutString(" Download Image To the STM32F10x Internal Flash ------- 1\r\n"); - SerialPutString(" Execute The New Program ------------------------------ 2\r\n"); - SerialPutString(" Disable the write protection ------------------------- 3\r\n"); + SerialPutString("Download Image To the STM32F10x Internal Flash ------- 1\r\n"); + SerialPutString("Execute The New Program ------------------------------ 2\r\n"); + SerialPutString("Disable the write protection ------------------------- 3\r\n"); } else { FlashProtection = FALSE; - SerialPutString(" Download Image To the STM32F10x Internal Flash ------- 1\r\n"); - SerialPutString(" Execute The New Program ------------------------------ 2\r\n"); + SerialPutString("Download Image To the STM32F10x Internal Flash ------- 1\r\n"); + SerialPutString("Execute The New Program ------------------------------ 2\r\n"); } /* Loop through 1mS check for specified time */ diff --git a/flight/Bootloaders/OpenPilot/inc/bootloader.h b/flight/Bootloaders/OpenPilot/inc/bootloader.h index b36d08fbc..f890c7ef7 100644 --- a/flight/Bootloaders/OpenPilot/inc/bootloader.h +++ b/flight/Bootloaders/OpenPilot/inc/bootloader.h @@ -31,7 +31,7 @@ typedef void (*pFunction)(void); /* Global Defines */ #define CMD_STRING_SIZE 128 -#define ApplicationAddress (0x8008000) +#define ApplicationAddress (0x8006000) #define PAGE_SIZE (0x800) #define FLASH_SIZE (0x80000) /* 512K */ diff --git a/flight/Bootloaders/OpenPilot/inc/pios_board.h b/flight/Bootloaders/OpenPilot/inc/pios_board.h index 98e5530b1..62ddbc597 100644 --- a/flight/Bootloaders/OpenPilot/inc/pios_board.h +++ b/flight/Bootloaders/OpenPilot/inc/pios_board.h @@ -91,8 +91,8 @@ // PIOS_USART //------------------------- #define PIOS_USART_NUM 1 -#define PIOS_USART_RX_BUFFER_SIZE 128 -#define PIOS_USART_TX_BUFFER_SIZE 128 +#define PIOS_USART_RX_BUFFER_SIZE 64 +#define PIOS_USART_TX_BUFFER_SIZE 64 #define PIOS_COM_DEBUG_PORT USART_1 //------------------------- diff --git a/flight/Bootloaders/OpenPilot/inc/pios_config.h b/flight/Bootloaders/OpenPilot/inc/pios_config.h index 0e0e9ddd7..4f819eb9f 100644 --- a/flight/Bootloaders/OpenPilot/inc/pios_config.h +++ b/flight/Bootloaders/OpenPilot/inc/pios_config.h @@ -30,24 +30,14 @@ /* Enable/Disable PiOS Modules */ -//#define PIOS_INCLUDE_ADC #define PIOS_INCLUDE_DELAY -//#define PIOS_INCLUDE_I2C #define PIOS_INCLUDE_IRQ #define PIOS_INCLUDE_LED -//#define PIOS_INCLUDE_PWM -//#define PIOS_INCLUDE_SERVO -//#define PIOS_INCLUDE_SPI #define PIOS_INCLUDE_SYS #define PIOS_INCLUDE_USART -//#define PIOS_INCLUDE_USB_COM #define PIOS_INCLUDE_USB_HID #define PIOS_INCLUDE_USB -//#define PIOS_INCLUDE_BMP085 #define PIOS_INCLUDE_COM -//#define PIOS_INCLUDE_SDCARD -//#define PIOS_INCLUDE_SETTINGS -//#define PIOS_INCLUDE_FREERTOS #if !defined(PIOS_INCLUDE_FREERTOS) #define vSemaphoreCreateBinary(a) a = 0; diff --git a/flight/Bootloaders/OpenPilot/inc/ymodem.h b/flight/Bootloaders/OpenPilot/inc/ymodem.h index fd0053036..e71d031eb 100644 --- a/flight/Bootloaders/OpenPilot/inc/ymodem.h +++ b/flight/Bootloaders/OpenPilot/inc/ymodem.h @@ -64,9 +64,6 @@ #define CONVERTHEX_alpha(c) (IS_AF(c) ? (c - 'A'+10) : (c - 'a'+10)) #define CONVERTHEX(c) (IS_09(c) ? (c - '0') : CONVERTHEX_alpha(c)) -/* Global Variables */ -extern uint8_t tab_1024[1024]; - /* Public Functions */ extern int32_t Ymodem_Receive(uint8_t *buf); diff --git a/flight/Bootloaders/OpenPilot/ymodem.c b/flight/Bootloaders/OpenPilot/ymodem.c index a5680ef76..39f9b864f 100644 --- a/flight/Bootloaders/OpenPilot/ymodem.c +++ b/flight/Bootloaders/OpenPilot/ymodem.c @@ -34,7 +34,6 @@ static uint32_t Str2Int(uint8_t *inputstr, int32_t *intnum); /* Global variables */ uint32_t FlashDestination = ApplicationAddress; /* Flash user program offset */ -uint8_t tab_1024[1024]; /* Local variables */ static uint8_t file_name[FILE_NAME_LENGTH]; diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index 4aa41656d..21f5d5e0a 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -27,7 +27,7 @@ # Set to YES for debugging DEBUG = YES ENABLE_DEBUG_PINS = NO -USE_BOOTLOADER = NO +USE_BOOTLOADER = YES # Set to YES when using Code Sourcery toolchain CODE_SOURCERY = YES diff --git a/flight/OpenPilot/System/inc/pios_board.h b/flight/OpenPilot/System/inc/pios_board.h index 115586bfb..b6dab1d05 100644 --- a/flight/OpenPilot/System/inc/pios_board.h +++ b/flight/OpenPilot/System/inc/pios_board.h @@ -206,7 +206,7 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8 #define PIOS_MASTER_CLOCK 72000000 #define PIOS_PERIPHERAL_CLOCK (PIOS_MASTER_CLOCK / 2) #if defined(USE_BOOTLOADER) -#define PIOS_NVIC_VECTTAB_FLASH ((uint32_t)0x08008000) +#define PIOS_NVIC_VECTTAB_FLASH ((uint32_t)0x08006000) #else #define PIOS_NVIC_VECTTAB_FLASH ((uint32_t)0x08000000) #endif diff --git a/flight/PiOS/Common/pios_com.c b/flight/PiOS/Common/pios_com.c index fd33a2aad..ffd3172cf 100644 --- a/flight/PiOS/Common/pios_com.c +++ b/flight/PiOS/Common/pios_com.c @@ -77,6 +77,7 @@ int32_t PIOS_COM_SendBufferNonBlocking(COMPortTypeDef port, uint8_t *buffer, uin { /* Branch depending on selected port */ switch(port) { +#if defined(PIOS_INCLUDE_USART) case COM_DEBUG_USART: return PIOS_USART_TxBufferPutMoreNonBlocking(PIOS_COM_DEBUG_PORT, buffer, len); case COM_USART1: @@ -85,6 +86,7 @@ int32_t PIOS_COM_SendBufferNonBlocking(COMPortTypeDef port, uint8_t *buffer, uin return PIOS_USART_TxBufferPutMoreNonBlocking(USART_2, buffer, len); case COM_USART3: return PIOS_USART_TxBufferPutMoreNonBlocking(USART_3, buffer, len); +#endif case COM_USB_HID: return PIOS_USB_HID_TxBufferPutMoreNonBlocking(buffer, len); default: @@ -106,6 +108,7 @@ int32_t PIOS_COM_SendBuffer(COMPortTypeDef port, uint8_t *buffer, uint16_t len) { /* Branch depending on selected port */ switch(port) { +#if defined(PIOS_INCLUDE_USART) case COM_DEBUG_USART: return PIOS_USART_TxBufferPutMore(PIOS_COM_DEBUG_PORT, buffer, len); case COM_USART1: @@ -114,6 +117,7 @@ int32_t PIOS_COM_SendBuffer(COMPortTypeDef port, uint8_t *buffer, uint16_t len) return PIOS_USART_TxBufferPutMore(USART_2, buffer, len); case COM_USART3: return PIOS_USART_TxBufferPutMore(USART_3, buffer, len); +#endif case COM_USB_HID: return PIOS_USB_HID_TxBufferPutMore(buffer, len); default: @@ -224,6 +228,7 @@ int32_t PIOS_COM_SendFormattedString(COMPortTypeDef port, char *format, ...) uint8_t PIOS_COM_ReceiveBuffer(COMPortTypeDef port) { switch(port) { +#if defined(PIOS_INCLUDE_USART) case COM_DEBUG_USART: return PIOS_USART_RxBufferGet(PIOS_COM_DEBUG_PORT); case COM_USART1: @@ -232,6 +237,7 @@ uint8_t PIOS_COM_ReceiveBuffer(COMPortTypeDef port) return PIOS_USART_RxBufferGet(USART_2); case COM_USART3: return PIOS_USART_RxBufferGet(USART_3); +#endif case COM_USB_HID: return PIOS_USB_HID_RxBufferGet(); /* To suppress warnings */ @@ -248,6 +254,7 @@ uint8_t PIOS_COM_ReceiveBuffer(COMPortTypeDef port) int32_t PIOS_COM_ReceiveBufferUsed(COMPortTypeDef port) { switch(port) { +#if defined(PIOS_INCLUDE_USART) case COM_DEBUG_USART: return PIOS_USART_RxBufferUsed(PIOS_COM_DEBUG_PORT); case COM_USART1: @@ -256,6 +263,7 @@ int32_t PIOS_COM_ReceiveBufferUsed(COMPortTypeDef port) return PIOS_USART_RxBufferUsed(USART_2); case COM_USART3: return PIOS_USART_RxBufferUsed(USART_3); +#endif case COM_USB_HID: return PIOS_USB_HID_DATA_LENGTH; /* To suppress warnings */ diff --git a/flight/PiOS/STM32F10x/link_stm32f10x_HD_BL.ld b/flight/PiOS/STM32F10x/link_stm32f10x_HD_BL.ld index 1dd023228..391b08fa3 100644 --- a/flight/PiOS/STM32F10x/link_stm32f10x_HD_BL.ld +++ b/flight/PiOS/STM32F10x/link_stm32f10x_HD_BL.ld @@ -28,7 +28,7 @@ MEMORY { RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K - FLASH (rx) : ORIGIN = 0x08008000, LENGTH = 480K + FLASH (rx) : ORIGIN = 0x08006000, LENGTH = 488K FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0 EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0