Hello there,
I am porting a piece of firmware for the STM32 L476 from C to Rust to see if Rust is feasible for our use cases. My firmware requires the Memory Firewall feature of that particular MCU. I am using the STM32L4xx HAL to keep things simple. Following the C-HAL provided by STM I tried to activate the Firewall by writing the configuration registers as follows:
let peripherals = pac::Peripherals::take().unwrap();
peripherals.FIREWALL.nvdssa.write(|w| unsafe {w.bits(PROTECTED_FLASH_ADDRESS)});
peripherals.FIREWALL.nvdsl.write(|w| unsafe {w.bits(PROTECTED_FLASH_SIZE)});
peripherals.FIREWALL.cssa.write(|w| unsafe {w.bits(0)});
peripherals.FIREWALL.csl.write(|w| unsafe {w.bits(0)});
peripherals.FIREWALL.vdssa.write(|w| unsafe {w.bits(0)});
peripherals.FIREWALL.vdsl.write(|w| unsafe {w.bits(0)});
peripherals.SYSCFG.cfgr1.modify(|r,w| unsafe{w.bits(r.bits() & !0x1u32)});
Now the C-HAL requires enabling of the firewall by setting a bit in the APB2 register of the RCC and I don't know how to do that. I've tried the following:
- Checked the documentation of the register in the corresponding Rust crate. I could not find anything helpful in it and writing to it like with the Firewall configuration registers above does not work.
- Searched the source code for something helpful. The thing that comes closest to being helpful is an enable-function that is created by some macros. I am however not sure how to call them.
It is probably a real simple solution and I just need a nudge into the right direction. Any helpful insight is much appreciated. Thanks.