2021-11-07 12:35 AM
Hi,
I'm using an STM32L496G board, currently flashing it through CubeMX/Touchgfx Designer.
In the future, i'd like to be able to flashthe board by running a bash/python/other script from a linux machine.
The board will be connected to the linux machine via uart.
I'm not sure how to do that, and I wasn't able to find helpful instructions online.
I'd appreciate your help.
Thank you!
Solved! Go to Solution.
2021-11-30 11:28 PM
My solution:
(script is obviously very basic and needs error checking etc.)
import os
CUBE_PROGRAMMER_CLI_PATH = 'C:\\Program Files\\STMicroelectronics\\STM32Cube\\STM32CubeProgrammer\\bin'
FILE_TO_DOWNLOAD_NAME = 'MyFlashes\\MyFile.elf'
CONNECTION_PORT = 'swd'
EXTERNAL_LOADER_PATH = 'MX25R6435F_STM32L496G-DISCO.stldr'
def main():
os.chdir(CUBE_PROGRAMMER_CLI_PATH)
os.system(f"STM32_Programmer_CLI.exe -c port={CONNECTION_PORT} -w {FILE_TO_DOWNLOAD_NAME} -v -el {EXTERNAL_LOADER_PATH}")
os.system(f"STM32_Programmer_CLI.exe -c port={CONNECTION_PORT} -hardRst")
if __name__ == '__main__':
main()
2021-11-07 12:45 AM
There are command line tools available: openOCD and stlink-tools.
hth
KnarfB
2021-11-07 06:58 AM
STM32CubeProgrammer has a command line interface (CLI) available as well. That's probably the simplest.
2021-11-25 11:32 PM
Hello @CHech.1 ,
Were you able to resolve the issue you described in this post ?
If yes, please share the final solution you found and mark the reply as Best answer.
Imen
2021-11-30 11:28 PM
My solution:
(script is obviously very basic and needs error checking etc.)
import os
CUBE_PROGRAMMER_CLI_PATH = 'C:\\Program Files\\STMicroelectronics\\STM32Cube\\STM32CubeProgrammer\\bin'
FILE_TO_DOWNLOAD_NAME = 'MyFlashes\\MyFile.elf'
CONNECTION_PORT = 'swd'
EXTERNAL_LOADER_PATH = 'MX25R6435F_STM32L496G-DISCO.stldr'
def main():
os.chdir(CUBE_PROGRAMMER_CLI_PATH)
os.system(f"STM32_Programmer_CLI.exe -c port={CONNECTION_PORT} -w {FILE_TO_DOWNLOAD_NAME} -v -el {EXTERNAL_LOADER_PATH}")
os.system(f"STM32_Programmer_CLI.exe -c port={CONNECTION_PORT} -hardRst")
if __name__ == '__main__':
main()