{"slug": "mainline-linux-7-1-on-the-29-cubie-a7z-dual-4-lane-isp-and-open-npu", "title": "Mainline Linux 7.1 on the $29 Cubie A7Z – Dual 4-Lane ISP and Open NPU", "summary": "Embedded engineer Tim Michals brought up the Radxa Cubie A7Z v2, a $29 Allwinner A733 edge-AI SBC, on mainline Linux 7.1.0 with PREEMPT_RT, using a single 592 MiB sdcard.img that auto-detects between the Cubie A7A (LPDDR5) and A7Z v2 (LPDDR4/4X) at boot. The unified image relies on a three-stage boot chain—SPL DRAM training, U-Boot GPADC/BOARD-ID-SEL-GPIO strap detection, and a boot.cmd/config.txt overlay engine—and enables dual 4-lane Sony IMX214 camera bring-up plus NPU and memory benchmarks across both boards.", "body_md": "**By Tim Michals**\n\n*Embedded Linux, Edge AI & Robotics Engineering Blog*\n\n## Cubie A7Z v2 Boot-Up: What's New in v2 and Why One Unified Image?\n\nWe just got the new **Radxa Cubie A7Z v2** on the bench\nand brought it up on mainline **Linux `7.1.0 SMP PREEMPT_RT`**!\n\nIf you saw [Hackster.io's\nlaunch coverage of the original Radxa Cubie A7Z v1](https://www.hackster.io/news/radxa-targets-cost-conscious-edge-ai-projects-with-the-compact-radxa-cubie-a7z-131ac9f35921), you already know\nthe core appeal: an octa-core **Allwinner A733\n(`sun60i`)** edge-AI SBC (dual Cortex-A76 + hexa\nCortex-A55, 3.0 TOPS `VIP9000Nano-DI` NPU, Hardware ISP 602,\nCedrus VPU, and a 200 MHz XuanTie E902 RISC-V core) packed into a\nRaspberry Pi Zero-sized PCB.\n\nBefore diving into the **Cubie A7Z v2 boot-up**, look at\nwhat changed on the backside of the v2.00 hardware revision:\n\n*Radxa Cubie A7Z\nv2.00 backside layout: microSD slot (left), **dual 4-lane MIPI\nCSI-2 camera connectors** (highlighted in red, top and bottom,\nwired to `MCSIA`/` i2c4` and\n`MCSIB`/` i2c3`), display/expansion FPC (green),\nand 1-lane PCIe Gen 3 FPC (cyan) beside the onboard UFS/eMMC\nflash.*\n\nCompared to the single-camera v1 board, **Cubie A7Z v2 adds a\nsecond 4-lane MIPI CSI-2 connector (`MCSIA` /\n`i2c4`)** alongside an updated backside FPC layout\n(dual red CSI ports, green display FPC, cyan 1-lane PCIe Gen 3 FPC, UFS,\nand microSD)—turning a Zero-sized SBC into a native **stereo\ndual-camera edge-AI board**.\n\nTo boot the **Cubie A7Z v2** without forking our\nexisting **Cubie A7A** (LPDDR5, Gigabit Ethernet, single\n2-lane OV5647) Buildroot tree into a second SD card image, we built\ndirectly on my earlier Hackster.io deep dive—**[Using\nDevice Trees to Configure Linux Hardware Interfaces](https://www.hackster.io/MichalsTC/using-device-trees-to-configure-linux-hardare-interfaces-4b0569)** ([devicetreeOverlay.md](https://github.com/tcmichals/cubie-a5e/blob/main/docs/articles/devicetreeOverlay.md))—and\nextended our Raspberry Pi-style `/boot/config.txt` +\n`boot.cmd` overlay engine to **runtime multi-board\nauto-detection**.\n\nThe result is **one single 592 MiB\n`sdcard.img`** that boots cleanly on\n**both** the Cubie A7A (**LPDDR5**) and Cubie\nA7Z v2 (**LPDDR4/4X**) without touching a single file on\nthe card—enabling dual 4-lane Sony IMX214 camera bring-up on A7Z v2 and\nsetting up apples-to-apples NPU and memory performance benchmarks across\nboth boards:\n\n1. **Stage 0 (`boot0` / `SPL-2.0` +\n`boot_package.fex`)** : How the early bootloader\nauto-trains**LPDDR5** vs.**LPDDR4/4X** from\nhardware straps before handing off to a patched FIT image (BL31 +\nU-Boot, minus`scp.fex` ).\n2. **Stage 1 (Radxa A733 U-Boot)** : How U-Boot reads the\nPCB's**GPADC + `BOARD-ID-SEL-GPIO`** straps at\nruntime to set`${fdtfile}` automatically.\n3. **Stage 2 (`boot.cmd` +\n`/boot/config.txt`)** : How our dynamic boot script\nauto-selects**both** the board's base Device Tree\n(`.dtb` )**and** its board-specific Device Tree\nOverlays (`.dtbo` ) with automatic rollback on error—proven on\nlive A7A and A7Z v2 silicon.\n\n## 1. Cubie A7A vs. Cubie A7Z v2: What Actually Differs on the PCB?\n\nBefore unifying the image, we audited\n`radxa_cubie_a7z_schematic_v2.00.pdf` against the Cubie A7A\nand refactored all common A733 SoC peripherals (CPU clusters, CCU,\n`npu@3600000`, `syscon`/` sunxi_sram`,\n`cedrus-enc`, `sun6i-csi-capture` +\n`csi1`, `sun60i-isp`, THS thermal zones, E902\n`remoteproc`, USB/MMC/I2C/UART) into a shared\n**`sun60i-a733.dtsi`**.\n\nThat left two small, clean board\nfiles—`sun60i-a733-cubie-a7a.dts` and\n`sun60i-a733-cubie-a7z.dts`—capturing the exact PCB\ndeltas:\n\n| Subsystem | Radxa Cubie A7A ( `sun60i-a733-cubie-a7a.dts` ) | Radxa Cubie A7Z v2.00 ( `sun60i-a733-cubie-a7z.dts` ) | \n|---|---|---|\n| **DRAM** | **LPDDR5** (`DRAM Type = 9` , 2400 MHz, e.g. 6 GiB) | **LPDDR4 / LPDDR4X** (`DRAM Type = 8` , e.g. 2 GiB / 4 GiB) | \n| **PMIC (`s_twi0 @ 0x36`)** | `x-powers,axp8191` | **AXP318-WBBGA** (register-compatible with`x-powers,axp8191` ) | \n| **Ethernet** | Gigabit RGMII ( `gmac0` +`mdio0` , PHY reset`PH16` ) | **None** (Wi-Fi 6 / BT 5.4 only) | \n| **Onboard Wi-Fi 6 / BT** | USB1 AIC8800D80 ( `PM0` PWR,`PM1` REG_ON) | USB1 AIC8800D80 ( `PM0` PWR,`PM1` WL-REG-ON) | \n| **USB VBUS Control** | `usb0-vbus` (`PL2` ),`usb1-vbus` (`PM5` ) | `usb0-vbus` (`PL2`` USB0-DRVVBUS` );**`PM5` freed for 40-pin GPIO** | \n| **Status LEDs** | Blue user ( `PJ27` ), Green power (`PJ26` ) | Single Green user ( `PM2` ,`radxa:green:user` ,`heartbeat` ) | \n| **MIPI CSI-2 Cameras** | Single port: `MCSIB` (`dphy1` /`mipi1` /`csi` ,`i2c3` ) →**2-lane OV5647** | **Dual 4-lane** : CSI-R (`MCSIB` /`i2c3` ) + CSI-L (`MCSIA` /`dphy0` /`mipi0` /`csi1` /`i2c4` ) →**2× Sony IMX214** | \n\nBecause every SoC block lives in `sun60i-a733.dtsi`, a\nsingle `Image` binary handles both boards identically—as long\nas the boot chain trains the right DRAM and hands Linux the right merged\nDevice Tree.\n\n```\n+------------------------------------------------------------------------------+\n|                   UNIFIED ALLWINNER A733 SINGLE-IMAGE BOOT                   |\n+------------------------------------------------------------------------------+\n  |\n  +-> 1. boot0 / SPL-2.0 (raw 0..16 MiB, radxa_a733_bootloader.bin)\n  |      Reads DDR-PARA-SEL-GPIO + DDR-PARA-SEL-ADC (GPADC0)\n  |      -> A7A: LPDDR5 (Type 9, 2400 MHz) | A7Z: LPDDR4/4X (Type 8)\n  |      -> Loads FIT @ sector 848 (0x6a000): BL31 + U-Boot (NO scp.fex!)\n  |\n  +-> 2. Radxa A733 U-Boot (board_late_init)\n  |      Reads BOARD-ID-SEL-ADC (GPADC) + BOARD-ID-SEL-GPIO\n  |      -> Sets ${fdtfile} = \"allwinner/sun60i-a733-cubie-a7a.dtb\"\n  |                        or \"allwinner/sun60i-a733-cubie-a7z.dtb\"\n  |      -> Runs board-agnostic uboot.env -> loads & executes boot.scr\n  |\n  +-> 3. boot.scr (compiled from boot.cmd) + /boot/config.txt (FAT32 mmc 0:1)\n  |      Maps ${fdtfile} -> ${base_dtb}\n  |      Imports /boot/config.txt via `env import -t`\n  |      -> A7A: dtoverlay_a7a = \"cubie-a7a-rproc cubie-a7a-ov5647\"\n  |      -> A7Z: dtoverlay_a7z = \"cubie-a7a-rproc cubie-a7z-imx214\"\n  |      Loads ${base_dtb} -> `fdt resize 0x10000` -> `fdt apply` each .dtbo\n  |      (Rolls back to clean ${base_dtb} automatically if any overlay fails)\n  |\n  +-> 4. Mainline Linux 7.1.0 PREEMPT_RT (`booti ${kernel_addr_r} - ${fdt_addr_r}`)\n         Same kernel Image + same ext4 rootfs + board-accurate merged FDT\n```\n\n## 2.\nPillar 1: `boot0` DRAM Auto-Training & Stripping\n`scp.fex` from the FIT\n\n### How One Bootloader Blob Trains Both LPDDR5 and LPDDR4/4X\n\nBefore U-Boot or Linux can touch RAM, Allwinner's first-stage\n`boot0` (`SPL-2.0` preboot) runs from on-chip\nSRAM. Radxa's unified A733 bootloader blob\n(`radxa_a733_bootloader.bin`, stored in the first 16 MiB of\nthe SD card) embeds multiple DRAM parameter tables\n(`boot_package.fex` / DRAM config) covering the A733 board\nlineup.\n\nOn power-up, `boot0` initializes the AXP8191/AXP318 PMIC,\nbrings up the CPU/DSU PLLs, and samples two hardware straps on the\nPCB:\n\n- **`DDR-PARA-SEL-GPIO`** : digital strap\n(`gpio_idx` )\n- **`DDR-PARA-SEL-ADC`** via**` GPADC0`** : analog resistor-divider strap\n(`adc_idx` )\n\nHere is an actual live serial capture from a **Cubie\nA7A** cold boot showing `boot0` probing those straps\nand selecting the LPDDR5 training table (`DRAM Type = 9`)\nbefore handing off to U-Boot SPL and Arm Trusted Firmware (BL31):\n\n```\n[215] SPL-2.0 - preboot 2026-06-17 10:06:51 +0800 {853efe0f-dirty}\n[229] PMU: AXP8191\n[234] set pll start\n[248] set pll end\n[257] cur pin val 0\n[259] GPADC0: Clk init ok\n[262] GPADC0: Init ok\n[274] adc_idx 1 gpio_idx 0\nDRAM BOOT DRIVE INFO: V0.6036\nDRAM_VCC set to 560 mv\nDRAM CLK =2400 MHZ\nDRAM Type =9 (8:LPDDR4,9:LPDDR5)\nTraining result is = 7\nDRAM Pstate 1 training, frequency is 1200 Mhz\nDRAM Pstate 2 training, frequency is 800 Mhz\nDRAM Pstate 3 training, frequency is 400 Mhz\nDRAM Pstate 0 training, frequency is 2400 Mhz\nActual DRAM SIZE =6144 M\nDRAM simple test OK.\n[4709] DRAM size 6144 MB\n\nU-Boot SPL 2026.04-3-boot-dlan17-g24da4dae7637-dirty\nDRAM: 6144 MiB\nTrying to boot from MMC1\nNOTICE:  BL31: OP-TEE 32bit detected\nNOTICE:  BL31: U-BOOT 64bit used\n```\n\nInsert the **exact same SD card** into a **Cubie\nA7Z v2**, and the A7Z's `DDR-PARA-SEL-ADC` /\n`DDR-PARA-SEL-GPIO` resistor straps select the\n**LPDDR4/4X (`DRAM Type = 8`)** parameter table\ninstead, training the 2 GiB (or 4 GiB) LPDDR4/4X package cleanly with\nzero software changes.\n\n### Freeing\nthe XuanTie E902 RISC-V Core: `patch_fit_no_scp.py`\n\nRight after DRAM comes up, U-Boot SPL loads the FIT image embedded at\n**sector 848 (`0x6a000`)** inside\n`radxa_a733_bootloader.bin`. By default, Radxa's FIT\n`/configurations/config-1` lists:\n\n```\nloadables = \"scp\", \"uboot\";\n```\n\nWhen `\"scp\"` is present, stock BL31 loads Allwinner's\n`scp.fex` and boots the on-die 200 MHz **XuanTie E902\nRISC-V** core as its `arisc` power-management\ncoprocessor—locking Linux `remoteproc0` out of the E902.\n\nRather than recompiling or binary-patching BL31, our Buildroot\n`post-image.sh` runs [`patch_fit_no_scp.py`](https://github.com/tcmichals/cubie-a5e/blob/main/project-cubie-a5e/board/radxa/cubie_a7a/patch_fit_no_scp.py)\non a pristine copy of `radxa_a733_bootloader.bin`. It walks\nthe FDT structure inside the FIT and edits `loadables`\n**in place** from `\"scp\\0uboot\\0\"` (10 bytes) to\n`\"uboot\\0\"` (6 bytes), filling the freed 4-byte word with\n`FDT_NOP` (`0x00000004`):\n\n```\nold_span = align4(len(OLD_VALUE))\nnew_span = align4(len(NEW_VALUE))\nstruct.pack_into(\">I\", fit, pos + 4, len(NEW_VALUE))\nfit[pos + 12:pos + 12 + new_span] = NEW_VALUE.ljust(new_span, b\"\\0\")\nfor nop in range(pos + 12 + new_span, pos + 12 + old_span, 4):\n    struct.pack_into(\">I\", fit, nop, FDT_NOP)\n```\n\nThe FIT total size and every image offset remain byte-for-byte\nidentical, BL31 stays 100% stock, and the E902 RISC-V core is left free\nfor Linux `remoteproc0` on **both** A7A and\nA7Z.\n\n### Preserving\nthe MBR Partition Table in `genimage.cfg`\n\nFinally, [`genimage.cfg`](https://github.com/tcmichals/cubie-a5e/blob/main/project-cubie-a5e/board/radxa/cubie_a7a/genimage.cfg)\nlays down the 16 MiB bootloader blob at offset `0` while\npunching a hole over bytes `440..512` so\n`genimage` can write a clean MBR partition table for the 64\nMiB FAT32 `/boot` partition (at offset `16M`) and\nthe 512 MiB `rootfs.ext4` partition:\n\n```\nimage boot.vfat {\n    vfat {\n        files = {\n            \"sun60i-a733-cubie-a7a.dtb\",\n            \"sun60i-a733-cubie-a7z.dtb\",\n            \"cubie-a7a-rproc.dtbo\",\n            \"cubie-a7a-ov5647.dtbo\",\n            \"cubie-a7z-imx214.dtbo\",\n            \"config.txt\",\n            \"uEnv.txt\",\n            \"boot.scr\",\n            \"Image\",\n            \"uboot.env\"\n        }\n    }\n    size = 64M\n}\n\nimage sdcard.img {\n    hdimage {}\n\n    partition u-boot {\n        in-partition-table = false\n        image = \"radxa_a733_bootloader.bin\"\n        offset = 0\n        holes = {\"(440; 512)\"}\n    }\n\n    partition boot {\n        partition-type = 0xC\n        bootable = \"true\"\n        image = \"boot.vfat\"\n        offset = 16M\n    }\n\n    partition rootfs {\n        partition-type = 0x83\n        image = \"rootfs.ext4\"\n    }\n}\n```\n\n## 3.\nPillar 2: How Radxa A733 U-Boot Auto-Detects A7A vs. A7Z\n(`${fdtfile}`)\n\nOnce BL31 hands off to 64-bit U-Boot proper, U-Boot needs to know\n*which* A733 board it is running on.\n\nChecking the **Cubie A7Z v2.00 schematic**\n(`radxa_cubie_a7z_schematic_v2.00.pdf`), Radxa implements a\nhardware board-ID matrix using two signals:\n\n1. **`BOARD-ID-SEL-ADC` (`BOARD-ID-ADC0` /\n`BOARD-ID-ADC1`)** : An analog voltage divider\nconnected to the A733's on-die**GPADC** . A fixed**10 kΩ 1% pull-up resistor (`R5`)** ties the\nline to`AVCC` , while a board-specific**pull-down\nresistor (`R6`)** sets a unique voltage band per\nSKU.\n2. **`BOARD-ID-SEL-GPIO`** : A digital GPIO\nstrap on the`VCC-PK` rail used alongside the GPADC reading\nto disambiguate board variants.\n\nDuring U-Boot initialization—**even after\n`Loading Environment from FAT... OK` reads\n`uboot.env`**—Radxa's A733 board code samples the\nGPADC and `BOARD-ID-SEL-GPIO`, maps the hardware ID to the\nboard's canonical DTB name, and updates `${fdtfile}`:\n\n```\nLoading Environment from FAT... OK\nIn:    serial@2500000\nOut:   serial@2500000\nErr:   serial@2500000\nAllwinner mUSB OTG (Peripheral)\nOverride default fdtfile to allwinner/sun60i-a733-cubie-a7a.dtb\n```\n\nOn the **Cubie A7Z v2**, that exact same line\nprints:\n\n```\nOverride default fdtfile to allwinner/sun60i-a733-cubie-a7z.dtb\n```\n\nAt the same time, U-Boot fixes up the `/memory@40000000`\nnode in the loaded FDT with the exact DRAM capacity trained by\n`boot0` (e.g., 6 GiB on A7A, 2 GiB / 1.9 GiB usable on A7Z\nv2), so Linux always sees the true physical RAM size regardless of the\nfallback `reg` in the `.dts` file.\n\n### The Golden Rule for\n`uboot.env`\n\nKeep `uboot.env` **100% board-agnostic**. Our\n[`uboot-env.txt`](https://github.com/tcmichals/cubie-a5e/blob/main/project-cubie-a5e/board/radxa/cubie_a7a/uboot-env.txt)\nonly defines memory map addresses and a single boot command:\n\n```\nbootdelay=1\nbaudrate=115200\nbootcmd=load mmc 0:1 0x4fc00000 boot.scr && source 0x4fc00000\n\nkernel_addr_r=0x40200000\nfdt_addr_r=0x4fa00000\nscriptaddr=0x4fc00000\nfdtoverlay_addr_r=0x4fe00000\nramdisk_addr_r=0x4ff00000\n```\n\nIt never hardcodes `fdtfile` or `base_dtb`, so\nU-Boot's hardware-detected `${fdtfile}` passes straight into\n`boot.scr`.\n\n## 4.\nPillar 3: Dynamic Multi-DTB & Per-Board Overlays\n(`boot.cmd` + `/boot/config.txt`)\n\n### Building Both DTBs and All Overlays in One Pass\n\nIn Buildroot's [`cubie_a7a_defconfig`](https://github.com/tcmichals/cubie-a5e/blob/main/project-cubie-a5e/configs/cubie_a7a_defconfig),\ncompiling both base Device Trees is a single line:\n\n```\nBR2_LINUX_KERNEL_INTREE_DTS_NAME=\"allwinner/sun60i-a733-cubie-a7a allwinner/sun60i-a733-cubie-a7z\"\n```\n\nAnd [`post-image.sh`](https://github.com/tcmichals/cubie-a5e/blob/main/project-cubie-a5e/board/radxa/cubie_a7a/post-image.sh)\nstages every compiled `.dtbo` overlay alongside\n`boot.scr`, `uboot.env`, and\n`config.txt` into `${BINARIES_DIR}` before\ninvoking `genimage`:\n\n```\n${HOST_DIR}/bin/mkimage -A arm64 -T script -C none -d \"${BOARD_DIR}/boot.cmd\" \"${BINARIES_DIR}/boot.scr\"\n${HOST_DIR}/bin/mkenvimage -s 0x10000 -o \"${BINARIES_DIR}/uboot.env\" \"${BOARD_DIR}/uboot-env.txt\"\n\nfor ov in cubie-a7a-rproc.dtbo cubie-a7a-ov5647.dtbo cubie-a7z-imx214.dtbo; do\n    if [ -f \"${BOARD_DIR}/../../dts-overlay/allwinner/${ov}\" ]; then\n        cp -f \"${BOARD_DIR}/../../dts-overlay/allwinner/${ov}\" \"${BINARIES_DIR}/${ov}\"\n    fi\ndone\n```\n\n### Extending\n`/boot/config.txt` from Single-Board (A5E) to Multi-Board\n(A7A + A7Z)\n\nIn **[Using\nDevice Trees to Configure Linux Hardware Interfaces](https://www.hackster.io/MichalsTC/using-device-trees-to-configure-linux-hardare-interfaces-4b0569)**, a\nsingle-board Cubie A5E image only needed one `dtoverlay=`\nline in `/boot/config.txt` because every card booted the same\nmotherboard. On a unified multi-board A733 image, auto-selecting the\nbase `.dtb` is only half the story: if you apply the Cubie\nA7A's `cubie-a7a-ov5647.dtbo` overlay on a Cubie A7Z v2 with\ndual IMX214 cameras attached, Linux tries to probe `ov5647`\nat `i2c3 0x36` (which fails) while leaving both IMX214\nsensors unpowered!\n\nSo we extended the exact same Raspberry Pi-style [`/boot/config.txt`](https://github.com/tcmichals/cubie-a5e/blob/main/project-cubie-a5e/board/radxa/cubie_a7a/config.txt)\npattern with board-scoped overlay variables (`dtoverlay_a7a`\nand `dtoverlay_a7z`) while preserving generic\n`dtoverlay=` as a backward-compatible fallback:\n\n```\n# /boot/config.txt - Radxa Cubie A7A/A7Z Hardware & Overlay Configuration\n# (Raspberry Pi style configuration for Allwinner A733)\n\n# Per-board default overlays (unified A733 SD image):\n# - Cubie A7A: XuanTie E902 remoteproc + OV5647 camera (MIPI CSI-2)\n# - Cubie A7Z: XuanTie E902 remoteproc + Dual Radxa Camera 13M 214 (IMX214)\ndtoverlay_a7a=cubie-a7a-rproc cubie-a7a-ov5647\ndtoverlay_a7z=cubie-a7a-rproc cubie-a7z-imx214\n\n# Optional extra kernel command-line arguments\ncmdline=\n```\n\nNotice how clean the modularity is:\n\n- **`cubie-a7a-rproc.dtbo`** is**shared\nby both boards** —it reserves the E902 DRAM carveout and enables`remoteproc0` on both A7A and A7Z.\n- **`cubie-a7a-ov5647.dtbo`** (A7A only) wires\nthe 2-lane OmniVision OV5647 on`i2c3 @ 0x36` with a 25 MHz\nfixed clock and`PE8` power-down to`mipi1_in` .\n- **`cubie-a7z-imx214.dtbo`** (A7Z only) wires**two 4-lane Sony IMX214 sensors** simultaneously:\n  - **CSI-R (`MCSIB` / `dphy1` /\n`mipi1`)** :` i2c3 @ 0x10` , 24 MHz`CLK_CSI_MASTER1` (`PE5` ),`PE8` STBY-R\nregulator,`PE9` RST-R, 4 data lanes\n(`PK10..PK19` ).\n  - **CSI-L (`MCSIA` / `dphy0` /\n`mipi0`)** :` i2c4 @ 0x10` , 24 MHz`CLK_CSI_MASTER0` (`PE0` ),`PE12` STBY-L regulator,`PE13` RST-L, 4 data lanes\n(`PK0..PK9` ).\n\n### Inside\n`boot.cmd`: Runtime DTB + Overlay Dispatch with Rollback\n\nHere is the core logic from [`project-cubie-a5e/board/radxa/cubie_a7a/boot.cmd`](https://github.com/tcmichals/cubie-a5e/blob/main/project-cubie-a5e/board/radxa/cubie_a7a/boot.cmd):\n\n```\n# 1. Auto-select board DTB from Radxa A733 U-Boot's GPADC/GPIO-detected ${fdtfile}\necho \">>> U-Boot detected fdtfile: ${fdtfile}\"\nif test \"${fdtfile}\" = \"allwinner/sun60i-a733-cubie-a7z.dtb\"; then\n    setenv base_dtb sun60i-a733-cubie-a7z.dtb\nelif test \"${fdtfile}\" = \"allwinner/sun60i-a733-cubie-a7a.dtb\"; then\n    setenv base_dtb sun60i-a733-cubie-a7a.dtb\nelse\n    setenv base_dtb sun60i-a733-cubie-a7a.dtb\nfi\nsetenv overlays \"\"\n\n# 2. Import Raspberry Pi-style config.txt (with armbianEnv.txt / uEnv.txt fallbacks)\nif load mmc 0:1 ${ramdisk_addr_r} config.txt; then\n    echo \">>> Found Raspberry Pi-style config.txt! Importing configuration...\"\n    env import -t ${ramdisk_addr_r} ${filesize}\nelif load mmc 0:1 ${ramdisk_addr_r} armbianEnv.txt; then\n    env import -t ${ramdisk_addr_r} ${filesize}\nelif load mmc 0:1 ${ramdisk_addr_r} uEnv.txt; then\n    env import -t ${ramdisk_addr_r} ${filesize}\nfi\n\n# 3. Pick board-specific overlay list (falling back to generic dtoverlay)\nif test \"${base_dtb}\" = \"sun60i-a733-cubie-a7z.dtb\" && test -n \"${dtoverlay_a7z}\"; then\n    setenv overlays \"${dtoverlay_a7z}\"\nelif test \"${base_dtb}\" = \"sun60i-a733-cubie-a7a.dtb\" && test -n \"${dtoverlay_a7a}\"; then\n    setenv overlays \"${dtoverlay_a7a}\"\nelif test -n \"${dtoverlay}\"; then\n    setenv overlays \"${dtoverlay}\"\nfi\n\n# 4. Load base DTB and expand FDT buffer by 64 KB (0x10000) for overlays\nif load mmc 0:1 ${fdt_addr_r} ${base_dtb}; then\n    fdt addr ${fdt_addr_r}\n    fdt resize 0x10000\nelse\n    echo \"ERROR: Failed to load base DTB ${base_dtb}!\"\n    reset\nfi\n\n# 5. Apply each .dtbo in RAM; roll back to clean base DTB on any failure\nif test -n \"${overlays}\"; then\n    setenv fdt_apply_error 0\n    for overlay in ${overlays}; do\n        setenv loaded 0\n        if load mmc 0:1 ${fdtoverlay_addr_r} ${overlay}.dtbo; then\n            setenv loaded 1\n        elif load mmc 0:1 ${fdtoverlay_addr_r} ${overlay}; then\n            setenv loaded 1\n        elif load mmc 0:1 ${fdtoverlay_addr_r} overlays/${overlay}.dtbo; then\n            setenv loaded 1\n        fi\n\n        if test \"${loaded}\" = \"1\"; then\n            if fdt apply ${fdtoverlay_addr_r}; then\n                echo \"    [OK] Applied ${overlay} successfully.\"\n            else\n                echo \"    [ERROR] fdt apply failed for ${overlay}!\"\n                setenv fdt_apply_error 1\n            fi\n        fi\n    done\n\n    if test \"${fdt_apply_error}\" = \"1\"; then\n        echo \">>> [WARNING] One or more overlays failed! Reloading clean base DTB...\"\n        load mmc 0:1 ${fdt_addr_r} ${base_dtb} && fdt addr ${fdt_addr_r}\n    fi\nfi\n\n# 6. Boot mainline Linux 7.1 kernel Image with the merged FDT\nload mmc 0:1 ${kernel_addr_r} Image && booti ${kernel_addr_r} - ${fdt_addr_r}\n```\n\nTwo details here save hours of field debugging:\n\n- **`fdt resize 0x10000`** adds 64 KiB of\nheadroom to the in-memory FDT before`fdt apply` . Without it,\napplying a second overlay like`cubie-a7z-imx214.dtbo` fails\nwith`FDT_ERR_NOSPACE` .\n- **Automatic clean-base rollback** : If an experimental\noverlay has a broken phandle target,`boot.cmd` detects`fdt_apply_error=1` , reloads the pristine`${base_dtb}` , and still boots Linux into a recoverable shell\ninstead of hanging at`Starting kernel ...` .\n\n## 5. First-Silicon Verification on Both Boards\n\nWe flashed the single unified `bld.a7a/images/sdcard.img`\n(**592 MiB**, mainline **Linux\n`7.1.0 SMP PREEMPT_RT`**) and booted it live on\n**both** the Radxa Cubie A7A (LPDDR5) and Radxa Cubie A7Z\nv2.00 (LPDDR4/4X, tested bare without a heatsink at a 780 MHz thermal\ncap, 37.0–50.9 °C):\n\n| Subsystem | Cubie A7A (LPDDR5) | Cubie A7Z v2.00 (LPDDR4/4X) | \n|---|---|---|\n| **Auto-Selected DTB** | `sun60i-a733-cubie-a7a.dtb` (`Radxa Cubie A7A` , 6 GiB) | `sun60i-a733-cubie-a7z.dtb` (`Radxa Cubie A7Z` , 1.9 GiB usable) | \n| **Auto-Applied Overlays** | `cubie-a7a-rproc` +`cubie-a7a-ov5647` | `cubie-a7a-rproc` +`cubie-a7z-imx214` | \n| **PMIC & CPU DVFS** | AXP8191, `policy0` (416–1794 MHz) &`policy6` (416–2002 MHz) | AXP318/AXP8191 (all 45 regulators), `policy0` &`policy6` DVFS live | \n| **Thermal & Cooling Maps** | 5 THS zones ( `cpu-big` ,`ddr` ,`npu` ,`cpu-little` ,`gpu` ) +`npu-thermal` | 5 THS zones + `cdev0/cdev1` (`cpufreq` ) +`npu-thermal` (70/90 °C →`3600000.npu` ) | \n| **Networking** | Gigabit `eth0` (`gmac0` ) + USB1 AIC8800D80 Wi-Fi 6 | USB1 AIC8800D80 Wi-Fi 6 ( `a69c:8d80` →`a69c:8d81` ,`wlan0` HT/VHT/HE UP) | \n| **Status LEDs** | `radxa:blue:user` (`PJ27` ),`radxa:green:power` (`PJ26` ) | `radxa:green:user` (`PM2` ,`[heartbeat]` ) | \n| **E902 `remoteproc0`** | `start` →`running` , live`trace0` + RPMsg, clean`stop` | `start` →`running` , live`trace0` telemetry, clean`stop` →`offline` | \n| **3.0 TOPS NPU (`etnaviv` + Teflon)** | `/dev/dri/renderD128` , 6/6 bit-exact, 203 FPS MobileNetV1 | `/dev/dri/renderD128` ,**`/usr/bin/npu-smoke-test` 6/6 PASS (`max_diff=0`, `Cosine=1.000000`)** | \n| **Cedrus VPU & ISP 602** | `cedrus-enc` (`/dev/video3` ),`sun60i-isp` (`/dev/video1..2` ) | `cedrus-enc` (`/dev/video3` ,`NV12` → H.264/HEVC),`sun60i-isp`**1080p NV12 (15/15 frames)** | \n| **MIPI CSI-2 Cameras** | OV5647 ( `i2c-3 0x36` ) 2-lane capture | **Dual 4-lane IMX214** (`i2c-3 0x10 = UU` +`i2c-4 0x10 = UU` ), live**1080p `RG10` @ ~47 FPS** | \n\n**One honest open item on A7Z v2:** Warm software\n`reboot` on the A7Z v2 currently resets without returning to\n`boot0` (cold power-cycle boots cleanly every time). We are\ninvestigating whether AXP318's cold-reset register\n(`0x54`/` 0x55`) or the A733 watchdog timer reset\n(`WDT_CFG`) needs a board-specific quirk.\n\n## 6. Live Cubie A7Z v2 Silicon Results: Dual 4-Lane Cameras, Hardware H.264/H.265 & NPU Performance Comparison\n\nWith the unified image booted on the **Cubie A7Z v2**, we benchmarked the full edge-AI vision stack—dual 4-lane IMX214 cameras, Cedrus 1080p H.264/H.265 hardware compression, and Mainline Linux 7.1 `etnaviv` + Mesa Teflon NPU vs. CPU + LPDDR4/4X using `tools/npu_perf_compare.py`:\n\n*Live mainline Linux 7.1 performance summary on the Radxa Cubie A7Z v2 (full clock 1.79/2.00 GHz with fan, 36.3–43.6 °C) alongside Cubie A7A (LPDDR5) reference numbers.*\n\n### 6.1 Concurrent Dual 4-Lane Sony IMX214 Capture (95.41 FPS Combined, 1.2% CPU)\n\n*(Captured on a bare board with passive cooling—no heatsink or fan—accounting for the 53.0–53.1 °C readings compared to the fan-cooled runs in Sections 6.3 and 6.4.)*\n\n- **1× CSI-R Solo (`/dev/video0`, 100 frames, 1080p RAW10)** :**46.76 FPS** ,` p50 = 20.55 ms` ,**0.7% CPU** ,`53.1 °C`\n- **2× Concurrent Dual-Cam (100 frames each, 1080p RAW10)** :\n  - **CSI-R (`/dev/video0`, `imx214 3-0010`)** :**46.76 FPS** (` p50 = 20.55 ms` , real Bayer pixels**98.6% non-zero** ,`mean=63.7` )\n  - **CSI-L (`/dev/video1`, `imx214 4-0010`)** :**48.65 FPS** (` p50 = 20.55 ms` ,**`p99 = 20.57 ms`** ,**20 µs jitter** , real Bayer pixels**100.0% non-zero** ,`mean=64.7` )\n  - **Combined throughput** :**95.41 FPS** sustained (peak**97.3 FPS** ) at just**1.2% total CPU** and**53.0 °C** .\n\n### 6.2 Hardware Video Compression (`cedrus-enc` 1080p H.264 & H.265/HEVC — up to 72.62 FPS)\n\n*(Captured on a bare board with passive cooling—no heatsink or fan—accounting for the 53.1–55.9 °C readings.)*\n\n- **H.264 (AVC)** :**51.65–62.97 FPS** (**15.88–19.36 ms/frame** ,`75.6 KB` for 60 frames),**4.2–4.5% total CPU** ,`53.1–55.1 °C`\n- **H.265 (HEVC)** :**72.62 FPS** (**13.77 ms/frame** ,`32.2 KB` —**2.3× smaller** than H.264),**5.8% total CPU** ,`55.9 °C`\n\n### 6.3 4-Engine Concurrent Vision Pipeline (Dual-Cam TDM200 + ISP 602 NV12 + Dual 3A + Live H.265 + 3.0 TOPS NPU)\n\nWith all hardware engines running **simultaneously** on Mainline Linux 7.1 `PREEMPT_RT` (full clocks 1.79/2.00 GHz, fan on, zero dropped frames and zero ISP/TDM errors; note that V4L2 `/dev/videoX` indices shift when dual-ISP channels and both 3A params/stats nodes occupy `/dev/video2..5`, moving `cedrus-enc` from `/dev/video3` in Section 5's single-ISP table to `/dev/video6`):\n\n- **Dual-Camera Time-Multiplexed Hardware ISP 602 (TDM200 offline mode + VIPP/BK virtual-channel demux)** :\n  - **Forward Camera (CSI-R `/dev/video0`, 4-lane IMX214 → TDM200 RX0 → ISP 602 ch0 → 1080p NV12)** :**48.65 FPS** (150/150 frames, 0 drops,`rx_fe=0` ,`ist=0` )\n  - **Downward Camera (CSI-L `/dev/video1`, 4-lane IMX214 → TDM200 RX1 → ISP 602 ch1 → 1080p NV12)** :**48.65 FPS** (150/150 frames, 0 drops —**97.30 FPS combined dual-camera Hardware ISP 602 1080p NV12** )\n  - **Independent Dual Closed-Loop Hardware 3A (`/usr/bin/a733-isp-3a --ch 0` & `--ch 1`)** : Live per-frame hardware AE zone readback (` 432 × u16` zones via`/dev/video3` &`/dev/video5` ) + dynamic WB gain injection (`/dev/video2` &`/dev/video4` ) running on both channels simultaneously (120/120 stats frames each,`rc=0` )\n- **3.0 TOPS NPU (`etnaviv` + Mesa Teflon) Concurrently with Dual-ISP 1080p NV12 + Dual 3A** :**MobileNetV1 INT8 @ 170.0 FPS** (`5.37 ms` p50,**`Cosine = 0.999958`** , 411 NPU IRQs,**13.9% total 8-core CPU** ;**191.3 FPS** /`5.23 ms` mean /**4% avg CPU** /**36.3 °C peak** alongside CSI-R ISP NV12 + CSI-L RAW10 + live Cedrus H.265)\n- **Cedrus H.265 Encoder (`/dev/video6`)** :**60/60 live IMX214 + ISP 602 1080p NV12 frames → `173.6 KB` valid `HEVC (Main) 1920×1080` bitstream** (verified clean decode via`ffprobe` /`ffmpeg` )\n\n### 6.4 Standard TFLite INT8 NPU Benchmarks (`etnaviv` + Teflon vs. CPU) & LPDDR4/4X\n\nCaptured live on the Cubie A7Z v2 at **full clock (`1.79 GHz` A55 / `2.00 GHz` A76, fan on, 36.3–43.6 °C)** using official Google TFLite INT8 models (30 timed iterations):\n\n- **MobileNetV1 INT8 (224×224)** :**197.3 FPS** (**5.07 ms** , 60 NPU IRQs,**10.9% CPU** ,**`Cosine = 0.999958`** , 39.4 °C) —**within 2.8% of the LPDDR5 Cubie A7A (203.0 FPS)** ; vs. CPU-4T`74.4 FPS` (50.5% CPU) / CPU-1T`51.2 FPS` .\n- **MobileNetV2 INT8 (224×224)** :**180.8 FPS** (**5.53 ms** , 360 NPU IRQs,**16.3% CPU** , 36.3 °C) —**within 2.8% of the LPDDR5 Cubie A7A (186.0 FPS)** ; vs. CPU-4T`63.0 FPS` (50.1% CPU) / CPU-1T`20.9 FPS` .\n- **SSD-MobileNetV1 INT8 (300×300 Object Detection)** :**78.9 FPS** (**12.67 ms** , 272 NPU IRQs,**13.8% CPU** , 43.6 °C); vs. CPU-4T`45.8 FPS` (43.7% CPU) / CPU-1T`36.7 FPS` .\n- **LPDDR4/4X DRAM Probe (32 MiB × 20 @ full clock)** :**3,639.8 MB/s copy** (**7,279.5 MB/s** total R+W traffic) |**7,967.9 MB/s write** .\n- **Onboard 128 GB UFS 3.x Storage (`ufs-sun60i`, HS-G4 Rate B)** :**YMTC `YMUS8A1TE2D1C1` (`/dev/sda`, 119 GiB)** enumerated in 180 ms at**757.2 MB/s sequential read** (512 MiB in 0.676 s — ~20× faster than microSD).\n\n### 6.5 How the A733 Open-Source NPU Compares Against Other Edge Platforms (`mobilenet_v1_1.0_224_quant.tflite`, INT8)\n\n| Platform / Accelerator | Driver Stack | MobileNetV1 INT8 | Notes | \n|---|---|---|---|\n| **Radxa Cubie A7A (A733, LPDDR5)***(measured)* | Mainline 7.1 `etnaviv` + Mesa Teflon (100% open-source) | **4.93 ms (203.0 FPS)** | Built-in 3.0 TOPS NPU, zero proprietary blobs | \n| **Radxa Cubie A7Z v2 (A733, LPDDR4/4X)***(measured)* | Mainline 7.1 `etnaviv` + Mesa Teflon (100% open-source) | **5.07 ms (197.3 FPS)** | 10.9% CPU, `Cosine=0.999958` (**191.3 FPS** with dual 1080p cams + ISP + H.265) | \n| **Google Coral USB (4 TOPS)***(published ref)* | Proprietary EdgeTPU compiler/runtime | ~5–7 ms (~140–200 FPS) | External ~$60 USB dongle (EOL) | \n| **Rockchip RK3588 (6 TOPS)***(published ref)* | Open-source Mesa Teflon (single-core) | ~10–11 ms (~90–100 FPS) | $100+ SBC; multi-core requires vendor RKNN blob | \n| **Raspberry Pi 5 (4× A76 CPU)***(published ref)* | TFLite XNNPACK CPU | ~10–15 ms (~67–100 FPS) | High CPU load; NPU requires ~$70 Hailo-8L HAT | \n| **Cubie A7Z v2 (CPU-only, 4T @ 2.0 GHz)***(measured)* | TFLite CPU | 13.44 ms (74.4 FPS) | 50.5% CPU (2.7× slower than its own NPU) | \n\nRunning **100% open-source Mainline Linux 7.1 + Mesa Teflon**, the $29–$39 Cubie A7Z v2 matches or beats a discontinued $60 Google Coral USB dongle and runs ~2× faster than single-core open-source RK3588 Teflon—while simultaneously handling dual 4-lane 1080p cameras, Hardware ISP 602, H.265 encoding, and 128 GB UFS 3.x storage.\n\n## 7. Why This Pattern Scales\n\nAdding a third A733 board—such as the **Radxa Cubie\nA7S**—takes four small steps instead of a whole new\ndistribution:\n\n1. Add `sun60i-a733-cubie-a7s.dts``#include \"sun60i-a733.dtsi\"` and append it to`BR2_LINUX_KERNEL_INTREE_DTS_NAME` .\n2. Add it to `boot.vfat` in`genimage.cfg` .\n3. Add an `elif` branch for`${fdtfile}` and a`dtoverlay_a7s=` entry in`boot.cmd` and`/boot/config.txt` .\n4. Flash one SD card and plug it into any A733 board on the bench.\n\n## Where to Grab the Code\n\n- **Boot Script, Config, Packaging & FIT Patcher** ([cubie-a5e](https://github.com/tcmichals/cubie-a5e) ):\n- **Device Tree Overlays** :\n- **Mainline Linux 7.1 Device Trees** ([linux-cubie\n(`a7a_remoteproc_camera_usb`)](https://github.com/tcmichals/linux-cubie) ):\n  - `arch/arm64/boot/dts/allwinner/sun60i-a733.dtsi`\n  - `arch/arm64/boot/dts/allwinner/sun60i-a733-cubie-a7a.dts`\n  - `arch/arm64/boot/dts/allwinner/sun60i-a733-cubie-a7z.dts`", "url": "https://wpnews.pro/news/mainline-linux-7-1-on-the-29-cubie-a7z-dual-4-lane-isp-and-open-npu", "canonical_source": "http://allthingsembedded.blogspot.com/2026/12/cubie-a7z-v2-boot-up-on-mainline-linux.html", "published_at": "2026-12-06 21:29:40+00:00", "updated_at": "2026-12-06 21:45:10.370048+00:00", "lang": "en", "topics": ["ai-chips", "ai-infrastructure", "computer-vision", "developer-tools", "artificial-intelligence"], "entities": ["Radxa", "Cubie A7Z", "Cubie A7A", "Allwinner A733", "Tim Michals", "Linux 7.1.0", "Sony IMX214", "VIP9000Nano-DI"], "also_reported_by": [], "takeaway": "A single 592 MiB sdcard.img can boot both the LPDDR5 Cubie A7A and LPDDR4/4X Cubie A7Z v2 by combining SPL DRAM auto-training, U-Boot GPADC/BOARD-ID-SEL-GPIO strap detection to set ${fdtfile}, and a boot.cmd overlay engine that selects the base .dtb and board .dtbo with automatic rollback.", "recommendation": {"advice": "When supporting multiple boards from one image, detect hardware straps in U-Boot to set ${fdtfile} and apply board-specific overlays with automatic rollback on error.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/mainline-linux-7-1-on-the-29-cubie-a7z-dual-4-lane-isp-and-open-npu", "markdown": "https://wpnews.pro/news/mainline-linux-7-1-on-the-29-cubie-a7z-dual-4-lane-isp-and-open-npu.md", "text": "https://wpnews.pro/news/mainline-linux-7-1-on-the-29-cubie-a7z-dual-4-lane-isp-and-open-npu.txt", "jsonld": "https://wpnews.pro/news/mainline-linux-7-1-on-the-29-cubie-a7z-dual-4-lane-isp-and-open-npu.jsonld"}}