cd /news/ai-chips/freeing-the-allwinner-a733-3-0-tops-… · home › topics › ai-chips › article
[ARTICLE · art-174419] src=github.com ↗ pub= topic=ai-chips verified=true sentiment=↑ positive

Freeing the Allwinner A733 3.0 Tops NPU Mainline Linux (Etnaviv and Mesa Teflon)

Developer Tim Michals documented bringing up the 3.0 TOPS Vivante VIP9000 NPU on Allwinner's A733 SoC under mainline Linux using the open-source etnaviv driver and Mesa Teflon, targeting the Radxa Cubie A7A (A733) and Cubie A5E (T527) boards. The write-up explains how the NPU splits work between fixed-function 8-bit NN cores and a programmable PPU/shader core, and how Linux dma-buf lets the camera, video encoder and NPU share one physical buffer for zero-copy frame processing. The effort matters because most SBCs keep this NPU locked behind a vendor 5.15 kernel, closed-source libVIPlite.so libraries and proprietary .nb model compilers.

recommendation

Use dma-buf to share camera and NPU buffers instead of copying frames through CPU memory, and offload non-convolution ops to the NPU's programmable PPU shader core.

more in playbook: Inference and self-hosting
read29 min views5 publishedNov 23, 2026
Freeing the Allwinner A733 3.0 Tops NPU Mainline Linux (Etnaviv and Mesa Teflon)
Image: Michielbdejong (auto-discovered)

By Tim Michals

Featured for Hackster.io — Open-Source Edge AI, Mainline Linux & Embedded Vision

Pick up almost any modern single-board computer and the headline spec jumps right off the box: "Octa-Core CPU + 3.0 TOPS AI NPU!" For robotics, smart cameras, and edge-vision projects, that promise sounds simple—plug in a camera, run a neural network, and detect objects in real time without needing a desktop GPU or sending video to the cloud.

Before diving into Linux drivers or silicon registers, it helps to step back and ask a simpler question: what is an AI accelerator actually doing, and why does a normal CPU struggle with it?

When a computer vision model looks at a camera frame—say, a 1920×1080 image—it doesn't "see" a person or a stop sign all at once. Instead, it passes the image through dozens of layers of convolution (CONV_2D).

A convolution is surprisingly simple: imagine taking a tiny 3×3 magnifying glass (called a kernel or filter) and sliding it across every single pixel of the image. At each stop, the computer multiplies those 9 pixel values by 9 learned weights and adds them up into one output number. Early layers look for simple things like vertical edges or bright spots; deeper layers combine those patterns into wheels, faces, or text. A single modern vision model might perform billions of these tiny multiply-and-add steps on every single frame—30 times a second. A general-purpose CPU is built for complex logic and branching, not doing billions of repetitive multiplies per second, so it quickly gets hot, burns power, and drops frames.

Models are usually trained on big server GPUs using 32-bit floating-point numbers (FP32—high-precision decimals). On a tiny embedded board, you don't need 32 bits of decimal precision just to tell a cat from a coffee mug. Quantization converts those FP32 weights and pixel values into compact 8-bit whole numbers (INT8 or UINT8, from -128..127 or 0..255).

Shrinking from 32-bit decimals to 8-bit integers makes each multiply-add circuit roughly 15–20× smaller and more power-efficient, and cuts memory traffic by 4×. When a chip advertises "3.0 TOPS" (Tera Operations Per Second), it means 3 trillion 8-bit integer operations per second—not 32-bit desktop floating point.

An NPU (Neural Processing Unit) isn't just one giant calculator. Real AI pipelines do more than convolutions: you also have to resize/normalize camera pixels before inference, or run custom math, activations, and image filters afterward. Inside modern NPUs like the Vivante VIP9000 on Allwinner's A733, the silicon is split into two complementary helpers:

  • NN (Neural Network) Cores : Fixed-function hardware arrays packed with hundreds of 8-bit multipliers. They are unbeatable at convolutions, but theycannot run arbitraryif/else code or general math.
  • PPU / Shader Core : A small programmable parallel processor (like a mini compute GPU) that runs short parallel programs (shaders ) across hundreds of pixels or tensor elements at once—handling custom math, image pre/post-processing, and ops the fixed-function NN cores don't support.

Even with a fast NPU, copying a 1080p camera frame from the camera driver into CPU memory, converting it, and copying it back to the NPU wastes huge amounts of memory bandwidth. On Linux, dma-buf lets the camera hardware, video encoder, and NPU share the exact same physical memory buffer—so frames move from camera to NPU with zero CPU copies.

Most SBCs lock this NPU hardware inside an old vendor kernel (5.15), closed-source userspace libraries ( libVIPlite.so), and proprietary offline .nb model compilers. On the Radxa Cubie A7A (Allwinner A733) and Cubie A5E (Allwinner T527), we set out to unlock this stack on 100% open-source mainline Linux 7.1 using the upstream etnaviv DRM driver (/dev/dri/renderD128), Mesa 26.1.8 Teflon ( libteflon.so, which runs standard .tflite models directly), and V4L2 dma-buf zero-copy camera pipelines.

Real silicon bring-up is messy, and this article shares the whole journey—what already works on live Cubie A7A hardware (PPU shader compute at 0.059–0.396 ms, zero-copy V4L2 /dev/video0 and CMA dma-buf -> NPU PRIME at 0.401–0.487 ms, and ov5647 CSI + Cedrus H.265 video), as well as the open HW_V83 NN conv2d DRAM-read investigation still underway.

