Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add USB MSC support for esp32s3 #14966

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -827,3 +827,23 @@ Then check the partition::
crw-rw-rw- 0 ttyS0
frw-rw-rw- 4096 txtable
crw-rw-rw- 0 zero

usbmsc
------

Basic USBMSC(USB Mass Storage Class) configuration based on esp32s3-devkit:usb_device

You can run the configuration and compilation procedure::

$ ./tools/configure.sh -l esp32s3-devkit:usbmsc
$ make flash ESPTOOL_PORT=/dev/ttyACMx -j16

To test it, just run the following::

# Device
nsh> mkrd -m 10 -s 512 640
nsh> msconn

# Host
$ sudo mkfs.ext4 /dev/sdx
$ sudo mount /dev/sdx ./mnt/
4 changes: 4 additions & 0 deletions boards/xtensa/esp32s3/common/src/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ ifeq ($(CONFIG_ESP32S3_SDMMC),y)
CSRCS += esp32s3_board_sdmmc.c
endif

ifeq ($(CONFIG_USBMSC),y)
CSRCS += esp32s3_usbmsc.c
endif

DEPPATH += --dep-path src
VPATH += :src
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
Expand Down
62 changes: 62 additions & 0 deletions boards/xtensa/esp32s3/common/src/esp32s3_usbmsc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/****************************************************************************
* boards/xtensa/esp32s3/common/src/esp32s3_usbmsc.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>

#include <stdio.h>
#include <syslog.h>
#include <errno.h>

#include <nuttx/board.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

/* Configuration ************************************************************/

/****************************************************************************
* Public Functions
****************************************************************************/

/****************************************************************************
* Name: board_usbmsc_initialize
*
* Description:
* Perform architecture specific initialization as needed to establish
* the mass storage device that will be exported by the USB MSC device.
*
****************************************************************************/

int board_usbmsc_initialize(int port)
{
/* If system/usbmsc is built as an NSH command, then SD slot should
* already have been initialized in board_app_initialize()
* In this case, there is nothing further to be done here.
*/

return OK;
}
9 changes: 9 additions & 0 deletions boards/xtensa/esp32s3/esp32s3-devkit/configs/usbmsc/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "../usb_device/defconfig"
CONFIG_BCH=y
CONFIG_DEV_ZERO=y
CONFIG_ESP32S3_SPIFLASH=y
CONFIG_SYSTEM_USBMSC=y
CONFIG_SYSTEM_USBMSC_DEVPATH1="/dev/ram10"
CONFIG_USBMSC=y
CONFIG_USBMSC_EPBULKIN=2
CONFIG_USBMSC_EPBULKOUT=1