summaryrefslogtreecommitdiff
path: root/apps/platform
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-11-01 07:50:35 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-11-01 07:50:35 -0600
commit9741311259ee5434987dc8c9918f29e355d22c4f (patch)
treedfee89d28f7e4e17937f0d047ec69f8be4d44998 /apps/platform
parent8d05d097e7089f3a4ce15e29cf3b7701580665b2 (diff)
downloadnuttx-9741311259ee5434987dc8c9918f29e355d22c4f.tar.gz
nuttx-9741311259ee5434987dc8c9918f29e355d22c4f.tar.bz2
nuttx-9741311259ee5434987dc8c9918f29e355d22c4f.zip
The Mikroe STM32 F4 board now uses /dev/config for configuration data storage. From Ken Pettit
Diffstat (limited to 'apps/platform')
-rw-r--r--apps/platform/mikroe-stm32f4/Kconfig10
-rw-r--r--apps/platform/mikroe-stm32f4/mikroe_configdata.c66
2 files changed, 61 insertions, 15 deletions
diff --git a/apps/platform/mikroe-stm32f4/Kconfig b/apps/platform/mikroe-stm32f4/Kconfig
index 55a1475bd..a26765ccf 100644
--- a/apps/platform/mikroe-stm32f4/Kconfig
+++ b/apps/platform/mikroe-stm32f4/Kconfig
@@ -12,7 +12,7 @@ choice
default MIKROE_STM32F4_CONFIGDATA_PART
config MIKROE_STM32F4_CONFIGDATA_PART
- bool "Dedicated FLASH partition"
+ bool "Dedicated FLASH partition using /dev/config"
config MIKROE_STM32F4_CONFIGDATA_FS
bool "File system file"
@@ -32,14 +32,6 @@ config MIKROE_STM32F4_CONFIGDATA_FILENAME
endif
-if MIKROE_STM32F4_CONFIGDATA_PART
-
-config MIKROE_STM32F4_CONFIGDATA_PART_SIZE
- int "Size (in erase blocks) of configuration data partition"
- default 2
-
-endif
-
endif
endif
diff --git a/apps/platform/mikroe-stm32f4/mikroe_configdata.c b/apps/platform/mikroe-stm32f4/mikroe_configdata.c
index 5147a95c9..957bc0985 100644
--- a/apps/platform/mikroe-stm32f4/mikroe_configdata.c
+++ b/apps/platform/mikroe-stm32f4/mikroe_configdata.c
@@ -46,6 +46,8 @@
#include <debug.h>
#include <apps/platform/configdata.h>
+#include <nuttx/fs/ioctl.h>
+#include <nuttx/configdata.h>
#ifdef CONFIG_PLATFORM_CONFIGDATA
@@ -108,6 +110,11 @@ int platform_setconfig(enum config_data_e id, int instance,
#ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_FS
FILE* fd;
#endif
+#if CONFIG_MIKROE_STM32F4_CONFIGDATA_PART
+ struct config_data_s config;
+ int ret;
+ int fd;
+#endif
switch (id)
{
@@ -137,9 +144,29 @@ int platform_setconfig(enum config_data_e id, int instance,
fclose(fd);
return OK;
-#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_PART
-# error This configuration not supported yet!
-#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
+#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_PART
+
+ /* Try to open the /dev/config device file */
+
+ if ((fd = open("/dev/config", O_RDOK)) == -1)
+ {
+ /* Error opening the config device */
+
+ return -1;
+ }
+
+ /* Setup structure for the SETCONFIG ioctl */
+
+ config.id = (enum config_data_e)id;
+ config.instance = instance;
+ config.configdata = (FAR uint8_t *) configdata;
+ config.len = datalen;
+
+ ret = ioctl(fd, CFGDIOC_SETCONFIG, (unsigned long) &config);
+ close(fd);
+ return ret;
+
+#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
/* We are reading from a read-only system, so nothing to do. */
@@ -194,12 +221,17 @@ int platform_getconfig(enum config_data_e id, int instance,
size_t bytes;
enum config_data_e saved_id;
int saved_instance;
-#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
+#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
static const uint8_t touch_cal_data[] = {
- 0x9a, 0x2f, 0x00, 0x00,
+ 0x9a, 0x2f, 0x00, 0x00,
0x40, 0xbc, 0x69, 0xfe, 0x70, 0x2e, 0x00,
0x00, 0xb8, 0x2d, 0xdb, 0xff };
#endif
+#if CONFIG_MIKROE_STM32F4_CONFIGDATA_PART
+ struct config_data_s config;
+ int ret;
+ int fd;
+#endif
switch (id)
{
@@ -240,7 +272,29 @@ int platform_getconfig(enum config_data_e id, int instance,
return OK;
-#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
+#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_PART
+
+ /* Try to open the /dev/config device file */
+
+ if ((fd = open("/dev/config", O_RDOK)) == -1)
+ {
+ /* Error opening the config device */
+
+ return -1;
+ }
+
+ /* Setup structure for the SETCONFIG ioctl */
+
+ config.id = (enum config_data_e)id;
+ config.instance = instance;
+ config.configdata = configdata;
+ config.len = datalen;
+
+ ret = ioctl(fd, CFGDIOC_GETCONFIG, (unsigned long) &config);
+ close(fd);
+ return ret;
+
+#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM
memcpy(configdata, touch_cal_data, datalen);
return OK;