Skip to content

Commit

Permalink
Merge pull request #21 from TheCacophonyProject/fix-flashing
Browse files Browse the repository at this point in the history
fix firmware
  • Loading branch information
gferraro authored Aug 28, 2024
2 parents 4e06ac3 + 22ef075 commit 9ef146e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ script:
- if [ -n "$TRAVIS_TAG" ]; then sed -i "s/version = \"0.0.0-snapshot\"/version = \"${TRAVIS_TAG#v}\"/g" Cargo.toml; fi
- cargo install cargo-deb --version 2.3.0
- wget -O _releases/tc2-firmware.sha256 https://github.com/TheCacophonyProject/tc2-firmware/releases/download/v${RP2040_FIRMWARE_VERSION}/tc2-firmware.sha256
- cat _releases/tc2-firmware.sha256
- wget -O _releases/tc2-firmware https://github.com/TheCacophonyProject/tc2-firmware/releases/download/v${RP2040_FIRMWARE_VERSION}/tc2-firmware
- cargo build --release --target=aarch64-unknown-linux-musl
- cargo deb --target=aarch64-unknown-linux-musl --output tc2-agent_${TRAVIS_TAG#v}_arm64.deb
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,6 @@ fn main() {
let mut sent_reset_request = false;
let mut has_failed = false;
let mut got_startup_info = false;
let mut audio_mode = false;
let mut radiometry_enabled = false;
let mut firmware_version = 0;
let mut lepton_serial_number = String::from("");
Expand Down Expand Up @@ -978,11 +977,7 @@ fn main() {
radiometry_enabled = LittleEndian::read_u32(&chunk[0..4]) == 2;
firmware_version = LittleEndian::read_u32(&chunk[4..8]);
lepton_serial_number = format!("{}", LittleEndian::read_u32(&chunk[8..12]));
audio_mode = LittleEndian::read_u32(&chunk[12..16]) > 0;
RP2040_MODE.store(if audio_mode { 1 } else { 0 }, Ordering::Relaxed);

got_startup_info = true;
info!("Got startup info: radiometry enabled: {}, firmware version: {}, lepton serial #{} audio mode {}", radiometry_enabled, firmware_version, lepton_serial_number, audio_mode);
if firmware_version != EXPECTED_RP2040_FIRMWARE_VERSION {
exit_cleanly(&mut dbus_conn);
info!("Unsupported firmware version, expected {}, got {}. Will reprogram RP2040.", EXPECTED_RP2040_FIRMWARE_VERSION, firmware_version);
Expand All @@ -993,6 +988,11 @@ fn main() {
}
process::exit(0);
}

let audio_mode = LittleEndian::read_u32(&chunk[12..16]) > 0;
RP2040_MODE.store(if audio_mode { 1 } else { 0 }, Ordering::Relaxed);
info!("Got startup info: radiometry enabled: {}, firmware version: {}, lepton serial #{} audio mode {}", radiometry_enabled, firmware_version, lepton_serial_number, audio_mode);

if device_config.use_low_power_mode() && !radiometry_enabled && !device_config.is_audio_device() {
exit_cleanly(&mut dbus_conn);
error!("Low power mode is currently only supported on lepton sensors with radiometry or audio device, exiting.");
Expand Down

0 comments on commit 9ef146e

Please sign in to comment.