mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
nucleo-f446re: add romfs support
This commit is contained in:
@@ -31,4 +31,26 @@ config NUCLEO_F446RE_AJOY_MINBUTTONS
|
|||||||
minimal set: SELECT (joystick down), FIRE (BUTTON B), and JUMP
|
minimal set: SELECT (joystick down), FIRE (BUTTON B), and JUMP
|
||||||
(BUTTON A).
|
(BUTTON A).
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
endif # ARCH_BOARD_NUCLEO_F446RE
|
endif # ARCH_BOARD_NUCLEO_F446RE
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ ifeq ($(CONFIG_BOARD_STM32_IHM08M1),y)
|
|||||||
CSRCS += stm32_foc_ihm08m1.c
|
CSRCS += stm32_foc_ihm08m1.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_STM32_ROMFS),y)
|
||||||
|
CSRCS += stm32_romfs_initialize.c
|
||||||
|
endif
|
||||||
|
|
||||||
DEPPATH += --dep-path board
|
DEPPATH += --dep-path board
|
||||||
VPATH += :board
|
VPATH += :board
|
||||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#include <nuttx/mmcsd.h>
|
#include <nuttx/mmcsd.h>
|
||||||
|
|
||||||
#include <stm32.h>
|
#include <stm32.h>
|
||||||
#include <stm32_uart.h>
|
#include <stm32_romfs.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
@@ -90,6 +90,15 @@ int stm32_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_FS_PROCFS */
|
#endif /* CONFIG_FS_PROCFS */
|
||||||
|
|
||||||
|
#ifdef CONFIG_STM32_ROMFS
|
||||||
|
ret = stm32_romfs_initialize();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to mount romfs at %s: %d\n",
|
||||||
|
CONFIG_STM32_ROMFS_MOUNTPOINT, ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_INPUT_BUTTONS
|
#ifdef CONFIG_INPUT_BUTTONS
|
||||||
/* Register the BUTTON driver */
|
/* Register the BUTTON driver */
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/stm32/nucleo-f446re/src/stm32_romfs.h
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __BOARDS_ARM_STM32_NUCLEO_F446RE_SRC_STM32_ROMFS_H
|
||||||
|
#define __BOARDS_ARM_STM32_NUCLEO_F446RE_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_begin) 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_STM32_NUCLEO_F446RE_SRC_STM32_ROMFS_H */
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/stm32/nucleo-f446re/src/stm32_romfs_initialize.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* This file provides contents of an optional ROMFS volume, mounted at boot */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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_begin) should contain
|
||||||
|
* ROMFS volume data, as included in the assembly snippet above (l. 84).
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int stm32_romfs_initialize(void)
|
||||||
|
{
|
||||||
|
uintptr_t romfs_data_len;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Create a ROM disk for the /etc filesystem */
|
||||||
|
|
||||||
|
romfs_data_len = (uintptr_t)romfs_data_end - (uintptr_t)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 */
|
||||||
Reference in New Issue
Block a user