diff --git a/Cargo.toml b/Cargo.toml index cad5cb7..6df001c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,8 @@ name = "tc2-agent" maintainer = "Cacophony Developers " depends = "" assets = [ - ["target/release/tc2-agent", "/usr/bin/", "755"], # Binary asset + ["target/release/tc2-agent", "/usr/bin/", "755"], ["_releases/tc2-agent.service", "/etc/systemd/system/tc2-agent.service", "664"], + ["_releases/rp2040-firmware.elf", "/etc/cacophony/rp2040-firmware.elf", "664"], ] maintainer-scripts = "_releases/scripts" \ No newline at end of file diff --git a/_releases/rp2040-firmware.elf b/_releases/rp2040-firmware.elf new file mode 100755 index 0000000..4fe0bf6 Binary files /dev/null and b/_releases/rp2040-firmware.elf differ diff --git a/_releases/scripts/postinst b/_releases/scripts/postinst index 0264f49..a459d2f 100644 --- a/_releases/scripts/postinst +++ b/_releases/scripts/postinst @@ -1,4 +1,9 @@ #!/bin/bash systemctl daemon-reload -systemctl enable tc2-agent.service -systemctl restart tc2-agent.service \ No newline at end of file +systemctl stop tc2-agent.service + +## Program RP2040 firmware +#openocd -f /etc/cacophony/raspberrypi-swd.cfg -f /target/rp2040.cfg -c /etc/cacophony/rp2040.elf +tc2-hat-rp2040 --elf /etc/cacophony/rp2040-firmware.elf + +systemctl start tc2-agent.service \ No newline at end of file diff --git a/_releases/tc2-agent.service b/_releases/tc2-agent.service index fef5fbc..9954be9 100644 --- a/_releases/tc2-agent.service +++ b/_releases/tc2-agent.service @@ -6,7 +6,7 @@ After=multi-user.target [Service] Type=simple ExecStart=/usr/bin/tc2-agent -Restart=on-failure +Restart=always RestartSec=5s # Give real-time priority diff --git a/src/main.rs b/src/main.rs index 06ef4ca..9805e90 100644 --- a/src/main.rs +++ b/src/main.rs @@ -198,7 +198,8 @@ fn main() { let mut raw_read_buffer = [0u8; 1024 * 1024]; //let spi_speed = 30_000_000; // rPi4 can handle this in PIO mode - let spi_speed = config.spi_speed * 1_000_000; // rPi3 can handle 12Mhz (@600Mhz), may need to back it off a little to have some slack. + //let spi_speed = config.spi_speed * 1_000_000; // rPi3 can handle 12Mhz (@600Mhz), may need to back it off a little to have some slack. + let spi_speed = 8_000_000; println!("Initialising SPI at {}Mhz", config.spi_speed); let mut spi = Spi::new(Bus::Spi0, SlaveSelect::Ss0, spi_speed, Mode::Mode2).unwrap(); spi.set_bits_per_word(8).unwrap();