-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Change into a workspace. - Create `beslib` - TODO: Move logic from `oldbestool` here. - Begin creating logical structure for `bestool` - a `beslib` frontend. - Add port enumeration function. Signed-off-by: Dom Rodriguez <[email protected]>
- Loading branch information
Showing
24 changed files
with
2,471 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"src/beslib", | ||
"src/bestool", | ||
] | ||
|
||
[workspace.package] | ||
authors = ["Ben V. Brown <[email protected]>", "Dom Rodriguez <[email protected]>"] | ||
edition = "2021" | ||
homepage = "https://github.com/Ralim/bestool" | ||
readme = "/README.md" | ||
repository = "https://github.com/Ralim/bestool.git" | ||
rust-version = "1.67.0" | ||
version = "0.3.0" | ||
|
||
[workspace.dependencies] | ||
clap = { version = "4.5.1", features = ["derive"] } | ||
crc = "3.0.1" | ||
serde = { version = "1.0.196", features = ["derive"] } | ||
serde_json = "1.0.113" | ||
serialport = "4.3.0" | ||
tracing = "0.1.40" | ||
tracing-subscriber = "0.3.18" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
authors = { workspace = true } | ||
description = "Support library for `bestool`; a command-line utility for BES2300 chips." | ||
edition = { workspace = true } | ||
homepage = { workspace = true } | ||
# license = { workspace = true } # TODO: Specify license with REUSE. | ||
name = "beslib" | ||
repository = { workspace = true } | ||
rust-version = { workspace = true } | ||
version = { workspace = true } | ||
|
||
[dependencies] | ||
crc = { workspace = true } | ||
serialport = { workspace = true } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pub mod enums; | ||
pub mod consts { | ||
pub const BOOT_MAGIC_NUMBER: u32 = 0xBE57EC1C; | ||
pub const BOOT_HASH_TYPE_MD5: u8 = 1; | ||
} | ||
pub const MAX_READ_DATA_LEN: u16 = 16; | ||
pub const MAX_WRITE_DATA_LEN: u16 = 16; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#![allow(non_camel_case_types)] | ||
|
||
#[derive(Debug, Default, PartialEq, Eq)] | ||
pub enum MsgTypeKind { | ||
TYPE_SYS = 0x00, | ||
TYPE_READ = 0x01, | ||
TYPE_WRITE = 0x02, | ||
TYPE_BULK_READ = 0x03, | ||
TYPE_EXT_WRITE = 0x04, | ||
TYPE_BULK_WRITE_START = 0x05, | ||
TYPE_BULK_WRITE_DATA = 0x06, | ||
TYPE_NOTIF = 0x10, | ||
TYPE_SYNC = 0x50, | ||
TYPE_SIG_INFO = 0x51, | ||
TYPE_SIG = 0x52, | ||
TYPE_CODE_INFO = 0x53, | ||
TYPE_CODE = 0x54, | ||
TYPE_RUN = 0x55, | ||
TYPE_SECTOR_SIZE = 0x60, | ||
TYPE_ERASE_BURN_START = 0x61, | ||
TYPE_ERASE_BURN_DATA = 0x62, | ||
TYPE_OBSOLETED_63 = 0x63, | ||
TYPE_OBSOLETED_64 = 0x64, | ||
TYPE_FLASH_CMD = 0x65, | ||
TYPE_GET_SECTOR_INFO = 0x66, | ||
TYPE_SEC_REG_ERASE_BURN_START = 0x67, | ||
TYPE_SEC_REG_ERASE_BURN_DATA = 0x68, | ||
|
||
// Extended types | ||
TYPE_PROD_TEST = 0x81, | ||
TYPE_RUNTIME_CMD = 0x82, | ||
TYPE_BT_CALIB_CMD = 0x83, | ||
TYPE_PROTO_EL = 0xA0, | ||
|
||
TYPE_INVALID = 0xFF, | ||
|
||
#[default] | ||
Unknown, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Eq)] | ||
pub enum SysCmdKind { | ||
SYS_CMD_REBOOT = 0xF1, | ||
SYS_CMD_SHUTDOWN = 0xF2, | ||
SYS_CMD_FLASH_BOOT = 0xF3, | ||
SYS_CMD_SET_BOOTMODE = 0xE1, | ||
SYS_CMD_CLR_BOOTMODE = 0xE2, | ||
SYS_CMD_GET_BOOTMODE = 0xE3, | ||
SYS_CMD_SET_DLD_RATE = 0xD1, | ||
|
||
#[default] | ||
Unknown, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Eq)] | ||
pub enum ErrCodeKind { | ||
ERR_NONE = 0x00, | ||
ERR_LEN = 0x01, | ||
ERR_CHECKSUM = 0x02, | ||
ERR_NOT_SYNC = 0x03, | ||
ERR_NOT_SEC = 0x04, | ||
ERR_SYNC_WORD = 0x05, | ||
ERR_SYS_CMD = 0x06, | ||
ERR_DATA_ADDR = 0x07, | ||
ERR_DATA_LEN = 0x08, | ||
ERR_ACCESS_RIGHT = 0x09, | ||
|
||
ERR_TYPE_INVALID = 0x0F, | ||
|
||
ERR_BOOT_OK = 0x10, | ||
ERR_BOOT_MAGIC = 0x11, | ||
ERR_BOOT_SEC = 0x12, | ||
ERR_BOOT_HASH_TYPE = 0x13, | ||
ERR_BOOT_KEY_TYPE = 0x14, | ||
ERR_BOOT_KEY_LEN = 0x15, | ||
ERR_BOOT_SIG_LEN = 0x16, | ||
ERR_BOOT_SIG = 0x17, | ||
ERR_BOOT_CRC = 0x18, | ||
ERR_BOOT_LEN = 0x19, | ||
ERR_SIG_CODE_SIZE = 0x1A, | ||
ERR_SIG_SIG_LEN = 0x1B, | ||
ERR_SIG_INFO_MISSING = 0x1C, | ||
ERR_BOOT_KEY_ID = 0x1D, | ||
ERR_BOOT_HASH = 0x1E, | ||
|
||
ERR_CODE_OK = 0x20, | ||
ERR_BOOT_MISSING = 0x21, | ||
ERR_CODE_SIZE_SIG = 0x22, | ||
ERR_CODE_ADDR_SIZE = 0x23, | ||
ERR_CODE_INFO_MISSING = 0x24, | ||
ERR_CODE_CRC = 0x25, | ||
ERR_CODE_SIG = 0x26, | ||
|
||
ERR_CODE_MISSING = 0x31, | ||
ERR_VERSION = 0x32, | ||
|
||
ERR_BURN_OK = 0x60, | ||
ERR_SECTOR_SIZE = 0x61, | ||
ERR_SECTOR_SEQ_OVERFLOW = 0x62, | ||
ERR_BURN_INFO_MISSING = 0x63, | ||
ERR_SECTOR_DATA_LEN = 0x64, | ||
ERR_SECTOR_DATA_CRC = 0x65, | ||
ERR_SECTOR_SEQ = 0x66, | ||
ERR_ERASE_FLSH = 0x67, | ||
ERR_BURN_FLSH = 0x68, | ||
ERR_VERIFY_FLSH = 0x69, | ||
ERR_FLASH_CMD = 0x6A, | ||
|
||
ERR_TYPE_MISMATCHED = 0xE1, | ||
ERR_SEQ_MISMATCHED = 0xE2, | ||
ERR_BUF_TOO_SMALL = 0xE3, | ||
|
||
ERR_INTERNAL = 0xFF, | ||
|
||
#[default] | ||
Unknown, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Eq)] | ||
pub enum ParseState { | ||
PARSE_HEADER, | ||
PARSE_DATA, | ||
PARSE_EXTRA, | ||
|
||
#[default] | ||
Unknown, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod boot; |
Oops, something went wrong.