Skip to content

Commit d362a6a

Browse files
authored
Merge pull request #104 from rust-embedded-community/release/v0.6.0
Release/v0.6.0
2 parents e08947f + 2d2c889 commit d362a6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3350
-1815
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,5 @@ jobs:
1919
- uses: actions/checkout@v1
2020
- name: Build
2121
run: cargo build --no-default-features --features ${{matrix.features}} --verbose
22-
- name: Unpack Disk
23-
run: gunzip -fk disk.img.gz
24-
- name: Run Test Mount example
25-
run: cargo run --no-default-features --features ${{matrix.features}} --example test_mount ./disk.img
26-
- name: Unpack Disk
27-
run: gunzip -fk disk.img.gz
28-
- name: Run Create Test example
29-
run: cargo run --no-default-features --features ${{matrix.features}} --example create_test ./disk.img
30-
- name: Unpack Disk
31-
run: gunzip -fk disk.img.gz
32-
- name: Run Write Test example
33-
run: cargo run --no-default-features --features ${{matrix.features}} --example write_test ./disk.img
34-
- name: Run Unit Tests
22+
- name: Run Tests
3523
run: cargo test --no-default-features --features ${{matrix.features}} --verbose
36-

CHANGELOG.md

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,45 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
5+
The format is based on [Keep a Changelog] and this project adheres to [Semantic Versioning].
76

8-
## [Unreleased](https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.5.0...develop)
7+
## [Unreleased]
8+
9+
* None
10+
11+
## [Version 0.6.0] - 2023-10-20
912

1013
### Changed
1114

