Giter Club home page Giter Club logo

esp-idf-part's People

Contributors

avee avatar jessebraham avatar mabezdev avatar maximeborges avatar sergiogasquez avatar thetek42 avatar tiwalun avatar wcampbell0x2a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp-idf-part's Issues

no_std support still depends on std

esp-idf-part still appears to depend on the std crate even when used without the std feature.

The serde_plain dependency pulls in a dependency on std, as it depends on serde with the default features.
This could be made an optional dependency, but there are still other std dependency requirements: serde appears to only support untagged enums when the std feature is enabled, and this is used for the SubType enum. It probably would be possible to put all derive(Serialize, Deserialize) attributes behind a cfg_attr check.

All that said, given that PartitionTable::try_from_bytes() is only available with the std feature I don't think that no_std support is going to be useful for what I was hoping to do anyway. The dependency on deku seems to be the main hurdle to making try_from_bytes() work with no-std and no-alloc. For my use case I know my buffer will be aligned, so it's probably easiest for me to just declare my own #[repr(C)] PartitionTableEntry struct and just use bytemuck::from_bytes() to read the table entries through that structure.

Using `SubType::Custom` to generate a partition table causes panic when flashing

Using SubType::Custom when generating a partition table causes panic when flashing:

Partition::new(
  "fs",
  Type::Data,
  SubType::Custom(0x83), // littlefs 
  0x810_000, // App offsets must be multiples of 0x10000 (64KB)
  0x600_000,
  false,
);

a snippet used to generate a partition table file

Unfortunately, panic occurs when flashing:

Error:   × Main thread panicked.
  ├─▶ at /home/rencedm112/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-idf-part-0.4.1/src/partition/mod.rs:171:56
  ╰─▶ called `Option::unwrap()` on a `None` value
  help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.

The panic occurs here:

/// Create a [SubType::Data] variant from an integer value
pub fn data(value: u8) -> Self {
    Self::Data(DataType::from_repr(value as usize).unwrap())
}

the panic occurs because 0x832 subtype is not recognized, which causes DataType::from_repr() to return Option::None

Add test cases which we expect to fail

Currently our tests are run on input which is assumed to be correct. It would be good to add some intentionally invalid partition tables to ensure that parsing fails as expected.

Add support for `readonly` Flag (esp-idf >=5.2)

Apart from the encrypted flag, the csv partition tables can also contain the readonly flag. The latter flag is currently not handled throughout the code-base.

EDIT:
It seems that the readonly flag is not yet part of esp-idf stable (only 5.2beta), so its quite understandable that this was not implemented so far.

example usage

how would one use this?

i currently need to increase the app partition size as the default 1MB is to small, how would i do this, using this library?

without using this library i would create the .csv by hand and apply it via cargo pio espidf menuconfig

No information is provided on _why_ a partition table is invalid

The following partition table can't be parsed because the "data" partition type doesn't have a "data" subtype (note to self: it has an "undefined" subtype). It would be useful is espflash would be able to point this out to me, instead of just a simple "The partition table is invalid" error.

# Name,   Type, SubType, Offset,  Size, Flags
otadata,  data, ota,     ,        0x2000,
ota_0,    app,  ota_0,   ,        2M,
ota_1,    app,  ota_1,   ,        2M,
storage,  data, data,    ,        3M,

Improve documentation

There should be reasonably complete descriptions of each type, and the top-level documentation should contains some basic examples and much more information than it currently does.

MAX_PART_SIZE (16MB) should not apply to data partitions.

In the validate function in lib.rs there's a check that says partition sizes cannot be larger then 16MB:

esp-idf-part/src/lib.rs

Lines 320 to 324 in 3774056

// Partitions cannot exceed 16MB; see:
// https://github.com/espressif/esp-idf/blob/c212305/components/bootloader_support/src/esp_image_format.c#L158-L161
if partition.size() > MAX_PART_SIZE {
return Err(Error::PartitionTooLarge(partition.name()));
}

This check should not apply to data partitions which can be used even when they exceed 16MB. I think this check should be
if partition.ty() == Type::App && partition.size() > MAX_PART_SIZE {

The IDF bootloader code referenced there does indeed check this 16MB limit, but if I read that code correctly it only does so for the partition it tries to boot from. If I write a partition table manually using espflash write-bin 0x8000 partitions.bin to a S3 with 32MB flash I can use a 28MB data partition just fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.