From d670a509a4626bd5b08fd062fc511c422f1f7f37 Mon Sep 17 00:00:00 2001 From: benstrb Date: Wed, 15 Apr 2026 23:29:45 +0200 Subject: [PATCH] the only thing that doesn't work is the buffer, which is bad, but at least the board lights up --- .cargo/config.toml | 11 +++++------ .gdbinit | 2 +- build.rs | 19 ------------------- ccmram.x | 10 ---------- memory.x | 20 +++++++++----------- src/main.rs | 14 ++++++++------ src/test.rs | 18 ++++++++++++++++++ 7 files changed, 41 insertions(+), 53 deletions(-) delete mode 100644 build.rs delete mode 100644 ccmram.x create mode 100644 src/test.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index 07574cf..baf2d15 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,10 +1,9 @@ -[build] -target = "thumbv7em-none-eabihf" - -[target.thumbv7em-none-eabihf] -# Using probe-rs for flashing -runner = "probe-rs run --chip STM32F469NIx" +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +runner = "arm-none-eabi-gdb -q -x .gdbinit" rustflags = [ "-C", "link-arg=-Tlink.x", ] + +[build] +target = "thumbv7em-none-eabihf" diff --git a/.gdbinit b/.gdbinit index 7795319..2cdf492 100755 --- a/.gdbinit +++ b/.gdbinit @@ -17,7 +17,7 @@ break rust_begin_unwind # end # *try* to stop at the user entry point (it might be gone due to inlining) -break main +# break main monitor arm semihosting enable diff --git a/build.rs b/build.rs deleted file mode 100644 index b7f5305..0000000 --- a/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -// I totally understand this and it's not copied from -// https://github.com/cyang812/rust_stm32f469i/blob/main/led_blinky/ -// hehe -use std::env; -use std::fs; -use std::path::PathBuf; - -fn main() { - let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); - fs::write(out.join("memory.x"), include_bytes!("memory.x")).unwrap(); - println!("cargo:rustc-link-search={}", out.display()); - - // Only link CCM script when the feature is enabled. - // Enable with: cargo build --features ccmram - if env::var_os("CARGO_FEATURE_CCMRAM").is_some() { - fs::write(out.join("ccmram.x"), include_bytes!("ccmram.x")).unwrap(); - println!("cargo:rustc-link-arg=-Tccmram.x"); - } -} diff --git a/ccmram.x b/ccmram.x deleted file mode 100644 index 3bafd68..0000000 --- a/ccmram.x +++ /dev/null @@ -1,10 +0,0 @@ -/* Extra linker script to place data into CCM SRAM */ -SECTIONS -{ - .ccmram (NOLOAD) : - { - . = ALIGN(4); - *(.ccmram .ccmram.*) - . = ALIGN(4); - } > CCMRAM -} INSERT AFTER .rodata; diff --git a/memory.x b/memory.x index 6833557..895822d 100644 --- a/memory.x +++ b/memory.x @@ -1,18 +1,16 @@ -/* Memory layout of the STM32F469NI */ MEMORY { - FLASH : ORIGIN = 0x08000000, LENGTH = 2M - RAM : ORIGIN = 0x20000000, LENGTH = 384K - CCMRAM : ORIGIN = 0x10000000, LENGTH = 64K - SDRAM : ORIGIN = 0xC0000000, LENGTH = 16M + FLASH : ORIGIN = 0x08000000, LENGTH = 2M + RAM : ORIGIN = 0x20000000, LENGTH = 320K + SDRAM : ORIGIN = 0xC0000000, LENGTH = 16M } SECTIONS { - .sdram (NOLOAD) : - { - *(.sdram .sdram.*); - } > SDRAM + .sdram (NOLOAD) : + { + . = ALIGN(4); + *(.sdram) + . = ALIGN(4); + } >SDRAM } - -_stack_start = ORIGIN(RAM) + LENGTH(RAM); diff --git a/src/main.rs b/src/main.rs index 5d605a0..fac913f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,13 +10,10 @@ use crate::hal::{ prelude::*, }; use cortex_m_rt::entry; -use defmt_rtt as _; use otm8009a::{Otm8009A, Otm8009AConfig}; -use panic_probe as _; +use panic_halt as _; use stm32f4xx_hal::{self as hal, ltdc, rcc::Config}; -defmt::timestamp!("{=u32}", 0u32); - const WIDTH: usize = 480; const HEIGHT: usize = 800; @@ -175,6 +172,7 @@ fn main() -> ! { }); while fmc.sdsr().read().busy().bit_is_set() {} fmc.sdrtr().write(|w| w.count().set(1385)); + while fmc.sdsr().read().busy().bit_is_set() {} let mut lcd_reset = gpioh.ph7.into_push_pull_output(); lcd_reset.set_low(); @@ -193,12 +191,12 @@ fn main() -> ! { DISPLAY_CONFIGURATION, Some(hse_freq), ); - display.enable_layer(ltdc::Layer::L1); display.config_layer( ltdc::Layer::L1, unsafe { &mut BUFF[..] }, PixelFormat::ARGB8888, ); + display.enable_layer(ltdc::Layer::L1); let dsi_pll_config = unsafe { DsiPllConfig::manual(125, 2, 0, 4) }; let dsi_config = DsiConfig { @@ -239,7 +237,6 @@ fn main() -> ! { dsi_host.enable_bus_turn_around(); dsi_host.set_command_mode_transmission_kind(DsiCmdModeTransmissionKind::AllInHighSpeed); dsi_host.force_rx_low_power(true); - dsi_host.enable_color_test(); let mut otm = Otm8009A::new(); otm.init( @@ -255,6 +252,11 @@ fn main() -> ! { ) .unwrap(); + unsafe { + (0..480 * 800).for_each(|i| BUFF[i] = 0xFF0000FF); + } + display.reload(); + gpiog.pg6.into_push_pull_output().set_low(); gpiod.pd4.into_push_pull_output().set_low(); gpiod.pd5.into_push_pull_output().set_low(); diff --git a/src/test.rs b/src/test.rs new file mode 100644 index 0000000..93e80af --- /dev/null +++ b/src/test.rs @@ -0,0 +1,18 @@ +#![no_main] +#![no_std] +use crate::hal::prelude::*; +use cortex_m_rt::entry; +use panic_halt as _; +use stm32f4xx_hal::{self as hal, rcc::Config}; + +#[entry] +fn main() -> ! { + let peripherals = hal::pac::Peripherals::take().unwrap(); + let mut rcc = peripherals.RCC.freeze(Config::hse(8.MHz())); + + let gpiok = peripherals.GPIOK.split(&mut rcc); + let mut led = gpiok.pk3.into_push_pull_output(); + led.set_low(); + + loop {} +}