cleanup and fixes
This commit is contained in:
parent
b41050c2c6
commit
a88ce8c12f
@ -168,6 +168,7 @@ void processRequest(Request *request)
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::signal(SIGPIPE, SIG_IGN);
|
std::signal(SIGPIPE, SIG_IGN);
|
||||||
|
std::signal(SIGINT, [](int) { loop.exit(0); });
|
||||||
std::thread(serverThread).detach();
|
std::thread(serverThread).detach();
|
||||||
|
|
||||||
auto cm = std::make_unique<CameraManager>();
|
auto cm = std::make_unique<CameraManager>();
|
||||||
|
|||||||
28
chip_test_example/Makefile
Normal file
28
chip_test_example/Makefile
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Build on device:
|
||||||
|
# apt install g++
|
||||||
|
# make
|
||||||
|
# All deps (spidev, gpiochip, i2c-dev, termios) are kernel headers — no apt libs needed.
|
||||||
|
|
||||||
|
CXX ?= g++
|
||||||
|
CXXFLAGS ?= -O2 -std=c++17 -Wall -Wextra
|
||||||
|
|
||||||
|
TARGETS = lora_tx lora_rx imu_test gps_test
|
||||||
|
|
||||||
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
lora_tx: lora_tx.cpp lr1121_malnus.hpp
|
||||||
|
$(CXX) $(CXXFLAGS) $< -lpthread -o $@
|
||||||
|
|
||||||
|
lora_rx: lora_rx.cpp lr1121_malnus.hpp
|
||||||
|
$(CXX) $(CXXFLAGS) $< -lpthread -o $@
|
||||||
|
|
||||||
|
imu_test: imu_test.cpp icm20948.hpp
|
||||||
|
$(CXX) $(CXXFLAGS) $< -lpthread -o $@
|
||||||
|
|
||||||
|
gps_test: gps_test.cpp gps.hpp
|
||||||
|
$(CXX) $(CXXFLAGS) $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(TARGETS)
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
@ -3,6 +3,8 @@
|
|||||||
Tests for LR1121 LoRa, ICM-20948 IMU, u-blox GPS on Raspberry Pi Zero W 2.
|
Tests for LR1121 LoRa, ICM-20948 IMU, u-blox GPS on Raspberry Pi Zero W 2.
|
||||||
Header-only drivers, kernel ioctls, no external libs.
|
Header-only drivers, kernel ioctls, no external libs.
|
||||||
|
|
||||||
|
Driver: `lr1121_malnus.hpp` — crystal oscillator, RF switch via DIO5/DIO6.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Wiring
|
## Wiring
|
||||||
@ -10,17 +12,23 @@ Header-only drivers, kernel ioctls, no external libs.
|
|||||||
### LR1121 (SPI0)
|
### LR1121 (SPI0)
|
||||||
|
|
||||||
| Module | Pi GPIO | Pi pin |
|
| Module | Pi GPIO | Pi pin |
|
||||||
|--------|---------|--------|
|
|---------|---------|--------|
|
||||||
| SCK | GPIO11 | 23 |
|
| SCK | GPIO11 | 23 |
|
||||||
| MOSI | GPIO10 | 19 |
|
| MOSI | GPIO10 | 19 |
|
||||||
| MISO | GPIO9 | 21 |
|
| MISO | GPIO9 | 21 |
|
||||||
| NSS | GPIO8 | 24 |
|
| NSS | GPIO8 | 24 |
|
||||||
| BUSY | GPIO24 | 18 |
|
| BUSY | GPIO24 | 18 |
|
||||||
| NRESET | GPIO25 | 22 |
|
| NRESET | GPIO25 | 22 |
|
||||||
|
| DIO5 | — | chip-driven RF switch (RFSW0) |
|
||||||
|
| DIO6 | — | chip-driven RF switch (RFSW1) |
|
||||||
| DIO9 | GPIO4 | 7 |
|
| DIO9 | GPIO4 | 7 |
|
||||||
| DIO8 | GPIO23 | 16 |
|
| DIO8 | GPIO23 | 16 |
|
||||||
|
|
||||||
Enable: `sudo raspi-config` → Interfaces → SPI → Yes → reboot
|
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)
|
### ICM-20948 (I2C1)
|
||||||
|
|
||||||
@ -63,28 +71,29 @@ sudo ./imu_test -v
|
|||||||
## LoRa debug
|
## LoRa debug
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
ls /dev/spidev0.0 # SPI on?
|
ls /dev/spidev0.0 # SPI enabled?
|
||||||
sudo ./lora_rx -v --433 # step labels show exactly which command hangs
|
sudo ./lora_rx -v --433 # step labels show exactly which command hangs
|
||||||
```
|
```
|
||||||
|
|
||||||
If it hangs at `Calibrate` — that's a TCXO config issue. Try in order:
|
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.
|
||||||
|
|
||||||
```sh
|
If TX/RX runs but packets never arrive — check that DIO5/DIO6 reach the RF
|
||||||
sudo ./lora_rx -v --433 --tcxo-none # skip TCXO entirely (crystal mode)
|
switch on your module. Without the switch, the antenna path is disconnected.
|
||||||
sudo ./lora_rx -v --433 --tcxo-27 # TCXO 2.7V
|
|
||||||
sudo ./lora_rx -v --433 --tcxo-33 # TCXO 3.3V (default)
|
|
||||||
```
|
|
||||||
|
|
||||||
The one that gets past "Calibrate done" is your module's config.
|
To try 2.4 GHz instead (different antenna required):
|
||||||
Use the same TCXO flag on TX and RX.
|
|
||||||
|
|
||||||
If using the 2.4 GHz antenna instead:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo ./lora_rx -v --24
|
sudo ./lora_rx -v --24
|
||||||
sudo ./lora_tx -v --24
|
sudo ./lora_tx -v --24
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If the chip is stuck in bootloader (fw < 0x02xx), escape with:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo ./lora_rx --reset
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## IMU debug
|
## IMU debug
|
||||||
@ -107,14 +116,3 @@ stty -F /dev/serial0 38400 raw && cat /dev/serial0 # raw NMEA bytes
|
|||||||
./gps_test -v -a # all sentences
|
./gps_test -v -a # all sentences
|
||||||
./gps_test -b 9600 # try different baud
|
./gps_test -b 9600 # try different baud
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## TCXO voltage reference
|
|
||||||
|
|
||||||
| Flag | Value | Voltage |
|
|
||||||
|------|-------|---------|
|
|
||||||
| `--tcxo-none` | 0xFF | no TCXO (crystal) |
|
|
||||||
| `--tcxo-27` | 0x05 | 2.7V |
|
|
||||||
| `--tcxo-33` | 0x07 | 3.3V |
|
|
||||||
| `--tcxo-v N` | 0x00–0x07 | raw byte |
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@ GLuint compile(GLenum t, const std::string& src)
|
|||||||
if (!ok) {
|
if (!ok) {
|
||||||
char log[1024];
|
char log[1024];
|
||||||
glGetShaderInfoLog(s, sizeof(log), NULL, log);
|
glGetShaderInfoLog(s, sizeof(log), NULL, log);
|
||||||
std::cout << "shader compile failed:\n" << log;
|
std::cerr << "shader compile failed:\n" << log;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -51,8 +51,8 @@ int main()
|
|||||||
|
|
||||||
if(!img1 || !img2)
|
if(!img1 || !img2)
|
||||||
{
|
{
|
||||||
std::cout << "image load failed\n";
|
std::cerr << "image load failed\n";
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------- TEXTURES ----------------
|
// ---------------- TEXTURES ----------------
|
||||||
@ -99,7 +99,8 @@ int main()
|
|||||||
if (!linked) {
|
if (!linked) {
|
||||||
char log[1024];
|
char log[1024];
|
||||||
glGetProgramInfoLog(prog, sizeof(log), NULL, log);
|
glGetProgramInfoLog(prog, sizeof(log), NULL, log);
|
||||||
std::cout << "program link failed:\n" << log;
|
std::cerr << "program link failed:\n" << log;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------- QUAD (FIXED) ----------------
|
// ---------------- QUAD (FIXED) ----------------
|
||||||
@ -133,8 +134,10 @@ int main()
|
|||||||
glBindFramebuffer(GL_FRAMEBUFFER,fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER,fbo);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,outTex,0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,outTex,0);
|
||||||
|
|
||||||
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
std::cout << "FBO broken\n";
|
std::cerr << "FBO broken\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------- RENDER ----------------
|
// ---------------- RENDER ----------------
|
||||||
glUseProgram(prog);
|
glUseProgram(prog);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user