-
Notifications
You must be signed in to change notification settings - Fork 150
Add Block Device Support #191
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
base: develop
Are you sure you want to change the base?
Changes from 19 commits
2fe9c0a
c492cbc
a5d1f15
cd8ede0
d99e21e
68f73ff
d560d39
636aedb
09eb8a3
4546450
08d4d0d
c49b5d1
efc5beb
e8c039b
50ba717
c7b9f6f
184b218
c927911
b99621a
aab5675
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ PICOTOOL: | |
SYNOPSIS: | ||
picotool info [-b] [-m] [-p] [-d] [--debug] [-l] [-a] [device-selection] | ||
picotool info [-b] [-m] [-p] [-d] [--debug] [-l] [-a] <filename> [-t <type>] | ||
picotool bdev ls|mkdir|cp|rm|cat | ||
picotool config [-s <key> <value>] [-g <group>] [device-selection] | ||
picotool config [-s <key> <value>] [-g <group>] <filename> [-t <type>] | ||
picotool load [--ignore-partitions] [--family <family_id>] [-p <partition>] [-n] [-N] [-u] [-v] [-x] <filename> [-t <type>] [-o | ||
|
@@ -39,6 +40,7 @@ SYNOPSIS: | |
COMMANDS: | ||
info Display information from the target device(s) or file. | ||
Without any arguments, this will display basic information for all connected RP-series devices in BOOTSEL mode | ||
bdev Commands related to embedded block devices | ||
config Display or change program configuration settings from the target device(s) or file. | ||
load Load the program / memory range stored in a file onto the device. | ||
encrypt Encrypt the program. | ||
|
@@ -1392,6 +1394,266 @@ OPTIONS: | |
The file name | ||
``` | ||
|
||
## bdev | ||
|
||
The `bdev` commands are for interacting with block devices in Flash. These can either be defined using binary info, or you can specify a partition to use as a block device. They work with a LittleFS filesystem, or a FatFS filesystem. | ||
|
||
```text | ||
$ picotool help bdev | ||
BDEV: | ||
Commands related to embedded block devices | ||
|
||
SYNOPSIS: | ||
picotool bdev ls <dirname> [-r] [-p <partition>] [--filesystem <fs>] [--format] [device-selection] | ||
picotool bdev mkdir <dirname> [-p <partition>] [--filesystem <fs>] [--format] [device-selection] | ||
picotool bdev cp <src> <dest> [-p <partition>] [--filesystem <fs>] [--format] [device-selection] | ||
picotool bdev rm <filename> [-p <partition>] [--filesystem <fs>] [--format] [device-selection] | ||
picotool bdev cat <filename> [-p <partition>] [--filesystem <fs>] [--format] [device-selection] | ||
|
||
SUB COMMANDS: | ||
ls List contents of the block device | ||
mkdir Create directory on the block device | ||
cp Copy file to/from the block device - use :filename to indicate files on the device (eg `cp main.py :main.py` to upload to the | ||
device) | ||
rm Delete a file or an empty directory on the block device | ||
cat Print contents of file on the block device | ||
``` | ||
|
||
### ls | ||
|
||
List contents of the block device | ||
|
||
```text | ||
$ picotool help bdev ls | ||
BDEV LS: | ||
List contents of the block device | ||
|
||
SYNOPSIS: | ||
picotool bdev ls <dirname> [-r] [-p <partition>] [--filesystem <fs>] [--format] [device-selection] | ||
|
||
OPTIONS: | ||
<dirname> | ||
The directory name to list (optional) | ||
-r, --recursive | ||
List files in directories recursively | ||
Block device options | ||
-p, --partition | ||
Partition to use as block device | ||
<partition> | ||
partition number | ||
--filesystem | ||
Specify filesystem to use | ||
<fs> | ||
littlefs|fatfs | ||
--format | ||
Format the drive if necessary (may result in data loss) | ||
Comment on lines
+1448
to
+1449
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added it as a flag because of where the formatting occurs in the code - it will only format the drive if no filesystem (of the type specified by
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh! I see now that I'd misread "Format the drive if necessary" as just "Format the drive" 🤦 So I guess that means if you had a blockdevice that was already fatfs-formatted, and you wanted to explicitly reformat it, you'd need to do something like:
? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, so it probably is worth adding a separate |
||
Target device selection | ||
--bus <bus> | ||
Filter devices by USB bus number | ||
--address <addr> | ||
Filter devices by USB device address | ||
--vid <vid> | ||
Filter by vendor id | ||
--pid <pid> | ||
Filter by product id | ||
--ser <ser> | ||
Filter by serial number | ||
-f, --force | ||
Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the | ||
command (unless the command itself is a 'reboot') the device will be rebooted back to application mode | ||
-F, --force-no-reboot | ||
Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the | ||
command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the | ||
USB drive mounted | ||
``` | ||
|
||
### mkdir | ||
|
||
Create directory on the block device | ||
|
||
```text | ||
$ picotool help bdev mkdir | ||
BDEV MKDIR: | ||
Create directory on the block device | ||
|
||
SYNOPSIS: | ||
picotool bdev mkdir <dirname> [-p <partition>] [--filesystem <fs>] [--format] [device-selection] | ||
|
||
OPTIONS: | ||
<dirname> | ||
The directory name | ||
Block device options | ||
-p, --partition | ||
Partition to use as block device | ||
<partition> | ||
partition number | ||
--filesystem | ||
Specify filesystem to use | ||
<fs> | ||
littlefs|fatfs | ||
--format | ||
Format the drive if necessary (may result in data loss) | ||
Target device selection | ||
--bus <bus> | ||
Filter devices by USB bus number | ||
--address <addr> | ||
Filter devices by USB device address | ||
--vid <vid> | ||
Filter by vendor id | ||
--pid <pid> | ||
Filter by product id | ||
--ser <ser> | ||
Filter by serial number | ||
-f, --force | ||
Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the | ||
command (unless the command itself is a 'reboot') the device will be rebooted back to application mode | ||
-F, --force-no-reboot | ||
Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the | ||
command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the | ||
USB drive mounted | ||
``` | ||
|
||
### cp | ||
|
||
Copy file to/from the block device - use :filename to indicate files on the device (e.g. `cp main.py :main.py` to upload to the device, or `cp :main.py main.py` to download from the device) | ||
|
||
|
||
```text | ||
$ picotool help bdev cp | ||
BDEV CP: | ||
Copy file to/from the block device - use :filename to indicate files on the device (eg `cp main.py :main.py` to upload to the device) | ||
|
||
SYNOPSIS: | ||
picotool bdev cp <src> <dest> [-p <partition>] [--filesystem <fs>] [--format] [device-selection] | ||
|
||
OPTIONS: | ||
<src> | ||
The file name | ||
<dest> | ||
The file name | ||
Block device options | ||
-p, --partition | ||
Partition to use as block device | ||
<partition> | ||
partition number | ||
--filesystem | ||
Specify filesystem to use | ||
<fs> | ||
littlefs|fatfs | ||
--format | ||
Format the drive if necessary (may result in data loss) | ||
Target device selection | ||
--bus <bus> | ||
Filter devices by USB bus number | ||
--address <addr> | ||
Filter devices by USB device address | ||
--vid <vid> | ||
Filter by vendor id | ||
--pid <pid> | ||
Filter by product id | ||
--ser <ser> | ||
Filter by serial number | ||
-f, --force | ||
Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the | ||
command (unless the command itself is a 'reboot') the device will be rebooted back to application mode | ||
-F, --force-no-reboot | ||
Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the | ||
command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the | ||
USB drive mounted | ||
``` | ||
|
||
### rm | ||
|
||
Delete a file or an empty directory on the block device | ||
|
||
```text | ||
$ picotool help bdev rm | ||
BDEV RM: | ||
Delete a file or an empty directory on the block device | ||
|
||
SYNOPSIS: | ||
picotool bdev rm <filename> [-p <partition>] [--filesystem <fs>] [--format] [device-selection] | ||
|
||
OPTIONS: | ||
<filename> | ||
The file name | ||
Block device options | ||
-p, --partition | ||
Partition to use as block device | ||
<partition> | ||
partition number | ||
--filesystem | ||
Specify filesystem to use | ||
<fs> | ||
littlefs|fatfs | ||
--format | ||
Format the drive if necessary (may result in data loss) | ||
Target device selection | ||
--bus <bus> | ||
Filter devices by USB bus number | ||
--address <addr> | ||
Filter devices by USB device address | ||
--vid <vid> | ||
Filter by vendor id | ||
--pid <pid> | ||
Filter by product id | ||
--ser <ser> | ||
Filter by serial number | ||
-f, --force | ||
Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the | ||
command (unless the command itself is a 'reboot') the device will be rebooted back to application mode | ||
-F, --force-no-reboot | ||
Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the | ||
command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the | ||
USB drive mounted | ||
``` | ||
|
||
### cat | ||
|
||
Print contents of file on the block device | ||
lurch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```text | ||
$ picotool help bdev cat | ||
BDEV CAT: | ||
Print contents of file on the block device | ||
lurch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
SYNOPSIS: | ||
picotool bdev cat <filename> [-p <partition>] [--filesystem <fs>] [--format] [device-selection] | ||
|
||
OPTIONS: | ||
<filename> | ||
The file name | ||
Block device options | ||
-p, --partition | ||
Partition to use as block device | ||
<partition> | ||
partition number | ||
--filesystem | ||
Specify filesystem to use | ||
<fs> | ||
littlefs|fatfs | ||
--format | ||
Format the drive if necessary (may result in data loss) | ||
Target device selection | ||
--bus <bus> | ||
Filter devices by USB bus number | ||
--address <addr> | ||
Filter devices by USB device address | ||
--vid <vid> | ||
Filter by vendor id | ||
--pid <pid> | ||
Filter by product id | ||
--ser <ser> | ||
Filter by serial number | ||
-f, --force | ||
Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the | ||
command (unless the command itself is a 'reboot') the device will be rebooted back to application mode | ||
-F, --force-no-reboot | ||
Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the | ||
command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the | ||
USB drive mounted | ||
``` | ||
|
||
## Binary Information | ||
|
||
Binary information is machine locatable and generally machine consumable. I say generally because anyone can | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
cc_library( | ||
name = "littlefs", | ||
srcs = [ | ||
"lfs.c", | ||
"lfs_util.c", | ||
], | ||
hdrs = [ | ||
"lfs.h", | ||
"lfs_util.h", | ||
], | ||
includes = ["."], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
add_library(littlefs INTERFACE) | ||
|
||
target_sources(littlefs INTERFACE | ||
${CMAKE_CURRENT_LIST_DIR}/lfs.c | ||
${CMAKE_CURRENT_LIST_DIR}/lfs_util.c) | ||
|
||
target_include_directories(littlefs INTERFACE ${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
target_compile_definitions(littlefs INTERFACE LFS_NO_ERROR=1) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Copyright (c) 2022, The littlefs authors. | ||
Copyright (c) 2017, Arm Limited. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
- Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
- 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. | ||
- Neither the name of ARM 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 HOLDER 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
littlefs library | ||
================ | ||
|
||
The upstream source for the files in this directory is | ||
https://github.com/littlefs-project/littlefs | ||
|
||
The current files come from v2.11.1 |
Uh oh!
There was an error while loading. Please reload this page.