Code tweaks for STM32U385 port
Posted: Sun Dec 14, 2025 8:24 pm
A few minor tweaks for STM32U385 port compilation using trunk baseline.
First:
Second:
SYSCLK was returning a speed of 96.01MHz but STM32_MSIRC0_MODE was set to RCC_MSIRC0_PLL_HSE. It should have returned 96MHz. I found this typo which fixed the speed. I verified all the clocks using a frequency counter on MCO pin.
Thanks!
First:
Code: Select all
diff --git a/os/hal/ports/STM32/LLD/EXTIv1/stm32_exti.h b/os/hal/ports/STM32/LLD/EXTIv1/stm32_exti.h
index 4b9dcd93a..5d1d06526 100644
--- a/os/hal/ports/STM32/LLD/EXTIv1/stm32_exti.h
+++ b/os/hal/ports/STM32/LLD/EXTIv1/stm32_exti.h
@@ -47,7 +47,8 @@
/* Handling differences in ST headers.*/
#if !defined(STM32H7XX) && !defined(STM32L4XX) && !defined(STM32L4XXP) && \
!defined(STM32C0XX) && !defined(STM32G0XX) && !defined(STM32G4XX) && \
- !defined(STM32WBXX) && !defined(STM32WLXX) && !defined(STM32H5XX)
+ !defined(STM32WBXX) && !defined(STM32WLXX) && !defined(STM32H5XX) && \
+ !defined(STM32U3XX)
#define EMR1 EMR
#define IMR1 IMR
#define PR1 PR
Second:
Code: Select all
diff --git a/os/various/newlib_bindings/syscalls.c b/os/various/newlib_bindings/syscalls.c
index f1f9a41c8..764fb0a08 100644
--- a/os/various/newlib_bindings/syscalls.c
+++ b/os/various/newlib_bindings/syscalls.c
@@ -64,8 +64,8 @@ int _open_r(struct _reent *r, const char *p, int oflag, int mode) {
#else
(void)r;
(void)p;
- (void)a;
- (void)b;
+ (void)oflag;
+ (void)mode;
__errno_r(r) = EINVAL;
return -1;
#endif
SYSCLK was returning a speed of 96.01MHz but STM32_MSIRC0_MODE was set to RCC_MSIRC0_PLL_HSE. It should have returned 96MHz. I found this typo which fixed the speed. I verified all the clocks using a frequency counter on MCO pin.
Code: Select all
diff --git a/os/hal/ports/STM32/STM32U3xx/hal_lld.h b/os/hal/ports/STM32/STM32U3xx/hal_lld.h
index 855f96334..288670f98 100644
--- a/os/hal/ports/STM32/STM32U3xx/hal_lld.h
+++ b/os/hal/ports/STM32/STM32U3xx/hal_lld.h
@@ -1479,7 +1479,7 @@
#else /* PLL mode enabled.*/
#if STM32_MSIPLL1N_VALUE == 0
#define STM32_MSIPLL1N 0U
- #if STM32_MSIPLL1SEL == 0
+ #if STM32_MSIPLL0SEL == 0
#define RCC_MSIRC0CLK 96010000U
#define RCC_MSIRC1CLK 23986000U
#else
Thanks!