Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
55 changes: 55 additions & 0 deletions components/aic8800/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,53 @@ const FIRMWARE_FILES: &[FirmwareFile] = &[
remote_path: "aic8800DC/fw_patch_table_8800dc_u02.bin",
sha256: "e7eea12cc85fca5d8667182b4520b6a0929044c70c6d9e9a3d7ece8b16169688",
},
FirmwareFile {
name: "fmacfw_patch_tbl_8800dc_u02.bin",
remote_path: "aic8800DC/fmacfw_patch_tbl_8800dc_u02.bin",
sha256: "62d53a223eda1ea064ba82a6fe67829d0720e9f4e87d26763fd13316ccd2a90b",
},
// AIC8800DC-H (sub_id==2, chip_id_h) WiFi-only patch + patch table.
// In-tree only (from vendor rootfs); not on the pinned upstream mirror.
FirmwareFile {
name: "fmacfw_patch_8800dc_h_u02.bin",
remote_path: "",
sha256: "e3257b02541d722fb02bcde673a5377bb38b0d7c5cb8c1c15a7fbb6a3c46238b",
},
FirmwareFile {
name: "fmacfw_patch_tbl_8800dc_h_u02.bin",
remote_path: "",
sha256: "1494ffd7e8d12536e516ab4d9551890aa24e52df4a8817a0a57d463f3dff0df5",
},
// AIC8800DC-H DPD calibration firmware: uploaded to 0x130000 and run via
// start_app(0x130009, FNCALL) to power on the RF/misc-RAM (0x110000) region
// before patch_config. In-tree only.
FirmwareFile {
Comment thread
ZR233 marked this conversation as resolved.
name: "fmacfw_calib_8800dc_h_u02.bin",
remote_path: "",
sha256: "4a3892ef1a61ad6f531d743786f911be4af68d4969d821fa6513f4c8df4620c8",
},
// RF config blobs (ldpc/agc/txgain) extracted from the vendor BSP source
// `aic8800dc_compat.c` as little-endian u32 arrays; in-tree only (no upstream).
FirmwareFile {
name: "dc_ldpc_cfg_ram.bin",
remote_path: "",
sha256: "57d0cf8c72806b08cb9d312977a2967de07a9e2c1725e3726b368f6144cf5765",
},
FirmwareFile {
name: "dc_agc_cfg_ram.bin",
remote_path: "",
sha256: "f2b81eece11b9b7704d626ebfa0f26e6284a94298b820a6ecfef7d335575d5ba",
},
FirmwareFile {
name: "dc_txgain_map.bin",
remote_path: "",
sha256: "539b30d9569e7df2b79e8b7d53d7d299fbb09606e051c3ea1b7e060ddd0ab284",
},
FirmwareFile {
name: "dc_txgain_map_h.bin",
remote_path: "",
sha256: "7007b07bf5348f04b7f1cb013447497efa136750213cb38c40488d7b0bd368eb",
},
FirmwareFile {
name: "fmacfw_8800d80_u02.bin",
remote_path: "aic8800_and_aic8800D80/fmacfw_8800d80_u02.bin",
Expand Down Expand Up @@ -95,6 +142,14 @@ fn read_if_matches(path: &Path, expected_sha256: &str) -> Option<Vec<u8>> {

/// Download a blob from the pinned upstream commit and verify its digest.
fn download(file: &FirmwareFile) -> Vec<u8> {
assert!(
!file.remote_path.is_empty(),
"firmware {} has no upstream mirror (remote_path is empty) and was not found in the \
in-tree firmware dir or $AIC8800_FIRMWARE_DIR. This blob is vendored in \
components/aic8800/firmware/ — ensure it is checked out (it is allow-listed in that \
dir's .gitignore).",
file.name
);
let url = format!(
"https://raw.githubusercontent.com/{}/{}/{}",
FIRMWARE_REPO, FIRMWARE_COMMIT, file.remote_path
Expand Down
14 changes: 13 additions & 1 deletion components/aic8800/firmware/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# AIC8800 firmware blobs are fetched on demand by the xtask build tooling
# (see scripts/axbuild/src/firmware.rs) and integrity-checked against pinned
# SHA-256 digests. They are intentionally not vendored into version control.
# SHA-256 digests. Files available on the pinned upstream mirror are NOT
# vendored into version control.
*.bin
*.ini

# Exception: AIC8800DC-H firmware + RF config blobs have NO upstream mirror
# (remote_path "" in build.rs — extracted from the vendor BSP/rootfs). They
# must be vendored so the build (and CI clippy) can include_bytes! them.
!fmacfw_patch_8800dc_h_u02.bin
!fmacfw_patch_tbl_8800dc_h_u02.bin
!fmacfw_calib_8800dc_h_u02.bin
!dc_ldpc_cfg_ram.bin
!dc_agc_cfg_ram.bin
!dc_txgain_map.bin
!dc_txgain_map_h.bin
Binary file not shown.
Binary file added components/aic8800/firmware/dc_ldpc_cfg_ram.bin
Binary file not shown.
Binary file added components/aic8800/firmware/dc_txgain_map.bin
Binary file not shown.
Binary file added components/aic8800/firmware/dc_txgain_map_h.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions components/aic8800/src/fdrv/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ pub const INTR_CONFIG_VALUE: u8 = 0x07;
/// 堆栈起始参数
pub const STACK_START_PARAM: [u8; 4] = [0x01, 0x00, 0x00, 0x00];

/// AP 模式下注册表(registered_stas)的容量上限。防止异常情况下(如持续收到
/// 不同 MAC 的 AssocReq 而无对应 deauth)注册表无界增长。当前固件 SoftAP 实际
/// 关联数远低于此值。
pub const MAX_REGISTERED_STAS: usize = 16;

/// AP 控制端口(authorize)打开命令的最大重试次数。开放网络关联后必须显式授权,
/// 否则固件丢弃该 STA 的所有数据帧(DHCP/ARP/IP)。单核协作调度下该命令可能
/// 概率性超时,AP worker 周期对账据此重试,到上限仍失败则放弃(STA 多半已离线)。
pub const CONTROL_PORT_MAX_RETRY: u8 = 20;

/// AP worker 控制端口对账的周期(毫秒)。仅在存在未授权 STA 时才周期性自唤醒。
pub const CONTROL_PORT_RECONCILE_MS: u64 = 50;

// ============================================================
// 协议头部常量
// ============================================================
Expand Down
17 changes: 17 additions & 0 deletions components/aic8800/src/fdrv/core/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ impl TxState {
}
}

/// 已注册 STA 的表项:(MAC, sta_idx, 控制端口是否已成功打开, 控制端口重试次数)。
pub type RegisteredSta = ([u8; 6], u8, bool, u8);

/// AP 模式状态:待处理的关联请求队列。
///
/// RX 线程收到 AssocReq 时把整帧 mpdu 入队(非阻塞),由独立的 AP worker
Expand All @@ -172,6 +175,18 @@ impl TxState {
pub struct ApState {
pub assoc_queue: Mutex<VecDeque<Vec<u8>>>,
pub assoc_pollset: PollSet,
/// 待从固件 STA 表删除的 sta_idx 队列。deauth/disassoc 在 RX 线程触发,但
/// MM_STA_DEL_REQ 走 send_cmd 阻塞等 CFM(CFM 由 RX 线程处理)——在 RX 线程里
/// 直接发会死锁,故入队交给 AP worker 线程执行(与 assoc_queue 同理)。
pub sta_del_queue: Mutex<VecDeque<u8>>,
/// 已注册 STA 的 (MAC, sta_idx, 控制端口是否已成功打开, 控制端口重试次数)。
/// - 手机重传 AssocReq 时据此去重:同一 MAC 已注册就不再发 ME_STA_ADD
/// (固件对重复注册不回 CFM,会让 AP worker 阻塞 5 秒超时、连接抖动)。
/// - 控制端口标志为 false 时(首次开失败/超时),AP worker 周期对账会主动重试
/// 打开(不依赖手机重传 AssocReq),实现自愈,避免数据帧被固件丢弃导致
/// ping 不通;重试次数到上限后放弃,防止已离线 STA 空转。
/// - 收到 deauth/disassoc 时移除该 MAC,使重连能完整重新注册。
pub registered_stas: Mutex<Vec<RegisteredSta>>,
}

impl Default for ApState {
Expand All @@ -185,6 +200,8 @@ impl ApState {
Self {
assoc_queue: Mutex::new(VecDeque::new()),
assoc_pollset: PollSet::new(),
sta_del_queue: Mutex::new(VecDeque::new()),
registered_stas: Mutex::new(Vec::new()),
}
}
}
Expand Down
Loading