boards/arm/stm32f7: move ROMFS logic to common directory

move ROMFS logic to common directory
This commit is contained in:
raiden00pl
2024-10-20 13:15:56 +02:00
committed by Xiang Xiao
parent b606c17619
commit d4e158f86d
23 changed files with 70 additions and 591 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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"

View File

@@ -1,5 +1,5 @@
/****************************************************************************
* boards/arm/stm32f7/nucleo-f722ze/src/stm32_romfs.h
* boards/arm/stm32f7/common/include/stm32_romfs.h
*
* Copyright (C) 2017 Tomasz Wozniak. All rights reserved.
* Author: Tomasz Wozniak <t.wozniak@samsung.com>
@@ -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 */

View File

@@ -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})

View File

@@ -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

View File

@@ -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_STM32_ROMFS_IMAGEFILE
# error "CONFIG_STM32_ROMFS_IMAGEFILE must be defined"
#ifndef CONFIG_STM32F7_ROMFS
# error "CONFIG_STM32F7_ROMFS must be defined"
#endif
#ifndef CONFIG_STM32_ROMFS_DEV_MINOR
# error "CONFIG_STM32_ROMFS_DEV_MINOR must be defined"
#ifndef CONFIG_STM32F7_ROMFS_IMAGEFILE
# error "CONFIG_STM32F7_ROMFS_IMAGEFILE must be defined"
#endif
#ifndef CONFIG_STM32_ROMFS_MOUNTPOINT
# error "CONFIG_STM32_ROMFS_MOUNTPOINT must be defined"
#ifndef CONFIG_STM32F7_ROMFS_DEV_MINOR
# error "CONFIG_STM32F7_ROMFS_DEV_MINOR must be defined"
#endif
#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 */

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -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 <t.wozniak@samsung.com>
*
* 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 */

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -1,76 +0,0 @@
/****************************************************************************
* boards/arm/stm32f7/nucleo-f746zg/src/stm32_romfs.h
*
* Copyright (C) 2017 Tomasz Wozniak. All rights reserved.
* Author: Tomasz Wozniak <t.wozniak@samsung.com>
*
* 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 */

View File

@@ -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 <t.wozniak@samsung.com>
*
* 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 */

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -1,76 +0,0 @@
/****************************************************************************
* boards/arm/stm32f7/nucleo-f767zi/src/stm32_romfs.h
*
* Copyright (C) 2017 Tomasz Wozniak. All rights reserved.
* Author: Tomasz Wozniak <t.wozniak@samsung.com>
*
* 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 */