From c8cca16c204543b8f6dd7261c643b48ba8c95a94 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Fri, 21 Aug 2020 11:54:55 +0200 Subject: [PATCH] samples: subsys: usb: mass: add support for Adafruit feather nRF52840 Add configuration and overlay files for Adafruit feather nRF52840. README has also been updated and improved. Documentation related to littlefs has been moved to an independent section as it could apply to any sample. Signed-off-by: Gerard Marull-Paretas --- samples/subsys/usb/mass/README.rst | 46 +++++++++++++++++-- .../boards/adafruit_feather_nrf52840.conf | 23 ++++++++++ .../boards/adafruit_feather_nrf52840.overlay | 20 ++++++++ 3 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 samples/subsys/usb/mass/boards/adafruit_feather_nrf52840.conf create mode 100644 samples/subsys/usb/mass/boards/adafruit_feather_nrf52840.overlay diff --git a/samples/subsys/usb/mass/README.rst b/samples/subsys/usb/mass/README.rst index 6b303d744da..a629a61ed97 100644 --- a/samples/subsys/usb/mass/README.rst +++ b/samples/subsys/usb/mass/README.rst @@ -79,9 +79,7 @@ nrf52840dk_nrf52840 Example This board configures to use the external 64 MiBi QSPI flash chip with a 64 KiBy `littlefs`_ partition compatible with the one produced by the -:ref:`littlefs-sample`. While a FAT-based file system can be mounted by -many systems automatically, mounting the littlefs file system on a Linux -or FreeBSD system can be accomplished using the `littlefs-FUSE`_ utility. +:ref:`littlefs-sample`. .. zephyr-app-commands:: :zephyr-app: samples/subsys/usb/mass @@ -113,7 +111,47 @@ different): F 5 newfile End of files -Determine the local device name from the system log, e.g.: +For information on mounting littlefs file system on Linux or FreeBSD +systems refer to the "littlefs Usage" section below. + +adafruit_feather_nrf52840 Example +================================= + +This board configures to use the external 16 MiBi QSPI flash chip with a +2 MiBy FAT partition. + +.. zephyr-app-commands:: + :zephyr-app: samples/subsys/usb/mass + :board: adafruit_feather_nrf52840 + :goals: build + :compact: + +After you have built and flashed the sample app image to your board, +connect the board's USB connector to a host capable of mounting FAT +drives. The output to the console will look something like this +(file system contents will be different): + +.. code-block:: none + + *** Booting Zephyr OS build zephyr-v2.3.0-1991-g4c8d1496eafb *** + Area 4 at 0x0 on GD25Q16 for 2097152 bytes + Mount /NAND:: 0 + /NAND:: bsize = 512 ; frsize = 1024 ; blocks = 2028 ; bfree = 1901 + /NAND: opendir: 0 + F 0 SAMPLE.TXT + End of files + [00:00:00.077,423] main: The device is put in USB mass storage mode. + +On most operating systems the drive will be automatically mounted. + +littlefs Usage +============== + +While a FAT-based file system can be mounted by many systems automatically, +mounting the littlefs file system on a Linux or FreeBSD system can be +accomplished using the `littlefs-FUSE`_ utility. + +First determine the local device name from the system log, e.g.: .. code-block:: none diff --git a/samples/subsys/usb/mass/boards/adafruit_feather_nrf52840.conf b/samples/subsys/usb/mass/boards/adafruit_feather_nrf52840.conf new file mode 100644 index 00000000000..706b7b8fac4 --- /dev/null +++ b/samples/subsys/usb/mass/boards/adafruit_feather_nrf52840.conf @@ -0,0 +1,23 @@ +# qspi NOR driver +CONFIG_NORDIC_QSPI_NOR=y +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 + +# flash +CONFIG_FLASH_MAP=y +CONFIG_FLASH_PAGE_LAYOUT=y + +# mass storage +CONFIG_MASS_STORAGE_DISK_NAME="NAND" + +# disk +CONFIG_DISK_ACCESS_FLASH=y +CONFIG_DISK_FLASH_DEV_NAME="GD25Q16" +CONFIG_DISK_FLASH_START=0x0 +CONFIG_DISK_VOLUME_SIZE=0x200000 +CONFIG_DISK_FLASH_MAX_RW_SIZE=4096 +CONFIG_DISK_FLASH_ERASE_ALIGNMENT=0x1000 +CONFIG_DISK_ERASE_BLOCK_SIZE=0x1000 + +# file system +CONFIG_FILE_SYSTEM=y +CONFIG_FAT_FILESYSTEM_ELM=y diff --git a/samples/subsys/usb/mass/boards/adafruit_feather_nrf52840.overlay b/samples/subsys/usb/mass/boards/adafruit_feather_nrf52840.overlay new file mode 100644 index 00000000000..c1ac6529124 --- /dev/null +++ b/samples/subsys/usb/mass/boards/adafruit_feather_nrf52840.overlay @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2020 Teslabs Engineering S.L. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/delete-node/ &storage_partition; + +&gd25q16 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "storage"; + reg = <0x00000000 0x00200000>; + }; + }; +};