Running AI locally on the board ("at the edge") instead of in the cloud delivers sub-millisecond latency (critical for robotics and drones), privacy (camera feeds never leave the device), offline reliability, and high performance per watt:

  • CPU : Great for operating systems, networking, and branching logic (if/else ); poor at billions of repetitive matrix multiplies.
  • GPU : Built for 32-bit floating-point graphics and parallel math, but power-hungry and absent or small on many headless embedded SoCs.
  • NPU : Purpose-built for quantized 8-bit neural network math and on-chip SRAM dataflow at a fraction of the power.

If you want to go deeper—or help crack the remaining open HW_V83 NN bring-up items—these companion guides cover each layer of the stack:

If you have ever deployed a computer vision model (like YOLOv8, MobileNetV2, or PoseNet) on an embedded Linux single-board computer, you have felt the wall that general-purpose CPU cores hit when processing real-time 1080p video.

Even on a modern octa-core processor like the Allwinner A733 (2× Arm Cortex-A76 @ 2.0 GHz + 6× Cortex-A55 @ 1.8 GHz, powering the Radxa Cubie A7A) or the Allwinner T527 (8× Cortex-A55 @ 1.8 GHz, powering the Radxa Cubie A5E), running millions of multiply-accumulate operations per frame on the CPU means:

  • Burning 3–5 Watts of CPU thermal budget on matrix math instead of application logic.
  • Saturating the CPU's L1/L2 caches and external DRAM bus by repeatedly fetching weights and writing intermediate feature maps.
  • Dropping frames whenever the CPU also has to handle camera capture, H.264/H.265 video encoding, or network streaming.

To solve this, silicon designers place a dedicated Neural Processing Unit (NPU) right on the SoC die. On the Allwinner A733 (verified on live Radxa Cubie A7A silicon), that NPU is a 3.0 TOPS-class VeriSilicon Vivante VIP9000Nano-DI (npu@3600000, model 0x9000, rev 0x9202, HW_V83); on the Allwinner T527, it is a 2.0 TOPS VeriSilicon Vivante VIP9000Nano-SI+ (npu@7120000, rev 0x9003).

Unlike a CPU (which fetches scalar or small SIMD instructions one by one) or a GPU (which runs general-purpose 32-bit floating-point shaders), a neural network accelerator is a spatial dataflow engine purpose-built around four hardware principles:

8-Bit Quantized Tensor Math (INT8 / UINT8) : Neural networks trained in 32-bit floating point (FP32 ) are quantized to 8-bit integers (INT8 orUINT8 ) using per-tensor or per-channel scale and zero-point parameters. An 8-bit integer multiply-accumulate (MAC ) circuit takes roughly15–20× less silicon area and switching energy than anFP32 fused multiply-add, allowing the A733 NPU to pack8 parallel NN cores × 64 MADs/core (with ZDP3 spatial reuse, delivering up to3.0 TOPS marketed peak at high OPP clocks) into a compact silicon footprint. 2. Spatial Weight & Activation Broadcast Across 8 NN Cores : In a 2D convolution ($3 \times 3$ or$1 \times 1$ ), the exact same kernel weights slide across thousands of$(x, y)$ pixel locations, while the same input pixel patch is multiplied against dozens of output channels. Instead of reading weights from DRAM over and over, the NPU loads weights and input tiles once into512 KB of ultra-wide on-chip VIP SRAM (128 bytes / 1024 bits per cycle physical width on the A733) and broadcasts them simultaneously across its8 Neural Network (NN) cores . 3. On-the-Fly Hardware Weight Decompression (Huffman + ZRL) : Neural network weights contain large runs of zeros and clustered small integer values. When a model is loaded, its weights are compressed usingHuffman coding and Zero-Run-Length (ZRL) encoding. Inside the NPU, a dedicated hardware bitstream decoder decompresses weights as DMA streams them from LPDDR5—cutting external memory bandwidth by2–4× with zero CPU overhead. 4. Fused Hardware Pooling, Activation & Requantization : Before a partial sum ever leaves an NN core, dedicated inline stages apply 32-bit bias addition, non-linear activation (ReLU ,ReLU6 ,Clamp ),$2 \times 2$ max or average pooling, and 8-bit requantization in a single pass. On SoCs with a dedicatedTensor Processor (TP) (such as the T527), layout transposes and LUT activations run on TP cores; on the A7330x9202 (TP_ENGINE = 0 ), non-NN ops fall to the companionProgrammable Shader / PPU core (NumShaderCores = 1 ) or CPU.

A common misconception is that an "NPU" is one single black-box circuit. On the Allwinner A733 (VIP9000Nano-DI, rev 0x9202), the block at 0x03600000 is actually a two-engine heterogeneous compute cluster sharing one Front-End DMA parser and MMUv2:

  • 8× NN Cores (Fixed-Function Convolution Arrays) : Ultra-dense INT8 multiply-accumulate hardware (512 MACs/cycle). Blazing fast forCONV_2D ,DEPTHWISE_CONV_2D , andFULLY_CONNECTED (90%+ of a YOLO or MobileNet backbone),but unable to run general-purpose code (if/else , float32 math, FFTs, image filters, or bounding-box NMS).
  • 1× PPU / Shader Core (Programmable Processing Unit, 256 Hardware Threads) : Ashader is simply a small parallel program (OpenCL / SIMD vector kernel) that executes across hundreds of pixels or tensor elements simultaneously—like a mini compute GPU bolted onto the NPU die. It handles everything fixed-function NN cores cannot: float32/fp16 math, image pre/post-processing, optical flow, custom activations, and tensor layout shuffles.
  • No Dedicated TP Engine (TP_ENGINE = 0) : Older Vivante NPUs (T527 0x9003 , i.MX8MP0x8002 ) included a third dedicatedTensor Processor (TP) to transpose tensors (NHWC ↔ NCHW ) and run LUT activations. On A7330x9202 , Vivante removed the TP hardware to save die area—making software support forboth the NN engine (Path A) and PPU/CPU ops (Path B) essential.

