Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2fe9c0a
Add bdev commands
will-v-pi Nov 12, 2024
c492cbc
Only include bdev if has_libusb
will-v-pi Nov 27, 2024
a5d1f15
Fix bazel build
will-v-pi Nov 27, 2024
cd8ede0
Merge put and get into cp, add rm, and make ls non-recursive with abi…
will-v-pi Dec 6, 2024
d99e21e
Add cat command, use partitions option, and format option
will-v-pi Dec 6, 2024
68f73ff
Respect write and format flags on block device
will-v-pi Dec 13, 2024
d560d39
Add initial FatFS support
will-v-pi Dec 18, 2024
636aedb
Fix Bazel build
will-v-pi Dec 18, 2024
09eb8a3
Add filesystem auto-detection
will-v-pi Dec 18, 2024
4546450
Add FatFS support to all bdev commands
will-v-pi Dec 18, 2024
08d4d0d
Fix support for CircuitPython block device (Fat) and add full Flash T…
will-v-pi Dec 19, 2024
c49b5d1
Fix segfault in release builds, and add output to all commands
will-v-pi Aug 19, 2025
efc5beb
Add commands to readme
will-v-pi Aug 19, 2025
e8c039b
Add support for using partition with ID "blockdev"
will-v-pi Aug 19, 2025
50ba717
Review fixups
will-v-pi Aug 29, 2025
c7b9f6f
Update readme
will-v-pi Aug 29, 2025
184b218
Fix mkdir dirname desc
will-v-pi Aug 29, 2025
c927911
Add error strings
will-v-pi Aug 29, 2025
b99621a
Update LittleFS to v2.11.1
will-v-pi Aug 29, 2025
aab5675
fixups
will-v-pi Sep 1, 2025
1a46bf0
Merge remote-tracking branch 'origin/develop' into block-device-support
will-v-pi Jun 16, 2026
64a855d
Fixups from develop merge
will-v-pi Jun 16, 2026
fb4b6ba
Fix bazel build
will-v-pi Jun 16, 2026
3700fef
Hopefully fix Windows build
will-v-pi Jun 16, 2026
d4c4622
BLOCK_DEVICE_PARTITION_ID moved into SDK, so just kept here for SDK 2…
will-v-pi Jun 17, 2026
89454ce
Allow picking partition by name or ID
will-v-pi Jun 17, 2026
8175ff9
review fixup
will-v-pi Jun 17, 2026
49b5b31
Update readme
will-v-pi Jun 17, 2026
55f849c
Allow overwriting format and write flags
will-v-pi Jun 18, 2026
7370c39
BLOCK_DEVICE_PARTITION_ID -> BLOCK_DEVICE_DEFAULT_PARTITION_ID
will-v-pi Jun 18, 2026
36e4b37
Add format command
will-v-pi Jun 18, 2026
1145db7
Fix optional_untyped_path_selection_x and optional_untyped_file_selec…
will-v-pi Jun 18, 2026
190cc25
Allow passing : filenames to other bdev commands
will-v-pi Jun 22, 2026
b9dd108
Merge remote-tracking branch 'origin/develop' into block-device-support
will-v-pi Jun 23, 2026
ee55da8
Suppress compile warning from oofatfs
will-v-pi Jun 23, 2026
7227746
Only suppress warnings when not on Windows
will-v-pi Jun 23, 2026
1aac8a0
Fix corrupt fatfs error message
will-v-pi Jun 23, 2026
f567307
Add bdev_test.sh script
will-v-pi Jun 23, 2026
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
2 changes: 2 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ cc_binary(
"//errors",
"//lib/nlohmann_json:json",
"//picoboot_connection",
"//lib/littlefs",
"//lib/oofatfs:fatfs",
"@libusb",
"@pico-sdk//src/common/boot_picobin_headers",
"@pico-sdk//src/common/boot_picoboot_headers",
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)

add_subdirectory(lib)
suppress_oofatfs_warnings()

if (NOT DEFINED USE_PRECOMPILED)
set(USE_PRECOMPILED true)
Expand Down Expand Up @@ -340,6 +341,8 @@ else()
target_compile_definitions(picotool PRIVATE HAS_LIBUSB=1)
target_link_libraries(picotool
picoboot_connection_cxx
fatfs
littlefs
${LIBUSB_LIBRARIES})
endif()

Expand Down
450 changes: 444 additions & 6 deletions README.md

Large diffs are not rendered by default.

79 changes: 79 additions & 0 deletions bdev_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

set -e

cat >tmppt.json << EOL
{
"version": [1, 0],
"unpartitioned": {
"families": ["absolute"],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
}
},
"partitions": [
{
"name": "Filesystem",
"id": "0x626C6F636B646576",
"size": "100K",
"families": [],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
}
}
]
}
EOL

picotool erase || true
picotool reboot
while ! picotool info; do sleep 1; done

picotool partition create tmppt.json tmppt.bin
picotool load -x tmppt.bin
while ! picotool info; do sleep 1; done

declare -a filesystems=("littlefs" "fatfs")
for filesystem in "${filesystems[@]}"
do
picotool bdev format --filesystem $filesystem

echo "this is file 1" > tmpfile1.txt
echo "this is file 2" > tmpfile2.txt
picotool bdev cp tmpfile1.txt :/
picotool bdev cp tmpfile2.txt :/
picotool bdev ls | grep "tmpfile2.txt"
picotool bdev rm tmpfile2.txt
if picotool bdev ls | grep "tmpfile2.txt"; then
echo "Error: tmpfile2.txt was not deleted"
exit 1
fi
picotool bdev cat tmpfile1.txt
picotool bdev cat tmpfile1.txt > tmpfile1.txt.device

if ! cmp -s tmpfile1.txt tmpfile1.txt.device; then
echo "Error: tmpfile1.txt content has changed"
exit 1
fi

echo "this is new file 2" > tmpfile2.txt
picotool bdev cp tmpfile2.txt :/
picotool bdev cat tmpfile2.txt
picotool bdev cat tmpfile2.txt > tmpfile2.txt.device

if ! cmp -s tmpfile2.txt tmpfile2.txt.device; then
echo "Error: tmpfile2.txt content has changed"
exit 1
fi
done

rm tmpfile1.txt
rm tmpfile1.txt.device
rm tmpfile2.txt
rm tmpfile2.txt.device
rm tmppt.json
rm tmppt.bin
3 changes: 3 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ endif()
set(JSON_BuildTests OFF CACHE INTERNAL "")
add_subdirectory(nlohmann_json EXCLUDE_FROM_ALL)

add_subdirectory(oofatfs EXCLUDE_FROM_ALL)
add_subdirectory(littlefs EXCLUDE_FROM_ALL)

add_subdirectory(whereami EXCLUDE_FROM_ALL)

# Taken from pico-sdk/src/rp2_common/pico_mbedtls/CMakeLists.txt
Expand Down
16 changes: 16 additions & 0 deletions lib/littlefs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")

package(default_visibility = ["//visibility:public"])

cc_library(
name = "littlefs",
srcs = [
"lfs.c",
"lfs_util.c",
],
hdrs = [
"lfs.h",
"lfs_util.h",
],
includes = ["."],
)
9 changes: 9 additions & 0 deletions lib/littlefs/CMakeLists.txt
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 LFS_NO_WARN=1 LFS_NO_DEBUG=1)
25 changes: 25 additions & 0 deletions lib/littlefs/LICENSE.md
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.
7 changes: 7 additions & 0 deletions lib/littlefs/README.md
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
Loading
Loading