make it compile for esp32-wroom-32
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
let
|
||||
host-triple = "x86_64-unknown-linux-gnu";
|
||||
gcc-arch = "xtensa-esp-elf";
|
||||
gcc-release = "16.1.0_20260609";
|
||||
toolchain-pkg = pkgs.stdenv.mkDerivation rec {
|
||||
pname = "esp32-xtensa-rust-toolchain";
|
||||
version = "1.97.0.0";
|
||||
srcs = [
|
||||
(pkgs.fetchurl {
|
||||
url = "https://github.com/esp-rs/rust-build/releases/download/v${version}/rust-${version}-${host-triple}.tar.xz";
|
||||
hash = "sha256-qZv+5pIh6f9thjiPaBHuaIzUBeagQAo80XhOjUY+nZk=";
|
||||
})
|
||||
(pkgs.fetchurl {
|
||||
url =
|
||||
let
|
||||
gcc-file = "${gcc-arch}-${gcc-release}-x86_64-linux-gnu.tar.xz";
|
||||
in
|
||||
"https://github.com/espressif/crosstool-NG/releases/download/esp-${gcc-release}/${gcc-file}";
|
||||
hash = "sha256-9wh1Lrs1yrIfGEsldBFO0Rh2GdsO24pLqRPAbKL6Z14=";
|
||||
})
|
||||
(pkgs.fetchurl {
|
||||
url = "https://github.com/esp-rs/rust-build/releases/download/v${version}/rust-src-${version}.tar.xz";
|
||||
hash = "sha256-Vo1oi5+PMy7E0EZXVE+tI+mc4R6ebPWDWXnmiijGi3M=";
|
||||
})
|
||||
# TODO maybe I need clang but so far it works without https://github.com/esp-rs/espup/blob/main/src/toolchain/llvm.rs
|
||||
];
|
||||
sourceRoot = ".";
|
||||
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
|
||||
buildInputs = [
|
||||
pkgs.zlib
|
||||
pkgs.stdenv.cc.cc.lib
|
||||
];
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
patchShebangs --build rust-nightly-x86_64-unknown-linux-gnu/install.sh rust-src-nightly/install.sh
|
||||
|
||||
rust-nightly-x86_64-unknown-linux-gnu/install.sh --destdir="$out" --prefix="" --without=rust-docs-json-preview,rust-docs --disable-ldconfig
|
||||
rust-src-nightly/install.sh --destdir="$out" --prefix="" --disable-ldconfig
|
||||
|
||||
cp -pr --reflink=auto -- xtensa-esp-elf "$out";
|
||||
# ensure linker is in PATH
|
||||
ln -s $out/xtensa-esp-elf/bin/* "$out/bin/"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in
|
||||
(pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
espflash
|
||||
toolchain-pkg
|
||||
];
|
||||
})
|
||||
+12
-24
@@ -60,24 +60,12 @@ fn main() -> ! {
|
||||
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
||||
let peripherals = esp_hal::init(config);
|
||||
|
||||
// The following pins are used to bootstrap the chip. They are available
|
||||
// for use, but check the datasheet of the module for more information on them.
|
||||
// - GPIO0
|
||||
// - GPIO3
|
||||
// - GPIO45
|
||||
// - GPIO46
|
||||
// These GPIO pins are in use by some feature of the module and should not be used.
|
||||
let _ = peripherals.GPIO27;
|
||||
let _ = peripherals.GPIO28;
|
||||
let _ = peripherals.GPIO29;
|
||||
let _ = peripherals.GPIO30;
|
||||
let _ = peripherals.GPIO31;
|
||||
let _ = peripherals.GPIO32;
|
||||
let _ = peripherals.GPIO33;
|
||||
let _ = peripherals.GPIO34;
|
||||
let _ = peripherals.GPIO35;
|
||||
let _ = peripherals.GPIO36;
|
||||
let _ = peripherals.GPIO37;
|
||||
let sck = peripherals.GPIO18;
|
||||
let mosi = peripherals.GPIO23;
|
||||
let miso = peripherals.GPIO19;
|
||||
let cs_main = peripherals.GPIO5;
|
||||
let dc = peripherals.GPIO17;
|
||||
let reset_main = peripherals.GPIO16;
|
||||
|
||||
esp_alloc::heap_allocator!(#[esp_hal::ram(reclaimed)] size: 73744);
|
||||
|
||||
@@ -96,16 +84,16 @@ fn main() -> ! {
|
||||
.with_mode(Mode::_0),
|
||||
)
|
||||
.unwrap()
|
||||
.with_sck(peripherals.GPIO36)
|
||||
.with_mosi(peripherals.GPIO35)
|
||||
.with_miso(peripherals.GPIO37);
|
||||
.with_sck(sck)
|
||||
.with_mosi(mosi)
|
||||
.with_miso(miso);
|
||||
|
||||
let cs_main = Output::new(peripherals.GPIO11, Level::High, OutputConfig::default());
|
||||
let cs_main = Output::new(cs_main, Level::High, OutputConfig::default());
|
||||
|
||||
let mut delay = Delay::new();
|
||||
let spi_dev = ExclusiveDevice::new(spi_bus, cs_main, delay).unwrap();
|
||||
let reset_main = Output::new(peripherals.GPIO10, Level::High, OutputConfig::default());
|
||||
let spi_dc = Output::new(peripherals.GPIO12, Level::High, OutputConfig::default());
|
||||
let reset_main = Output::new(reset_main, Level::High, OutputConfig::default());
|
||||
let spi_dc = Output::new(dc, Level::High, OutputConfig::default());
|
||||
let iface = SPIInterface::new(spi_dev, spi_dc);
|
||||
|
||||
let mut display = Ili9341::new(
|
||||
|
||||
Reference in New Issue
Block a user