Real edge-vision and robotics pipelines are never 100% convolutions. Matching each stage to the right silicon block on the A733 is why this dual-path mainline stack matters:

A common pitfall when reading vendor headers is guessing which gc_feature_database.h row matches an SoC without checking silicon. Before booting the A7A, it was easy to assume the A733 carried Allwinner's 12-core 0x9113 (VIP9000UL-DI+) block—live hardware readback on the Radxa Cubie A7A (/sys/kernel/debug/dri/0/gpu) proved the A733 silicon is actually model 0x9000, revision 0x9202 (product_id 0x05090009, customer_id 0x1000003b, eco_id 0x08000000, chip date 2023-05-18) — VeriSilicon VIP9000Nano-DI (HW_V83, VIP_VERSION 0x398).

Live silicon register readbacks and VeriSilicon's hardware feature database (allwinner/gc_feature_database.h) highlight the exact architectural differences between the A733 and T527:

Traditionally, using a Vivante VIP9000 NPU on an Allwinner SoC meant accepting a locked-down vendor BSP stack:

  • Kernel Space : A ~44,000-line out-of-tree kernel module (vipcore.ko orgalcore.ko exposing/dev/vipcore or/dev/galcore ) that breaks on every minor Linux kernel upgrade (EXTRA_CFLAGS removal,in_irq() deprecation,MAX_ORDER rename,platform_driver``.remove signature changes).
  • Userspace : Precompiled closed-source shared libraries (libVIPlite.so ,libVIPuser.so , orTIM-VX ) tied to a specific glibc/Android ABI.
  • Offline Model Lock-In : You cannot load a standard.tflite model directly. Instead, you must run a proprietary x86 offline compiler (acuity-toolkit /pegasus ) to convert your model into a locked.nb (network_binary.nb ) blob tailored to a single chip revision.

To run on mainline Linux 7.1 with zero binary blobs, we replaced the entire vendor stack with upstream open-source components:

To be fair to the vendor stack, Allwinner and VeriSilicon's proprietary tools (ACUITY + .nb + libVIPlite.so / libNBGlinker.so + Allwinner awnn) exist for a reason and do offer real advantages today when running on the vendor 5.15 BSP:

  • Ahead-of-Time Whole-Graph Optimization (.nb) : ACUITY compiles ONNX, PyTorch, or TFLite models offline on an x86 PC into a pre-scheduled.nb binary—eliminating runtime graph compilation overhead and fusingConv + Bias + ReLU + Pool aggressively.
  • Hardware Weight Compression & VIP SRAM Tiling :ACUITY emitsHuffman + Zero-Run-Length (ZRL) compressed weights (2–4× less LPDDR5 traffic) and statically tiles intermediate feature maps inside the512 KB on-chip VIP SRAM across consecutive layers so tensors stay on-die instead of bouncing through external DRAM.
  • Broader Operator & Precision Coverage : SupportsINT8 ,UINT8 , andINT16 , custom OpenVX/PPU kernels, and turnkey Allwinnerawnn /vpm_run demos (YOLOv5 ,YOLOv8 , face/pose) out of the box.

Can we use libVIPlite.so, ACUITY, or awnn inside our open-source mainline stack? No — not directly. libVIPlite.so, libNBGlinker.so, awnn, and the ACUITY compiler are closed-source proprietary binaries tied to the out-of-tree /dev/vipcore ioctl ABI (not Linux DRM /dev/dri/renderD128), and vipcore.ko cannot be upstreamed into mainline Linux.

Wait—doesn't ACUITY need an x86 PC? Can open source actually match its speed on the board? VeriSilicon ships ACUITY as an x86-only offline tool largely for convenience and IP protection, not because the Arm SoC can't do the graph compilation. Compressing quantized weights (Huffman/ZRL), planning 512 KB VIP SRAM tiles, and building the command stream take a fraction of a second once at model-load time on the A733's Cortex-A76/A55 cores (and can be cached to disk so subsequent runs load in milliseconds)—no x86 Docker container required.

Because all of the underlying capabilities (Huffman/ZRL weight compression, VIP SRAM tiling, multi-layer batching, and PPU shaders) are hardware features of the VIP9000 die, we are still resolving the HW_V83 NN DRAM-read issue first, and our next steps are to bring those exact optimizations clean-room into MIT-licensed Mesa etnaviv / Teflon so the open-source stack can match proprietary .nb performance without binary blobs or kernel lock-in.

To understand what happens inside the silicon at 0x03600000 when an AI inference job runs—and why specific clock, reset, and MMUv2 registers had to be unlocked for the Allwinner A733—let's trace the internal hardware blocks from the power rail down to the 8 NN cores.

Before a single register at 0x03600000 responds to CPU reads, three hardware prerequisites must be satisfied in strict order:

Power Supply & Silicon Island (AXP8191 dcdc2 + PCK-600 PD_NPU) :

  • The external vdd-gpu-npu power rail is driven by theAXP8191 PMIC dcdc2 buck converter (800 mV at 492–852 MHz boot nominal, scaling up to960–1080 mV at 1008–1120 MHz OPP bins).
  • Inside the A733 SoC, the PCK-600 Power Controller (7060000.power-controller ) controls power isolation for the NPU island via domain**PD_NPU (id 4, pstate=0x8, on)** . When etnaviv callspm_runtime_resume_and_get() , Linuxgenpd powers onPD_NPU and releases isolation clamps.
  1. The external

The 4-Clock Tree in Mainline ccu-sun60i-a733.c : #

