PIO unified debugger and sublimetext

Hello,

I am unable to use the platformio unified debugger with sublime text…
I used the debugger feature with atom and vscode successfully.

I changed my IDE recently to sublime and I am unable to use the debugging feature.
Sublimegdb is installed.
I run the debug command and I get this error

irrespective of the different boards I try with…
I tried with 3-4 different stm32 discovery boards and I get the same issue every time.

These are the sublimegdb specific settings in the pio generated platformio.sublime-project.

   "settings":
    {
         "sublimegdb_workingdir": "/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/disco_f030r8",
         "sublimegdb_exec_cmd": "-exec-continue",
         "sublimegdb_commandline": "/Users/srikrishnachaitanyanarumanchi/.platformio/penv/bin/platformio -f -c sublimetext debug --interface=gdb --interpreter=mi -x .pioinit"

    }

and this is the sublimegdb settings file

{
// All options in here can also be specified in your project settings
// with a prepended “sublimegdb_”. You probably want to
// have something like this in your project settings:
//
// “settings”:
// {
// “sublimegdb_workingdir”: “${folder:${project_path:your_executable_name}}”,
// // NOTE: You MUST provide --interpreter=mi for the plugin to work
// “sublimegdb_commandline”: “gdb --interpreter=mi ./your_executable_name”
//
// }
//
// generalized pattern for using always the current open file with an executable name
// as the current file
// “settings”:
// {
// “sublimegdb_workingdir”: “${folder:${file}}”,
// // put your arguments hear
// “sublimegdb_arguments”: “”,
// // NOTE: You MUST provide --interpreter=mi for the plugin to work
// “sublimegdb_commandline”: “gdb --interpreter=mi --args ./${file_base_name}”
//
//
// }
//
// If you want to debug different executables as part of the same project, you can add something
// like this to your project settings:
//
// “settings”:
// {
// “sublimegdb_executables”:
// {
// “first_executable_name”:
// {
// “workingdir”: “${folder:${project_path:first_executable_name}}”,
// “commandline”: “gdb --interpreter=mi ./first_executable”
// },
// “second_executable_name”:
// {
// “workingdir”: “${folder:${project_path:second_executable_name}}”,
// “commandline”: “gdb --interpreter=mi ./second_executable”
// }
// }
// }
//
// When you start debugging, you will be prompted to choose from one of your executables. Any
// settings not specified for that project will be searched in your project settings (with a
// sublimegdb_ prefix), then in your user settings, then in the default settings.
//
// (Note: if you have multiple executables, and you have a breakpoint set in a source file which
// is not included in the current executable, you may have to set either debug_ext or
// i_know_how_to_use_gdb_thank_you_very_much.)
//
// ${home}, ${project_path:}, ${folder:}, ${file} and ${file_base_name}
// tokens can be used in ‘workingdir’, ‘commandline’, ‘arguments’ options.
//
// ${home} is replaced with the value of the HOME environment variable.
//
// ${project_path:} tries to find a file with the given name in all the registered project folders and
// returns the first file found, or the original file name if none is found.
// Example: ${project_path:main.cpp} tries to find a file named “main.cpp” relative
// to the current project’s folders. If none is found, it is replaced with “main.cpp”.
//
// ${folder:} is replaced with the dirname of the given path.
// Example: ${folder:/path/to/file} is replaced with “/path/to”.
// “workingdir”: “/tmp”,
//
// ${file} is replaced with absolute path to currently open file (if any)
// Example: /home/user/main.cpp
//
// ${file_base_name} is replaced with name without extension of currently
// open file (if any)
// Example: replaced with “main” for file “/home/user/main.cpp”
“workingdir”: “notset”,

// NOTE: You MUST provide --interpreter=mi for the plugin to work
// "commandline": "gdb --interpreter=mi ./executable",
"commandline": "notset",

// Environments for running gdb and gdb server
// Example: "env": {"DISPLAY": ":100"}
"env": "notset",

// Arguments for the program.
// Example: to run "./executable foo bar"
// "arguments": "foo bar"
// To provide user input (stdin) use
// "arguments": "< input.dat"
"arguments": "",

// GDB Server 
// Specify a command and working dir for launching a GDB Server
// This is useful for dealing with "remote" servers that are actually locally 
// connected JTAG boxes
"server_workingdir": "notset",
"server_commandline": "notset",

// The command to use to run the program.
// If you are attaching to a remote program, you
// probably want to change this to -exec-continue
"exec_cmd": "-exec-run",

// Load the image to the remote target
"load_cmd": "-target-download",

// Immediately run the target upload connecting
// When attaching to a remote program, you
// may want to set this to false 
"run_after_init": true,

// Attempt to update stack information while the program is running
// If your remote target does not support non-stop, set this to false
"update_while_running" : true,

// Attach to a remote target?  This is needed here because "-gdb-set target-async 1" must be
// done prior to attaching
"attach_cmd" : "notset",

// For the larger binaries with lot of shared libraries
// the loading within the gdb could take much longer.
// Configure the thread wait timeout by setting gdb_timeout
"gdb_timeout": 60,

// Define debugging window layout (window split)
// first define column/row separators, then refer to them to define cells
"layout":
{
    "cols": [0.0, 0.33, 0.66, 1.0],
    "rows": [0.0, 0.75, 1.0],
    "cells":
    [ // c1 r1 c2 r2
        [0, 0, 3, 1], // -> (0.00, 0.00), (1.00, 0.75)
        [0, 1, 1, 2], // -> (0.00, 0.75), (0.33, 1.00)
        [1, 1, 2, 2], // -> (0.33, 0.75), (0.66, 1.00)
        [2, 1, 3, 2]  // -> (0.66, 0.75), (1.00, 1.00)
    ]
},

// visual stuff
"breakpoint_scope": "keyword.gdb",
"breakpoint_icon": "circle",
"position_scope": "entity.name.class",
"position_icon": "bookmark",
"changed_variable_scope": "entity.name.class",
"changed_variable_icon": "",

// The group used for opening files
"file_group": 0,

"session_group": 1,
"session_open": true,

"console_group": 1,
"console_open": true,

"variables_group": 1,
"variables_open": true,

"callstack_group": 2,
"callstack_open": true,

"registers_group": 2,
"registers_open": false,

"disassembly_group": 2,
"disassembly_open": false,
// Set to "intel" for intel disassembly flavor. All other
// values default to using "att" flavor.
"disassembly_flavor": "intel",

"threads_group": 3,
"threads_open": true,

"breakpoints_group": 3,
"breakpoints_open": true,

// If set to true will push the layout before debugging
// and pop it when debugging ends
"push_pop_layout": true,

// If set to true will close the gdb views when the
// debugging session ends
"close_views": true,

// File to optionally write all the raw data read from and written to the gdb session and the inferior program.
// Setting it to "stdout" will write the output to the python console
"debug_file": "stdout",

// Add "pending breakpoints" for symbols that are dynamically loaded from
// external shared libraries
"debug_ext" : false,

// Whether to log the raw data read from and written to the gdb session and the inferior program.
"debug": true,

// Disables showing the error message dialog when something goes wrong
"i_know_how_to_use_gdb_thank_you_very_much": false

}

