2025-01-22 07:15 AM
Hi All,
1. [Part Number] STM32WL33CC1
2. [Environment] Windows OS, STM32CubeIDE version 1.17.0, Firmware package STM32Cube FW_WL3 V1.0.0
3. [Schematics] STM32 Nucleo-64 development board
4. [Details] See below.
5. [Expected behavior] The script would patch file same baudrate
6. [How to reproduce] Write a script and add the script to the Prebuild step in Settings.
7. [Occurrence] Consistent
8. [Sanity checks] See below.
Here’s a rephrased version of your text:
I am attempting to patch a file before building, but I have not been successful. I tried using both a .sh bash script and a Windows .bat file, and they work as expected when executed directly from their respective terminals.
However, when I run them through the STM32CubeIDE Pre-build step in the Settings, they fail to work as intended. Interestingly, the .bat file appears to execute and displays a message in the STM32CubeIDE console stating that the patch was applied. Yet, the actual file remains unchanged.
From git-bash I can run the following command from the root of the project
./stm32wl33x.sh
Below is the bash script that I tried running. This works fine when I use git-bash
#!/bin/bash
git apply stm32wl3x_hal_rcc_ex.patch
STRING="Patch applied successfully!"
echo $STRING
Below is the bat file that I tried running. Again this works fine under CMD.
@Echo off
REM Define the patch file path
set PATCH_FILE=C:\devl\WL33Devl\stm32wl3x_hal_rcc_ex.patch
REM Check if the patch file exists
if not exist "%PATCH_FILE%" (
echo Error: Patch file "%PATCH_FILE%" not found!
exit /b 1
)
REM Apply the patch
echo Applying patch from %PATCH_FILE%...
git apply "%PATCH_FILE%"
if errorlevel 1 (
echo Error applying patch!
exit /b 1
)
In the project setting I added the following to the Prebuild step as shown below
In STM32CubeIDE build output I get the following.
make -j20 all
..\stm32wl33x.bat
Applying patch from C:\devl\WL33Devl\stm32wl3x_hal_rcc_ex.patch...
Patch applied successfully!
Even though it is showing that the patch has been applied successfully the stm32wl33x_hal_rcc_ex.c file is not modified by the patch.
Am I missing something? While I can work around this issue by running the patch from an external terminal, I would prefer to automate the patching process to avoid forgetting it.
Below is the content of the stm32wl3x_hal_rcc_ex.patch file:
diff --git a/Drivers/STM32WL3x_HAL_Driver/Src/stm32wl3x_hal_rcc_ex.c b/Drivers/STM32WL3x_HAL_Driver/Src/stm32wl3x_hal_rcc_ex.c
index 3b4b8f6..855e2c2 100644
--- a/Drivers/STM32WL3x_HAL_Driver/Src/stm32wl3x_hal_rcc_ex.c
+++ b/Drivers/STM32WL3x_HAL_Driver/Src/stm32wl3x_hal_rcc_ex.c
@@ -265,6 +265,8 @@ uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk)
frequency = LSE_VALUE;
break;
case RCC_LPUART1_CLKSOURCE_16M:
+ frequency = 16000000;
+ break;
default:
frequency = HSE_VALUE / 2;
break;
Many thanks in advance.
Ola
Solved! Go to Solution.
2025-01-22 02:05 PM
Hi Bob S,
Thank you for your suggestion. Changing directory up one level in the bat file solved the problem.
Many thanks.
Ola
2025-01-22 01:41 PM
As you already presumably know, the current directory for the IDE build is the 'Debug" or "Release" directory. And your .bat or .sh file is in the project root. So you correctly run the .sh or .bat with "..\". However, the "current directory" remains the "Debug" or "Release" directory. You can verify this by echoing the current directory from the .bat or .sh file. Add a line to the beginning of the .bat or .sh to change directories up one level. Then everything else should work.
2025-01-22 02:05 PM
Hi Bob S,
Thank you for your suggestion. Changing directory up one level in the bat file solved the problem.
Many thanks.
Ola