mirror of
https://github.com/apache/nuttx.git
synced 2026-05-13 10:38:40 +08:00
boards/esp32c3: Add romfs configuration
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="risc-v"
|
||||
CONFIG_ARCH_BOARD="esp32c3-devkit"
|
||||
CONFIG_ARCH_BOARD_ESP32C3_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32c3"
|
||||
CONFIG_ARCH_CHIP_ESP32C3=y
|
||||
CONFIG_ARCH_CHIP_ESP32C3WROOM02=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=1536
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_EXAMPLES_ROMFS=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_ARCHROMFS=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_ROMFSDEVNO=6
|
||||
CONFIG_NSH_ROMFSETC=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=29
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
@@ -0,0 +1,25 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/esp32c3/esp32c3-devkit/include/nsh_romfsimg.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_RISCV_ESP32C3_ESP32C3_DEVKIT_INCLUDE_NSH_ROMFSIMG_H
|
||||
#define __BOARDS_RISCV_ESP32C3_ESP32C3_DEVKIT_INCLUDE_NSH_ROMFSIMG_H
|
||||
extern const unsigned char romfs_img[];
|
||||
extern const unsigned int romfs_img_len;
|
||||
#endif
|
||||
@@ -86,6 +86,13 @@ ifeq ($(CONFIG_BOARDCTL_UNIQUEID),y)
|
||||
CSRCS += esp32c3_uid.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_ROMFSETC),y)
|
||||
ifneq ($(CONFIG_NSH_CUSTOMROMFS),y)
|
||||
RCSRCS = etc/init.d/rcS
|
||||
RCRAWS = etc/group etc/passwd
|
||||
endif
|
||||
endif
|
||||
|
||||
SCRIPTIN = $(SCRIPTDIR)$(DELIM)esp32c3.template.ld
|
||||
SCRIPTOUT = $(SCRIPTDIR)$(DELIM)esp32c3_out.ld
|
||||
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
README
|
||||
======
|
||||
|
||||
Overview
|
||||
--------
|
||||
This directory contains logic to support a custom ROMFS start-up script.
|
||||
This startup script is used by by the NSH when it starts provided that
|
||||
CONFIG_NSH_ARCHROMFS=y. The script provides a ROMFS volume that will be
|
||||
mounted at /etc and will look like this at run-time:
|
||||
|
||||
NuttShell (NSH) NuttX-10.1.0-RC1
|
||||
MOTD: username=admin password=Administrator
|
||||
nsh> ls -Rl /etc
|
||||
/etc:
|
||||
dr-xr-xr-x 0 .
|
||||
-r--r--r-- 20 group
|
||||
dr-xr-xr-x 0 init.d/
|
||||
-r--r--r-- 35 passwd
|
||||
/etc/init.d:
|
||||
dr-xr-xr-x 0 ..
|
||||
-r--r--r-- 110 rcS
|
||||
nsh>
|
||||
|
||||
/etc/init.d/rcS is the start-up script; /etc/passwd is a the password
|
||||
file. It supports a single user:
|
||||
|
||||
USERNAME: admin
|
||||
PASSWORD: Administrator
|
||||
|
||||
nsh> cat /etc/passwd
|
||||
admin:8Tv+Hbmr3pLddSjtzL0kwC:0:0:/
|
||||
|
||||
The encrypted passwords in the provided passwd file are only valid if the
|
||||
TEA key is set to: 012345678 9abcdef0 012345678 9abcdef0. Changes to either
|
||||
the key or the password word will require regeneration of the nsh_romfimg.h
|
||||
header file.
|
||||
|
||||
The format of the password file is:
|
||||
|
||||
user:x:uid:gid:home
|
||||
|
||||
Where:
|
||||
user: User name
|
||||
x: Encrypted password
|
||||
uid: User ID (0 for now)
|
||||
gid: Group ID (0 for now)
|
||||
home: Login directory (/ for now)
|
||||
|
||||
/etc/group is a group file. It is not currently used.
|
||||
|
||||
nsh> cat /etc/group
|
||||
root:*:0:root,admin
|
||||
|
||||
The format of the group file is:
|
||||
|
||||
group:x:gid:users
|
||||
|
||||
Where:
|
||||
group: The group name
|
||||
x: Group password
|
||||
gid: Group ID
|
||||
users: A comma separated list of members of the group
|
||||
|
||||
Updating the ROMFS File System
|
||||
------------------------------
|
||||
The content on the nsh_romfsimg.h header file is generated from a sample
|
||||
directory structure. You can directly modify files under etc/ folder,
|
||||
The build system will regenerate nsh_romfsimg.h automatically.
|
||||
|
||||
See the esp32c3-devkit/nsh configuration for an example of the use of this file
|
||||
system.
|
||||
|
||||
Replacing the Password File
|
||||
---------------------------
|
||||
The esp32c3-devkit/nsh configuration can also be used to create a new password file.
|
||||
First, make these configuration changes:
|
||||
|
||||
1. Disable logins
|
||||
|
||||
- CONFIG_NSH_CONSOLE_LOGIN=y
|
||||
+ # CONFIG_NSH_CONSOLE_LOGIN is not set
|
||||
# CONFIG_NSH_TELNET_LOGIN is not set
|
||||
|
||||
2. Move the password file to a write-able file system:
|
||||
|
||||
- CONFIG_FSUTILS_PASSWD_PATH="/etc/passwd"
|
||||
+ CONFIG_FSUTILS_PASSWD_PATH="/tmp/passwd"
|
||||
|
||||
3. make the password file modifiable
|
||||
|
||||
- CONFIG_FSUTILS_PASSWD_READONLY=y
|
||||
# CONFIG_FSUTILS_PASSWD_READONLY is not set
|
||||
|
||||
Now rebuild the simulation. No login should be required to enter the
|
||||
shell and you should find the 'useradd', 'userdel', and 'passwd' commands
|
||||
available in the help summary, provided that they are enabled. Make
|
||||
certain that the 'useradd' command is not disabled:
|
||||
|
||||
# CONFIG_NSH_DISABLE_USERADD is not set
|
||||
|
||||
Use the NSH 'useradd' command to add new uses with new user passwords like:
|
||||
|
||||
nsh> useradd <username> <password>
|
||||
|
||||
Do this as many times as you would like. Each time that you do this a new
|
||||
entry with an encrypted password will be added to the passwd file at
|
||||
/tmp/passwd. You can see the passwd file like:
|
||||
|
||||
nsh> cat /tmp/passwd
|
||||
|
||||
When you are finished, you can simply copy the /tmp/passwd content from the
|
||||
'cat' command and paste it into an editor. Make sure to remove any
|
||||
carriage returns that may have ended up on the file if you are using
|
||||
Windows.
|
||||
|
||||
Then recreate the nsh_romfsimg.h file as described above. In step 2,
|
||||
simply replace the old /etc/passwd file with the one in your editor.
|
||||
When you are finished, the new passwd file will be in the ROMFS file
|
||||
system at the path /etc/passwd. When you restore the original NSH
|
||||
sim configuration, these are the passwords that will be used.
|
||||
@@ -0,0 +1 @@
|
||||
root:*:0:root,admin
|
||||
@@ -0,0 +1,36 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rcS
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#define CONCAT_(x, y) x##y
|
||||
#define CONCAT(x, y) CONCAT_(x, y)
|
||||
|
||||
#ifdef CONFIG_NSH_ROMFSETC
|
||||
#ifdef CONFIG_FS_FAT
|
||||
|
||||
/* Create a RAMDISK and mount it at /tmp */
|
||||
|
||||
mkrd -m CONFIG_NSH_FATDEVNO -s CONFIG_NSH_FATSECTSIZE CONFIG_NSH_FATNSECTORS
|
||||
mkfatfs CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO)
|
||||
mount -t vfat CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) CONFIG_NSH_FATMOUNTPT
|
||||
|
||||
#endif /* CONFIG_FS_FAT */
|
||||
#endif /* CONFIG_NSH_ROMFSETC */
|
||||
@@ -0,0 +1 @@
|
||||
admin:8Tv+Hbmr3pLddSjtzL0kwC:0:0:/
|
||||
Reference in New Issue
Block a user