1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-27 16:54:15 +01:00

OP-917 Various review fixes:

-Fixed casing for PIOS_BL_HELPER_FLASH_ERASE_BOOTLOADER
-fixed wrong condition in f1 bl_helper
-other cosmetic changes and use of stdbool in f1 pios_bl_helper
-remove now unused macros

+review OPReview-456
This commit is contained in:
Alessio Morale 2013-04-28 10:19:08 +02:00
parent 9f56fe9a1e
commit 41ecc09c3f
6 changed files with 19 additions and 30 deletions

View File

@ -36,7 +36,7 @@ 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 uint8_t PIOS_BL_HELPER_FLASH_ERASE_BOOTLOADER();
extern uint8_t PIOS_BL_HELPER_FLASH_Erase_Bootloader();
extern void PIOS_BL_HELPER_CRC_Ini();
#endif /* PIOS_BL_HELPER_H */

View File

@ -28,13 +28,13 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "pios.h"
#include <pios.h>
#ifdef PIOS_INCLUDE_BL_HELPER
#include <pios_board_info.h>
#include "stm32f10x_flash.h"
#include <stm32f10x_flash.h>
#include <stdbool.h>
uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress)
{
@ -62,7 +62,7 @@ uint8_t PIOS_BL_HELPER_FLASH_Start()
return (success) ? 1 : 0;
}
uint8_t PIOS_BL_HELPER_FLASH_ERASE_BOOTLOADER() {
uint8_t PIOS_BL_HELPER_FLASH_Erase_Bootloader() {
/// Bootloader memory space erase
uint32_t startAddress = BL_BANK_BASE;
uint32_t endAddress = BL_BANK_BASE + BL_BANK_SIZE;
@ -73,23 +73,22 @@ uint8_t PIOS_BL_HELPER_FLASH_ERASE_BOOTLOADER() {
}
static bool erase_flash(uint32_t startAddress, uint32_t endAddress) {
uint32_t pageAdress = startAddress;
uint8_t fail = FALSE;
while ((pageAdress < endAddress)
|| (fail == TRUE)) {
uint32_t pageAddress = startAddress;
uint8_t fail = false;
while ((pageAddress < endAddress) && (fail == false)) {
for (int retry = 0; retry < MAX_DEL_RETRYS; ++retry) {
if (FLASH_ErasePage(pageAdress) == FLASH_COMPLETE) {
fail = FALSE;
if (FLASH_ErasePage(pageAddress) == FLASH_COMPLETE) {
fail = false;
break;
} else {
fail = TRUE;
fail = true;
}
}
#ifdef STM32F10X_HD
pageAdress += 2048;
pageAddress += 2048;
#elif defined (STM32F10X_MD)
pageAdress += 1024;
pageAddress += 1024;
#endif
}
return !fail;

View File

@ -28,15 +28,14 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "pios.h"
#include <pios.h>
#ifdef PIOS_INCLUDE_BL_HELPER
#include <pios_board_info.h>
#include "stm32f4xx_flash.h"
#include <stm32f4xx_flash.h>
#include <stdbool.h>
uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress)
{
return (uint8_t *) (SectorAddress);
@ -151,7 +150,7 @@ uint8_t PIOS_BL_HELPER_FLASH_Start()
}
uint8_t PIOS_BL_HELPER_FLASH_ERASE_BOOTLOADER() {
uint8_t PIOS_BL_HELPER_FLASH_Erase_Bootloader() {
/// Bootloader memory space erase
uint32_t startAddress = BL_BANK_BASE;
uint32_t endAddress = BL_BANK_BASE + BL_BANK_SIZE;
@ -165,8 +164,7 @@ static bool erase_flash(uint32_t startAddress, uint32_t endAddress)
{
uint32_t pageAddress = startAddress;
bool fail = false;
while ((pageAddress < endAddress)
&& (fail == false)) {
while ((pageAddress < endAddress) && (fail == false)) {
uint8_t sector_number;
uint32_t sector_start;
uint32_t sector_size;

View File

@ -34,7 +34,6 @@
#define PIOS_INCLUDE_DELAY
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_IRQ
//#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_BL_HELPER
#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT

View File

@ -37,9 +37,6 @@ extern void PIOS_Board_Init(void);
extern void FLASH_Download();
void error(int, int);
#ifdef STM32F4XX
#define FLASH_ErasePage(x) FLASH_EraseSector((x) > 0x08000000 ? FLASH_Sector_1 : FLASH_Sector_0, VoltageRange_3)
#endif
/* The ADDRESSES of the _binary_* symbols are the important
* data. This is non-intuitive for _binary_size where you
* might expect its value to hold the size but you'd be wrong.
@ -93,7 +90,7 @@ int main()
bool fail;
fail = (PIOS_BL_HELPER_FLASH_ERASE_BOOTLOADER() != 1);
fail = (PIOS_BL_HELPER_FLASH_Erase_Bootloader() != 1);
if (fail == true){
error(PIOS_LED_HEARTBEAT, 3);
@ -105,7 +102,7 @@ int main()
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT);
for (uint8_t retry = 0; retry < MAX_WRI_RETRYS; ++retry) {
if (result == false) {
result = (FLASH_ProgramWord(0x08000000 + (offset * 4), embedded_image_start[offset]) == FLASH_COMPLETE);
result = (FLASH_ProgramWord(BL_BANK_BASE + (offset * 4), embedded_image_start[offset]) == FLASH_COMPLETE);
}
}
if (result == false) {

View File

@ -34,10 +34,6 @@
* NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE
*/
#include <board_hw_defs.c>
#ifdef STM32F4XX
#define FLASH_ErasePage(x) FLASH_EraseSector(x,VoltageRange_3)
#endif
void PIOS_Board_Init(void) {
const struct pios_board_info * bdinfo = &pios_board_info_blob;