Any ideas on what I am missing?? Did anyone else face this issue with sublime and pio??

Thanks in advance!! :slight_smile:

Ok…
never mind… It was a PEBKAC error… :stuck_out_tongue:

For anyone else who might run into the same issue.
The board in question is STM32F030 discovery.

You must add the extra commands as shown in
http://docs.platformio.org/en/latest/plus/debugging.html#st-util-and-st-link

These lines specifically.

debug_tool = custom
debug_port = :4242
debug_server = $PLATFORMIO_HOME_DIR/packages/tool-stlink/bin/st-util

Once I added those lines in the platformio.ini file, sublimegdb started working… :slight_smile:

Manually running the command in the sublime-project shone some light as to the possible cause what I did wrong…

In retrospect I realise, I gave absolutely no information about my project, board, platformio.ini files… :-I

Does it work now? Can you do step debugging?

Actually I spoke too early. The sublimegdb opened the debug session. However there was absolutely no indication that I was able to debug.

I tried with a simple Blinky for the target board and I never got the leds to blink.
I am at work now and have tried to debug with a stm32l100 discovery board.
I had to create a custom board for this, since the stm32l100 discovery is not in the present boards.

this is my disco_l100rct6.json file

{
“platform”: “ststm32”,
“build”: {
“core”: “stm32”,
“cpu”: “cortex-m3”,
“extra_flags”: “-DSTM32L100xC”,
“f_cpu”: “32000000L”,
“mcu”: “stm32l100rct6”
},
“debug”: {
“default_tools”: [
“stlink”
],
“onboard_tools”: [
“stlink”
],
“openocd_target”: “stm32l1”,
“svd_path”: “STM32L1xx.svd”
},
“frameworks”: [
“stm32cube”,
“mbed”
],
“name”: “ST 32L100DISCOVERY”,
“upload”: {
“maximum_ram_size”: 16384,
“maximum_size”: 262144,
“protocol”: “stlink”,
“protocols”: [
“stlink”,
“blackmagic”,
“mbed”
]
},
“url”: “32L100CDISCOVERY - Discovery kit with STM32L100RC MCU - STMicroelectronics”,
“vendor”: “ST”
}

and this is my platformio.ini file.

; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; Redirecting...

[env:disco_l100rct6]
platform = ststm32
board = disco_l100rct6
framework = stm32cube
build_flags = -IInc
debug_tool = custom
debug_port = :4242
debug_server = $PLATFORMIO_HOME_DIR/packages/tool-stlink/bin/st-util
debug_extra_cmds =
break main.c:99
watch counter

