stm32h7/linum-stm32h753bi: Add support to usbmsc with sdcard

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
Jorge Guzman 2024-04-24 09:05:52 -03:00 committed by Xiang Xiao
parent c4f199e929
commit b4d977715e
5 changed files with 175 additions and 2 deletions

View File

@ -593,7 +593,7 @@ This example use the flash memory W25Q128JV via qspi with the littlefs file syst
rndis
-----
This exemple use ethernet over usb and show how configure ip and download file with wget command from server.
This example use ethernet over usb and show how configure ip and download file with wget command from server.
After flash the board check if the linux found and recognized the new network driver::
@ -618,7 +618,7 @@ After flash the board check if the linux found and recognized the new network dr
TX packets 99 bytes 22896 (22.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
obs: In network settings of PC enable "Shared to other computers"
**OBS:** In network settings of PC enable "Shared to other computers"
Configure the IP of target::
@ -691,3 +691,32 @@ Testing wget to download file from server::
nsh> ls
/tmp:
nuttx_logo.txt
usbmsc-sdcard
-------------
This example uses the USB Mass Storage with SD Card.
Enable the USB Mass Storage with the command **msconn**::
nsh> msconn
mcsonn_main: Creating block drivers
mcsonn_main: handle=0x38003020
mcsonn_main: Bind LUN=0 to /dev/mmcsd0
mcsonn_main: Connected
After that check if your PC recognized the usb driver::
$ sudo dmesg | tail
[sudo] password for jaga:
[27219.361934] usbcore: registered new interface driver uas
[27220.378231] scsi 0:0:0:0: Direct-Access NuttX Mass Storage 0101 PQ: 0 ANSI: 2
[27220.378646] sd 0:0:0:0: Attached scsi generic sg0 type 0
[27220.379203] sd 0:0:0:0: [sda] 1930240 512-byte logical blocks: (988 MB/943 MiB)
[27220.597414] sd 0:0:0:0: [sda] Write Protect is off
[27220.597419] sd 0:0:0:0: [sda] Mode Sense: 0f 00 00 00
[27220.817620] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[27221.265245] sda: sda1
[27221.266103] sd 0:0:0:0: [sda] Attached SCSI removable disk
[27228.147377] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
**OBS:** This example disable the macro CONFIG_STM32H7_SDMMC_IDMA, for more information read the file: arch/arm/stm32h7/stm32_sdmmc.c

View File

@ -0,0 +1,77 @@
#
# 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_MMCSD_HAVE_WRITEPROTECT is not set
# CONFIG_MMCSD_MMCSUPPORT is not set
# CONFIG_STANDARD_SERIAL is not set
# CONFIG_STM32H7_SDMMC_IDMA is not set
# CONFIG_STM32H7_USE_LEGACY_PINMAP is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="linum-stm32h753bi"
CONFIG_ARCH_BOARD_LINUM_STM32H753BI=y
CONFIG_ARCH_CHIP="stm32h7"
CONFIG_ARCH_CHIP_STM32H753BI=y
CONFIG_ARCH_CHIP_STM32H7=y
CONFIG_ARCH_CHIP_STM32H7_CORTEXM7=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
CONFIG_ARMV7M_DTCM=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_BOARD_LOOPSPERMSEC=43103
CONFIG_BUILTIN=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_EXAMPLES_ALARM=y
CONFIG_FAT_DMAMEMORY=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
CONFIG_GRAN=y
CONFIG_GRAN_INTR=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=4096
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBM=y
CONFIG_MMCSD=y
CONFIG_MMCSD_SDIO=y
CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE=y
CONFIG_MM_REGIONS=4
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_DISABLE_IFUPDOWN=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_OTG_ID_GPIO_DISABLE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=245760
CONFIG_RAM_START=0x20010000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_RTC_ALARM=y
CONFIG_RTC_DATETIME=y
CONFIG_RTC_DRIVER=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDMMC1_SDIO_MODE=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_STM32H7_HSI48=y
CONFIG_STM32H7_OTGFS=y
CONFIG_STM32H7_PWR=y
CONFIG_STM32H7_RTC=y
CONFIG_STM32H7_SDMMC1=y
CONFIG_STM32H7_USART1=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_USBMSC=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USBDEV=y
CONFIG_USBMSC=y
CONFIG_USBMSC_REMOVABLE=y

View File

@ -56,6 +56,10 @@ if(CONFIG_MTD_W25QXXXJV)
list(APPEND SRCS stm32_w25q.c)
endif()
if(CONFIG_USBMSC)
list(APPEND SRCS stm32_usbmsc.c)
endif()
target_sources(board PRIVATE ${SRCS})
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")

View File

@ -54,6 +54,10 @@ ifeq ($(CONFIG_MTD_W25QXXXJV),y)
CSRCS += stm32_w25q.c
endif
ifeq ($(CONFIG_USBMSC),y)
CSRCS += stm32_usbmsc.c
endif
ifeq ($(CONFIG_BOARDCTL),y)
CSRCS += stm32_appinitialize.c
endif

View File

@ -0,0 +1,59 @@
/****************************************************************************
* boards/arm/stm32h7/linum-stm32h753bi/src/stm32_usbmsc.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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <syslog.h>
#include <errno.h>
#include <nuttx/board.h>
/****************************************************************************
* 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()
* (see stm32_appinit.c).
* In this case, there is nothing further to be done here.
*/
#ifndef CONFIG_NSH_BUILTIN_APPS
stm32_mmcsd_initialize(0);
#else
return OK;
#endif
}