Skip to content

Commit

Permalink
Allows a board config to override the number of partitions and names
Browse files Browse the repository at this point in the history
   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.
  • Loading branch information
David Sidrane authored and LorenzMeier committed Jan 20, 2017
1 parent b4235fb commit 85de43e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/systemcmds/mtd/mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

#include <arch/board/board.h>

#include "systemlib/px4_macros.h"
#include "systemlib/systemlib.h"
#include "systemlib/param/param.h"
#include "systemlib/err.h"
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 85de43e

Please sign in to comment.