diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index dece98a972..564e375eb3 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -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) diff --git a/cpu/native/include/eeprom_native.h b/cpu/native/include/eeprom_native.h index 788405cfa2..eb1238029a 100644 --- a/cpu/native/include/eeprom_native.h +++ b/cpu/native/include/eeprom_native.h @@ -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 * diff --git a/cpu/native/include/periph_cpu.h b/cpu/native/include/periph_cpu.h index cdf3b529de..8d34804fe0 100644 --- a/cpu/native/include/periph_cpu.h +++ b/cpu/native/include/periph_cpu.h @@ -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 diff --git a/cpu/native/startup.c b/cpu/native/startup.c index 9c149f203c..a9fb963dd3 100644 --- a/cpu/native/startup.c +++ b/cpu/native/startup.c @@ -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=\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);