stm32duino / Arduino_Core_STM32

STM32 core support for Arduino

Home Page:https://github.com/stm32duino/Arduino_Core_STM32/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request: setting DTR and RTS when using STM32CubeProgrammer (Serial)

gbr1 opened this issue · comments

Desktop:

  • OS: macOS 14.3.1
  • Arduino IDE version: 2.3.2
  • STM32 core version: 2.7.1
  • Upload method: STM32 Cube Programmer (Serial)

Board:

  • Name: STM32F4 based

Description:

STM32CubeProgrammer allows the set DTR and RTS values when uploading with serial method.
This seems impossible to do into Arduino framework stm32duino.

There isn't any option parameter in any menu to set DTR and RTS neither seems to be possible to do using a custom board.txt file.

Following is an example of a custom board.txt used in testing.

menu.opt=Optimize
menu.dbg=Debug symbols and core logs
menu.rtlib=C Runtime Library

my_custom_board.name=MY CUSTOM BOARD

my_custom_board.build.core=STMicroelectronics:arduino
my_custom_board.build.board=my_custom_board
my_custom_board.build.st_extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} {build.bootloader_flags}
my_custom_board.build.mcu=cortex-m4
my_custom_board.build.fpu=-mfpu=fpv4-sp-d16
my_custom_board.build.float-abi=-mfloat-abi=hard
my_custom_board.build.series=STM32F4xx

my_custom_board.build.board=STMicroelectronics:GENERIC_F411RCTX
my_custom_board.build.product_line=STM32F411xE
my_custom_board.build.variant=STM32F4xx/F411R(C-E)T

my_custom_board.build.flash_offset=0x0
my_custom_board.upload.maximum_size=262144
my_custom_board.upload.maximum_data_size=131072


# Upload menu
my_custom_board.upload.protocol=1
my_custom_board.upload.options={serial.port.file} rts=low dtr=high
my_custom_board.upload.tool=STMicroelectronics:stm32CubeProg

Note: upload.protocol=1 means serial uploading.

When you upload from Arduino IDE, the script file stm32CubeProg.sh is called, and at line 144 it relies on this command:

${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE:+"-e all"} -q -d "${FILEPATH}" "${ADDRESS}" -s "${ADDRESS}" "${OPTS}"

By reading the documentation of STM32CP_CLI, the -c parameter can accept rts and dtr parameter.

board.txt doesn't allow an "extra_options" parameter, so you have to put rts and dtr after {serial.port.file}. Unfortunately this doesn't work properly because the command interpreter splits upload.options parameter getting only the serial port name.
rts and dtr values are putted at the end of the line and skipped because they are not in -c flag parameter.

Using the OPTS, parameters are added at the end of the command, so they cannot be included in the -c flag.

You can review this by looking STM32CubeProgrammer logs in the terminal.

Hello @gbr1
Just for my information, what is the use case behind this request?
Could help to know to test 😉

hi @fpistm !
We have an ESP32 attached to a STM32F411RC. wrote a sketch in Arduino to make
an USB-to-serial bridge and it works properly with STM32CubeProgrammer.
To get it working you need to set to HIGH the DTR checkbox
Screenshot 2024-03-15 at 10 14 32

If I use Arduino IDE 2.3.2 I cannot select DTR=high. Looking into your uploading system, a script is called and it is impossible to pass correctly the DTR parameter.

Let me know if you need to any other information