SkyLok/chip_test_example
2026-05-29 09:29:57 +02:00
..
deploy.sh sloppified ai example but working, yaaaaaay, :,) 2026-05-28 10:42:05 +02:00
gps_test.cpp readmes and gps changes 2026-05-21 14:11:06 +02:00
gps.hpp readmes and gps changes 2026-05-21 14:11:06 +02:00
icm20948.hpp lora ai changes not fixed probably 2026-05-22 14:23:37 +02:00
imu_test.cpp lora ai changes not fixed probably 2026-05-22 14:23:37 +02:00
lora_rx.cpp ai debloat 2026-05-29 09:29:57 +02:00
lora_tx.cpp ai debloat 2026-05-29 09:29:57 +02:00
lr1121_malnus.hpp ai debloat 2026-05-29 09:29:57 +02:00
Makefile cleanup and fixes 2026-05-21 15:23:13 +02:00
README.md cleanup and fixes 2026-05-21 15:23:13 +02:00

chip_test_example

Tests for LR1121 LoRa, ICM-20948 IMU, u-blox GPS on Raspberry Pi Zero W 2. Header-only drivers, kernel ioctls, no external libs.

Driver: lr1121_malnus.hpp — crystal oscillator, RF switch via DIO5/DIO6.


Wiring

LR1121 (SPI0)

Module Pi GPIO Pi pin
SCK GPIO11 23
MOSI GPIO10 19
MISO GPIO9 21
NSS GPIO8 24
BUSY GPIO24 18
NRESET GPIO25 22
DIO5 chip-driven RF switch (RFSW0)
DIO6 chip-driven RF switch (RFSW1)
DIO9 GPIO4 7
DIO8 GPIO23 16

DIO5 and DIO6 are driven directly by the LR1121 — they go to your module's RF switch and do not connect to the Pi. The driver configures them automatically via SetDioAsRfSwitch: HIGH on DIO5 in RX, HIGH on DIO6 in TX, both LOW in standby.

Enable SPI: sudo raspi-config → Interfaces → SPI → Yes → reboot

ICM-20948 (I2C1)

Module Pi GPIO Pi pin
SDA GPIO2 3
SCL GPIO3 5
AD0 GND → addr 0x68 / VCC → addr 0x69

Enable: sudo raspi-config → Interfaces → I2C → Yes → reboot

u-blox GPS (UART0)

Module Pi GPIO Pi pin
TX GPIO15 10
RX GPIO14 8

Enable: sudo raspi-config → Interfaces → Serial Port → login shell: No, hardware: Yes → reboot


Build

sudo apt install g++ make
make

Run verbose first so you see exactly where it fails:

sudo ./lora_rx -v --433
sudo ./imu_test -v
./gps_test -v

LoRa debug

ls /dev/spidev0.0         # SPI enabled?
sudo ./lora_rx -v --433   # step labels show exactly which command hangs

If it hangs at Calibrate — the chip isn't responding over SPI at all. Check wiring, CS, and that SPI is enabled. The crystal needs no tuning.

If TX/RX runs but packets never arrive — check that DIO5/DIO6 reach the RF switch on your module. Without the switch, the antenna path is disconnected.

To try 2.4 GHz instead (different antenna required):

sudo ./lora_rx -v --24
sudo ./lora_tx -v --24

If the chip is stuck in bootloader (fw < 0x02xx), escape with:

sudo ./lora_rx --reset

IMU debug

sudo i2cdetect -y 1     # 0x68 or 0x69 must show
sudo ./imu_test -v      # auto-detects both addresses
sudo ./imu_test -v -r   # raw 16-bit values

Nothing on i2cdetect: I2C not enabled, wrong wiring, or no pull-ups on SDA/SCL.


GPS debug

ls -la /dev/serial0
stty -F /dev/serial0 38400 raw && cat /dev/serial0   # raw NMEA bytes
./gps_test -v -a                                      # all sentences
./gps_test -b 9600                                    # try different baud