embassy icon indicating copy to clipboard operation
embassy copied to clipboard

STM32L475/6 do not implement BK1NSSPin for any pins

Open i509VCB opened this issue 1 year ago • 4 comments

L475 and L476 have a single bank QSPI which uses bank 1 internally.

However there are no implementors of BK1NSSPin for both, which means the QSPI is unusable.

  • https://docs.embassy.dev/embassy-stm32/git/stm32l475re/qspi/trait.BK1NSSPin.html
  • https://docs.embassy.dev/embassy-stm32/git/stm32l476re/qspi/trait.BK1NSSPin.html

i509VCB avatar Feb 25 '25 00:02 i509VCB

I'm having the same issue. I investigated a bit, and it appears that NSS is now named NCS. I had to edit embassy-stm32/build.rs in:

        (("quadspi", "BK1_IO0"), quote!(crate::qspi::BK1D0Pin)),
        (("quadspi", "BK1_IO1"), quote!(crate::qspi::BK1D1Pin)),
        (("quadspi", "BK1_IO2"), quote!(crate::qspi::BK1D2Pin)),
        (("quadspi", "BK1_IO3"), quote!(crate::qspi::BK1D3Pin)),
-       (("quadspi", "BK1_NCS"), quote!(crate::qspi::BK1NCSPin)),
+       (("quadspi", "NCS"), quote!(crate::qspi::BK1NCSPin)),
        (("quadspi", "BK2_IO0"), quote!(crate::qspi::BK2D0Pin)),
        (("quadspi", "BK2_IO1"), quote!(crate::qspi::BK2D1Pin)),
        (("quadspi", "BK2_IO2"), quote!(crate::qspi::BK2D2Pin)),
        (("quadspi", "BK2_IO3"), quote!(crate::qspi::BK2D3Pin)),

and rename all references to BK1NSSPin in BK1NCSPin in smbassy-stm32/src/qspi/mod.rs This is because the corresponding stm32-data-generated json does not contain the prefix BK1 (nor NSS). I would create a PR but i don't know if this affects other chips.

hjeldin avatar Nov 26 '25 14:11 hjeldin

@hjeldin If some chips name it NSS and others NCS, it should be fixed in stm32-data. The name should be consistent in all chips. You can add an if somewhere in stm32-data-gen to fix the bad name.

Dirbaio avatar Nov 26 '25 15:11 Dirbaio

It's not only a matter of NSS -> NCS (or viceversa), but also a missing prefix (QUADSPI_NCS vs QUADSPI_BK1_NCS). These specific chips do not have dual-flash so the distinction BK1 or BK2 is pointless. These are the chips and pins subject to this edit:

[STM32L486VG] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L486VG] Renaming BK1_NCS for pin PE11 with AF Some(10)
[STM32L486ZG] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L486ZG] Renaming BK1_NCS for pin PE11 with AF Some(10)
[STM32L471QG] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L471QG] Renaming BK1_NCS for pin PE11 with AF Some(10)
[STM32L471RE] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L471VE] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L471VE] Renaming BK1_NCS for pin PE11 with AF Some(10)
[STM32L471ZE] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L471ZE] Renaming BK1_NCS for pin PE11 with AF Some(10)
[STM32L475RE] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L475VE] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L475VE] Renaming BK1_NCS for pin PE11 with AF Some(10)
[STM32L476JE] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L476ME] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L476QE] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L476QE] Renaming BK1_NCS for pin PE11 with AF Some(10)
[STM32L476VE] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L476VE] Renaming BK1_NCS for pin PE11 with AF Some(10)
[STM32L476RC] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L476ZG] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L476ZG] Renaming BK1_NCS for pin PE11 with AF Some(10)
[STM32L486JG] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L486QG] Renaming BK1_NCS for pin PB11 with AF Some(10)
[STM32L486QG] Renaming BK1_NCS for pin PE11 with AF Some(10)
[STM32L486RG] Renaming BK1_NCS for pin PB11 with AF Some(10)

here's the diff:

diff --git a/stm32-data-gen/src/generator.rs b/stm32-data-gen/src/generator.rs
index 2ebbcb961..a2ecedd3e 100644
--- a/stm32-data-gen/src/generator.rs
+++ b/stm32-data-gen/src/generator.rs
@@ -663,6 +663,15 @@ fn merge_periph_pins_info(
             }
         }
     }
+
+    // Rename QUADSPI_NCS for the STM32L* family to QUADSPI_BK1_NCS
+    if periph_name == "QUADSPI" {
+        for pin in &mut core_pins[..] {
+            if pin.signal == "NCS" {
+                pin.signal = "BK1_NCS".to_string();
+            }
+        }
+    }
 }
 
 /// Resolve the address of a peripheral.

No other edits to embassy-stm32 are required (if we don't care about the NCS/NSS nomenclature difference). @Dirbaio Let me know if you want a PR or if the diff is enough

hjeldin avatar Nov 26 '25 22:11 hjeldin

@hjeldin Please.

xoviat avatar Nov 27 '25 00:11 xoviat