Skip to main content
Associate II
February 24, 2025
Question

Using STM32G4 with Zephyr and USB Networking

I am trying to stand up a project using an STM32G4 using Zephyr with USB Device Next Networking. I have a similar project up and running on an nRF52. I'm getting the error on my STM32 project that upon system reset, I get a hard fault in z_cstart() -> ... -> statics_init() -> sys_heap_init(). I've isolated this to be a problem when I turn on CONFIG_NET_L2_ETHERNET=y.  If I set CONFIG_DEBUG=y I see a similar failure upon the call to z_bss_zero().
 
From what I can tell, the errors are consistent with an error initializing the soc memory.  This is a custom board with a G473CC soc.  I've made a custom zephyr dts for this board with #include <st/g4/stm32g473Xc.dtsi> so afaik the memory definitions should be correct.
 
I haven't set any memory protections in the option bytes, is there perhaps a default protection in place that comes from the factory that may be causing an issue?
This topic has been closed for replies.

4 replies

Associate II
February 24, 2025

For whatever reason, I don't have the same memory initialization issues when I use a Nucleo-H533RE.  I can't use my Nucleo-G431RB for testing, as it doesn't expose the USB port.

All said though, I never see the Zephyr USB-Device-Next stack initialize on the Nucleo-H533RE.  When I use a Nordic nRF52840-DK, I can see the USB stack come online with:

usbd: msg_cb: USBD message: VBUS ready

However I don't get the same from my H533RE.  From what I can tell, USBD never "really" starts up, though I don't see warnings or errors to say why.

ST Employee
February 27, 2025

Hello @JayBeavers, 

Could you share the memory regions defined in your DTS file and linker script? 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate II
March 10, 2025
&flash0 {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		slot0_partition: partition@0 {
			label = "image-0";
			reg = <0x00000000 DT_SIZE_K(252)>;
		};
		/* Set 4Kb of storage at the end of the 256Kb of flash */
		storage_partition: partition@3f000 {
			label = "storage";
			reg = <0x0003f000 DT_SIZE_K(4)>;
		};
	};
};

I'm using the default linker scripts as generated by west's cmake export. 

Associate II
March 17, 2025

Any further thoughts?