- Thingino firmware on Ingenic T41/T31 device
- Cross-compilation toolchain (mipsel-linux-musl)
- SSH access to device
cd thingino-accel
./build.shThis will create:
build/lib/libnna.so- Shared librarybuild/lib/libnna.a- Static librarybuild/bin/test_init- Test program
# Replace with your device IP
DEVICE_IP=192.168.x.x
# Copy library and test
scp build/lib/libnna.so root@$DEVICE_IP:/usr/lib/
scp build/bin/test_init root@$DEVICE_IP:/tmp/ssh root@$DEVICE_IP
# Load NNA kernel module (if not already loaded)
insmod /lib/modules/soc-nna.ko
# Run test
/tmp/test_initExpected output:
╔══════════════════════════════════════════════════════════╗
║ thingino-accel - Initialization Test ║
╚══════════════════════════════════════════════════════════╝
[1/6] Library version
Version: 0.1.0-dev
✓ Version retrieved
[2/6] NNA initialization
NNA initialized: ORAM @ 0x12620000 (384 KB)
✓ NNA initialized
[3/6] Hardware information
ORAM Physical: 0x12620000
ORAM Virtual: 0xb6f00000
ORAM Size: 384 KB
NNA Version: 0x20
✓ Hardware info retrieved
[4/6] DDR memory allocation
Allocated: 1048576 bytes @ 0x77f00000
✓ DDR memory is writable
✓ DDR memory freed
[5/6] ORAM allocation
Allocated: 4096 bytes @ 0xb6f00000
ORAM usage: 4 / 384 KB (1.0%)
✓ ORAM allocation successful
[6/6] Tensor operations
Shape: [1, 224, 224, 3]
Elements: 150528
Bytes: 150528
✓ Tensor created
✓ Tensor data written
✓ Tensor destroyed
[CLEANUP] Shutting down
✓ NNA deinitialized
╔══════════════════════════════════════════════════════════╗
║ ✓ ALL TESTS PASSED! ║
╚══════════════════════════════════════════════════════════╝
#include <nna.h>
#include <nna_memory.h>
#include <nna_tensor.h>
int main() {
// Initialize NNA
if (nna_init() != NNA_SUCCESS) {
return 1;
}
// Create input tensor (1x224x224x3 RGB image)
nna_shape_t shape = nna_shape_make(1, 224, 224, 3);
nna_tensor_t *input = nna_tensor_create(
&shape,
NNA_DTYPE_UINT8,
NNA_FORMAT_NHWC
);
// Fill with image data
unsigned char *data = nna_tensor_data(input);
// ... load image into data ...
// TODO: Load model and run inference
// Cleanup
nna_tensor_destroy(input);
nna_deinit();
return 0;
}mipsel-linux-gcc -o myapp myapp.c \
-I/path/to/thingino-accel/include \
-L/path/to/thingino-accel/build/lib \
-lnna -lpthreadMake sure the kernel module is loaded:
lsmod | grep soc-nna
# If not loaded:
insmod /lib/modules/soc-nna.koORAM is limited (384 KB on T41). Use DDR for large allocations:
void *large_buffer = nna_malloc(1024 * 1024); // DDR
void *small_buffer = nna_oram_malloc(4096); // ORAMMake sure toolchain is in PATH:
export PATH="/path/to/thingino/toolchain/bin:$PATH"
export CROSS_COMPILE=mipsel-linux-- Explore the API - See
include/directory - Read DEVELOPMENT.md - Learn about internals
- Check REVERSE_ENGINEERING.md - Understand OEM library
- Contribute - Help implement model loading and inference!
nna_init()- Initialize NNAnna_deinit()- Cleanupnna_get_hw_info()- Get hardware infonna_is_ready()- Check if initialized
nna_malloc()- Allocate DDR memorynna_free()- Free memorynna_oram_malloc()- Allocate ORAMnna_oram_free()- Free ORAM
nna_tensor_create()- Create tensornna_tensor_destroy()- Destroy tensornna_tensor_data()- Get data pointernna_shape_make()- Create shape
- GitHub Issues: (TBD)
- Documentation: See
*.mdfiles in repo - Examples: See
examples/directory