Arduino IDE 2 & Debug feature

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
Post Reply
luca_stm32
Posts: 4
Joined: Tue Feb 18, 2020 3:37 pm

Arduino IDE 2 & Debug feature

Post by luca_stm32 »

Hi.
Last week Arduino released IDE 2 (IDE 1.8.X is now "legacy"). As described here https://docs.arduino.cc/software/ide-v2 ... 2-debugger, Arduino IDE 2 has the debug functionality!

Searching on google, I found this link https://forum.arduino.cc/t/update-on-ar ... g/980363/3: it seems to me that platform.txt should be modified in order to add this feature (see https://github.com/arduino/ArduinoCore- ... #L129-L140).

Is the implementation of this feature in the STM32duino core roadmap?

Thanks for all your great job.
Regards.
Luca
User avatar
fpiSTM
Posts: 1433
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 73
Location: Le Mans
Contact:

Re: Arduino IDE 2 & Debug feature

Post by fpiSTM »

Hi,

we probably test this.
Anyway any help are welcome. If you succeed to configure it properly do not hesitate to share feedback or do a a PR.

Note that the ide 2.0.0 has some issue. I use it since 1 week and saw several small issues.
luca_stm32
Posts: 4
Joined: Tue Feb 18, 2020 3:37 pm

Re: Arduino IDE 2 & Debug feature

Post by luca_stm32 »

Hi.
In this days, I made some tests in order to make the debugger work with Arduino IDE 2.
I'm on Linux and I used a STlink chinese clone as programmer/debugger.
I tried with a Bluepill board.
I use Arduino IDE 2 AppImage.

First of all, I installed Arduino SAMD board package (ver 1.8.13) in order to have openocd installed.
Then I modified platform.txt and boards.txt as follow:
In platform platform.txt I added the following lines:

# Debugger configuration (general options)
# ----------------------------------------
# EXPERIMENTAL feature:
# - this is alpha and may be subject to change without notice
debug.executable={build.path}/{build.project_name}.elf
debug.toolchain=gcc
debug.toolchain.path={runtime.tools.xpack-arm-none-eabi-gcc-10.3.1-2.3.path}/bin/
debug.toolchain.prefix=arm-none-eabi-
debug.server=openocd
debug.server.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path}/bin/openocd
debug.server.openocd.scripts_dir={runtime.tools.openocd-0.10.0-arduino7.path}/share/openocd/scripts/
debug.server.openocd.script={runtime.platform.path}/variants/{build.variant}/{build.openocdscript}

#
# OpenOCD sketch upload - version with configurable bootloader size
# FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences
#

tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path}
tools.openocd-withbootsize.cmd=bin/openocd
tools.openocd-withbootsize.cmd.windows=bin/openocd.exe

tools.openocd-withbootsize.upload.params.verbose=-d2
tools.openocd-withbootsize.upload.params.quiet=-d0
tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown"

# Program flashes the binary at 0x0000, so use the linker script without_bootloader
tools.openocd-withbootsize.program.params.verbose=-d2
tools.openocd-withbootsize.program.params.quiet=-d0
tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown"

tools.openocd-withbootsize.erase.params.verbose=-d3
tools.openocd-withbootsize.erase.params.quiet=-d0
tools.openocd-withbootsize.erase.pattern=

tools.openocd-withbootsize.bootloader.params.verbose=-d2
tools.openocd-withbootsize.bootloader.params.quiet=-d0
tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown"

In boards.txt, I added only last line to Generic F1 section

################################################################################
# Generic F1
GenF1.name=Generic STM32F1 series

GenF1.build.core=arduino
GenF1.build.board=GenF1
GenF1.build.mcu=cortex-m3
GenF1.build.series=STM32F1xx
GenF1.build.cmsis_lib_gcc=arm_cortexM3l_math
GenF1.build.st_extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} {build.bootloader_flags}
GenF1.build.openocdscript=openocd_scripts/stm32F103.cfg

Then I added two folder under /.arduino15/packages/STMicroelectronics/hardware/stm32/2.3.0/variants/STM32F1xx/F103C4T_F103C6(T-U)/
debug_scripts and openocd_scripts (I don't know why Bluepill variants point to F103C4T_F103C6(T_U) directory).
In debug_scripts I added the file variant.gdb
#
# STM32F103 OpenOCD script.
#
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

# Define 'reset' command
define reset

info reg

break main

# End of 'reset' command
end

target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21g18" -f target/stm32f1x.cfg -c "gdb_port pipe; log_output openocd.log"

and under openocd_script I added the file stm32F103.cfg

#
# STM32F103 OpenOCD script.
#
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

source [find interface/stlink.cfg]

# chip name
set CHIPNAME STM32F103
set ENDIAN little

# choose a port here
set telnet_port 0

source [find target/stm32f1x.cfg]


With this configuration I can debug the code.
I hope I have not forgot something.
I hope this could help.

Regards.
Luca
Post Reply

Return to “IDE's”