From 2541a4cb13f0fa02fa1bd1586e244093012d9ae2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 3 Jun 2016 07:58:54 -0600 Subject: [PATCH 1/6] apps/fsutils/flash_eraseall: Add MDIOC_BULKERASE IOCTL wrapper function --- ChangeLog.txt | 2 + fsutils/Kconfig | 1 + fsutils/flash_eraseall/.gitignore | 11 +++ fsutils/flash_eraseall/Kconfig | 15 ++++ fsutils/flash_eraseall/Make.defs | 38 +++++++++ fsutils/flash_eraseall/Makefile | 102 ++++++++++++++++++++++++ fsutils/flash_eraseall/flash_eraseall.c | 97 ++++++++++++++++++++++ include/fsutils/flash_eraseall.h | 61 ++++++++++++++ 8 files changed, 327 insertions(+) create mode 100644 fsutils/flash_eraseall/.gitignore create mode 100644 fsutils/flash_eraseall/Kconfig create mode 100644 fsutils/flash_eraseall/Make.defs create mode 100644 fsutils/flash_eraseall/Makefile create mode 100644 fsutils/flash_eraseall/flash_eraseall.c create mode 100644 include/fsutils/flash_eraseall.h diff --git a/ChangeLog.txt b/ChangeLog.txt index 2c04f50ba..cb9d30d0b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1610,4 +1610,6 @@ * apps/system/flash_eraseall: Removed! This logic violates the OS/ application interface and cannot be supported. The old code can still be found in the 'Obsoleted' repository (2016-06-03). + * apps/fsutils/flash_eraseall: IOCTL wrapper for MDCIO_BULKERASE command + (2016-06-04). diff --git a/fsutils/Kconfig b/fsutils/Kconfig index b6f57cc34..ce853cfda 100644 --- a/fsutils/Kconfig +++ b/fsutils/Kconfig @@ -5,6 +5,7 @@ menu "File System Utilities" +source "$APPSDIR/fsutils/flash_eraseall/Kconfig" source "$APPSDIR/fsutils/inifile/Kconfig" source "$APPSDIR/fsutils/mksmartfs/Kconfig" source "$APPSDIR/fsutils/passwd/Kconfig" diff --git a/fsutils/flash_eraseall/.gitignore b/fsutils/flash_eraseall/.gitignore new file mode 100644 index 000000000..83bd7b811 --- /dev/null +++ b/fsutils/flash_eraseall/.gitignore @@ -0,0 +1,11 @@ +/Make.dep +/.depend +/.built +/*.asm +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src +/*.obj diff --git a/fsutils/flash_eraseall/Kconfig b/fsutils/flash_eraseall/Kconfig new file mode 100644 index 000000000..01728391f --- /dev/null +++ b/fsutils/flash_eraseall/Kconfig @@ -0,0 +1,15 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config FSUTILS_FLASH_ERASEALL + bool "flash_eraseall() function" + default n + ---help--- + Enables support for the callable flash_eraseall() function that can + be used to erase all FLASH backing up a block device driver. + +if FSUTILS_FLASH_ERASEALL + +endif # FSUTILS_FLASH_ERASEALL diff --git a/fsutils/flash_eraseall/Make.defs b/fsutils/flash_eraseall/Make.defs new file mode 100644 index 000000000..ab55a031e --- /dev/null +++ b/fsutils/flash_eraseall/Make.defs @@ -0,0 +1,38 @@ +############################################################################ +# apps/fsutils/flash_eraseall/Make.defs +# +# Copyright (C) 2016 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_FSUTILS_FLASH_ERASEALL),y) +CONFIGURED_APPS += fsutils/flash_eraseall +endif diff --git a/fsutils/flash_eraseall/Makefile b/fsutils/flash_eraseall/Makefile new file mode 100644 index 000000000..85139c3c3 --- /dev/null +++ b/fsutils/flash_eraseall/Makefile @@ -0,0 +1,102 @@ +############################################################################ +# apps/fsutils/flash_eraseall/Makefile +# +# Copyright (C) 2016 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# Password file access library + +ASRCS = +CSRCS = + +ifeq ($(CONFIG_FSUTILS_FLASH_ERASEALL),y) +CSRCS += flash_eraseall.c +endif + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + $(Q) touch .built + +install: + +context: + +.depend: Makefile $(SRCS) + $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep diff --git a/fsutils/flash_eraseall/flash_eraseall.c b/fsutils/flash_eraseall/flash_eraseall.c new file mode 100644 index 000000000..9deb0570b --- /dev/null +++ b/fsutils/flash_eraseall/flash_eraseall.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * apps/fsutils/flash_eraseall/flash_eraseall.c + * + * Copyright (C) 2011, 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: flash_eraseall + * + * Description: + * Call a block driver with the MDIOC_BULKERASE ioctl command. This will + * cause the MTD driver to erase all of the flash. + * + ****************************************************************************/ + +int flash_eraseall(FAR const char *driver) +{ + int errcode; + int fd; + int ret; + + /* Open the block driver */ + + fd = open(driver, O_RDONLY); + if (fd < 0) + { + errcode = errno; + fdbg("ERROR: Failed to open '%s': %d\n", driver, errcode); + ret = -errcode; + } + else + { + /* Invoke the block driver ioctl method */ + + ret = ioctl(fd, MTDIOC_BULKERASE, 0); + if (ret < 0) + { + errcode = errno; + fdbg("ERROR: MTD ioctl(%04x) failed: %d\n", MTDIOC_BULKERASE, errcode); + ret = -errcode; + } + + /* Close the block driver */ + + (void)close(fd); + } + + return ret; +} diff --git a/include/fsutils/flash_eraseall.h b/include/fsutils/flash_eraseall.h new file mode 100644 index 000000000..69d1ee55c --- /dev/null +++ b/include/fsutils/flash_eraseall.h @@ -0,0 +1,61 @@ +/**************************************************************************** + * apps/include/fsutils/flash_eraseall.h + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __APPS_INCLUDE_FSUTILS_FLASH_ERASEALL_H +#define __APPS_INCLUDE_FSUTILS_FLASH_ERASEALL_H 1 + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: flash_eraseall + * + * Description: + * Call a block driver with the MDIOC_BULKERASE ioctl command. This will + * cause the MTD driver to erase all of the flash. + * + ****************************************************************************/ + +int flash_eraseall(FAR const char *driver); + +#endif /* __APPS_INCLUDE_FSUTILS_FLASH_ERASEALL_H */ From 3734b4c96644e3c8a3d66494c1db7245844b5e01 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 3 Jun 2016 08:15:37 -0600 Subject: [PATCH 2/6] Restore apps/system/flash_eraseall/ using new IOCTL wrapper --- ChangeLog.txt | 2 + system/Kconfig | 1 + system/Make.defs | 4 + system/Makefile | 2 +- system/flash_eraseall/.gitignore | 11 ++ system/flash_eraseall/Kconfig | 15 +++ system/flash_eraseall/Makefile | 151 +++++++++++++++++++++++++ system/flash_eraseall/README.txt | 12 ++ system/flash_eraseall/flash_eraseall.c | 71 ++++++++++++ 9 files changed, 268 insertions(+), 1 deletion(-) create mode 100644 system/flash_eraseall/.gitignore create mode 100644 system/flash_eraseall/Kconfig create mode 100644 system/flash_eraseall/Makefile create mode 100644 system/flash_eraseall/README.txt create mode 100644 system/flash_eraseall/flash_eraseall.c diff --git a/ChangeLog.txt b/ChangeLog.txt index cb9d30d0b..db39f1a84 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1612,4 +1612,6 @@ be found in the 'Obsoleted' repository (2016-06-03). * apps/fsutils/flash_eraseall: IOCTL wrapper for MDCIO_BULKERASE command (2016-06-04). + * apps/system/flash_eraseall: Restored! Using the new IOCTL wrapper at + apps/fsutils/flash_eraseall (2016-06-04). diff --git a/system/Kconfig b/system/Kconfig index ecf6b6317..fac8504fe 100644 --- a/system/Kconfig +++ b/system/Kconfig @@ -8,6 +8,7 @@ menu "System Libraries and NSH Add-Ons" source "$APPSDIR/system/free/Kconfig" source "$APPSDIR/system/cle/Kconfig" source "$APPSDIR/system/cu/Kconfig" +source "$APPSDIR/system/flash_eraseall/Kconfig" source "$APPSDIR/system/install/Kconfig" source "$APPSDIR/system/hex2bin/Kconfig" source "$APPSDIR/system/i2c/Kconfig" diff --git a/system/Make.defs b/system/Make.defs index dd822d15a..73d964f30 100644 --- a/system/Make.defs +++ b/system/Make.defs @@ -50,6 +50,10 @@ ifeq ($(CONFIG_SYSTEM_CUTERM),y) CONFIGURED_APPS += system/cu endif +ifeq ($(CONFIG_SYSTEM_FLASH_ERASEALL),y) +CONFIGURED_APPS += system/flash_eraseall +endif + ifeq ($(CONFIG_SYSTEM_FREE),y) CONFIGURED_APPS += system/free endif diff --git a/system/Makefile b/system/Makefile index c62d8ea9d..3d4722e8d 100644 --- a/system/Makefile +++ b/system/Makefile @@ -37,7 +37,7 @@ # Sub-directories containing system tasks/libraries -SUBDIRS = cdcacm cle composite cu free i2c hex2bin install +SUBDIRS = cdcacm cle composite cu free flash_eraseall i2c hex2bin install SUBDIRS += hexed lm75 mdio netdb nxplayer ramtest readline SUBDIRS += stackmonitor sudoku symtab ubloxmodem usbmonitor usbmsc vi SUBDIRS += zmodem zoneinfo diff --git a/system/flash_eraseall/.gitignore b/system/flash_eraseall/.gitignore new file mode 100644 index 000000000..83bd7b811 --- /dev/null +++ b/system/flash_eraseall/.gitignore @@ -0,0 +1,11 @@ +/Make.dep +/.depend +/.built +/*.asm +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src +/*.obj diff --git a/system/flash_eraseall/Kconfig b/system/flash_eraseall/Kconfig new file mode 100644 index 000000000..64ea620d2 --- /dev/null +++ b/system/flash_eraseall/Kconfig @@ -0,0 +1,15 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config SYSTEM_FLASH_ERASEALL + bool "FLASH Erase-all Command" + default n + depends on MTD && NSH_BUILTIN_APPS && !BUILD_PROTECTED && !BUILD_KERNEL + ---help--- + Enable support for the FLASH eraseall tool. + +if SYSTEM_FLASH_ERASEALL +endif + diff --git a/system/flash_eraseall/Makefile b/system/flash_eraseall/Makefile new file mode 100644 index 000000000..d9e97e5d1 --- /dev/null +++ b/system/flash_eraseall/Makefile @@ -0,0 +1,151 @@ +############################################################################ +# apps/system/flash_eraseall/Makefile +# +# Copyright (C) 2016 Gregory Nutt. All rights reserved. +# Copyright (C) 2013 Ken Pettit. All rights reserved. +# Author: Ken Pettit +# Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +# TODO, this makefile should run make under the app dirs, instead of +# sourcing the Make.defs! + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +ifeq ($(WINTOOL),y) +INCDIROPT = -w +endif + +# Hello Application +# TODO: appname can be automatically extracted from the directory name + +APPNAME = flash_eraseall +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 1024 + +ASRCS = +CSRCS = +MAINSRC = flash_eraseall.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) +MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) +OBJS = $(AOBJS) $(COBJS) + +ifneq ($(CONFIG_BUILD_KERNEL),y) + OBJS += $(MAINOBJ) +endif + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +ifeq ($(WINTOOL),y) + INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}" +else + INSTALL_DIR = $(BIN_DIR) +endif + +CONFIG_XYZ_PROGNAME ?= flash_eraseall$(EXEEXT) +PROGNAME = $(CONFIG_XYZ_PROGNAME) + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: preconfig context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + $(Q) touch .built + +ifeq ($(CONFIG_BUILD_KERNEL),y) +$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ) + @echo "LD: $(PROGNAME)" + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS) + $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) + +install: $(BIN_DIR)$(DELIM)$(PROGNAME) + +else +install: + +endif + +preconfig: + +# Register application + +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif + +# Create dependencies + +.depend: Makefile $(SRCS) + $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep diff --git a/system/flash_eraseall/README.txt b/system/flash_eraseall/README.txt new file mode 100644 index 000000000..0b90d7f22 --- /dev/null +++ b/system/flash_eraseall/README.txt @@ -0,0 +1,12 @@ +Flash Erase-all +=============== + + Source: NuttX + Author: Ken Pettit + Date: 5 May 2013 + +This application erases the FLASH of an MTD flash block. It is simply +a wrapper that calls the NuttX flash_eraseall interface. + +Usage: + flash_eraseall diff --git a/system/flash_eraseall/flash_eraseall.c b/system/flash_eraseall/flash_eraseall.c new file mode 100644 index 000000000..48896d563 --- /dev/null +++ b/system/flash_eraseall/flash_eraseall.c @@ -0,0 +1,71 @@ +/**************************************************************************** + * apps/system/flash_eraseall/flash_eraseall.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2013 Ken Pettit. All rights reserved. + * Author: Ken Pettit + * Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int flash_eraseall_main(int argc, char *argv[]) +#endif +{ + /* Argument given? */ + + if (argc < 2) + { + fprintf(stderr, "usage: flash_eraseall flash_block_device\n"); + return -1; + } + + /* Do the job */ + + flash_eraseall(argv[1]); + + return 0; +} From d06b721ba2052f15224440daae129c5589142c8d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 3 Jun 2016 09:11:22 -0600 Subject: [PATCH 3/6] Fix new dependencies for flash_eraseall --- fsutils/flash_eraseall/Kconfig | 1 + system/flash_eraseall/Kconfig | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fsutils/flash_eraseall/Kconfig b/fsutils/flash_eraseall/Kconfig index 01728391f..25217c251 100644 --- a/fsutils/flash_eraseall/Kconfig +++ b/fsutils/flash_eraseall/Kconfig @@ -6,6 +6,7 @@ config FSUTILS_FLASH_ERASEALL bool "flash_eraseall() function" default n + depends on MTD ---help--- Enables support for the callable flash_eraseall() function that can be used to erase all FLASH backing up a block device driver. diff --git a/system/flash_eraseall/Kconfig b/system/flash_eraseall/Kconfig index 64ea620d2..3f378aca1 100644 --- a/system/flash_eraseall/Kconfig +++ b/system/flash_eraseall/Kconfig @@ -6,7 +6,8 @@ config SYSTEM_FLASH_ERASEALL bool "FLASH Erase-all Command" default n - depends on MTD && NSH_BUILTIN_APPS && !BUILD_PROTECTED && !BUILD_KERNEL + depends on MTD && NSH_BUILTIN_APPS + select FSUTILS_FLASH_ERASEALL ---help--- Enable support for the FLASH eraseall tool. From 19be2cafea4960269225f7b9a78b7e5442e11494 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 5 Jun 2016 08:41:02 -0600 Subject: [PATCH 4/6] Fix name collision in flash_eraseall restoration. --- system/flash_eraseall/Makefile | 2 +- .../flash_eraseall/{flash_eraseall.c => flash_eraseall_main.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename system/flash_eraseall/{flash_eraseall.c => flash_eraseall_main.c} (100%) diff --git a/system/flash_eraseall/Makefile b/system/flash_eraseall/Makefile index d9e97e5d1..cad71b307 100644 --- a/system/flash_eraseall/Makefile +++ b/system/flash_eraseall/Makefile @@ -55,7 +55,7 @@ STACKSIZE = 1024 ASRCS = CSRCS = -MAINSRC = flash_eraseall.c +MAINSRC = flash_eraseall_main.c AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) diff --git a/system/flash_eraseall/flash_eraseall.c b/system/flash_eraseall/flash_eraseall_main.c similarity index 100% rename from system/flash_eraseall/flash_eraseall.c rename to system/flash_eraseall/flash_eraseall_main.c From a442f52a1efa56f0e78359efe309d86004015e88 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 5 Jun 2016 09:18:04 -0600 Subject: [PATCH 5/6] apps/canutils/libuavcan: Fix for recent change to STM32 timer frequency definiitions --- ...96ace50155573e545ed9bf2fb09964ee2367.patch | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/canutils/libuavcan/nuttx-b04396ace50155573e545ed9bf2fb09964ee2367.patch b/canutils/libuavcan/nuttx-b04396ace50155573e545ed9bf2fb09964ee2367.patch index 2751c666f..7ad7d9170 100644 --- a/canutils/libuavcan/nuttx-b04396ace50155573e545ed9bf2fb09964ee2367.patch +++ b/canutils/libuavcan/nuttx-b04396ace50155573e545ed9bf2fb09964ee2367.patch @@ -23,3 +23,43 @@ } }; +--- libuavcan/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp.orig 2016-06-05 09:12:29.086814547 -0600 ++++ libuavcan/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp 2016-06-05 09:15:03.676810202 -0600 +@@ -31,17 +31,30 @@ + + # if UAVCAN_STM32_NUTTX + # define TIMX UAVCAN_STM32_GLUE3(STM32_TIM, UAVCAN_STM32_TIMER_NUMBER, _BASE) +-# define TMR_REG(o) (TIMX + (o)) +-# define TIMX_INPUT_CLOCK STM32_TIM27_FREQUENCY ++# define TMR_REG(o) (TIMX + (o)) + +-# define TIMX_IRQn UAVCAN_STM32_GLUE2(STM32_IRQ_TIM, UAVCAN_STM32_TIMER_NUMBER) ++# if UAVCAN_STM32_TIMER_NUMBER == 2 ++# define TIMX_INPUT_CLOCK BOARD_TIM2_FREQUENCY ++# elif UAVCAN_STM32_TIMER_NUMBER == 3 ++# define TIMX_INPUT_CLOCK BOARD_TIM3_FREQUENCY ++# elif UAVCAN_STM32_TIMER_NUMBER == 4 ++# define TIMX_INPUT_CLOCK BOARD_TIM4_FREQUENCY ++# elif UAVCAN_STM32_TIMER_NUMBER == 5 ++# define TIMX_INPUT_CLOCK BOARD_TIM5_FREQUENCY ++# elif UAVCAN_STM32_TIMER_NUMBER == 6 ++# define TIMX_INPUT_CLOCK BOARD_TIM6_FREQUENCY ++# elif UAVCAN_STM32_TIMER_NUMBER == 7 ++# define TIMX_INPUT_CLOCK BOARD_TIM7_FREQUENCY ++# endif ++ ++# define TIMX_IRQn UAVCAN_STM32_GLUE2(STM32_IRQ_TIM, UAVCAN_STM32_TIMER_NUMBER) + # endif + + # if UAVCAN_STM32_TIMER_NUMBER >= 2 && UAVCAN_STM32_TIMER_NUMBER <= 7 +-# define TIMX_RCC_ENR RCC->APB1ENR +-# define TIMX_RCC_RSTR RCC->APB1RSTR +-# define TIMX_RCC_ENR_MASK UAVCAN_STM32_GLUE3(RCC_APB1ENR_TIM, UAVCAN_STM32_TIMER_NUMBER, EN) +-# define TIMX_RCC_RSTR_MASK UAVCAN_STM32_GLUE3(RCC_APB1RSTR_TIM, UAVCAN_STM32_TIMER_NUMBER, RST) ++# define TIMX_RCC_ENR RCC->APB1ENR ++# define TIMX_RCC_RSTR RCC->APB1RSTR ++# define TIMX_RCC_ENR_MASK UAVCAN_STM32_GLUE3(RCC_APB1ENR_TIM, UAVCAN_STM32_TIMER_NUMBER, EN) ++# define TIMX_RCC_RSTR_MASK UAVCAN_STM32_GLUE3(RCC_APB1RSTR_TIM, UAVCAN_STM32_TIMER_NUMBER, RST) + # else + # error "This UAVCAN_STM32_TIMER_NUMBER is not supported yet" + # endif From 98a9769a287d0c0e5d169b3509605442c8e4c096 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 5 Jun 2016 14:49:23 -0600 Subject: [PATCH 6/6] Updata ChangeLog --- ChangeLog.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index db39f1a84..98fd596e6 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1607,6 +1607,8 @@ 7.17 2016-xx-xx Gregory Nutt + * apps/examples/alarm: ioctl call was clobbering file descriptor + (2016-06-02). * apps/system/flash_eraseall: Removed! This logic violates the OS/ application interface and cannot be supported. The old code can still be found in the 'Obsoleted' repository (2016-06-03). @@ -1614,4 +1616,5 @@ (2016-06-04). * apps/system/flash_eraseall: Restored! Using the new IOCTL wrapper at apps/fsutils/flash_eraseall (2016-06-04). - + * apps/canutils/libuavcan: Fix for recent change to STM32 timer frequency + definiitions (2016-06-05).