and this is my main.c file (generated from the stm32cubemx software.

/**


  • @file : main.c
  • @brief : Main program body

** This notice applies to any and all portions of this file

  • that are not between comment pairs USER CODE BEGIN and
  • USER CODE END. Other portions of this file, whether
  • inserted by the user or by software development tools
  • are owned by their respective copyright owners.
  • COPYRIGHT(c) 2018 STMicroelectronics
  • Redistribution and use in source and binary forms, with or without modification,
  • are permitted provided that the following conditions are met:
    1. Redistributions of source code must retain the above copyright notice,
  •  this list of conditions and the following disclaimer.
    
    1. Redistributions in binary form must reproduce the above copyright notice,
  •  this list of conditions and the following disclaimer in the documentation
    
  •  and/or other materials provided with the distribution.
    
    1. Neither the name of STMicroelectronics nor the names of its contributors
  •  may be used to endorse or promote products derived from this software
    
  •  without specific prior written permission.
    
  • THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
  • AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  • IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  • DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  • FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  • DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  • SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  • CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  • OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  • OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/
/
Includes ------------------------------------------------------------------*/
#include “main.h”
#include “stm32l1xx_hal.h”

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private variables ---------------------------------------------------------*/

/* USER CODE BEGIN PV /
/
Private variables ---------------------------------------------------------*/

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);

/* USER CODE BEGIN PFP /
/
Private function prototypes -----------------------------------------------*/

/* USER CODE END PFP */

/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**

  • @brief The application entry point.
  • @retval None
    /
    int main(void)
    {
    /
    USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration----------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals /
MX_GPIO_Init();
/
USER CODE BEGIN 2 */
uint32_t counter = 0;
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_RESET);

/* USER CODE END 2 */

/* Infinite loop /
/
USER CODE BEGIN WHILE */
while (1)
{

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 /
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_8 | GPIO_PIN_9);
HAL_Delay(500);
counter++;
}
/
USER CODE END 3 */

}

/**

  • @brief System Clock Configuration
  • @retval None
    */
    void SystemClock_Config(void)
    {

RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;

/**Configure the main internal regulator output voltage 
*/

__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

/**Initializes the CPU, AHB and APB busses clocks 
*/

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = 16;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
_Error_Handler(FILE, LINE);
}

/**Initializes the CPU, AHB and APB busses clocks 
*/

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
_Error_Handler(FILE, LINE);
}

/**Configure the Systick interrupt time 
*/

HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

/**Configure the Systick 
*/

HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}

