The Mikroe STM32 F4 board now uses /dev/config for configuration data storage. From Ken Pettit

This commit is contained in:
Gregory Nutt
2013-11-01 07:50:35 -06:00
parent f1cb42dab4
commit ac5d6162e4
2 changed files with 62 additions and 25 deletions
+31 -15
View File
@@ -8,55 +8,71 @@ if ARCH_BOARD_MIKROE_STM32F4
config MIKROE_FLASH config MIKROE_FLASH
bool "MTD driver for onboard 1M FLASH" bool "MTD driver for onboard 1M FLASH"
default n default n
select MTD select MTD
select MTD_M25P select MTD_M25P
select MTD_SMART select MTD_SMART
select FS_SMARTFS select FS_SMARTFS
select STM32_SPI3 select STM32_SPI3
select MTD_BYTE_WRITE select MTD_BYTE_WRITE
---help--- ---help---
Configures an MTD device for use with the onboard flash Configures an MTD device for use with the onboard flash
config MIKROE_FLASH_MINOR config MIKROE_FLASH_MINOR
int "Minor number for the FLASH /dev/smart entry" int "Minor number for the FLASH /dev/smart entry"
default 0 default 0
depends on MIKROE_FLASH depends on MIKROE_FLASH
---help--- ---help---
Sets the minor number for the FLASH MTD /dev entry Sets the minor number for the FLASH MTD /dev entry
config MIKROE_FLASH_PART config MIKROE_FLASH_PART
bool "Enable partition support on FLASH" bool "Enable partition support on FLASH"
default n default n
depends on MIKROE_FLASH depends on MIKROE_FLASH
---help--- ---help---
Enables creation of partitions on the FLASH Enables creation of partitions on the FLASH
config MIKROE_FLASH_CONFIG_PART
bool "Create application config data partition on FLASH"
default y
depends on MIKROE_FLASH_PART
depends on PLATFORM_CONFIGDATA
---help---
Enables creation of a /dev/config partition on the FLASH
config MIKROE_FLASH_CONFIG_PART_NUMBER
int "Index number of config partition (in list below)"
default 0
depends on MIKROE_FLASH_CONFIG_PART
---help---
Specifies the index number of the config data partition
from the partition list.
config MIKROE_FLASH_PART_LIST config MIKROE_FLASH_PART_LIST
string "Flash partition size list" string "Flash partition size list"
default "256,768" default "8,248,768"
depends on MIKROE_FLASH_PART depends on MIKROE_FLASH_PART
---help--- ---help---
Comma separated list of partition sizes in KB Comma separated list of partition sizes in KB.
config MIKROE_RAMMTD config MIKROE_RAMMTD
bool "MTD driver for SMARTFS RAM disk" bool "MTD driver for SMARTFS RAM disk"
default n default n
select MTD select MTD
select RAMMTD select RAMMTD
---help--- ---help---
Configures an MTD based RAM device for use with SMARTFS. Configures an MTD based RAM device for use with SMARTFS.
config MIKROE_RAMMTD_MINOR config MIKROE_RAMMTD_MINOR
int "Minor number for RAM /dev/smart entry" int "Minor number for RAM /dev/smart entry"
default 1 default 1
depends on MIKROE_RAMMTD depends on MIKROE_RAMMTD
---help--- ---help---
Sets the minor number for the RAM MTD /dev entry Sets the minor number for the RAM MTD /dev entry
config MIKROE_RAMMTD_SIZE config MIKROE_RAMMTD_SIZE
int "Size in KB of the RAM device to create" int "Size in KB of the RAM device to create"
default 32 default 32
depends on MIKROE_RAMMTD depends on MIKROE_RAMMTD
---help--- ---help---
Sets the size of static RAM allocation for the SMART RAM device Sets the size of static RAM allocation for the SMART RAM device
+31 -10
View File
@@ -59,6 +59,12 @@
# include <apps/usbmonitor.h> # include <apps/usbmonitor.h>
#endif #endif
#ifdef CONFIG_MIKROE_FLASH_CONFIG_PART
#ifdef CONFIG_PLATFORM_CONFIGDATA
# include <nuttx/configdata.h>
#endif
#endif
#ifdef CONFIG_STM32_OTGFS #ifdef CONFIG_STM32_OTGFS
# include "stm32_usbhost.h" # include "stm32_usbhost.h"
#endif #endif
@@ -227,6 +233,7 @@ int nsh_archinitialize(void)
partno = 0; partno = 0;
ptr = partstring; ptr = partstring;
partoffset = 0; partoffset = 0;
while (*ptr != '\0') while (*ptr != '\0')
{ {
/* Get the partition size */ /* Get the partition size */
@@ -235,12 +242,27 @@ int nsh_archinitialize(void)
mtd_part = mtd_partition(mtd, partoffset, (partsize>>2)*16); mtd_part = mtd_partition(mtd, partoffset, (partsize>>2)*16);
partoffset += (partsize >> 2) * 16; partoffset += (partsize >> 2) * 16;
/* Now initialize a SMART Flash block device and bind it to the MTD device */ #ifdef CONFIG_MIKROE_FLASH_CONFIG_PART
/* Test if this is the config partition */
if (CONFIG_MIKROE_FLASH_CONFIG_PART_NUMBER == partno)
{
/* Register the partition as the config device */
mtdconfig_register(mtd_part);
}
else
#endif
{
/* Now initialize a SMART Flash block device and bind it
* to the MTD device.
*/
#if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS) #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS)
sprintf(partname, "p%d", partno); sprintf(partname, "p%d", partno);
smart_initialize(CONFIG_MIKROE_FLASH_MINOR, mtd_part, partname); smart_initialize(CONFIG_MIKROE_FLASH_MINOR, mtd_part, partname);
#endif #endif
}
/* Update the pointer to point to the next size in the list */ /* Update the pointer to point to the next size in the list */
@@ -258,7 +280,6 @@ int nsh_archinitialize(void)
partno++; partno++;
} }
}
#else /* CONFIG_MIKROE_FLASH_PART */ #else /* CONFIG_MIKROE_FLASH_PART */
/* Configure the device with no partition support */ /* Configure the device with no partition support */
@@ -266,20 +287,21 @@ int nsh_archinitialize(void)
smart_initialize(CONFIG_MIKROE_FLASH_MINOR, mtd, NULL); smart_initialize(CONFIG_MIKROE_FLASH_MINOR, mtd, NULL);
#endif /* CONFIG_MIKROE_FLASH_PART */ #endif /* CONFIG_MIKROE_FLASH_PART */
}
} }
/* Create a RAM MTD device if configured */ /* Create a RAM MTD device if configured */
#if defined(CONFIG_RAMMTD) && defined(CONFIG_MIKROE_RAMMTD) #if defined(CONFIG_RAMMTD) && defined(CONFIG_MIKROE_RAMMTD)
{ {
uint8_t *start = (uint8_t *) kmalloc(CONFIG_MIKROE_RAMMTD_SIZE * 1024); uint8_t *start = (uint8_t *) kmalloc(CONFIG_MIKROE_RAMMTD_SIZE * 1024);
mtd = rammtd_initialize(start, CONFIG_MIKROE_RAMMTD_SIZE * 1024); mtd = rammtd_initialize(start, CONFIG_MIKROE_RAMMTD_SIZE * 1024);
mtd->ioctl(mtd, MTDIOC_BULKERASE, 0); mtd->ioctl(mtd, MTDIOC_BULKERASE, 0);
/* Now initialize a SMART Flash block device and bind it to the MTD device */ /* Now initialize a SMART Flash block device and bind it to the MTD device */
#if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS) #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS)
smart_initialize(CONFIG_MIKROE_RAMMTD_MINOR, mtd, NULL); smart_initialize(CONFIG_MIKROE_RAMMTD_MINOR, mtd, NULL);
#endif #endif
} }
@@ -308,7 +330,6 @@ int nsh_archinitialize(void)
else else
{ {
message("nsh_archinitialize: Successfully bound SPI to the MMC/SD driver\n"); message("nsh_archinitialize: Successfully bound SPI to the MMC/SD driver\n");
} }
#endif #endif