韌體工程師的前置工作:把開發板架起來、裝好工具鏈、寫第一支程式
NVIDIA JetPack(Ubuntu base,L4T)。映像選擇與燒錄方式見「開發者環境」頁(Windows/macOS/Linux 皆有)。
| 項目 | 本平台 |
|---|---|
| 映像 | JetPack SDK / 官方映像(新平台以官方文件為準) |
| 預設使用者 | nvidia(依官方首次開機流程) |
| 首次開機 | 接螢幕或官方 headless 流程 |
| 更新 | sudo apt update && sudo apt upgrade -y |
相機由 DTB/Holoscan 管理;HSB 需先確認乙太網路
HSB 感測器走乙太網路;I2C 經橋接。
sudo apt update && sudo apt install -y build-essential cmake git \
i2c-tools v4l-utils python3-pip| 工具 | 用途 |
|---|---|
build-essential | gcc / make,編譯 C |
cmake | 專案建置系統 |
git | 版本控制 |
i2c-tools | i2cdetect / i2ctransfer |
v4l-utils | v4l2-ctl / media-ctl |
python3-pip | Python 工具 |
sudo i2cdetect -y# 依官方文件;HSB 先確認橋接
韌體工程師的核心技能——用 userspace I2C 直接跟感測器溝通。以下是讀 OV 感測器 ID 的最小程式:
#include#include #include #include #include #include /* 用 userspace I2C 讀感測器 ID(16-bit register,big-endian) */ int main(int argc, char **argv) { int bus = (argc > 1) ? atoi(argv[1]) : 0; int addr = 0x36; /* OV9281/OV5640 7-bit 位址 */ char path[32]; snprintf(path, sizeof(path), "/dev/i2c-%d", bus); int fd = open(path, O_RDWR); if (fd < 0) { perror("open /dev/i2c"); return 1; } if (ioctl(fd, I2C_SLAVE, addr) < 0) { perror("I2C_SLAVE"); return 1; } uint8_t reg[2] = {0x30, 0x0A}; /* ID 高位 register */ if (write(fd, reg, 2) != 2) { perror("write"); return 1; } uint8_t hi = 0, lo = 0; if (read(fd, &hi, 1) != 1) { perror("read"); return 1; } reg[1] = 0x0B; /* ID 低位 register */ if (write(fd, reg, 2) != 2) return 1; if (read(fd, &lo, 1) != 1) return 1; printf("Sensor ID: 0x%02X%02X\n", hi, lo); close(fd); return 0; }
gcc -o read_sensor_id read_sensor_id.c && sudo ./read_sensor_id 0
aarch64-linux-gnu-gcc 編 ARM 二進位。sudo apt install -y gcc-aarch64-linux-gnu aarch64-linux-gnu-gcc -o read_sensor_id read_sensor_id.c scp read_sensor_id nvidia(依官方首次開機流程)@IP:/home/nvidia(依官方首次開機流程)/
以 NVIDIA 官方 SDK 與文件為準(新平台仍在演進)。
| 工具 | 用途 |
|---|---|
dmesg | 內核訊息(probe/CSI 錯誤) |
strace | 追蹤 syscall(I2C 讀寫行為) |
i2cdump | dump 感測器 register |
perf | 效能分析 |