/** Configure pins as
* Analog
* Input
* Output
* EVENT_OUT
* EXTI
*/
static void MX_GPIO_Init(void)
{

GPIO_InitTypeDef GPIO_InitStruct;

/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, LD4_Pin|LD3_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin : B1_Pin */
GPIO_InitStruct.Pin = B1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : LD4_Pin LD3_Pin */
GPIO_InitStruct.Pin = LD4_Pin|LD3_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**

  • @brief This function is executed in case of error occurrence.
  • @param file: The file name as string.
  • @param line: The line in file as a number.
  • @retval None
    */
    void _Error_Handler(char file, int line)
    {
    /
    USER CODE BEGIN Error_Handler_Debug /
    /
    User can add his own implementation to report the HAL error return state /
    while(1)
    {
    }
    /
    USER CODE END Error_Handler_Debug */
    }

#ifdef USE_FULL_ASSERT
/**

  • @brief Reports the name of the source file and the source line number
  •     where the assert_param error has occurred.
    
  • @param file: pointer to the source file name
  • @param line: assert_param error line source number
  • @retval None
    /
    void assert_failed(uint8_t
    file, uint32_t line)
    {
    /* USER CODE BEGIN 6 /
    /
    User can add his own implementation to report the file name and line number,
    tex: printf(“Wrong parameters value: file %s on line %d\r\n”, file, line) /
    /
    USER CODE END 6 /
    }
    #endif /
    USE_FULL_ASSERT */

/**

  • @}
    */

/**

  • @}
    */

/************************ (C) COPYRIGHT STMicroelectronics *END OF FILE/

The code compiles and I am able to flash it to the board. The leds blink as well…
But I am back to square one with the same error popping up when I try to debug.
I get the same pop up “You have not configured the plugin correctly…”

I am guessing I configured something wrong in th board.json file…

Manually running the same command as specified in the sublime-project file for debugging using platformio seems to be working . It is however flaky and seems to quit often. Further it seems to delete the watchpoints.

This is the entire log of the operations when run from command line.

platformio -f -c sublimetext debug --interface=gdb --interpreter=mi -x .pioinit
~"PlatformIO Plus (https://pioplus.com) v1.3.6\n"
=thread-group-added,id="i1"
~"Reading symbols from /Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/.pioenvs/disco_l100rct6/firmware.elf..."
~"done.\n"
~"PlatformIO Unified Debugger > http://bit.ly/pio-debug\n"
~"PlatformIO: Initializing remote target...\n"
2018-07-09T09:54:57 INFO common.c: Loading device parameters....
2018-07-09T09:54:57 INFO common.c: Device connected is: L1 Medium-Plus-density device, id 0x10086427
2018-07-09T09:54:57 INFO common.c: SRAM size: 0x8000 bytes (32 KiB), Flash: 0x40000 bytes (256 KiB) in pages of 256 bytes
2018-07-09T09:54:57 INFO gdb-server.c: Chip ID is 00000427, Core ID is  2ba01477.
2018-07-09T09:54:57 INFO gdb-server.c: Listening at *:4242...
2018-07-09T09:54:57 INFO gdb-server.c: Found 6 hw breakpoint registers
2018-07-09T09:54:57 INFO gdb-server.c: GDB connected.
=thread-group-started,id="i1",pid="42000"
=thread-created,id="1",group-id="i1"
~"0x0800124c in Reset_Handler ()\n"
*stopped,frame={addr="0x0800124c",func="Reset_Handler",args=[]},thread-id="1",stopped-threads="all"
=breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x080002b0",func="main",file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="73",thread-groups=["i1"],times="0",original-location="main"}
2018-07-09T09:54:57 INFO gdb-server.c: Found 6 hw breakpoint registers
+download,{section=".isr_vector",section-size="316",total-size="832619"}
+download,{section=".isr_vector",section-sent="316",section-size="316",total-sent="316",total-size="832619"}
+download,{section=".text",section-size="4468",total-size="832619"}
+download,{section=".rodata",section-size="40",total-size="832619"}
+download,{section=".init_array",section-size="4",total-size="832619"}
+download,{section=".fini_array",section-size="4",total-size="832619"}
+download,{section=".data",section-size="4",total-size="832619"}
2018-07-09T09:54:57 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134217728 (0x8000000)
st-util 1.4.0
Flash page at addr: 0x08000000 erased2018-07-09T09:54:57 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:57 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:57 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:57 INFO common.c: Starting verification of write complete
2018-07-09T09:54:57 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:57 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134217984 (0x8000100)


Flash page at addr: 0x08000100 erased2018-07-09T09:54:57 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:57 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:57 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:57 INFO common.c: Starting verification of write complete
2018-07-09T09:54:57 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:57 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134218240 (0x8000200)


Flash page at addr: 0x08000200 erased2018-07-09T09:54:57 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:57 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:57 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:57 INFO common.c: Starting verification of write complete
2018-07-09T09:54:57 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:57 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134218496 (0x8000300)


Flash page at addr: 0x08000300 erased2018-07-09T09:54:57 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:57 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:57 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:57 INFO common.c: Starting verification of write complete
2018-07-09T09:54:57 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:57 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134218752 (0x8000400)


Flash page at addr: 0x08000400 erased2018-07-09T09:54:57 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:57 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:57 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:57 INFO common.c: Starting verification of write complete
2018-07-09T09:54:57 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:57 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134219008 (0x8000500)


Flash page at addr: 0x08000500 erased2018-07-09T09:54:57 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:57 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:57 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:57 INFO common.c: Starting verification of write complete
2018-07-09T09:54:57 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:57 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134219264 (0x8000600)


Flash page at addr: 0x08000600 erased2018-07-09T09:54:57 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:57 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:57 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134219520 (0x8000700)


Flash page at addr: 0x08000700 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134219776 (0x8000800)


Flash page at addr: 0x08000800 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134220032 (0x8000900)


Flash page at addr: 0x08000900 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134220288 (0x8000a00)


Flash page at addr: 0x08000a00 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134220544 (0x8000b00)


Flash page at addr: 0x08000b00 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134220800 (0x8000c00)


Flash page at addr: 0x08000c00 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134221056 (0x8000d00)


Flash page at addr: 0x08000d00 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134221312 (0x8000e00)


Flash page at addr: 0x08000e00 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134221568 (0x8000f00)


Flash page at addr: 0x08000f00 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134221824 (0x8001000)


Flash page at addr: 0x08001000 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134222080 (0x8001100)


Flash page at addr: 0x08001100 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO common.c: Attempting to write 256 (0x100) bytes to stm32 address: 134222336 (0x8001200)


Flash page at addr: 0x08001200 erased2018-07-09T09:54:58 INFO common.c: Finished erasing 1 pages of 256 (0x100) bytes
2018-07-09T09:54:58 INFO common.c: Starting Half page flash write for STM32L core id
2018-07-09T09:54:58 INFO flash_loader.c: Successfully loaded flash loader in sram
2018-07-09T09:54:58 INFO common.c: Starting verification of write complete
2018-07-09T09:54:58 INFO common.c: Flash written and verified! jolly good!
2018-07-09T09:54:58 INFO gdb-server.c: Found 6 hw breakpoint registers
=breakpoint-created,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x080002cc",func="main",file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="99",thread-groups=["i1"],times="0",original-location="main.c:99"}
~"PlatformIO: Initialization completed\n"
(gdb) 
~"PlatformIO: Resume the execution to `debug_init_break = tbreak main`\n"
0^running
*running,thread-id="all"
(gdb) 
~"Note: automatically using hardware breakpoints for read-only addresses.\n"
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x080002b0",func="main",file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="73",thread-groups=["i1"],times="1",original-location="main"}
~"\n"
~"Temporary breakpoint 1, main () at src/main.c:73\n"
~"73\t{\n"
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x080002b0",func="main",args=[],file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="73"},thread-id="1",stopped-threads="all"
=breakpoint-deleted,id="1"
(gdb) 
b main.c:113
&"b main.c:113\n"
~"Breakpoint 3 at 0x8000218: file src/main.c, line 113.\n"
=breakpoint-created,bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr="0x08000218",func="SystemClock_Config",file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="113",thread-groups=["i1"],times="0",original-location="main.c:113"}
^done
(gdb) 
watch counter
&"watch counter\n"
~"Watchpoint 4: counter\n"
=breakpoint-created,bkpt={number="4",type="watchpoint",disp="keep",enabled="y",what="counter",thread-groups=["i1"],times="0",original-location="counter"}
^done
(gdb) 
s
&"s\n"
^running
*running,thread-id="all"
(gdb) 
&"Error evaluating expression for watchpoint 4\n"
&"value has been optimized out\n"
~"Watchpoint 4 deleted.\n"
=breakpoint-modified,bkpt={number="4",type="watchpoint",disp="dstp",enabled="y",what="counter",thread-groups=["i1"],times="1",original-location="counter"}
~"main () at src/main.c:81\n"
~"81\t  HAL_Init();\n"
*stopped,frame={addr="0x080002b2",func="main",args=[],file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="81"},thread-id="1",stopped-threads="all"
=breakpoint-deleted,id="4"
(gdb) 
&"\n"
^done
(gdb) 

It is programming well, and starting the debug server gdb.
It breaks at the temporary breakpoint where I set a breakpoint at main.c line 113.
and set a watch on the variable counter.
It seems to hang when I run after setting the breakpoints and watchpoints.

I am guessing this is what is happening even with the disco_f030 board I tried yesterday as well.

changing the debug tool from stink to openocd gave this results.

platformio.ini file

[env:disco_l100rct6]
platform = ststm32
board = disco_l100rct6
framework = stm32cube
build_flags = -IInc
debug_tool = custom
# debug_port = :4242
debug_server =
  $PLATFORMIO_HOME_DIR/packages/tool-openocd/bin/openocd
  -f
  $PLATFORMIO_HOME_DIR/packages/tool-openocd/scripts/target/stm32l1.cfg
  -f
  $PLATFORMIO_HOME_DIR/packages/tool-openocd/scripts/interface/stlink-v2.cfg
debug_extra_cmds = 
	break main.c:112
	watch counter

command line output

platformio -f -c sublimetext debug --interface=gdb --interpreter=mi -x .pioinit
~"PlatformIO Plus (https://pioplus.com) v1.3.6\n"
~"Preparing firmware for debugging...\n"
~"Processing disco_l100rct6 (platform: ststm32; board: disco_l100rct6; framework: stm32cube)\n"
~"-----------------------------------------------------------------------------------------------------\n"
~"Verbose mode can be enabled via `-v, --verbose` option\n"
~"PLATFORM: ST STM32 > ST 32L100DISCOVERY\n"
~"SYSTEM: STM32L100RCT6 32MHz 16KB RAM (256KB Flash)\n"
~"DEBUG: CURRENT(custom) ON-BOARD(stlink) EXTERNAL(blackmagic)\n"
~"Library Dependency Finder -> http://bit.ly/configure-pio-ldf\n"
~"LDF MODES: FINDER(chain) COMPATIBILITY(soft)\n"
~"Collected 0 compatible libraries\n"
~"Scanning dependencies...\n"
~"No dependencies\n"
~"Compiling .pioenvs/disco_l100rct6/src/main.o\n"
~"Compiling .pioenvs/disco_l100rct6/src/stm32l1xx_hal_msp.o\n"
~"Compiling .pioenvs/disco_l100rct6/src/stm32l1xx_it.o\n"
~"Compiling .pioenvs/disco_l100rct6/src/system_stm32l1xx.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_adc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_adc_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_comp.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_cortex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_crc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_cryp.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_cryp_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_dac.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_dac_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_dma.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_flash.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_flash_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_flash_ramfunc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_gpio.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_i2c.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_i2s.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_irda.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_iwdg.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_lcd.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_nor.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_opamp.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_opamp_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_pcd.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_pcd_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_pwr.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_pwr_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_rcc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_rcc_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_rtc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_rtc_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_sd.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_smartcard.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_spi.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_spi_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_sram.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_tim.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_tim_ex.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_uart.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_usart.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_hal_wwdg.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_adc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_comp.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_crc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_dac.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_dma.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_exti.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_fsmc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_gpio.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_i2c.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_opamp.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_pwr.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_rcc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_rtc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_sdmmc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_spi.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_tim.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_usart.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkHALDriver/Src/stm32l1xx_ll_utils.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkCMSISDevice/gcc/startup_stm32l100xc.o\n"
~"Compiling .pioenvs/disco_l100rct6/FrameworkCMSISDevice/system_stm32l1xx.o\n"
~"Archiving .pioenvs/disco_l100rct6/libFrameworkCMSISDevice.a\n"
~"Indexing .pioenvs/disco_l100rct6/libFrameworkCMSISDevice.a\n"
~"Archiving .pioenvs/disco_l100rct6/libFrameworkHALDriver.a\n"
~"Indexing .pioenvs/disco_l100rct6/libFrameworkHALDriver.a\n"
~"Linking .pioenvs/disco_l100rct6/firmware.elf\n"
~"Building .pioenvs/disco_l100rct6/firmware.bin\n"
~"Checking size .pioenvs/disco_l100rct6/firmware.elf\n"
~"Memory Usage -> http://bit.ly/pio-memory-usage\n"
~"DATA:    [          ]   0.2% (used 36 bytes from 16384 bytes)\n"
~"PROGRAM: [          ]   1.7% (used 4512 bytes from 262144 bytes)\n"
~"==================================== [SUCCESS] Took 8.47 seconds ====================================\n"
=thread-group-added,id="i1"
~"Reading symbols from /Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/.pioenvs/disco_l100rct6/firmware.elf..."
~"done.\n"
~"PlatformIO Unified Debugger > http://bit.ly/pio-debug\n"
~"PlatformIO: Initializing remote target...\n"
&"GNU MCU Eclipse 64-bits Open On-Chip Debugger 0.10.0+dev-00392-gbe9ef0b0 (2018-01-12-16:51)\n"
&"Licensed under GNU GPL v2\n"
&"For bug reports, read\n"
&"\thttp://openocd.org/doc/doxygen/bugs.html\n"
&"Error: Debug adapter does not support any transports? Check config file order.\n"
&"Error: unable to select a session transport. Can't continue.\n"
&"shutdown command invoked\n"
&".pioinit:12: Error in sourced command file:\n"
&"Remote connection closed\n"

openocd does not seem to be able to even start a debug session.

I ll try invoking the tools manually and report back in a while…

[Edit]
Manually running the openocd bundled with platformio gives this screen.

invoking the platformio bundled arm gdb. I am able to connect to the openocd instance using “target remote localhost:3333” and load the firmware elf file and single step it.

The leds light up and expected and I am able run the debugger.

A minor quirk I noticed is that the compiler seems to be optimising out the “counter” variable. I am unable to watch the variable. “Info variables” doesn’t show the variable counter. I did add the “volatile” keyword to the variable declaration to prevent the optimisation but the compiler seems to be still optimising it out.

This is the screen I get.

@ivankravets Hope this a little more informative on isolating the issue. :slight_smile:

Could you try this board config and remove all debug_*** options from platformio.ini?

{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m3",
    "extra_flags": "-DSTM32L100xC",
    "f_cpu": "32000000L",
    "mcu": "stm32l100rct6"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "onboard_tools": [
      "stlink"
    ],
    "openocd_board": "st_nucleo_l1",
    "svd_path": "STM32L1xx.svd"
  },
  "frameworks": [
    "stm32cube",
    "mbed"
  ],
  "name": "ST 32L100DISCOVERY",
  "platform": "ststm32",
  "upload": {
    "maximum_ram_size": 16384,
    "maximum_size": 262144,
    "protocol": "stlink",
    "protocols": [
      "stlink",
      "blackmagic",
      "mbed"
    ]
  },
  "url": "https://www.st.com/en/evaluation-tools/32l100cdiscovery.html",
  "vendor": "ST"
}

It runs for a couple of times while I step and then fails again.

platformio -f -c sublimetext debug --interface=gdb --interpreter=mi -x .pioinit
~"PlatformIO Plus (https://pioplus.com) v1.3.6\n"
=thread-group-added,id="i1"
~"Reading symbols from /Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/.pioenvs/disco_l100rct6/firmware.elf..."
~"done.\n"
~"PlatformIO Unified Debugger > http://bit.ly/pio-debug\n"
~"PlatformIO: Initializing remote target...\n"
&"GNU MCU Eclipse 64-bits Open On-Chip Debugger 0.10.0+dev-00392-gbe9ef0b0 (2018-01-12-16:51)\n"
&"Licensed under GNU GPL v2\n"
&"For bug reports, read\n"
&"\thttp://openocd.org/doc/doxygen/bugs.html\n"
&"adapter speed: 300 kHz\n"
&"adapter_nsrst_delay: 100\n"
&"Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD\n"
&"none separate\n"
&"srst_only separate srst_nogate srst_open_drain connect_deassert_srst\n"
&"Info : tcl server disabled\n"
&"Info : telnet server disabled\n"
&"Info : Unable to match requested speed 300 kHz, using 240 kHz\n"
&"Info : Unable to match requested speed 300 kHz, using 240 kHz\n"
&"Info : clock speed 240 kHz\n"
&"Info : STLINK v2 JTAG v17 API v2 SWIM v0 VID 0x0483 PID 0x3748\n"
&"Info : using stlink api v2\n"
&"Info : Target voltage: 2.930000\n"
&"Info : stm32l1.cpu: hardware has 6 breakpoints, 4 watchpoints\n"
&"Info : accepting 'gdb' connection from pipe\n"
&"Info : Device: STM32L1xx (Cat.3 - Medium+ Density)\n"
&"Info : STM32L flash size is 256kb, base address is 0x8000000\n"
=thread-group-started,id="i1",pid="42000"
=thread-created,id="1",group-id="i1"
~"HAL_Delay (Delay=Delay@entry=500) at /Users/srikrishnachaitanyanarumanchi/.platformio/packages/framework-stm32cube/l1/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c:317\n"
~"317\t  while((HAL_GetTick() - tickstart) < Delay)\n"
*stopped,frame={addr="0x080004b8",func="HAL_Delay",args=[{name="Delay",value="500"},{name="Delay@entry",value="500"}],file="/Users/srikrishnachaitanyanarumanchi/.platformio/packages/framework-stm32cube/l1/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c",fullname="/Users/srikrishnachaitanyanarumanchi/.platformio/packages/framework-stm32cube/l1/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c",line="317"},thread-id="1",stopped-threads="all"
=breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x080002b4",func="main",file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="81",thread-groups=["i1"],times="0",original-location="main"}
&"adapter speed: 300 kHz\n"
@"adapter speed: 300 kHz\n"
&"target halted due to debug-request, current mode: Thread \n"
&"xPSR: 0x01000000 pc: 0x08001258 msp: 0x20004000\n"
@"target halted due to debug-request, current mode: Thread \n"
@"xPSR: 0x01000000 pc: 0x08001258 msp: 0x20004000\n"
&"adapter speed: 300 kHz\n"
&"target halted due to debug-request, current mode: Thread \n"
&"xPSR: 0x01000000 pc: 0x08001258 msp: 0x20004000\n"
&"STM32L: Enabling HSI\n"
&"adapter speed: 2000 kHz\n"
+download,{section=".isr_vector",section-size="316",total-size="832602"}
+download,{section=".isr_vector",section-sent="316",section-size="316",total-sent="316",total-size="832602"}
+download,{section=".text",section-size="4480",total-size="832602"}
+download,{section=".rodata",section-size="40",total-size="832602"}
+download,{section=".init_array",section-size="4",total-size="832602"}
+download,{section=".fini_array",section-size="4",total-size="832602"}
+download,{section=".data",section-size="4",total-size="832602"}
&"target halted due to breakpoint, current mode: Thread \n"
&"xPSR: 0x61000000 pc: 0x2000000e msp: 0x20004000\n"
&"adapter speed: 300 kHz\n"
&"target halted due to debug-request, current mode: Thread \n"
&"xPSR: 0x01000000 pc: 0x08001258 msp: 0x20004000\n"
&"adapter speed: 300 kHz\n"
@"adapter speed: 300 kHz\n"
&"target halted due to debug-request, current mode: Thread \n"
&"xPSR: 0x01000000 pc: 0x08001258 msp: 0x20004000\n"
@"target halted due to debug-request, current mode: Thread \n"
@"xPSR: 0x01000000 pc: 0x08001258 msp: 0x20004000\n"
~"PlatformIO: Initialization completed\n"
(gdb) 
~"PlatformIO: Resume the execution to `debug_init_break = tbreak main`\n"
0^running
*running,thread-id="all"
(gdb) 
~"Note: automatically using hardware breakpoints for read-only addresses.\n"
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x080002b4",func="main",file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="81",thread-groups=["i1"],times="1",original-location="main"}
~"\n"
~"Temporary breakpoint 1, main () at src/main.c:81\n"
~"81\t  HAL_Init();\n"
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x080002b4",func="main",args=[],file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="81"},thread-id="1",stopped-threads="all"
=breakpoint-deleted,id="1"
(gdb) 
b main.c:112
&"b main.c:112\n"
~"Breakpoint 2 at 0x80002e8: file src/main.c, line 112.\n"
=breakpoint-created,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x080002e8",func="main",file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="112",thread-groups=["i1"],times="0",original-location="main.c:112"}
^done
(gdb) 
c
&"c\n"
~"Continuing.\n"
^running
*running,thread-id="all"
(gdb) 
=breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x080002e8",func="main",file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="112",thread-groups=["i1"],times="1",original-location="main.c:112"}
~"\n"
~"Breakpoint 2, main () at src/main.c:112\n"
~"112\t  HAL_Delay(500);\n"
*stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame={addr="0x080002e8",func="main",args=[],file="src/main.c",fullname="/Users/srikrishnachaitanyanarumanchi/Documents/PlatformIO/Projects/stm32l100/src/main.c",line="112"},thread-id="1",stopped-threads="all"
(gdb) 
s
&"s\n"
^running
*running,thread-id="all"
(gdb) 
&"Info : halted: PC: 0x080002ec\n"
&"Info : halted: PC: 0x080004ac\n"
~"HAL_Delay (Delay=Delay@entry=500) at /Users/srikrishnachaitanyanarumanchi/.platformio/packages/framework-stm32cube/l1/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c:316\n"
~"316\t  tickstart = HAL_GetTick();\n"
*stopped,reason="end-stepping-range",frame={addr="0x080004b2",func="HAL_Delay",args=[{name="Delay",value="500"},{name="Delay@entry",value="500"}],file="/Users/srikrishnachaitanyanarumanchi/.platformio/packages/framework-stm32cube/l1/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c",fullname="/Users/srikrishnachaitanyanarumanchi/.platformio/packages/framework-stm32cube/l1/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c",line="316"},thread-id="1",stopped-threads="all"
(gdb) 
s
&"s\n"
^running
*running,thread-id="all"
(gdb) 
&"Info : halted: PC: 0x080004a0\n"
~"HAL_GetTick () at /Users/srikrishnachaitanyanarumanchi/.platformio/packages/framework-stm32cube/l1/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c:299\n"
~"299\t  return uwTick;\n"
*stopped,reason="end-stepping-range",frame={addr="0x080004a0",func="HAL_GetTick",args=[],file="/Users/srikrishnachaitanyanarumanchi/.platformio/packages/framework-stm32cube/l1/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c",fullname="/Users/srikrishnachaitanyanarumanchi/.platformio/packages/framework-stm32cube/l1/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c",line="299"},thread-id="1",stopped-threads="all"
(gdb) 

this is the console output when I run the debug command from command line.

My bad… It debugs fine even when I manually invoke the pio debug command.
I gave “s” as the input instead of “step”. Using “step” command to manually step through works just fine.

“continue” or “c” works just fine. I misread the output.
Now I need to get the sublimegdb plugin work with this. instead of manually doing so from the command line.
:slight_smile:

[Edit:]
My mistake was that in assuming the command line for platformio debug would behave the same as gdb.
GDB executes the last command if only enter is pressed. pio debug does not do that.

Further debugging shows this message in the sublime console.

Will write debug info to file: stdout
Running: notset
In directory: notset
error: You have not configured the plugin correctly, the default configuration file and your user configuration file will open in a new window

I am guessing that some settings in the sublime-project file generated by platformio are not setting correctly.
I ll investigate further and see if I can get it to run.

Ok.
It seems to a very weird quirky bug.

I connected the board again, reinitialised the project again using the command line.
then opened the sublime-project file, did nothing except “save all” from the menu of ST3.

Then sublimegdb started working just fine.
Even single stepping and watching the variables.
Sublimegdb works as expected now. :slight_smile:

@ivankravets Thank you for the board definition. maybe this board too can be added to the list of supported boards.

I am leaving this post here if anyone else runs into the same issue later.

Thanks! Added :wink:

Just a follow up post for reference.

The process blew up in my face again when I tried to debug boards.
I carefully retraced my steps and I think I finally figured it out…

I ran the Pio init command from the command line and specified sublimetext as the ide …
It initialised just fine…
but sublimegdb won’t work unless you open the project in sublime and save the project explicitly.

i.e “Project > Save Project as > platform.sublime-project”

it might overwrite the platformio.sublime-project file but a quick undo will revert the changes.
Then and only then does sublimegdb work.

Should we fix something here? https://github.com/platformio/platformio-core/blob/develop/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl

I see that we do automatic execution in wrong position. I’ve just fixed that Disable exec command for Sublime Text debugger · platformio/platformio-core@2ba41cd · GitHub

No Ivan,
The pio command did everything right. I m guessing it is a quirk with the sublime ide and/or sublimedebug package…

I didn’t have to do anything else except literally open the generated project and save it again to get sublimedebug work correctly.

Edit:
maybe this might explain why this is happening. When I generate a new project with “pio init” command, a new project is created. But I am unable to open the project in sublime. It just doesn’t do anything… I have to "Project > add folder to project > " and select the new project folder and then save it again…

Maybe the way that platformio is handling the sublime project creation isn’t entirely compatible??

You need to double click on platformio.sublime-project file from project folder.

I’ve just tested and it works even with complicated FreeRTOS project based on ESP32. See below

Yes, double clicking on the pio generated project file works perfectly…
Including sublimegdb and debugging…
As I have said earlier… PEBKAC error :stuck_out_tongue:

I literally didn’t have to do anything else… just double click on the sublime-project file and everything just magically works…

I m sorry, this entire thread has been a huge wild goose chase owing to my incompetence…
:-I