From 1d4ae4c68326bcb81e7162f457330a7cdba5ca74 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 19 Jan 2017 14:01:59 -1000 Subject: [PATCH] Allows a board config to override the number of partitions and names A board_config may define BOARD_HAS_MTD_PARTITION_OVERRIDE to uses it's own number of partitions and names. If a BOARD_HAS_MTD_PARTITION_OVERRIDE is not defined the hardcoded original values of fs/mtd_params & /fs/mtd_waypoints are used. on an mtd device. --- src/systemcmds/mtd/mtd.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/systemcmds/mtd/mtd.c b/src/systemcmds/mtd/mtd.c index 9e768842b2..1379ceae17 100644 --- a/src/systemcmds/mtd/mtd.c +++ b/src/systemcmds/mtd/mtd.c @@ -59,6 +59,7 @@ #include +#include "systemlib/px4_macros.h" #include "systemlib/systemlib.h" #include "systemlib/param/param.h" #include "systemlib/err.h" @@ -77,6 +78,13 @@ int mtd_main(int argc, char *argv[]) #else +# if defined(BOARD_HAS_MTD_PARTITION_OVERRIDE) +# define MTD_PARTITION_TABLE BOARD_HAS_MTD_PARTITION_OVERRIDE +# else +# define MTD_PARTITION_TABLE {"/fs/mtd_params", "/fs/mtd_waypoints"} +# endif + + #ifdef CONFIG_MTD_RAMTRON static void ramtron_attach(void); #else @@ -107,8 +115,8 @@ static struct mtd_dev_s *mtd_dev; static unsigned n_partitions_current = 0; /* note, these will be equally sized */ -static char *partition_names_default[] = {"/fs/mtd_params", "/fs/mtd_waypoints"}; -static const int n_partitions_default = sizeof(partition_names_default) / sizeof(partition_names_default[0]); +static char *partition_names_default[] = MTD_PARTITION_TABLE; +static const int n_partitions_default = arraySize(partition_names_default); static void mtd_status(void) @@ -353,7 +361,7 @@ int mtd_get_geometry(unsigned long *blocksize, unsigned long *erasesize, unsigne } *blocksize = geo.blocksize; - *erasesize = geo.blocksize; + *erasesize = geo.erasesize; *neraseblocks = geo.neraseblocks; /* Determine the size of each partition. Make each partition an even