Skip to content
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

Add serde derives to flash params #528

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add --confirm-port argument to flash command (#455)
- Add --chip argument for flash and write-bin commands (#514)
- Add --partition-table-offset argument for specifying the partition table offset (#516)
- Add `Serialize` and `Deserialize` to `FlashFrequency`, `FlashMode` and `FlashSize`. (#528)

### Fixed

Expand Down
31 changes: 28 additions & 3 deletions espflash/src/flasher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::{borrow::Cow, str::FromStr, thread::sleep};
use bytemuck::{Pod, Zeroable, __core::time::Duration};
use esp_idf_part::PartitionTable;
use log::{debug, info, warn};
use serde::{Deserialize, Serialize};
use serialport::UsbPortInfo;
use strum::{Display, EnumIter, EnumVariantNames};

Expand Down Expand Up @@ -39,7 +40,19 @@ const FLASH_SECTORS_PER_BLOCK: usize = FLASH_SECTOR_SIZE / FLASH_BLOCK_SIZE;
///
/// Note that not all frequencies are supported by each target device.
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq, Display, EnumVariantNames)]
#[derive(
Debug,
Default,
Clone,
Copy,
Hash,
PartialEq,
Eq,
Display,
EnumVariantNames,
Serialize,
Deserialize,
)]
#[non_exhaustive]
#[repr(u8)]
pub enum FlashFrequency {
Expand Down Expand Up @@ -85,7 +98,7 @@ impl FlashFrequency {

/// Supported flash modes
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
#[derive(Copy, Clone, Debug, Default, EnumVariantNames)]
#[derive(Copy, Clone, Debug, Default, EnumVariantNames, Serialize, Deserialize)]
#[non_exhaustive]
#[strum(serialize_all = "lowercase")]
pub enum FlashMode {
Expand All @@ -104,7 +117,19 @@ pub enum FlashMode {
///
/// Note that not all sizes are supported by each target device.
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Display, EnumVariantNames, EnumIter)]
#[derive(
Clone,
Copy,
Debug,
Default,
Eq,
PartialEq,
Display,
EnumVariantNames,
EnumIter,
Serialize,
Deserialize,
)]
#[non_exhaustive]
#[repr(u8)]
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
Expand Down