12-
- None
15+
- Writing to a file no longer flushes file metadata to the Directory Entry.
16+
Instead closing a file now flushes file metadata to the Directory Entry.
17+
Requires mutable access to the Volume ([#94]).
18+
- Files now have the correct length when modified, not appended ([#72]).
19+
- Calling `SdCard::get_card_type` will now perform card initialisation ([#87] and [#90]).
20+
- Removed warning about unused arguments.
21+
- Types are now documented at the top level ([#86]).
22+
- Renamed `Cluster` to `ClusterId` and stopped you adding two together
23+
24+
[#72]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/issues/72
25+
[#86]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/issues/86
26+
[#87]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/issues/87
27+
[#90]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/issues/90
28+
[#94]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/issues/94
1329

1430
### Added
1531

16-
- None
32+
- New examples, `append_file`, `create_file`, `delete_file`, `list_dir`, `shell`
33+
- New test cases `tests/directories.rs`, `tests/read_file.rs`
1734

1835
### Removed
1936

20-
- None
37+
- __Breaking Change__: `Controller` alias for `VolumeManager` removed.
38+
- __Breaking Change__: `VolumeManager::open_dir_entry` removed, as it was unsafe to the user to randomly pick a starting cluster.
39+
- Old examples `create_test`, `test_mount`, `write_test`, `delete_test`
2140

22-
## [Version 0.5.0](https://github.com/rust-embedded-community/embedded-sdmmc-rs/releases/tag/v0.5.0) - 2023-05-20
41+
## [Version 0.5.0] - 2023-05-20
2342

24-
### Changes
43+
### Changed
2544

2645
- __Breaking Change__: Renamed `Controller` to `VolumeManager`, to better describe what it does.
2746
- __Breaking Change__: Renamed `SdMmcSpi` to `SdCard`
@@ -39,13 +58,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3958

4059
- __Breaking Change__: Removed `BlockSpi` type - card initialisation now handled as an internal state variable
4160

42-
## [Version 0.4.0](https://github.com/rust-embedded-community/embedded-sdmmc-rs/releases/tag/v0.4.0) - 2023-01-18
61+
## [Version 0.4.0] - 2023-01-18
62+
63+
### Changed
4364

44-
### Changes
45-
- Optionally use [defmt](https://github.com/knurling-rs/defmt) for logging.
65+
- Optionally use [defmt] s/defmt) for logging.
4666
Controlled by `defmt-log` feature flag.
4767
- __Breaking Change__: Use SPI blocking traits instead to ease SPI peripheral sharing.
48-
See: https://github.com/rust-embedded-community/embedded-sdmmc-rs/issues/28
68+
See: <https://github.com/rust-embedded-community/embedded-sdmmc-rs/issues/28>
4969
- Added `Controller::has_open_handles` and `Controller::free` methods.
5070
- __Breaking Change__: Changed interface to enforce correct SD state at compile time.
5171
- __Breaking Change__: Added custom error type for `File` operations.
@@ -56,35 +76,46 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5676
- Add new constructor method `Controller::new_with_limits(block_device: D, timesource: T) -> Controller<D, T, MAX_DIRS, MAX_FILES>`
5777
to create a `Controller` with custom limits.
5878

59-
## [Version 0.3.0](https://github.com/rust-embedded-community/embedded-sdmmc-rs/releases/tag/v0.3.0) - 2019-12-16
79+
## [Version 0.3.0] - 2019-12-16
6080

61-
### Changes
81+
### Changed
6282

63-
* Updated to `v2` embedded-hal traits.
64-
* Added open support for all modes.
65-
* Added write support for files.
66-
* Added `Info_Sector` tracking for FAT32.
67-
* Change directory iteration to look in all the directory's clusters.
68-
* Added `write_test` and `create_test`.
69-
* De-duplicated FAT16 and FAT32 code (https://github.com/thejpster/embedded-sdmmc-rs/issues/10)
83+
- Updated to `v2` embedded-hal traits.
84+
- Added open support for all modes.
85+
- Added write support for files.
86+
- Added `Info_Sector` tracking for FAT32.
87+
- Change directory iteration to look in all the directory's clusters.
88+
- Added `write_test` and `create_test`.
89+
- De-duplicated FAT16 and FAT32 code (<https://github.com/thejpster/embedded-sdmmc-rs/issues/10>)
7090

71-
## [Version 0.2.1](https://github.com/rust-embedded-community/embedded-sdmmc-rs/releases/tag/v0.2.1) - 2019-02-19
91+
## [Version 0.2.1] - 2019-02-19
7292

73-
### Changes
93+
### Changed
7494

75-
* Added `readme=README.md` to `Cargo.toml`
95+
- Added `readme=README.md` to `Cargo.toml`
7696

77-
## [Version 0.2.0](https://github.com/rust-embedded-community/embedded-sdmmc-rs/releases/tag/v0.2.0) - 2019-01-24
97+
## [Version 0.2.0] - 2019-01-24
7898

79-
### Changes
99+
### Changed
80100

81-
* Reduce delay waiting for response. Big speed improvements.
101+
- Reduce delay waiting for response. Big speed improvements.
82102

83-
## [Version 0.1.0](https://github.com/rust-embedded-community/embedded-sdmmc-rs/releases/tag/v0.1.1) - 2018-12-23
103+
## [Version 0.1.0] - 2018-12-23
84104

85-
### Changes
105+
### Changed
86106

87-
* Can read blocks from an SD Card using an `embedded_hal::SPI` device and a
107+
- Can read blocks from an SD Card using an `embedded_hal::SPI` device and a
88108
`embedded_hal::OutputPin` for Chip Select.
89-
* Can read partition tables and open a FAT32 or FAT16 formatted partition.
90-
* Can open and iterate the root directory of a FAT16 formatted partition.
109+
- Can read partition tables and open a FAT32 or FAT16 formatted partition.
110+
- Can open and iterate the root directory of a FAT16 formatted partition.
111+
112+
[Keep a Changelog]: http://keepachangelog.com/en/1.0.0/
113+
[Semantic Versioning]: http://semver.org/spec/v2.0.0.html
114+
[Unreleased]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.6.0...develop
115+
[Version 0.6.0]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.6.0...v0.5.0
116+
[Version 0.5.0]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.5.0...v0.4.0
117+
[Version 0.4.0]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.4.0...v0.3.0
118+
[Version 0.3.0]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.3.0...v0.2.1
119+
[Version 0.2.1]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.2.1...v0.2.0
120+
[Version 0.2.0]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/compare/v0.2.0...v0.1.1
121+
[Version 0.1.1]: https://github.com/rust-embedded-community/embedded-sdmmc-rs/releases/tag/v0.1.1

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@ license = "MIT OR Apache-2.0"
88
name = "embedded-sdmmc"
99
readme = "README.md"
1010
repository = "https://github.com/rust-embedded-community/embedded-sdmmc-rs"
11-
version = "0.5.0"
11+
version = "0.6.0"
1212

1313
[dependencies]
1414
byteorder = {version = "1", default-features = false}
1515
defmt = {version = "0.3", optional = true}
1616
embedded-hal = "0.2.3"
17+
heapless = "0.7"
1718
log = {version = "0.4", default-features = false, optional = true}
1819

1920
[dev-dependencies]
2021
env_logger = "0.9"
2122
hex-literal = "0.3"
23+
flate2 = "1.0"
24+
sha256 = "1.4"
25+
chrono = "0.4"
2226

2327
[features]
2428
default = ["log"]

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,35 @@ let mut volume_mgr = embedded_sdmmc::VolumeManager::new(sdcard, time_source);
2323
// It doesn't hold a reference to the Volume Manager and so must be passed back
2424
// to every Volume Manager API call. This makes it easier to handle multiple
2525
// volumes in parallel.
26-
let mut volume0 = volume_mgr.get_volume(embedded_sdmmc::VolumeIdx(0))?;
26+
let volume0 = volume_mgr.get_volume(embedded_sdmmc::VolumeIdx(0))?;
2727
println!("Volume 0: {:?}", volume0);
2828
// Open the root directory (passing in the volume we're using).
2929
let root_dir = volume_mgr.open_root_dir(&volume0)?;
3030
// Open a file called "MY_FILE.TXT" in the root directory
31-
let mut my_file = volume_mgr.open_file_in_dir(
32-
&mut volume0,
33-
&root_dir,
31+
let my_file = volume_mgr.open_file_in_dir(
32+
root_dir,
3433
"MY_FILE.TXT",
3534
embedded_sdmmc::Mode::ReadOnly,
3635
)?;
3736
// Print the contents of the file
38-
while !my_file.eof() {
37+
while !volume_manager.file_eof(my_file).unwrap() {
3938
let mut buffer = [0u8; 32];
4039
let num_read = volume_mgr.read(&volume0, &mut my_file, &mut buffer)?;
4140
for b in &buffer[0..num_read] {
4241
print!("{}", *b as char);
4342
}
4443
}
45-
volume_mgr.close_file(&volume0, my_file)?;
46-
volume_mgr.close_dir(&volume0, root_dir);
44+
volume_mgr.close_file(my_file)?;
45+
volume_mgr.close_dir(root_dir)?;
4746
```
4847

4948
### Open directories and files
5049

51-
By default the `VolumeManager` will initialize with a maximum number of `4` open directories and files. This can be customized by specifying the `MAX_DIR` and `MAX_FILES` generic consts of the `VolumeManager`:
50+
By default the `VolumeManager` will initialize with a maximum number of `4` open directories, files and volumes. This can be customized by specifying the `MAX_DIR`, `MAX_FILES` and `MAX_VOLUMES` generic consts of the `VolumeManager`:
5251

5352
```rust
54-
// Create a volume manager with a maximum of 6 open directories and 12 open files
55-
let mut cont: VolumeManager<_, _, 6, 12> = VolumeManager::new_with_limits(block, time_source);
53+
// Create a volume manager with a maximum of 6 open directories, 12 open files, and 4 volumes (or partitions)
54+
let mut cont: VolumeManager<_, _, 6, 12, 4> = VolumeManager::new_with_limits(block, time_source);
5655
```
5756

5857
## Supported features

examples/append_file.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//! Append File Example.
2+
//!
3+
//! ```bash
4+
//! $ cargo run --example append_file -- ./disk.img
5+
//! $ cargo run --example append_file -- /dev/mmcblk0
6+
//! ```
7+
//!
8+
//! If you pass a block device it should be unmounted. No testing has been
9+
//! performed with Windows raw block devices - please report back if you try
10+
//! this! There is a gzipped example disk image which you can gunzip and test
11+
//! with if you don't have a suitable block device.
12+
//!
13+
//! ```bash
14+
//! zcat ./tests/disk.img.gz > ./disk.img
15+
//! $ cargo run --example append_file -- ./disk.img
16+
//! ```
17+
18+
extern crate embedded_sdmmc;
19+
20+
mod linux;
21+
use linux::*;
22+
23+
const FILE_TO_APPEND: &str = "README.TXT";
24+
25+
use embedded_sdmmc::{Error, Mode, VolumeIdx, VolumeManager};
26+
27+
fn main() -> Result<(), embedded_sdmmc::Error<std::io::Error>> {
28+
env_logger::init();
29+
let mut args = std::env::args().skip(1);
30+
let filename = args.next().unwrap_or_else(|| "/dev/mmcblk0".into());
31+
let print_blocks = args.find(|x| x == "-v").map(|_| true).unwrap_or(false);
32+
let lbd = LinuxBlockDevice::new(filename, print_blocks).map_err(Error::DeviceError)?;
33+
let mut volume_mgr: VolumeManager<LinuxBlockDevice, Clock, 8, 8, 4> =
34+
VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000);
35+
let volume = volume_mgr.open_volume(VolumeIdx(0))?;
36+
let root_dir = volume_mgr.open_root_dir(volume)?;
37+
println!("\nCreating file {}...", FILE_TO_APPEND);
38+
let f = volume_mgr.open_file_in_dir(root_dir, FILE_TO_APPEND, Mode::ReadWriteAppend)?;
39+
volume_mgr.write(f, b"\r\n\r\nThis has been added to your file.\r\n")?;
40+
volume_mgr.close_file(f)?;
41+
volume_mgr.close_dir(root_dir)?;
42+
Ok(())
43+
}
44+
45+
// ****************************************************************************
46+
//
47+
// End Of File
48+
//
49+
// ****************************************************************************

examples/create_file.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//! Create File Example.
2+
//!
3+
//! ```bash
4+
//! $ cargo run --example create_file -- ./disk.img
5+
//! $ cargo run --example create_file -- /dev/mmcblk0
6+
//! ```
7+
//!
8+
//! If you pass a block device it should be unmounted. No testing has been
9+
//! performed with Windows raw block devices - please report back if you try
10+
//! this! There is a gzipped example disk image which you can gunzip and test
11+
//! with if you don't have a suitable block device.
12+
//!
13+
//! ```bash
14+
//! zcat ./tests/disk.img.gz > ./disk.img
15+
//! $ cargo run --example create_file -- ./disk.img
16+
//! ```
17+
18+
extern crate embedded_sdmmc;
19+
20+
mod linux;
21+
use linux::*;
22+
23+
const FILE_TO_CREATE: &str = "CREATE.TXT";
24+
25+
use embedded_sdmmc::{Error, Mode, VolumeIdx, VolumeManager};
26+
27+
fn main() -> Result<(), embedded_sdmmc::Error<std::io::Error>> {
28+
env_logger::init();
29+
let mut args = std::env::args().skip(1);
30+
let filename = args.next().unwrap_or_else(|| "/dev/mmcblk0".into());
31+
let print_blocks = args.find(|x| x == "-v").map(|_| true).unwrap_or(false);
32+
let lbd = LinuxBlockDevice::new(filename, print_blocks).map_err(Error::DeviceError)?;
33+
let mut volume_mgr: VolumeManager<LinuxBlockDevice, Clock, 8, 8, 4> =
34+
VolumeManager::new_with_limits(lbd, Clock, 0xAA00_0000);
35+
let volume = volume_mgr.open_volume(VolumeIdx(0))?;
36+
let root_dir = volume_mgr.open_root_dir(volume)?;
37+
println!("\nCreating file {}...", FILE_TO_CREATE);
38+
// This will panic if the file already exists: use ReadWriteCreateOrAppend
39+
// or ReadWriteCreateOrTruncate instead if you want to modify an existing
40+
// file.
41+
let f = volume_mgr.open_file_in_dir(root_dir, FILE_TO_CREATE, Mode::ReadWriteCreate)?;
42+
volume_mgr.write(f, b"Hello, this is a new file on disk\r\n")?;
43+
volume_mgr.close_file(f)?;
44+
volume_mgr.close_dir(root_dir)?;
45+
Ok(())
46+
}
47+
48+
// ****************************************************************************
49+
//
50+
// End Of File
51+
//
52+
// ****************************************************************************

0 commit comments

Comments
 (0)