CLK_NPU (0x0b00, "core") : The high-speed compute clock driving the 8 NN cores and 512 KB VIP SRAM (840 MHz default frompll-npu , muxable acrosspll-npu ,pll-periph0-800M/600M/480M ,pll-ve0 ,pll-ve1 ,pll-de-3x ) with a 5-bit divider (M ) and gateBIT(31) . #

CLK_AHB_NPU (0x05c0 bit 6) CLK_BUS_NPU (0x0b04 bit 0, "reg", 200 MHz) : On the A733, CPU register reads/writes to$\rightarrow$ 0x03600000 traversetwo series AHB clock gates : the top-level NPU AHB master gate (0x05c0 bit 6) and the NPU module bus gate (0x0b04 bit 0). Indrivers/clk/sunxi-ng/ccu-sun60i-a733.c , we parentedbus_npu_clk (CLK_BUS_NPU ) directly toahb_npu_clk (CLK_AHB_NPU ). That way, whenetnaviv enables its"reg" clock, the Linux Common Clock Framework automatically enablesboth0x05c0[6] and0x0b04[0] . #

CLK_MBUS_NPU (0x05e0 bit 18, "bus", 600 MHz) : Gates the 128-bit AXI/MBUS DMA master port, parented tombus_clk (600 MHz , synced with Junhui Liu's upstream A733 CCUv7 patch series). IfCLK_MBUS_NPU is left gated, MMIO register reads work fine, but the NPU's DMA engine stalls forever the moment it tries to fetch its first command buffer from LPDDR5! 4. 5. Triple Reset Lines (0x0b04 bits 16, 17, 18) :

  • Unlike the T527 (which has a single RST_BUS_NPU bit), A733 register0x0b04 splits the NPU reset into active-low lines:RST_BUS_NPU_CORE (BIT(16)) , RST_BUS_NPU_AXI (BIT(17)) , RST_BUS_NPU_AHB (BIT(18)) (plus RST_BUS_NPU_SRAM atBIT(19) , read back as0x000F0000 deasserted on silicon).
  • Mainline etnaviv previously calleddevm_reset_control_get_optional() , which only supports a single reset line. By switchingetnaviv_gpu_platform_probe() todevm_reset_control_array_get_optional_exclusive(&pdev->dev) (and updatingvivante,gc.yaml tomaxItems: 3 ),etnaviv cleanly asserts and deasserts all three reset lines as a unit.
  1. Unlike the T527 (which has a single

How does the NPU execute a multi-layer neural network without CPU intervention between layers?

At the front of the NPU sits the Front-End (FE) Command Parser. It is a dedicated DMA state machine that reads 64-bit instructions (LOAD_STATE, END, NOP, WAIT, LINK, STALL) directly from system memory:

Why ETNA_SEC_KERNEL (0x003A4) Is Mandatory : The VIP9000Nano-DI ( 0x9202 ) implements Vivante's Security AHB feature (MINOR_FEATURES7_BIT_SECURITY +MINOR_FEATURES10_SECURITY_AHB ). On this hardware, the legacyVIVS_FE_COMMAND_CONTROL (0x00658 ) kick register is a no-op. By adding the Allwinner0x9000 NPU entries (0x8303 ,0x9003 ,0x9113 ,0x9202 ) to the kernel'setnaviv_hwdb.c ,etnaviv enablesgpu->sec_mode = ETNA_SEC_KERNEL : it unlocks non-secure register writes at0x003A8 , writes the command buffer address toVIVS_FE_COMMAND_ADDR (0x00654 ), and starts the FE via**VIVS_MMUv2_SEC_COMMAND_CONTROL (0x003A4)** .

Every memory address inside an NPU job—the command buffer, compressed weights, bias tables, input feature maps, and output tensors—is a 32-bit NPU Virtual Address (NPU_VA).

Two-Level Page Walk (PTA MTLB STLB) :$\rightarrow$ $\rightarrow$

  • The NPU's internal MMUv2 translates every 32-bitNPU_VA into a40-bit LPDDR5 Physical Address (PA) using a Page Table Array ( PTA at0x0038C /0x00390 ), a 1024-entry Master TLB (MTLB , bits[31:22] ), and 1024-entry Slave TLB page tables (STLB , bits[21:12] , 4 KB pages).
  • Because the MMU translates scatter-gather physical pages into a contiguous virtual range, large neural network weight buffers do not need physically contiguous CMA memory—standard paged Linux GEM buffers work out of the box.
  1. The NPU's internal

The Revision 0x9202 MMU_PAGE_DESCRIPTOR (PDMODE) Architecture ( 0x003B4, 0x00388, 0x00184) :

  • On older Vivante cores like the T527 (0x9003 ),etnaviv_iommuv2_restore_sec() initializes MMUv2 via a Page Table Array (PTA at0x0038C /0x00390 /0x00394 ), runs a physical-mode FE command buffer (load_state(VIVS_MMUv2_PTA_CONFIG) ), and writes0x00388 = 0x01 .
  • On the A733 (0x9202 ), VeriSilicon enabled**MMU_PAGE_DESCRIPTOR = 1** ( mmu_pd_mode = 1 in Allwinner'svip_drv_hardware.c ). Instead of PTA indirection, the kernel writes the 4 KB Master TLB physical frame directly to**0x003B4 = ((mtlb_dma >> 12) << 4) | MODE4_K** (bit 0 = 0 foretnaviv 's 4 KB MTLB / 4 MB per-MTLB layout, vs1 for 1 KB / 16 MBMODE1_K ), skipsPTA_CONTROL , configures0x0055C = 0x00FFFFFF (MC_L2_CACHE_CONFIG ) and0x00090 |= BIT(6) (bypass_reorder ), and enables PDMODE via**0x00388 = 0x21** ( BIT(5) | ENABLE ).

Subtle TLB Flush Trap in etnaviv_buffer.c : Mainline etnaviv flushes the MMUv2 TLB by writing0x00000018 (MODE_MASK | FLUSH ) toVIVS_MMUv2_CONFIGURATION (0x00184 )—which leaves bit 8 (ADDRESS_MASK ) as0 , zeroing the MTLB base address under PDMODE! Matching Allwinner'svip_drv_mmu.c , PDMODE flushes must write**0xffffff7f** ( ADDRESS_MASK = 1 ,MODE_MASK = 1 ,FLUSH_MASK = 0 ,FLUSH = 1 ) so dynamic BO mappings flush the TLB without clobbering the page-table base. 4. On older Vivante cores like the T527 (

Once the FE parses a layer kick (VIVS_PS_NN_INST_ADDR at 0x010A0 + VIVS_PS_UNK10A4 at 0x010A4), the actual tensor math runs across the internal blocks wired to the 512 KB on-chip VIP SRAM:

  • 8 Parallel NN Cores (HW_V83, VIP_VERSION = 0x398) : The NN cluster fetches a 128-byte descriptor fromVIVS_PS_NN_INST_ADDR , streams compressed weights from LPDDR5 into the512 KB VIP SRAM (128-byte physical width, mapped viaVIVS_GL_OCB_REMAP_START/END ), and executes64 MADs/core across all8 NN cores in parallel (32 lanes/output cycle ). On0x9202 , VeriSilicon enabled**HW_V83** , NN_SMALL_BATCH_PHASE2 = 1 , NN_TENSOR_ADD_FIELD_MOVE_TO_EXT_CMD = 1 , and** ZRL_8BIT = 0** .
  • 1 Programmable Shader / PPU Core (No Dedicated TP Block) : Unlike the T527 (2 TP cores ), the A733's0x9202 silicon sets**TP_ENGINE = 0** and** TPEngine_CoreCount = 0** . All non-NN tensor manipulation (such as NHWC ↔ NCHW layout transpose, padding, or custom elementwise activations) must execute on the singleUSC / PPU Shader core (256 threads ,64 temp regs ,512 instructions ) or the Arm CPU—a key architectural difference that surfaced immediately during our live Mesa Teflon bring-up below.

How does a Python script or C/C++ application a standard .tflite file end up driving 8 NN cores through /dev/dri/renderD128? The software stack is cleanly split into four layers.

Your application uses the standard TensorFlow Lite C API (<tensorflow/lite/c/c_api.h>) or Python tflite_runtime. You do not link against any proprietary NPU SDK. Instead, you load Mesa's /usr/lib/libteflon.so as a standard TFLite external delegate plugin (tflite_plugin_create_delegate):

#include <dlfcn.h>
#include <tensorflow/lite/c/c_api.h>

typedef TfLiteDelegate* (*create_delegate_fn)(char**, char**, size_t,
                                              void (*)(const char*));
typedef void (*destroy_delegate_fn)(TfLiteDelegate*);

void run_npu_inference(const char *model_path) {
    /* 1. Dynamically load Mesa's open-source Teflon TFLite delegate */
    void *teflon_so = dlopen("/usr/lib/libteflon.so", RTLD_LAZY);
    create_delegate_fn create_delegate =
        (create_delegate_fn)dlsym(teflon_so, "tflite_plugin_create_delegate");
    destroy_delegate_fn destroy_delegate =
        (destroy_delegate_fn)dlsym(teflon_so, "tflite_plugin_destroy_delegate");

    TfLiteDelegate *npu_delegate = create_delegate(NULL, NULL, 0, NULL);

    /* 2. Attach the NPU delegate to TFLite InterpreterOptions */
    TfLiteModel *model = TfLiteModelCreateFromFile(model_path);
    TfLiteInterpreterOptions *opts = TfLiteInterpreterOptionsCreate();
    TfLiteInterpreterOptionsAddDelegate(opts, npu_delegate);

    /* 3. Create interpreter: Teflon partitions supported INT8/UINT8 subgraphs */
    TfLiteInterpreter *interp = TfLiteInterpreterCreate(model, opts);
    TfLiteInterpreterAllocateTensors(interp);

    /* 4. Fill input tensor, run on the 3.0 TOPS NPU, read output tensor */
    TfLiteInterpreterInvoke(interp);

    TfLiteInterpreterDelete(interp);
    TfLiteInterpreterOptionsDelete(opts);
    TfLiteModelDelete(model);
    destroy_delegate(npu_delegate);
    dlclose(teflon_so);
}

Or in Python (ctypes or tflite_runtime):

When TfLiteInterpreterCreate() and TfLiteInterpreterAllocateTensors() execute:

DRM Render Node Discovery : Teflon opens/dev/dri/renderD128 viapipe__drm_probe_fd() and instantiates a Galliumpipe_screen andpipe_context backed byetnaviv . 2. Automatic Graph Partitioning (Prepare) : Teflon walks every node in the.tflite flatbuffer graph. Supported quantized (INT8 /UINT8 ) operators—CONV_2D , DEPTHWISE_CONV_2D , FULLY_CONNECTED (lowered to$1 \times 1$ convolution), ADD , AVERAGE_POOL_2D , MAX_POOL_2D , PAD , LOGISTIC , and fused** RELU / RELU6** —are claimed by the Teflon delegate and merged into contiguous NPU subgraphs. Any unsupported operator (such as a finalSOFTMAX dequantization node) automatically remains on the Arm CPU. 3. Lowering to Gallium ML : Teflon converts the partitioned TFLite subgraph into an array of hardware-agnostic Galliumstruct pipe_ml_operation descriptors and hands them tocontext->ml_subgraph_create() .

Inside Mesa's etnaviv driver, the neural network subgraph is compiled directly into VIP9000 hardware descriptors, compressed weight bitstreams, and FE command buffers:

  1. Silicon Feature Database Lookup (allwinner/gc_feature_database.h) :
  • At screen creation, Mesa queries the kernel via DRM_IOCTL_ETNAVIV_GET_PARAM forMODEL (0x9000 ),REVISION (0x9202 ),PRODUCT_ID (0x05090009 ),CUSTOMER_ID (0x1000003b ), andECO_ID (0x08000000 ).
  • etna_query_feature_db() insrc/etnaviv/hwdb/etna_hwdb.c looks up the exact silicon row insrc/etnaviv/hwdb/allwinner/gc_feature_database.h and configures the compiler for the A733's**nn_core_count = 8** , nn_mad_per_core = 64 , on_chip_sram_size = 524288 (512 KB) , physical_vip_sram_width = 128 (128 bytes/cycle) , nn_zdp3 = true , and** nn_lanes_per_out_cycle = 32** .
  • The TP_ENGINE = 0 Discovery on Live 0x9202 Silicon : Earlier Mesa patches forcedinfo->npu.tp_core_count = db->TPEngine_CoreCount ? db->TPEngine_CoreCount : 1; assuming a single TP unit existed wheneverTPEngine_CoreCount was0 . Live silicon testing on the A7A (0x9202 , where**gcFEATURE_BIT_TP_ENGINE = 0** and** TPEngine_CoreCount = 0** ) proved that the hardware truly hasno TP engine — TP transpose/detranspose ops become silent no-ops, leaving intermediate and final buffers zeroed unless lowered to the PPU shader core or CPU!
  1. At screen creation, Mesa queries the kernel via
  2. One-Time Compilation During AllocateTensors() (etna_ml_subgraph_create) :
  • Hardware Transpose & Channel Reshuffle Insertion (etnaviv_ml_tp.c) : Whenever an input or output tensor layout requires realignment between TFLite'sNHWC and the NN engine'sNCHW , Mesa wraps the graph with transpose/detranspose stages (which use hardware TP cores on T5270x9003 , and need a PPU shader / CPU fallback on A7330x9202 ).
  • V8 Superblock Tiling & Weight Compression (etnaviv_ml_nn_v8.c) : Filter weights and biases are tiled into V8 superblocks matched to8 NN cores and the512 KB VIP SRAM , compressed into a bitstream, and uploaded into a write-combined GEM buffer object (coefficients ).
  • Command Stream Generation (etnaviv_ml.c) : Mesa records the entire sequence of FE register writes (VIVS_GL_OCB_REMAP_START/END ,VIVS_GL_NN_CONFIG ,VIVS_PS_NN_INST_ADDR ,VIVS_PS_UNK10A4 , andVIVS_GL_FLUSH_CACHE barriers).
  1. Zero-Recompile Inference During Invoke() (etna_ml_subgraph_invoke) :
  • Every call to TfLiteInterpreterInvoke() simply updates the input tensor BO, submits the pre-compiled command stream viaDRM_IOCTL_ETNAVIV_GEM_SUBMIT , and waits on the hardware fence viaDRM_IOCTL_ETNAVIV_WAIT_FENCE .
  1. Every call to

In kernel space, etnaviv provides:

  • Unprivileged Compute Access (/dev/dri/renderD128) : AI applications run as normal non-root users via the DRM render node.
  • Per-Process MMUv2 Isolation & dma-buf PRIME Import : Every process gets isolated MMUv2 page tables, and camera/video buffers from V4L2 or G2D can be imported directly into NPU virtual memory viaDRM_IOCTL_PRIME_FD_TO_HANDLE .
  • DRM GPU Scheduler (drm_gpu_scheduler) & Runtime PM : Fair job scheduling, hardware hang detection with automatic triple-reset recovery, and runtime power gating ofPD_NPU when idle.

🎥 5. Zero-Copy Video Processing: Connecting MIPI CSI-2, ISP 602, Hardware H.264/H.265 VE, and the 3.0 TOPS NPU #

In a real vision application—an autonomous drone, agricultural sprayer, security camera, or industrial inspection rig—the NPU does not live in isolation. It consumes live video frames from a camera while a video encoder simultaneously records or streams those frames over RTSP/WebRTC.

If the CPU had to copy every 1080p (1920 × 1088) NV12 frame (3.13 MB/frame, or ~94 MB/s at 30 fps) between the camera driver, the H.265 video encoder, and the NPU preprocessor, memcpy() and cache flushes alone would saturate an entire CPU core.

On the Allwinner A733 (Radxa Cubie A7A), we eliminate CPU frame copies by passing Linux dma-buf file descriptors allocated in shared LPDDR5 CMA memory directly across all hardware engines:

  1. MIPI CSI-2 Sensor (OV5647) & D-PHY ( 0x05800000) : The camera sensor streams 10-bit Raw Bayer ( SRGGB10_1X10 ) at1920 × 1080 @ 30 fps over a 2-lane MIPI CSI-2 link into the A733 combo D-PHY and CSI0 receiver (0x05811000 ).
  2. In-Line Hardware ISP 602 (0x05809400, sun60i-isp) : Running in on-the-fly ( online ) mode directly from the CSI parser FIFO at~148.5 Mpixels/s , theHardware ISP 602 performs black-level correction, lens shading, 2D noise reduction, Bayer demosaicing, color correction (CCM ), gamma, and RGB-to-NV12 color space conversion in dedicated silicon (0% CPU ). Userspaceaw-isp-2a runs only once per frame (30 Hz) to read compact 3A histogram statistics and update sensor exposure/gain over I²C.
  3. CSI DMA0 (0x05813000, /dev/video0) : Writes stride-aligned 1920 × 1088 planar**NV12** frames ( Y luma + interleavedUV chroma) directly into contiguous LPDDR5 CMA ring buffers (vb2-dma-contig ) and exports each buffer as a**dma-buf PRIME file descriptor** viaVIDIOC_EXPBUF .

When V4L2 dequeues a completed camera frame (VIDIOC_DQBUF), userspace hands the dma-buf FD to three hardware blocks in parallel without copying the 3.13 MB frame on the CPU:

Branch A — Hardware H.264 / H.265 Video Encoding (ve@1c10000, < 1.6% CPU) :

  • The V4L2 dma-buf FD is imported directly into theAllwinner A733 Video Engine (ve@1c10000, VE300 / V3102_0016) with VE_BUFFER_FLAG_DMA_BUF .
  • The VE's internal hardware CSI / ISP preprocessor (+0xA00) and** AVC (+0xB00) / HEVC (+0xC00) encoder sub-engines** read the Y andUV planes directly from the camera CMA buffer over the 128-bit MBUS DMA port (CLK_MBUS_VE at 600 MHz).

Measured Hardware Performance on Radxa Cubie A7A : - 1080p30 H.264 (AVC) Hardware Encoding :3.09 ms/frame (323.5 fps max throughput),0.89% total system CPU usage . - 1080p30 H.265 (HEVC) Hardware Encoding :6.34 ms/frame (157.8 fps max throughput),1.55% total system CPU usage . #

  1. The V4L2

Branch B — 3.0 TOPS-Class VIP9000Nano-DI NPU Inference (npu@3600000) :

  • Simultaneously, the NPU processes the detection tensor (e.g. 640 × 640 × 3 or320 × 320 × 3`` UINT8 /INT8 ).
  • Using Allwinner's G2D 2D hardware blitter (g2d@1480000 — hardware YUV-to-RGB color conversion + bilinear downscaler accepting the source V4L2dma-buf FD and writing directly into anetnaviv GEMdma-buf BO viadrmPrimeFDToHandle() ), or a fast NEON stride-gather into the write-combined Teflon input BO, the input tensor is mapped into the NPU'sMMUv2 (0x00388) page table.
  • Calling TfLiteInterpreterInvoke() runs the pre-compiledTeflon command stream across the8 NN cores and512 KB VIP SRAM , outputting bounding boxes, class IDs, and confidence scores while the Arm cores remain largely idle.
  1. Simultaneously, the NPU processes the detection tensor (

Branch C — Hard Real-Time Actuation on the On-Die 200 MHz RISC-V Core (rproc@7032000) :

  • When the NPU detects a target $(\Delta x, \Delta y, \text{class}, \text{confidence})$ , Linux writes a 16-byte setpoint intoSystem SRAM A2 (0x00044000) and rings theHardware MSGBOX0 ( 0x07033000) doorbell.
  • Within 14.47 µs , the on-die200 MHz XuanTie E902 RISC-V coprocessor updates its bare-metal PID / motor control loop with zero Linux scheduling jitter (see our companion Hackster.io guide onUnlocking the On-Die 200 MHz XuanTie RISC-V Core ).
  1. When the NPU detects a target

Here is the exact Device Tree, Kernel, Buildroot, and verification setup used on the Radxa Cubie A7A (Allwinner A733) in this repository.

In arch/arm64/boot/dts/allwinner/sun60i-a733-cubie-a7a.dts, we define the NPU node at 0x03600000 with its 3 clocks (bus, core, reg), 3 reset lines ( core, axi, ahb), PCK-600 power domain ( PD_NPU), and the AXP8191 dcdc2 (vdd-gpu-npu) regulator:

npu: npu@3600000 {
    compatible = "vivante,gc";
    reg = <0x03600000 0x1000>;
    interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
    clocks = <&ccu CLK_MBUS_NPU>,
             <&ccu CLK_NPU>,
             <&ccu CLK_BUS_NPU>;
    clock-names = "bus", "core", "reg";
    resets = <&ccu RST_BUS_NPU_CORE>,
             <&ccu RST_BUS_NPU_AXI>,
             <&ccu RST_BUS_NPU_AHB>;
    reset-names = "core", "axi", "ahb";
    power-domains = <&pck600 PD_NPU>;
    #cooling-cells = <2>;
};

Because the VIP9000Nano-DI (0x9202) combines a programmable Vivante PPU (OpenCL/Shader) core with an 8-core HW_V83 Neural Network (NN) engine, we validate and expose both compute paths on /dev/dri/renderD128 for different workloads:

  • Path A — Neural Network Inference (Mesa 26.1.8 Teflon + 8× NN Cores) : Zero-compile TFLite delegation for quantized CNNs (CONV_2D ,DEPTHWISE_CONV_2D ,FULLY_CONNECTED ).
  • Path B — General-Purpose Compute (etnaviv DRM + Vivante PPU Shader Core) : Low-latency custom kernels (npu_ppu_compute_test.c ) for image pre/post-processing, DSP math, or custom non-CNN algorithms.

Booting our mainline Linux 7.1.0 PREEMPT_RT Buildroot image on the Radxa Cubie A7A confirmed full kernel bring-up and live PPU + NN execution:

dmesg | grep -iE "etnaviv|npu"

cat /sys/kernel/debug/dri/0/gpu

Path B — Vivante PPU Compute Shader (npu_ppu_compute_test.c) : Executing a 28-DWORD cold-boot-deterministic Vivante PPU compute shader (img_load.u8$\rightarrow$ lshift.s32$\rightarrow$ rshift.s32$\rightarrow$ i2f.s32$\rightarrow$ mov t2, u2$\rightarrow$ mul$\rightarrow$ img_store.u8 ) directly on3600000.npu viaDRM_IOCTL_ETNAVIV_GEM_SUBMIT completed in**0.052–0.950 ms** per dispatch across10/10 consecutive runs with0 MMU faults ,0 hangs , clean**GIC_SPI 65** interrupts, andbit-exact IEEE-754 float32 outputs across all tested inputs: #

fill = 1$\rightarrow$ 0x3d808000 (0.062744 ) #

fill = 2$\rightarrow$ 0x3e008000 (0.125488 ) #

fill = 3$\rightarrow$ 0x3e40c000 (0.188232 ) #

fill = 5$\rightarrow$ 0x3ea0a000 (0.313721 ) #

fill = 7$\rightarrow$ 0x3ee0e000 (0.439209 ) 2. 3. Zero-Copy V4L2 / CMA dma-buf PRIME npu_v4l2_dmabuf_test.c) : Exporting a V4L2 capture buffer via$\rightarrow$ NPU PPU Shader (VIDIOC_EXPBUF (/dev/video0 ,0.206 ms ) or allocating a CMA dma-heap buffer (/dev/dma_heap/default_cma_region ,0.220 ms ) and importing it into etnaviv viaDRM_IOCTL_PRIME_FD_TO_HANDLE executed the PPU compute shader directly on the video buffer withbit-exact IEEE-754 float32 output (0x3ea0a000) and zero CPU memcpy . 4. Path A — Live Silicon Reverse-Engineering of HW_V83 (0x9202) NN Descriptors (WIP) : Comparing0x9202 against every other NPU in Mesa's HWDB revealed that Allwinner A733 is thefirst chip in Mesa combining four new VivanteHW_V83 features. Live register and descriptor sweeps on the Cubie A7A proved every single bitfield on silicon: #

FP_INIMAGE_POST_SCALE = 1 (NN_INT8_SCALE = 0) : On earlier V8 chips (e.g. Amlogic 0x8302 ), Mesa wroteshift = 127 - exp (e.g.8 ) intopost_shift . On0x9202 ,HW_V83 interpretspost_shift (w2[31:27] +w15[29:28] +w15[30] ) as theraw IEEE-754 biased exponent (scale_bits >> 23, e.g. 119/ 120) , paired with the 23-bit mantissa in post_multiplier* (w22[25:18] ,w17[31:24] ,w15[27:22] ,w2[26] ) and sign bit inw27[28] . Writing8 multiplied every accumulator by$2^{8-127} \approx 0$ (producing0 + out_zero_point = 128 everywhere); switching to the raw IEEE-754 exponent immediately produced real spatially-structured$3\times 3$ SAME -padded Conv2D feature maps on silicon (0.11 ms per dispatch). #

NN_CMD_SUPPORT_SLICE = 1 : w8[31:16] (out_image_y_stride ) andw16[31:16] (in_image_y_stride ) arechannel-slice byte strides (x * y) , not row counts ( y ). Programmingout_image_y_stride = 64 (8 * 8 ) immediately wrote all 4 output channels cleanly (256/256 bytes,TotalWrites = 0x20 ). #

TP_ENGINE = 0 (TPEngine_CoreCount = 0) : Vivante removed the hardware TP block on 0x9202 (replacing it with a Stream Processor,SP_VECTOR_DEPTH = 0x400 ). Our Mesa patch (0002-etnaviv-teflon-add-hw-v83-and-no-tp-support.patch ) reportstp_core_count = 0 and executes internalNHWC$\leftrightarrow$ NCHW layout transposes and strided reshuffles on CPU with GPU batch synchronization. #

MMU_PAGE_DESCRIPTOR = 1 (mmu_pd_mode = 1) & Current WIP Status : Controlled live probes showed that under legacy PTA mode (0x003B4 = 0x1 ,0x00388 = 0x01 ), NN descriptor and output writes hit DRAM while NN input/coefficient DMA streams read0xFF . Cross-checking Allwinner's vendorvip_drv_hardware.c andvip_drv_mmu.c confirmed0x9202 requires nativeMODE4_K MMUv2PDMODE (0x003B4 = ((mtlb_dma >> 12) << 4) | 0x0 ,0x00388 = 0x21 , skippingPTA_CONTROL , plus0xffffff7f TLB flushes). On live/usr/bin/npu-smoke-test ,quantized_add_8x8x3 matches CPU192/192 (0.002 ms ), andquantized_conv2d_8x8x3x4 dispatches cleanly (0.105 ms ), but still hits an open NN engine DRAM-read issue (max_abs_diff = 31 , constant per-channel output[104,104,104,104,92,92,92,92] ;run_lenet0 on officiallenet_v3.nb returns constant62 ). Testing vendor#[initial states kernel] +0x038C0=0, 0x038C4=1, 0x03818=1 confirmed it does not yet resolve this remaining NN DRAM-read bug. 5.

Developers on the Radxa Forums, Armbian Forums, and GitHub (Cubie A7A / A7Z / A7S, Orange Pi 4 Pro, Frigate NVR, and YOLOv8/YOLO11 projects) repeatedly run into the same set of A733 NPU roadblocks. Below is each real-world issue, its silicon root cause, and how our mainline etnaviv + Mesa Teflon stack resolves it:

── more in #ai-chips 4 stories · sorted by recency
── more on @allwinner 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/freeing-the-allwinne…] indexed:0 read:29min 2026-11-23 · —