hisiflash 0.1.0

Library for flashing HiSilicon chips
Documentation

hisiflash

A library for flashing HiSilicon chips.

This crate provides the core functionality for communicating with HiSilicon chips via serial port, including:

  • FWPKG firmware package parsing
  • WS63 protocol implementation
  • YMODEM file transfer
  • CRC16-XMODEM checksum calculation

Supported Chips

  • WS63 (primary support)
  • More chips coming in future releases

Supported Platforms

  • Native (default): Linux, macOS, Windows via the serialport crate
  • WASM (experimental): Web browsers via the Web Serial API

Features

  • native (default): Native serial port support
  • wasm: WASM/Web Serial API support (experimental)
  • serde: Serialization support for data types

Example

use hisiflash::{Ws63Flasher, Fwpkg};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Parse firmware package
    let fwpkg = Fwpkg::from_file("firmware.fwpkg")?;
    
    // Create flasher and connect (native only)
    #[cfg(feature = "native")]
    {
        let mut flasher = Ws63Flasher::open("/dev/ttyUSB0", 921600)?;
        flasher.connect()?;
        
        // Flash the firmware
        flasher.flash_fwpkg(&fwpkg, None, |name, current, total| {
            println!("Flashing {}: {}/{}", name, current, total);
        })?;
        
        // Reset the device
        flasher.reset()?;
    }
    
    Ok(())
}