on the SIDK S5JT200 evaluation board. It can be the
size of erase unit flash memory supports.
+config SIDK_S5JT200_FLASH_MINOR
+ int "Minor number for the FLASH /dev/smart entry"
+ default 0
+ depends on S5J_SFLASH
+ ---help---
+ Sets the minor number for /dev node of the external flash
+ device.
+
+config SIDK_S5JT200_FLASH_PART
+ bool "Enable partition support on FLASH"
+ default n
+ depends on S5J_SFLASH
+ ---help---
+ Enables creation of partitions on the FLASH
+
+config SIDK_S5JT200_FLASH_PART_LIST
+ string "Flash partition size list (in KBytes)"
+ default "8192,"
+ depends on SIDK_S5JT200_FLASH_PART
+ ---help---
+ Comma separated list of partition sizes in KB.
+
+config SIDK_S5JT200_FLASH_PART_TYPE
+ string "Flash partition type list"
+ default "none,"
+ ---help---
+ Comma separated list of partition types that can be
+ one of followings: none, smartfs
+
+config SIDK_S5JT200_FLASH_PART_NAME
+ string "FLash partition name list"
+ default "mx25,"
+ depends on SIDK_S5JT200_FLASH_PART
+ depends on MTD_PARTITION_NAMES
+ ---help---
+ Comma separated list of partition names.
+
endif
#include "s5j_rtc.h"
#include "up_internal.h"
+#include <tinyara/fs/mtd.h>
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#endif
}
+static void sidk_s5jt200_configure_partitions(void)
+{
+#if defined(CONFIG_SIDK_S5JT200_FLASH_PART)
+ int partno;
+ int partoffset;
+ const char *parts = CONFIG_SIDK_S5JT200_FLASH_PART_LIST;
+ const char *types = CONFIG_SIDK_S5JT200_FLASH_PART_TYPE;
+#if defined(CONFIG_MTD_PARTITION_NAMES)
+ const char *names = CONFIG_SIDK_S5JT200_FLASH_PART_NAME;
+#endif
+ FAR struct mtd_dev_s *mtd;
+ FAR struct mtd_geometry_s geo;
+
+ mtd = progmem_initialize();
+ if (!mtd) {
+ lldbg("ERROR: progmem_initialize failed\n");
+ return;
+ }
+
+ if (mtd->ioctl(mtd, MTDIOC_GEOMETRY, (unsigned long)&geo) < 0) {
+ lldbg("ERROR: mtd->ioctl failed\n");
+ return;
+ }
+
+ partno = 0;
+ partoffset = 0;
+
+ while (*parts) {
+ FAR struct mtd_dev_s *mtd_part;
+ int partsize;
+
+ partsize = strtoul(parts, NULL, 0) << 10;
+
+ if (partsize < geo.erasesize) {
+ lldbg("ERROR: Partition size is lesser than erasesize\n");
+ return;
+ }
+
+ if (partsize % geo.erasesize != 0) {
+ lldbg("ERROR: Partition size is not multiple of erasesize\n");
+ return;
+ }
+
+ mtd_part = mtd_partition(mtd, partoffset,
+ partsize / geo.erasesize, 0);
+ partoffset += partsize / geo.erasesize;
+
+ if (!mtd_part) {
+ lldbg("ERROR: failed to create partition.\n");
+ return;
+ }
+
+#if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS)
+ if (!strncmp(types, "smartfs,", 8)) {
+ char partref[4];
+ sprintf(partref, "p%d", partno);
+ smart_initialize(CONFIG_SIDK_S5JT200_FLASH_MINOR,
+ mtd_part, partref);
+ }
+#endif
+
+#if defined(CONFIG_MTD_PARTITION_NAMES)
+ if (strcmp(names, ""))
+ mtd_setpartitionname(mtd_part, names);
+
+ while (*names != ',' && *names) names++;
+ if (*names == ',') names++;
+#endif
+
+ while (*parts != ',' && *parts) parts++;
+ if (*parts == ',') parts++;
+
+ while (*types != ',' && *types) types++;
+ if (*types == ',') types++;
+
+ partno++;
+ }
+#endif /* CONFIG_SIDK_S5JT200_FLASH_PART */
+}
+
/****************************************************************************
* Name: board_app_initialize
*
FAR struct tm tp;
#endif
+ sidk_s5jt200_configure_partitions();
+
#ifdef CONFIG_S5J_I2C
s5j_i2c_register(0);
s5j_i2c_register(1);