Skip to content

Commit

Permalink
Add bdev commands
Browse files Browse the repository at this point in the history
Add ls, mkdir, put and get commands to access block devices

Currently only supports littlefs
  • Loading branch information
will-v-pi committed Nov 27, 2024
1 parent 57ca5fa commit 626beaa
Show file tree
Hide file tree
Showing 10 changed files with 7,799 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ target_link_libraries(picotool
elf2uf2
errors
nlohmann_json
littlefs
whereami)

if (NOT TARGET mbedtls)
Expand Down
2 changes: 2 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ endif()
set(JSON_BuildTests OFF CACHE INTERNAL "")
add_subdirectory(nlohmann_json EXCLUDE_FROM_ALL)

add_subdirectory(littlefs EXCLUDE_FROM_ALL)

add_subdirectory(whereami EXCLUDE_FROM_ALL)

if(EXISTS "${PICO_SDK_PATH}/lib/mbedtls/CMakeLists.txt")
Expand Down
7 changes: 7 additions & 0 deletions lib/littlefs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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})
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.8.2
Loading

5 comments on commit 626beaa

@lurch
Copy link
Contributor

@lurch lurch commented on 626beaa Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it might be better to use a git submodule for lib/littlefs, rather than copying all the littlefs source files into the picotool repo?

@lurch
Copy link
Contributor

@lurch lurch commented on 626beaa Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recursive ls by default, rather than non-recursive-by-default with a flag to turn on recursion feels a bit weird?

Does this support the "permissions" stuff in the partition_map, i.e. if the partition doesn't have "write" permissions, will the put and rm commands be prevented?

Could there theoretically be multiple partitions in the flash, each containing a separate filesystem?

@will-v-pi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it might be better to use a git submodule for lib/littlefs, rather than copying all the littlefs source files into the picotool repo?

I think we'd prefer not to have any submodules unless they become necessary, to prevent the differences between cloning recursively or not - similar to the JSON library picotool uses. This also makes it easier to add Bazel build configurations to librarys

@lurch
Copy link
Contributor

@lurch lurch commented on 626beaa Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough! I think the reason that I prefer submodules (even though they can be fiddly to work with) is that there's less "churn" when you need to bump versions. But there's so few files in littlefs that that's not really an issue here!

@will-v-pi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recursive ls by default, rather than non-recursive-by-default with a flag to turn on recursion feels a bit weird?

Have changed this with 988bd16, so there's now a -r flag

Does this support the "permissions" stuff in the partition_map, i.e. if the partition doesn't have "write" permissions, will the put and rm commands be prevented?

Added with 0e2ec19, to support embedded block device and partition permissions

Could there theoretically be multiple partitions in the flash, each containing a separate filesystem?

Yes - I've added support for specifying the partition to use

Please sign in to comment.