configs/pnev5180b/src/pc17_romfs: pnev5180b/src/lpc17_romfs: Automount baked-in ROMFS image. Includes support for linking a binary ROMFS image into the nuttx executable and for mounting it during board bringup.
This commit is contained in:
parent
b9d2e516ef
commit
478d27455d
@ -4,4 +4,32 @@
|
||||
#
|
||||
|
||||
if ARCH_BOARD_PNEV5180B
|
||||
|
||||
config LPC17_ROMFS
|
||||
bool "Automount baked-in ROMFS image"
|
||||
default n
|
||||
depends on FS_ROMFS
|
||||
---help---
|
||||
Specify which ROMFS image to mount where via LPC17_ROMFS_IMAGEFILE,
|
||||
LPC17_ROMFS_DEV_MINOR, and LPC17_ROMFS_MOUNTPOINT. ROMFS images are
|
||||
created with the genromfs Linux tool.
|
||||
|
||||
config LPC17_ROMFS_DEV_MINOR
|
||||
int "Minor for the block device backing the data"
|
||||
depends on LPC17_ROMFS
|
||||
default 64
|
||||
|
||||
config LPC17_ROMFS_MOUNTPOINT
|
||||
string "Mountpoint of the custom romfs image"
|
||||
depends on LPC17_ROMFS
|
||||
default "/mnt/romfs"
|
||||
|
||||
config LPC17_ROMFS_IMAGEFILE
|
||||
string "ROMFS image file to include into build"
|
||||
depends on LPC17_ROMFS
|
||||
default "../romfs.img"
|
||||
---help---
|
||||
The path to specify is relative to the 'src' directory of the
|
||||
currently selected configuration.
|
||||
|
||||
endif
|
||||
|
@ -62,4 +62,8 @@ ifeq ($(CONFIG_NXFLAT),y)
|
||||
CSRCS += lpc17_symtab.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LPC17_ROMFS),y)
|
||||
CSRCS += lpc17_romfs.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/configs/Board.mk
|
||||
|
@ -67,6 +67,10 @@
|
||||
# include <nuttx/board.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LPC17_ROMFS
|
||||
# include "lpc17_romfs.h"
|
||||
#endif
|
||||
|
||||
#include "lpc17_spi.h"
|
||||
#include "pnev5180b.h"
|
||||
#include "lpc17_symtab.h"
|
||||
@ -159,6 +163,15 @@ int pnev5180b_bringup(void)
|
||||
board_composite_connect(0, 0);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LPC17_ROMFS
|
||||
ret = lpc17_romfs_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: lpc17_romfs_initialize() failed: %d\n", ret);
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBMONITOR
|
||||
ret = usbmonitor_start();
|
||||
if (ret != OK)
|
||||
|
161
configs/pnev5180b/src/lpc17_romfs.c
Normal file
161
configs/pnev5180b/src/lpc17_romfs.c
Normal file
@ -0,0 +1,161 @@
|
||||
/*****************************************************************************
|
||||
* configs/pnev5180b/src/lpc17_romfs.c
|
||||
* This file provides contents of an optional ROMFS volume, mounted at boot.
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Michael Jung <mijung@gmx.net>
|
||||
*
|
||||
* Based on configs/nucleo-144/src/stm32_romfs_initialize.c
|
||||
*
|
||||
* 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/drivers/ramdisk.h>
|
||||
#include "lpc17_romfs.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_LPC17_ROMFS
|
||||
# error "CONFIG_LPC17_ROMFS must be defined"
|
||||
#else
|
||||
|
||||
#ifndef CONFIG_LPC17_ROMFS_IMAGEFILE
|
||||
# error "CONFIG_LPC17_ROMFS_IMAGEFILE must be defined"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_LPC17_ROMFS_DEV_MINOR
|
||||
# error "CONFIG_LPC17_ROMFS_DEV_MINOR must be defined"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_LPC17_ROMFS_MOUNTPOINT
|
||||
# error "CONFIG_LPC17_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_LPC17_ROMFS_DEV_MINOR)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
__asm__ (
|
||||
".section .rodata\n"
|
||||
".balign 16\n"
|
||||
".globl romfs_data_begin\n"
|
||||
"romfs_data_begin:\n"
|
||||
".incbin " STR(CONFIG_LPC17_ROMFS_IMAGEFILE) "\n"\
|
||||
\
|
||||
".balign " STR(ROMFS_SECTOR_SIZE) "\n"
|
||||
".globl romfs_data_end\n"
|
||||
"romfs_data_end:\n"
|
||||
".globl romfs_data_size\n"
|
||||
"romfs_data_size:\n"
|
||||
".word romfs_data_end - romfs_data_begin\n");
|
||||
|
||||
extern const uint8_t romfs_data_begin;
|
||||
extern const uint8_t romfs_data_end;
|
||||
extern const int romfs_data_size;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lpc17_romfs_initialize
|
||||
*
|
||||
* Description:
|
||||
* Registers the above included binary file as block device, then mounts
|
||||
* the block device as ROMFS file systems.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success, a negated errno value on error.
|
||||
*
|
||||
* Assumptions/Limitations:
|
||||
* Memory addresses [&romfs_data_begin .. &romfs_data_en) should contain
|
||||
* ROMFS volume data, as included in the assembly snippet above.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int lpc17_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_LPC17_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_LPC17_ROMFS_MOUNTPOINT, MOUNT_DEVNAME);
|
||||
|
||||
ret = mount(MOUNT_DEVNAME, CONFIG_LPC17_ROMFS_MOUNTPOINT,
|
||||
"romfs", MS_RDONLY, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: mount(%s,%s,romfs) failed: %d\n",
|
||||
MOUNT_DEVNAME, CONFIG_LPC17_ROMFS_MOUNTPOINT, errno);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_LPC17_ROMFS */
|
82
configs/pnev5180b/src/lpc17_romfs.h
Normal file
82
configs/pnev5180b/src/lpc17_romfs.h
Normal file
@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
* configs/pnev5180b/src/lpc17_romfs.h
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Michael Jung (mijung@gmx.net)
|
||||
*
|
||||
* Based on configs/nucleo-144/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 __CONFIGS_PNEV5180B_SRC_LPC17_ROMFS_H
|
||||
#define __CONFIGS_PNEV5180B_SRC_LPC17_ROMFS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_LPC17_ROMFS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ROMFS_SECTOR_SIZE 64
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lpc17_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 in
|
||||
* lpc17_romfs_initialize.c.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int lpc17_romfs_initialize(void);
|
||||
|
||||
#endif /* CONFIG_LPC17_ROMFS */
|
||||
|
||||
#endif /* __CONFIGS_PNEV5180B_SRC_LPC17_ROMFS_H */
|
Loading…
Reference in New Issue
Block a user