1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

native: pass eeprom file path via command line

This commit is contained in:
Alexandre Abadie 2019-11-14 13:51:25 +01:00
parent decd73129c
commit 5a9f01d91a
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
4 changed files with 32 additions and 8 deletions

View File

@ -73,7 +73,15 @@ ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
PORT ?= tap0
endif
TERMFLAGS := $(PORT) $(TERMFLAGS)
# Configure default eeprom file
EEPROM_FILE ?= $(BINDIR)/native.eeprom
# set the eeprom file flags only when the periph_eeprom feature is used.
# NOTE: This can be turned into normal conditional syntax once #9913 is fixed
EEPROM_FILE_FLAGS = $(if $(filter periph_eeprom,$(FEATURES_USED)),--eeprom $(EEPROM_FILE),)
TERMFLAGS += $(EEPROM_FILE_FLAGS)
TERMFLAGS += $(PORT)
ASFLAGS =
ifeq ($(shell basename $(DEBUGGER)),lldb)

View File

@ -27,6 +27,10 @@
extern "C" {
#endif
#ifndef EEPROM_FILEPATH_MAX_LEN
#define EEPROM_FILEPATH_MAX_LEN (128U) /**< Maximum path len to store the EEPROM filepath */
#endif
/**
* @brief Read the configured file containing the EEPROM content
*

View File

@ -99,9 +99,6 @@ typedef enum {
#ifndef EEPROM_SIZE
#define EEPROM_SIZE (1024U) /* 1kB */
#endif
#ifndef EEPROM_FILE
#define EEPROM_FILE "/tmp/riot_native.eeprom"
#endif
/** @} */
#ifdef __cplusplus

View File

@ -47,10 +47,6 @@
#include "periph/init.h"
#include "periph/pm.h"
#ifdef MODULE_PERIPH_EEPROM
#include "eeprom_native.h"
#endif
#define ENABLE_DEBUG (0)
#include "debug.h"
@ -90,6 +86,10 @@ netdev_tap_params_t netdev_tap_params[NETDEV_TAP_MAX];
socket_zep_params_t socket_zep_params[SOCKET_ZEP_MAX];
#endif
#ifdef MODULE_PERIPH_EEPROM
#include "eeprom_native.h"
extern char eeprom_file[EEPROM_FILEPATH_MAX_LEN];
#endif
static const char short_opts[] = ":hi:s:deEoc:"
#ifdef MODULE_MTD_NATIVE
@ -126,6 +126,9 @@ static const struct option long_opts[] = {
#endif
#ifdef MODULE_PERIPH_SPIDEV_LINUX
{ "spi", required_argument, NULL, 'p' },
#endif
#ifdef MODULE_PERIPH_EEPROM
{ "eeprom", required_argument, NULL, 'M' },
#endif
{ NULL, 0, NULL, '\0' },
};
@ -318,6 +321,12 @@ void usage_exit(int status)
" SPI_DEV(0) and SPI_HWCS(1).\n"
" Supports up to %d buses with %d CS lines each.\n", SPI_NUMOF, SPI_MAXCS
);
#endif
#ifdef MODULE_PERIPH_EEPROM
real_printf(
" -M <eeprom> , --eeprom=<eeprom>\n"
" Specify the file path where the EEPROM content is stored\n"
" Example: --eeprom=/tmp/riot_native.eeprom\n");
#endif
real_exit(status);
}
@ -504,6 +513,12 @@ __attribute__((constructor)) static void startup(int argc, char **argv, char **e
}
}
break;
#endif
#ifdef MODULE_PERIPH_EEPROM
case 'M': {
strncpy(eeprom_file, optarg, EEPROM_FILEPATH_MAX_LEN);
break;
}
#endif
default:
usage_exit(EXIT_FAILURE);