This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit d4e158f86df6c12138d631360c5acf4ccd73dcee Author: raiden00pl <[email protected]> AuthorDate: Sun Oct 20 13:15:56 2024 +0200 boards/arm/stm32f7: move ROMFS logic to common directory move ROMFS logic to common directory --- LICENSE | 8 +- boards/Kconfig | 3 + boards/arm/stm32f7/common/Kconfig | 22 +++ .../src => common/include}/stm32_romfs.h | 12 +- boards/arm/stm32f7/common/src/CMakeLists.txt | 4 + boards/arm/stm32f7/common/src/Make.defs | 4 + .../src/stm32_romfs_initialize.c | 34 +++-- boards/arm/stm32f7/nucleo-f722ze/Kconfig | 22 --- .../arm/stm32f7/nucleo-f722ze/src/CMakeLists.txt | 4 - boards/arm/stm32f7/nucleo-f722ze/src/Make.defs | 4 - .../arm/stm32f7/nucleo-f722ze/src/stm32_bringup.c | 8 +- boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs.h | 76 ---------- .../nucleo-f722ze/src/stm32_romfs_initialize.c | 153 --------------------- boards/arm/stm32f7/nucleo-f746zg/Kconfig | 22 --- .../arm/stm32f7/nucleo-f746zg/src/CMakeLists.txt | 4 - boards/arm/stm32f7/nucleo-f746zg/src/Make.defs | 4 - .../arm/stm32f7/nucleo-f746zg/src/stm32_bringup.c | 8 +- boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs.h | 76 ---------- .../nucleo-f746zg/src/stm32_romfs_initialize.c | 153 --------------------- boards/arm/stm32f7/nucleo-f767zi/Kconfig | 22 --- .../arm/stm32f7/nucleo-f767zi/src/CMakeLists.txt | 4 - boards/arm/stm32f7/nucleo-f767zi/src/Make.defs | 4 - .../arm/stm32f7/nucleo-f767zi/src/stm32_bringup.c | 8 +- 23 files changed, 69 insertions(+), 590 deletions(-) diff --git a/LICENSE b/LICENSE index bcaf54b851..9d9c89e9ef 100644 --- a/LICENSE +++ b/LICENSE @@ -3355,12 +3355,8 @@ boards/arm/stm32/omnibusf4/src/stm32_romfs.h boards/arm/stm32/omnibusf4/src/stm32_romfs_initialize.c boards/arm/stm32/stm32f4discovery/src/stm32_romfs.h boards/arm/stm32/stm32f4discovery/src/stm32_romfs_initialize.c -boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs.h -boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs_initialize.c -boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs.h -boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs_initialize.c -boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs.h -boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs_initialize.c +boards/arm/stm32f7/common/include/stm32_romfs.h +boards/arm/stm32f7/common/src/stm32_romfs_initialize.c ============================================================= Copyright (C) 2017 Tomasz Wozniak. All rights reserved. diff --git a/boards/Kconfig b/boards/Kconfig index 653086ac44..9a97bc3a5f 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -4604,6 +4604,9 @@ endif if ARCH_CHIP_STM32 source "boards/arm/stm32/common/Kconfig" endif +if ARCH_CHIP_STM32F7 +source "boards/arm/stm32f7/common/Kconfig" +endif if ARCH_CHIP_STM32F0L0G0 source "boards/arm/stm32f0l0g0/common/Kconfig" endif diff --git a/boards/arm/stm32f7/common/Kconfig b/boards/arm/stm32f7/common/Kconfig index 18c7905aed..5d02131b7f 100644 --- a/boards/arm/stm32f7/common/Kconfig +++ b/boards/arm/stm32f7/common/Kconfig @@ -3,3 +3,25 @@ # see the file kconfig-language.txt in the NuttX tools repository. # +config STM32F7_ROMFS + bool "Automount baked-in ROMFS image" + default n + depends on FS_ROMFS + ---help--- + Select STM32F7_ROMFS_IMAGEFILE, STM32F7_ROMFS_DEV_MINOR, STM32F7_ROMFS_MOUNTPOINT + +config STM32F7_ROMFS_DEV_MINOR + int "Minor for the block device backing the data" + depends on STM32F7_ROMFS + default 64 + +config STM32F7_ROMFS_MOUNTPOINT + string "Mountpoint of the custom romfs image" + depends on STM32F7_ROMFS + default "/rom" + +config STM32F7_ROMFS_IMAGEFILE + string "ROMFS image file to include into build" + depends on STM32F7_ROMFS + default "../../../rom.img" + diff --git a/boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs.h b/boards/arm/stm32f7/common/include/stm32_romfs.h similarity index 91% rename from boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs.h rename to boards/arm/stm32f7/common/include/stm32_romfs.h index 9a1a0afab4..4c6355a1fe 100644 --- a/boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs.h +++ b/boards/arm/stm32f7/common/include/stm32_romfs.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs.h + * boards/arm/stm32f7/common/include/stm32_romfs.h * * Copyright (C) 2017 Tomasz Wozniak. All rights reserved. * Author: Tomasz Wozniak <[email protected]> @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_STM32F7_NUCLEO144_SRC_STM32_ROMFS_H -#define __BOARDS_ARM_STM32F7_NUCLEO144_SRC_STM32_ROMFS_H +#ifndef __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_ROMFS_H +#define __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_ROMFS_H /**************************************************************************** * Included Files @@ -42,7 +42,7 @@ #include <nuttx/config.h> -#ifdef CONFIG_STM32_ROMFS +#ifdef CONFIG_STM32F7_ROMFS /**************************************************************************** * Pre-processor Definitions @@ -71,6 +71,6 @@ int stm32_romfs_initialize(void); -#endif /* CONFIG_STM32_ROMFS */ +#endif /* CONFIG_STM32F7_ROMFS */ -#endif /* __BOARDS_ARM_STM32F7_NUCLEO144_SRC_STM32_ROMFS_H */ +#endif /* __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_ROMFS_H */ diff --git a/boards/arm/stm32f7/common/src/CMakeLists.txt b/boards/arm/stm32f7/common/src/CMakeLists.txt index 61ec6b8d57..28a0318dd2 100644 --- a/boards/arm/stm32f7/common/src/CMakeLists.txt +++ b/boards/arm/stm32f7/common/src/CMakeLists.txt @@ -41,4 +41,8 @@ if(CONFIG_STM32F7_CAN) endif() endif() +if(CONFIG_STM32F7_ROMFS) + list(APPEND SRCS stm32_romfs_initialize.c) +endif() + target_sources(board PRIVATE ${SRCS}) diff --git a/boards/arm/stm32f7/common/src/Make.defs b/boards/arm/stm32f7/common/src/Make.defs index 15455395ee..eb7a96916f 100644 --- a/boards/arm/stm32f7/common/src/Make.defs +++ b/boards/arm/stm32f7/common/src/Make.defs @@ -41,6 +41,10 @@ CSRCS += stm32_cansock_setup.c endif endif +ifeq ($(CONFIG_STM32F7_ROMFS),y) +CSRCS += stm32_romfs_initialize.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src diff --git a/boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs_initialize.c b/boards/arm/stm32f7/common/src/stm32_romfs_initialize.c similarity index 84% rename from boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs_initialize.c rename to boards/arm/stm32f7/common/src/stm32_romfs_initialize.c index 6d5bd3bb0a..c053c82b69 100644 --- a/boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs_initialize.c +++ b/boards/arm/stm32f7/common/src/stm32_romfs_initialize.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs_initialize.c + * boards/arm/stm32f7/common/src/stm32_romfs_initialize.c * This file provides contents of an optional ROMFS volume, mounted at boot. * * Copyright (C) 2017 Tomasz Wozniak. All rights reserved. @@ -54,20 +54,20 @@ * Pre-processor Definitions ****************************************************************************/ -#ifndef CONFIG_STM32_ROMFS -# error "CONFIG_STM32_ROMFS must be defined" -#else +#ifndef CONFIG_STM32F7_ROMFS +# error "CONFIG_STM32F7_ROMFS must be defined" +#endif -#ifndef CONFIG_STM32_ROMFS_IMAGEFILE -# error "CONFIG_STM32_ROMFS_IMAGEFILE must be defined" +#ifndef CONFIG_STM32F7_ROMFS_IMAGEFILE +# error "CONFIG_STM32F7_ROMFS_IMAGEFILE must be defined" #endif -#ifndef CONFIG_STM32_ROMFS_DEV_MINOR -# error "CONFIG_STM32_ROMFS_DEV_MINOR must be defined" +#ifndef CONFIG_STM32F7_ROMFS_DEV_MINOR +# error "CONFIG_STM32F7_ROMFS_DEV_MINOR must be defined" #endif -#ifndef CONFIG_STM32_ROMFS_MOUNTPOINT -# error "CONFIG_STM32_ROMFS_MOUNTPOINT must be defined" +#ifndef CONFIG_STM32F7_ROMFS_MOUNTPOINT +# error "CONFIG_STM32F7_ROMFS_MOUNTPOINT must be defined" #endif #define NSECTORS(size) (((size) + ROMFS_SECTOR_SIZE - 1)/ROMFS_SECTOR_SIZE) @@ -76,7 +76,7 @@ #define STR(m) STR2(m) #define MKMOUNT_DEVNAME(m) "/dev/ram" STR(m) -#define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_STM32_ROMFS_DEV_MINOR) +#define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_STM32F7_ROMFS_DEV_MINOR) /**************************************************************************** * Private Data @@ -87,7 +87,7 @@ __asm__ ( ".balign 16\n" ".globl romfs_data_begin\n" "romfs_data_begin:\n" - ".incbin " STR(CONFIG_STM32_ROMFS_IMAGEFILE) "\n"\ + ".incbin " STR(CONFIG_STM32F7_ROMFS_IMAGEFILE) "\n"\ \ ".balign " STR(ROMFS_SECTOR_SIZE) "\n" ".globl romfs_data_end\n" @@ -125,7 +125,7 @@ int stm32_romfs_initialize(void) romfs_data_len = romfs_data_end - romfs_data_begin; - ret = romdisk_register(CONFIG_STM32_ROMFS_DEV_MINOR, romfs_data_begin, + ret = romdisk_register(CONFIG_STM32F7_ROMFS_DEV_MINOR, romfs_data_begin, NSECTORS(romfs_data_len), ROMFS_SECTOR_SIZE); if (ret < 0) { @@ -136,18 +136,16 @@ int stm32_romfs_initialize(void) /* Mount the file system */ finfo("Mounting ROMFS filesystem at target=%s with source=%s\n", - CONFIG_STM32_ROMFS_MOUNTPOINT, MOUNT_DEVNAME); + CONFIG_STM32F7_ROMFS_MOUNTPOINT, MOUNT_DEVNAME); - ret = nx_mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, + ret = nx_mount(MOUNT_DEVNAME, CONFIG_STM32F7_ROMFS_MOUNTPOINT, "romfs", MS_RDONLY, NULL); if (ret < 0) { ferr("ERROR: nx_mount(%s,%s,romfs) failed: %d\n", - MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, ret); + MOUNT_DEVNAME, CONFIG_STM32F7_ROMFS_MOUNTPOINT, ret); return ret; } return OK; } - -#endif /* CONFIG_STM32_ROMFS */ diff --git a/boards/arm/stm32f7/nucleo-f722ze/Kconfig b/boards/arm/stm32f7/nucleo-f722ze/Kconfig index d57fb238a3..c34fa5de59 100644 --- a/boards/arm/stm32f7/nucleo-f722ze/Kconfig +++ b/boards/arm/stm32f7/nucleo-f722ze/Kconfig @@ -5,28 +5,6 @@ if ARCH_BOARD_NUCLEO_F722ZE -config STM32_ROMFS - bool "Automount baked-in ROMFS image" - default n - depends on FS_ROMFS - ---help--- - Select STM32_ROMFS_IMAGEFILE, STM32_ROMFS_DEV_MINOR, STM32_ROMFS_MOUNTPOINT - -config STM32_ROMFS_DEV_MINOR - int "Minor for the block device backing the data" - depends on STM32_ROMFS - default 64 - -config STM32_ROMFS_MOUNTPOINT - string "Mountpoint of the custom romfs image" - depends on STM32_ROMFS - default "/rom" - -config STM32_ROMFS_IMAGEFILE - string "ROMFS image file to include into build" - depends on STM32_ROMFS - default "../../../rom.img" - choice prompt "Select Console wiring." default NUCLEO_F722ZE_CONSOLE_ARDUINO diff --git a/boards/arm/stm32f7/nucleo-f722ze/src/CMakeLists.txt b/boards/arm/stm32f7/nucleo-f722ze/src/CMakeLists.txt index 6f30cf4f8d..6d78330177 100644 --- a/boards/arm/stm32f7/nucleo-f722ze/src/CMakeLists.txt +++ b/boards/arm/stm32f7/nucleo-f722ze/src/CMakeLists.txt @@ -66,10 +66,6 @@ if(CONFIG_BOARDCTL_RESET) list(APPEND SRCS stm32_reset.c) endif() -if(CONFIG_STM32_ROMFS) - list(APPEND SRCS stm32_romfs_initialize.c) -endif() - if(CONFIG_SENSORS_QENCODER) list(APPEND SRCS stm32_qencoder.c) endif() diff --git a/boards/arm/stm32f7/nucleo-f722ze/src/Make.defs b/boards/arm/stm32f7/nucleo-f722ze/src/Make.defs index 2c6e6ac046..8c1d6f881a 100644 --- a/boards/arm/stm32f7/nucleo-f722ze/src/Make.defs +++ b/boards/arm/stm32f7/nucleo-f722ze/src/Make.defs @@ -68,10 +68,6 @@ ifeq ($(CONFIG_BOARDCTL_RESET),y) CSRCS += stm32_reset.c endif -ifeq ($(CONFIG_STM32_ROMFS),y) -CSRCS += stm32_romfs_initialize.c -endif - ifeq ($(CONFIG_SENSORS_QENCODER),y) CSRCS += stm32_qencoder.c endif diff --git a/boards/arm/stm32f7/nucleo-f722ze/src/stm32_bringup.c b/boards/arm/stm32f7/nucleo-f722ze/src/stm32_bringup.c index 33c883333f..473460b5ed 100644 --- a/boards/arm/stm32f7/nucleo-f722ze/src/stm32_bringup.c +++ b/boards/arm/stm32f7/nucleo-f722ze/src/stm32_bringup.c @@ -46,8 +46,8 @@ # include "stm32_cansock_setup.h" #endif -#ifdef CONFIG_STM32_ROMFS -#include "stm32_romfs.h" +#ifdef CONFIG_STM32F7_ROMFS +# include "stm32_romfs.h" #endif #ifdef CONFIG_SYSTEMTICK_HOOK @@ -94,14 +94,14 @@ int stm32_bringup(void) } #endif -#ifdef CONFIG_STM32_ROMFS +#ifdef CONFIG_STM32F7_ROMFS /* Mount the romfs partition */ ret = stm32_romfs_initialize(); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount romfs at %s: %d\n", - CONFIG_STM32_ROMFS_MOUNTPOINT, ret); + CONFIG_STM32F7_ROMFS_MOUNTPOINT, ret); } #endif diff --git a/boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs.h b/boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs.h deleted file mode 100644 index 1f309cd015..0000000000 --- a/boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs.h - * - * Copyright (C) 2017 Tomasz Wozniak. All rights reserved. - * Author: Tomasz Wozniak <[email protected]> - * - * 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 __BOARDS_ARM_STM32F7_NUCLEO144_SRC_STM32_ROMFS_H -#define __BOARDS_ARM_STM32F7_NUCLEO144_SRC_STM32_ROMFS_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#ifdef CONFIG_STM32_ROMFS - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define ROMFS_SECTOR_SIZE 64 - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_romfs_initialize - * - * Description: - * Registers built-in ROMFS image as block device and mounts it. - * - * Returned Value: - * Zero (OK) on success, a negated errno value on error. - * - * Assumptions/Limitations: - * Memory addresses [romfs_data_begin .. romfs_data_end) should contain - * ROMFS volume data, as included in the assembly snippet above (l. 84). - * - ****************************************************************************/ - -int stm32_romfs_initialize(void); - -#endif /* CONFIG_STM32_ROMFS */ - -#endif /* __BOARDS_ARM_STM32F7_NUCLEO144_SRC_STM32_ROMFS_H */ diff --git a/boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs_initialize.c b/boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs_initialize.c deleted file mode 100644 index c433ee9014..0000000000 --- a/boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs_initialize.c +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs_initialize.c - * This file provides contents of an optional ROMFS volume, mounted at boot. - * - * Copyright (C) 2017 Tomasz Wozniak. All rights reserved. - * Author: Tomasz Wozniak <[email protected]> - * - * 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 <nuttx/config.h> - -#include <sys/mount.h> -#include <sys/types.h> -#include <stdint.h> -#include <debug.h> -#include <errno.h> - -#include <nuttx/fs/fs.h> -#include <nuttx/drivers/ramdisk.h> -#include "stm32_romfs.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_STM32_ROMFS -# error "CONFIG_STM32_ROMFS must be defined" -#else - -#ifndef CONFIG_STM32_ROMFS_IMAGEFILE -# error "CONFIG_STM32_ROMFS_IMAGEFILE must be defined" -#endif - -#ifndef CONFIG_STM32_ROMFS_DEV_MINOR -# error "CONFIG_STM32_ROMFS_DEV_MINOR must be defined" -#endif - -#ifndef CONFIG_STM32_ROMFS_MOUNTPOINT -# error "CONFIG_STM32_ROMFS_MOUNTPOINT must be defined" -#endif - -#define NSECTORS(size) (((size) + ROMFS_SECTOR_SIZE - 1)/ROMFS_SECTOR_SIZE) - -#define STR2(m) #m -#define STR(m) STR2(m) - -#define MKMOUNT_DEVNAME(m) "/dev/ram" STR(m) -#define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_STM32_ROMFS_DEV_MINOR) - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -__asm__ ( - ".section .rodata\n" - ".balign 16\n" - ".globl romfs_data_begin\n" -"romfs_data_begin:\n" - ".incbin " STR(CONFIG_STM32_ROMFS_IMAGEFILE) "\n"\ - \ - ".balign " STR(ROMFS_SECTOR_SIZE) "\n" - ".globl romfs_data_end\n" -"romfs_data_end:\n"); - -extern const uint8_t romfs_data_begin[]; -extern const uint8_t romfs_data_end[]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_romfs_initialize - * - * Description: - * Registers the aboveincluded binary file as block device. - * Then mounts the block device as ROMFS filesystems. - * - * Returned Value: - * Zero (OK) on success, a negated errno value on error. - * - * Assumptions/Limitations: - * Memory addresses [romfs_data_begin .. romfs_data_end) should contain - * ROMFS volume data, as included in the assembly snippet above (l. 84). - * - ****************************************************************************/ - -int stm32_romfs_initialize(void) -{ - size_t romfs_data_len; - int ret; - - /* Create a ROM disk for the /etc filesystem */ - - romfs_data_len = romfs_data_end - romfs_data_begin; - - ret = romdisk_register(CONFIG_STM32_ROMFS_DEV_MINOR, romfs_data_begin, - NSECTORS(romfs_data_len), ROMFS_SECTOR_SIZE); - if (ret < 0) - { - ferr("ERROR: romdisk_register failed: %d\n", -ret); - return ret; - } - - /* Mount the file system */ - - finfo("Mounting ROMFS filesystem at target=%s with source=%s\n", - CONFIG_STM32_ROMFS_MOUNTPOINT, MOUNT_DEVNAME); - - ret = nx_mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, - "romfs", MS_RDONLY, NULL); - if (ret < 0) - { - ferr("ERROR: nx_mount(%s,%s,romfs) failed: %d\n", - MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, ret); - return ret; - } - - return OK; -} - -#endif /* CONFIG_STM32_ROMFS */ diff --git a/boards/arm/stm32f7/nucleo-f746zg/Kconfig b/boards/arm/stm32f7/nucleo-f746zg/Kconfig index d8ac578d2f..6697898410 100644 --- a/boards/arm/stm32f7/nucleo-f746zg/Kconfig +++ b/boards/arm/stm32f7/nucleo-f746zg/Kconfig @@ -5,28 +5,6 @@ if ARCH_BOARD_NUCLEO_F746ZG -config STM32_ROMFS - bool "Automount baked-in ROMFS image" - default n - depends on FS_ROMFS - ---help--- - Select STM32_ROMFS_IMAGEFILE, STM32_ROMFS_DEV_MINOR, STM32_ROMFS_MOUNTPOINT - -config STM32_ROMFS_DEV_MINOR - int "Minor for the block device backing the data" - depends on STM32_ROMFS - default 64 - -config STM32_ROMFS_MOUNTPOINT - string "Mountpoint of the custom romfs image" - depends on STM32_ROMFS - default "/rom" - -config STM32_ROMFS_IMAGEFILE - string "ROMFS image file to include into build" - depends on STM32_ROMFS - default "../../../rom.img" - choice prompt "Select Console wiring." default NUCLEO_F746ZG_CONSOLE_ARDUINO diff --git a/boards/arm/stm32f7/nucleo-f746zg/src/CMakeLists.txt b/boards/arm/stm32f7/nucleo-f746zg/src/CMakeLists.txt index a5e418b383..193920163f 100644 --- a/boards/arm/stm32f7/nucleo-f746zg/src/CMakeLists.txt +++ b/boards/arm/stm32f7/nucleo-f746zg/src/CMakeLists.txt @@ -66,10 +66,6 @@ if(CONFIG_BOARDCTL_RESET) list(APPEND SRCS stm32_reset.c) endif() -if(CONFIG_STM32_ROMFS) - list(APPEND SRCS stm32_romfs_initialize.c) -endif() - if(CONFIG_SENSORS_QENCODER) list(APPEND SRCS stm32_qencoder.c) endif() diff --git a/boards/arm/stm32f7/nucleo-f746zg/src/Make.defs b/boards/arm/stm32f7/nucleo-f746zg/src/Make.defs index ab7e5a4213..b5db10b2a9 100644 --- a/boards/arm/stm32f7/nucleo-f746zg/src/Make.defs +++ b/boards/arm/stm32f7/nucleo-f746zg/src/Make.defs @@ -68,10 +68,6 @@ ifeq ($(CONFIG_BOARDCTL_RESET),y) CSRCS += stm32_reset.c endif -ifeq ($(CONFIG_STM32_ROMFS),y) -CSRCS += stm32_romfs_initialize.c -endif - ifeq ($(CONFIG_SENSORS_QENCODER),y) CSRCS += stm32_qencoder.c endif diff --git a/boards/arm/stm32f7/nucleo-f746zg/src/stm32_bringup.c b/boards/arm/stm32f7/nucleo-f746zg/src/stm32_bringup.c index aff3bb55c0..5ef4a9699c 100644 --- a/boards/arm/stm32f7/nucleo-f746zg/src/stm32_bringup.c +++ b/boards/arm/stm32f7/nucleo-f746zg/src/stm32_bringup.c @@ -46,8 +46,8 @@ # include "stm32_cansock_setup.h" #endif -#ifdef CONFIG_STM32_ROMFS -#include "stm32_romfs.h" +#ifdef CONFIG_STM32F7_ROMFS +# include "stm32_romfs.h" #endif #ifdef CONFIG_SYSTEMTICK_HOOK @@ -94,14 +94,14 @@ int stm32_bringup(void) } #endif -#ifdef CONFIG_STM32_ROMFS +#ifdef CONFIG_STM32F7_ROMFS /* Mount the romfs partition */ ret = stm32_romfs_initialize(); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount romfs at %s: %d\n", - CONFIG_STM32_ROMFS_MOUNTPOINT, ret); + CONFIG_STM32F7_ROMFS_MOUNTPOINT, ret); } #endif diff --git a/boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs.h b/boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs.h deleted file mode 100644 index e84db19ae5..0000000000 --- a/boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs.h - * - * Copyright (C) 2017 Tomasz Wozniak. All rights reserved. - * Author: Tomasz Wozniak <[email protected]> - * - * 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 __BOARDS_ARM_STM32F7_NUCLEO144_SRC_STM32_ROMFS_H -#define __BOARDS_ARM_STM32F7_NUCLEO144_SRC_STM32_ROMFS_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#ifdef CONFIG_STM32_ROMFS - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define ROMFS_SECTOR_SIZE 64 - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_romfs_initialize - * - * Description: - * Registers built-in ROMFS image as block device and mounts it. - * - * Returned Value: - * Zero (OK) on success, a negated errno value on error. - * - * Assumptions/Limitations: - * Memory addresses [romfs_data_begin .. romfs_data_end) should contain - * ROMFS volume data, as included in the assembly snippet above (l. 84). - * - ****************************************************************************/ - -int stm32_romfs_initialize(void); - -#endif /* CONFIG_STM32_ROMFS */ - -#endif /* __BOARDS_ARM_STM32F7_NUCLEO144_SRC_STM32_ROMFS_H */ diff --git a/boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs_initialize.c b/boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs_initialize.c deleted file mode 100644 index 0f63609b32..0000000000 --- a/boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs_initialize.c +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs_initialize.c - * This file provides contents of an optional ROMFS volume, mounted at boot. - * - * Copyright (C) 2017 Tomasz Wozniak. All rights reserved. - * Author: Tomasz Wozniak <[email protected]> - * - * 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 <nuttx/config.h> - -#include <sys/mount.h> -#include <sys/types.h> -#include <stdint.h> -#include <debug.h> -#include <errno.h> - -#include <nuttx/fs/fs.h> -#include <nuttx/drivers/ramdisk.h> -#include "stm32_romfs.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef CONFIG_STM32_ROMFS -# error "CONFIG_STM32_ROMFS must be defined" -#else - -#ifndef CONFIG_STM32_ROMFS_IMAGEFILE -# error "CONFIG_STM32_ROMFS_IMAGEFILE must be defined" -#endif - -#ifndef CONFIG_STM32_ROMFS_DEV_MINOR -# error "CONFIG_STM32_ROMFS_DEV_MINOR must be defined" -#endif - -#ifndef CONFIG_STM32_ROMFS_MOUNTPOINT -# error "CONFIG_STM32_ROMFS_MOUNTPOINT must be defined" -#endif - -#define NSECTORS(size) (((size) + ROMFS_SECTOR_SIZE - 1)/ROMFS_SECTOR_SIZE) - -#define STR2(m) #m -#define STR(m) STR2(m) - -#define MKMOUNT_DEVNAME(m) "/dev/ram" STR(m) -#define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_STM32_ROMFS_DEV_MINOR) - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -__asm__ ( - ".section .rodata\n" - ".balign 16\n" - ".globl romfs_data_begin\n" -"romfs_data_begin:\n" - ".incbin " STR(CONFIG_STM32_ROMFS_IMAGEFILE) "\n"\ - \ - ".balign " STR(ROMFS_SECTOR_SIZE) "\n" - ".globl romfs_data_end\n" -"romfs_data_end:\n"); - -extern const uint8_t romfs_data_begin[]; -extern const uint8_t romfs_data_end[]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_romfs_initialize - * - * Description: - * Registers the aboveincluded binary file as block device. - * Then mounts the block device as ROMFS filesystems. - * - * Returned Value: - * Zero (OK) on success, a negated errno value on error. - * - * Assumptions/Limitations: - * Memory addresses [romfs_data_begin .. romfs_data_end) should contain - * ROMFS volume data, as included in the assembly snippet above (l. 84). - * - ****************************************************************************/ - -int stm32_romfs_initialize(void) -{ - size_t romfs_data_len; - int ret; - - /* Create a ROM disk for the /etc filesystem */ - - romfs_data_len = romfs_data_end - romfs_data_begin; - - ret = romdisk_register(CONFIG_STM32_ROMFS_DEV_MINOR, romfs_data_begin, - NSECTORS(romfs_data_len), ROMFS_SECTOR_SIZE); - if (ret < 0) - { - ferr("ERROR: romdisk_register failed: %d\n", -ret); - return ret; - } - - /* Mount the file system */ - - finfo("Mounting ROMFS filesystem at target=%s with source=%s\n", - CONFIG_STM32_ROMFS_MOUNTPOINT, MOUNT_DEVNAME); - - ret = nx_mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, - "romfs", MS_RDONLY, NULL); - if (ret < 0) - { - ferr("ERROR: nx_mount(%s,%s,romfs) failed: %d\n", - MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, ret); - return ret; - } - - return OK; -} - -#endif /* CONFIG_STM32_ROMFS */ diff --git a/boards/arm/stm32f7/nucleo-f767zi/Kconfig b/boards/arm/stm32f7/nucleo-f767zi/Kconfig index 83086d2372..d9cfd182bd 100644 --- a/boards/arm/stm32f7/nucleo-f767zi/Kconfig +++ b/boards/arm/stm32f7/nucleo-f767zi/Kconfig @@ -5,28 +5,6 @@ if ARCH_BOARD_NUCLEO_F767ZI -config STM32_ROMFS - bool "Automount baked-in ROMFS image" - default n - depends on FS_ROMFS - ---help--- - Select STM32_ROMFS_IMAGEFILE, STM32_ROMFS_DEV_MINOR, STM32_ROMFS_MOUNTPOINT - -config STM32_ROMFS_DEV_MINOR - int "Minor for the block device backing the data" - depends on STM32_ROMFS - default 64 - -config STM32_ROMFS_MOUNTPOINT - string "Mountpoint of the custom romfs image" - depends on STM32_ROMFS - default "/rom" - -config STM32_ROMFS_IMAGEFILE - string "ROMFS image file to include into build" - depends on STM32_ROMFS - default "../../../rom.img" - choice prompt "Select Console wiring." default NUCLEO_F767ZI_CONSOLE_ARDUINO diff --git a/boards/arm/stm32f7/nucleo-f767zi/src/CMakeLists.txt b/boards/arm/stm32f7/nucleo-f767zi/src/CMakeLists.txt index 73815d85c5..30e1c6b9bf 100644 --- a/boards/arm/stm32f7/nucleo-f767zi/src/CMakeLists.txt +++ b/boards/arm/stm32f7/nucleo-f767zi/src/CMakeLists.txt @@ -66,10 +66,6 @@ if(CONFIG_BOARDCTL_RESET) list(APPEND SRCS stm32_reset.c) endif() -if(CONFIG_STM32_ROMFS) - list(APPEND SRCS stm32_romfs_initialize.c) -endif() - if(CONFIG_SENSORS_QENCODER) list(APPEND SRCS stm32_qencoder.c) endif() diff --git a/boards/arm/stm32f7/nucleo-f767zi/src/Make.defs b/boards/arm/stm32f7/nucleo-f767zi/src/Make.defs index bc0f0db9e4..1eef7361c2 100644 --- a/boards/arm/stm32f7/nucleo-f767zi/src/Make.defs +++ b/boards/arm/stm32f7/nucleo-f767zi/src/Make.defs @@ -68,10 +68,6 @@ ifeq ($(CONFIG_BOARDCTL_RESET),y) CSRCS += stm32_reset.c endif -ifeq ($(CONFIG_STM32_ROMFS),y) -CSRCS += stm32_romfs_initialize.c -endif - ifeq ($(CONFIG_SENSORS_QENCODER),y) CSRCS += stm32_qencoder.c endif diff --git a/boards/arm/stm32f7/nucleo-f767zi/src/stm32_bringup.c b/boards/arm/stm32f7/nucleo-f767zi/src/stm32_bringup.c index a6942a4f9a..2f32d07346 100644 --- a/boards/arm/stm32f7/nucleo-f767zi/src/stm32_bringup.c +++ b/boards/arm/stm32f7/nucleo-f767zi/src/stm32_bringup.c @@ -46,8 +46,8 @@ # include "stm32_cansock_setup.h" #endif -#ifdef CONFIG_STM32_ROMFS -#include "stm32_romfs.h" +#ifdef CONFIG_STM32F7_ROMFS +# include "stm32_romfs.h" #endif #ifdef CONFIG_SYSTEMTICK_HOOK @@ -94,14 +94,14 @@ int stm32_bringup(void) } #endif -#ifdef CONFIG_STM32_ROMFS +#ifdef CONFIG_STM32F7_ROMFS /* Mount the romfs partition */ ret = stm32_romfs_initialize(); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount romfs at %s: %d\n", - CONFIG_STM32_ROMFS_MOUNTPOINT, ret); + CONFIG_STM32F7_ROMFS_MOUNTPOINT, ret); } #endif
