Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gbr1 opened this issue Mar 4, 2024 · 2 comments · May be fixed by #2323
Open

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

gbr1 opened this issue Mar 4, 2024 · 2 comments · May be fixed by #2323

Comments

@gbr1
Copy link
Contributor

gbr1 commented Mar 4, 2024

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.

@fpistm fpistm changed the title issue setting DTR and RTS when using STM32CubeProgrammer (Serial) Request: setting DTR and RTS when using STM32CubeProgrammer (Serial) Mar 4, 2024
@fpistm fpistm added this to To do in STM32 core based on ST HAL via automation Mar 4, 2024
@fpistm
Copy link
Member

fpistm commented Mar 15, 2024

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

@gbr1
Copy link
Contributor Author

gbr1 commented Mar 15, 2024

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

fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Mar 29, 2024
Fixes stm32duino#2292

This requires STM32Tools versions higher than 2.2.1.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Mar 29, 2024
Fixes stm32duino#2292

This requires STM32Tools versions higher than 2.2.1.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
@fpistm fpistm linked a pull request Mar 29, 2024 that will close this issue
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Mar 30, 2024
Fixes stm32duino#2292

This requires STM32Tools versions higher than 2.2.1.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants