Use arm-none-eabi-objcopy instead of llvm-objcopy

Since LLVM v15, llvm-objcopy seems to produce broken (misaligned?)
binaries, which when combined with some difficult to debug timing issues
caused by the calibrate_dac_feedback routine, would cause the
independent watchdog to kick in, and bootloop the Thermostat.

As NixOS 23.11 ships LLVM v16, upgrading to it breaks builds. Using
rust-objcopy from cargo-binutils does not help either since the pinned
version of Rust uses LLVM v15.

arm-none-eabi-objcopy doesn't have this problem, so use it instead.

See https://github.com/llvm/llvm-project/issues/58407 and
https://github.com/rust-lang/rust/issues/102983.
This commit is contained in:
atse 2024-01-17 14:53:59 +08:00
parent 6cd6a6a2c2
commit 8c8ac71a6f
2 changed files with 5 additions and 4 deletions

View File

@ -45,7 +45,7 @@ There are several options for flashing Thermostat. DFU requires only a micro-USB
### dfu-util on Linux
* Install the DFU USB tool (dfu-util).
* Convert firmware from ELF to BIN: `arm-none-eabi-objcopy -O binary thermostat thermostat.bin` (you can skip this step if using the BIN from Hydra)
* Convert firmware from ELF to BIN: `arm-none-eabi-objcopy -O binary target/thumbv7em-none-eabihf/release/thermostat thermostat.bin` (you can skip this step if using the BIN from Hydra)
* Connect to the Micro USB connector to Thermostat below the RJ45.
* Add jumper to Thermostat v2.0 across 2-pin jumper adjacent to JTAG connector.
* Cycle board power to put it in DFU update mode

View File

@ -39,7 +39,7 @@
};
};
nativeBuildInputs = [ pkgs.llvm ];
nativeBuildInputs = [ pkgs.gcc-arm-embedded ];
buildPhase = ''
cargo build --release --bin thermostat
@ -49,7 +49,7 @@
mkdir -p $out $out/nix-support
cp target/thumbv7em-none-eabihf/release/thermostat $out/thermostat.elf
echo file binary-dist $out/thermostat.elf >> $out/nix-support/hydra-build-products
llvm-objcopy -O binary target/thumbv7em-none-eabihf/release/thermostat $out/thermostat.bin
arm-none-eabi-objcopy -O binary target/thumbv7em-none-eabihf/release/thermostat $out/thermostat.bin
echo file binary-dist $out/thermostat.bin >> $out/nix-support/hydra-build-products
'';
@ -67,7 +67,8 @@
devShell.x86_64-linux = pkgs.mkShell {
name = "thermostat-dev-shell";
buildInputs = with pkgs; [
rust openocd dfu-util
rust gcc-arm-embedded
openocd dfu-util
] ++ (with python3Packages; [
numpy matplotlib
]);