Memory Firewall of STM32 L476

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.

I don't know STM32 controllers at all, so I can't help. But if you don't get any help here, you might try the Matrix channel. It's pretty active.

For low-level stuff it could be easier to use the stm32l4 crate directly without relying on the HAL crate.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.