mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
Merge remote-tracking branch 'origin/next' into brian/rfm22_FHSS
This commit is contained in:
commit
4778a12070
@ -34,6 +34,7 @@
|
|||||||
#ifdef PIOS_INCLUDE_FLASH
|
#ifdef PIOS_INCLUDE_FLASH
|
||||||
|
|
||||||
#include "pios_flash_jedec_priv.h"
|
#include "pios_flash_jedec_priv.h"
|
||||||
|
#include "pios_flash_jedec_catalog.h"
|
||||||
|
|
||||||
#define JEDEC_WRITE_ENABLE 0x06
|
#define JEDEC_WRITE_ENABLE 0x06
|
||||||
#define JEDEC_WRITE_DISABLE 0x04
|
#define JEDEC_WRITE_DISABLE 0x04
|
||||||
@ -119,21 +120,31 @@ static int32_t PIOS_Flash_Jedec_Validate(struct jedec_flash_dev * flash_dev) {
|
|||||||
/**
|
/**
|
||||||
* @brief Initialize the flash device and enable write access
|
* @brief Initialize the flash device and enable write access
|
||||||
*/
|
*/
|
||||||
int32_t PIOS_Flash_Jedec_Init(uintptr_t * flash_id, uint32_t spi_id, uint32_t slave_num, const struct pios_flash_jedec_cfg * cfg)
|
int32_t PIOS_Flash_Jedec_Init(uintptr_t * flash_id, uint32_t spi_id, uint32_t slave_num)
|
||||||
{
|
{
|
||||||
struct jedec_flash_dev * flash_dev = PIOS_Flash_Jedec_alloc();
|
struct jedec_flash_dev * flash_dev = PIOS_Flash_Jedec_alloc();
|
||||||
if (flash_dev == NULL)
|
if (!flash_dev) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
flash_dev->spi_id = spi_id;
|
flash_dev->spi_id = spi_id;
|
||||||
flash_dev->slave_num = slave_num;
|
flash_dev->slave_num = slave_num;
|
||||||
flash_dev->cfg = cfg;
|
flash_dev->cfg = NULL;
|
||||||
|
|
||||||
(void) PIOS_Flash_Jedec_ReadID(flash_dev);
|
(void) PIOS_Flash_Jedec_ReadID(flash_dev);
|
||||||
if ((flash_dev->manufacturer != flash_dev->cfg->expect_manufacturer) ||
|
|
||||||
(flash_dev->memorytype != flash_dev->cfg->expect_memorytype) ||
|
for (uint32_t i = 0; i < pios_flash_jedec_catalog_size; ++i) {
|
||||||
(flash_dev->capacity != flash_dev->cfg->expect_capacity)) {
|
const struct pios_flash_jedec_cfg flash_jedec_entry = pios_flash_jedec_catalog[i];
|
||||||
/* Mismatched device has been discovered */
|
|
||||||
|
if ((flash_dev->manufacturer == flash_jedec_entry.expect_manufacturer)
|
||||||
|
&& (flash_dev->memorytype == flash_jedec_entry.expect_memorytype)
|
||||||
|
&& (flash_dev->capacity == flash_jedec_entry.expect_capacity)) {
|
||||||
|
flash_dev->cfg = &pios_flash_jedec_catalog[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flash_dev->cfg) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
71
flight/PiOS/inc/pios_flash_jedec_catalog.h
Normal file
71
flight/PiOS/inc/pios_flash_jedec_catalog.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||||
|
* @{
|
||||||
|
* @addtogroup PIOS_FLASH JEDEC devices catalog
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file pios_flash_jedec_catalog.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
|
||||||
|
* @brief Driver for talking to most JEDEC flash chips
|
||||||
|
* @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_FLASH_JEDEC_CATALOG_H_
|
||||||
|
#define PIOS_FLASH_JEDEC_CATALOG_H_
|
||||||
|
#include <pios_flash_jedec_priv.h>
|
||||||
|
|
||||||
|
// this structure contains the catalog of all "known" flash chip used
|
||||||
|
const struct pios_flash_jedec_cfg pios_flash_jedec_catalog [] =
|
||||||
|
{
|
||||||
|
{ // m25p16
|
||||||
|
.expect_manufacturer = JEDEC_MANUFACTURER_ST,
|
||||||
|
.expect_memorytype = 0x20,
|
||||||
|
.expect_capacity = 0x15,
|
||||||
|
.sector_erase = 0xD8,
|
||||||
|
.chip_erase = 0xC7,
|
||||||
|
},
|
||||||
|
{ // m25px16
|
||||||
|
.expect_manufacturer = JEDEC_MANUFACTURER_ST,
|
||||||
|
.expect_memorytype = 0x71,
|
||||||
|
.expect_capacity = 0x15,
|
||||||
|
.sector_erase = 0xD8,
|
||||||
|
.chip_erase = 0xC7,
|
||||||
|
},
|
||||||
|
{ //w25x
|
||||||
|
.expect_manufacturer = JEDEC_MANUFACTURER_WINBOND,
|
||||||
|
.expect_memorytype = 0x30,
|
||||||
|
.expect_capacity = 0x13,
|
||||||
|
.sector_erase = 0x20,
|
||||||
|
.chip_erase = 0x60
|
||||||
|
},
|
||||||
|
{ //25q16
|
||||||
|
.expect_manufacturer = JEDEC_MANUFACTURER_WINBOND,
|
||||||
|
.expect_memorytype = 0x40,
|
||||||
|
.expect_capacity = 0x15,
|
||||||
|
.sector_erase = 0x20,
|
||||||
|
.chip_erase = 0x60
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const uint32_t pios_flash_jedec_catalog_size = NELEMENTS(pios_flash_jedec_catalog);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* PIOS_FLASH_JEDEC_CATALOG_H_ */
|
@ -47,6 +47,6 @@ struct pios_flash_jedec_cfg {
|
|||||||
uint32_t chip_erase;
|
uint32_t chip_erase;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t PIOS_Flash_Jedec_Init(uintptr_t * flash_id, uint32_t spi_id, uint32_t slave_num, const struct pios_flash_jedec_cfg * cfg);
|
int32_t PIOS_Flash_Jedec_Init(uintptr_t * flash_id, uint32_t spi_id, uint32_t slave_num);
|
||||||
|
|
||||||
#endif /* PIOS_FLASH_JEDEC_H */
|
#endif /* PIOS_FLASH_JEDEC_H */
|
||||||
|
@ -169,12 +169,20 @@ void PIOS_Board_Init(void) {
|
|||||||
uintptr_t fs_id;
|
uintptr_t fs_id;
|
||||||
switch(bdinfo->board_rev) {
|
switch(bdinfo->board_rev) {
|
||||||
case BOARD_REVISION_CC:
|
case BOARD_REVISION_CC:
|
||||||
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 1, &flash_w25x_cfg);
|
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 1)) {
|
||||||
PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_w25x_cfg, &pios_jedec_flash_driver, flash_id);
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
if (PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_w25x_cfg, &pios_jedec_flash_driver, flash_id)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BOARD_REVISION_CC3D:
|
case BOARD_REVISION_CC3D:
|
||||||
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 0, &flash_m25p_cfg);
|
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 0)) {
|
||||||
PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id);
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
if (PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PIOS_DEBUG_Assert(0);
|
PIOS_DEBUG_Assert(0);
|
||||||
|
@ -342,9 +342,15 @@ void PIOS_Board_Init(void) {
|
|||||||
#if defined(PIOS_INCLUDE_FLASH)
|
#if defined(PIOS_INCLUDE_FLASH)
|
||||||
/* Connect flash to the appropriate interface and configure it */
|
/* Connect flash to the appropriate interface and configure it */
|
||||||
uintptr_t flash_id;
|
uintptr_t flash_id;
|
||||||
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_id, 1, &flash_m25p_cfg);
|
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_id, 1)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
uintptr_t fs_id;
|
uintptr_t fs_id;
|
||||||
PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id);
|
if (PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialize UAVObject libraries */
|
/* Initialize UAVObject libraries */
|
||||||
|
@ -386,14 +386,20 @@ void PIOS_Board_Init(void) {
|
|||||||
}
|
}
|
||||||
/* Connect flash to the appropriate interface and configure it */
|
/* Connect flash to the appropriate interface and configure it */
|
||||||
uintptr_t flash_id;
|
uintptr_t flash_id;
|
||||||
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_id, 0, &flash_m25p_cfg);
|
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_id, 0)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Connect flash to the appropriate interface and configure it */
|
/* Connect flash to the appropriate interface and configure it */
|
||||||
uintptr_t flash_id;
|
uintptr_t flash_id;
|
||||||
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_accel_id, 1, &flash_m25p_cfg);
|
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_accel_id, 1)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
uintptr_t fs_id;
|
uintptr_t fs_id;
|
||||||
PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id);
|
if (PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize UAVObject libraries */
|
/* Initialize UAVObject libraries */
|
||||||
EventDispatcherInitialize();
|
EventDispatcherInitialize();
|
||||||
|
@ -414,13 +414,7 @@ static const struct flashfs_logfs_cfg flashfs_w25x_cfg = {
|
|||||||
.page_size = 0x00000100, /* 256 bytes */
|
.page_size = 0x00000100, /* 256 bytes */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct pios_flash_jedec_cfg flash_w25x_cfg = {
|
|
||||||
.expect_manufacturer = JEDEC_MANUFACTURER_WINBOND,
|
|
||||||
.expect_memorytype = 0x30,
|
|
||||||
.expect_capacity = 0x13,
|
|
||||||
.sector_erase = 0x20,
|
|
||||||
.chip_erase = 0x60
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct flashfs_logfs_cfg flashfs_m25p_cfg = {
|
static const struct flashfs_logfs_cfg flashfs_m25p_cfg = {
|
||||||
.fs_magic = 0x99abceef,
|
.fs_magic = 0x99abceef,
|
||||||
@ -433,14 +427,6 @@ static const struct flashfs_logfs_cfg flashfs_m25p_cfg = {
|
|||||||
.page_size = 0x00000100, /* 256 bytes */
|
.page_size = 0x00000100, /* 256 bytes */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct pios_flash_jedec_cfg flash_m25p_cfg = {
|
|
||||||
.expect_manufacturer = JEDEC_MANUFACTURER_ST,
|
|
||||||
.expect_memorytype = 0x20,
|
|
||||||
.expect_capacity = 0x15,
|
|
||||||
.sector_erase = 0xD8,
|
|
||||||
.chip_erase = 0xC7,
|
|
||||||
};
|
|
||||||
|
|
||||||
#include "pios_flash.h"
|
#include "pios_flash.h"
|
||||||
|
|
||||||
#endif /* PIOS_INCLUDE_FLASH */
|
#endif /* PIOS_INCLUDE_FLASH */
|
||||||
|
@ -462,14 +462,6 @@ static const struct flashfs_logfs_cfg flashfs_m25p_cfg = {
|
|||||||
.page_size = 0x00000100, /* 256 bytes */
|
.page_size = 0x00000100, /* 256 bytes */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct pios_flash_jedec_cfg flash_m25p_cfg = {
|
|
||||||
.expect_manufacturer = JEDEC_MANUFACTURER_ST,
|
|
||||||
.expect_memorytype = 0x20,
|
|
||||||
.expect_capacity = 0x15,
|
|
||||||
.sector_erase = 0xD8,
|
|
||||||
.chip_erase = 0xC7,
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* PIOS_INCLUDE_FLASH */
|
#endif /* PIOS_INCLUDE_FLASH */
|
||||||
|
|
||||||
#if defined(PIOS_OVERO_SPI)
|
#if defined(PIOS_OVERO_SPI)
|
||||||
|
@ -617,14 +617,6 @@ static const struct flashfs_logfs_cfg flashfs_m25p_cfg = {
|
|||||||
.page_size = 0x00000100, /* 256 bytes */
|
.page_size = 0x00000100, /* 256 bytes */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct pios_flash_jedec_cfg flash_m25p_cfg = {
|
|
||||||
.expect_manufacturer = JEDEC_MANUFACTURER_ST,
|
|
||||||
.expect_memorytype = 0x20,
|
|
||||||
.expect_capacity = 0x15,
|
|
||||||
.sector_erase = 0xD8,
|
|
||||||
.chip_erase = 0xC7,
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* PIOS_INCLUDE_FLASH */
|
#endif /* PIOS_INCLUDE_FLASH */
|
||||||
|
|
||||||
#include <pios_usart_priv.h>
|
#include <pios_usart_priv.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user