platformio / platformio-core

Your Gateway to Embedded Software Development Excellence :alien:
https://platformio.org
Apache License 2.0
7.89k stars 792 forks source link

The debug tool does not work ! #1802

Closed Navis-Raven closed 6 years ago

Navis-Raven commented 6 years ago

What kind of issue is this?

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system: Windows 8.1

PlatformIO Version (platformio --version): PlatformIO, version 3.6.0

HW/SW Configuration: [env:disco_l475vg_iot01a] platform = ststm32 board = disco_l475vg_iot01a framework = stm32cube

Description of problem

The debug tool does not work at all for STM32CUBEL4+disco_l475vg_iot01a,

Steps to Reproduce

  1. Click on debug button image

  2. Select PIO Debug image

Actual Results

An error message is displayed, saying that PlatformIO Pre-Debug is unfindable

image

Expected Results

The debugger should work

Additional info:

I've tried also the without pre-debug option, and it does not work. Here are the steps to reproduce this tentative:

  1. Click on debug button (like before) image

  2. Now select "PIO Debug (Skip Pre-Debug)" task: image

Actual Results

It gave me this message error this time image

And these console error message:

Preparing firmware for debugging...
Processing disco_l475vg_iot01a (platform: ststm32; board: disco_l475vg_iot01a; framework: stm32cube)

Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST DISCO-L475VG-IOT01A
SYSTEM: STM32L475VGT6 80MHz 128KB RAM (1MB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvsdisco_l475vg_iot01asrcmain.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcLegacystm32l4xx_hal_can.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_adc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_adc_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_can.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_comp.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_cortex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_crc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_crc_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_cryp.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_cryp_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_dac.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_dac_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_dcmi.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_dfsdm.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_dfsdm_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_dma.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_dma2d.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_dma_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_dsi.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_firewall.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_flash.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_flash_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_flash_ramfunc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_gfxmmu.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_gpio.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_hash.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_hash_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_hcd.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_i2c.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_i2c_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_irda.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_iwdg.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_lcd.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_lptim.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_ltdc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_ltdc_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_nand.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_nor.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_opamp.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_opamp_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_ospi.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_pcd.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_pcd_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_pwr.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_pwr_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_qspi.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_rcc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_rcc_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_rng.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_rtc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_rtc_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_sai.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_sai_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_sd.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_sd_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_smartcard.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_smartcard_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_smbus.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_spi.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_spi_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_sram.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_swpmi.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_tim.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_tim_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_tsc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_uart.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_uart_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_usart.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_usart_ex.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_hal_wwdg.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_adc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_comp.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_crc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_crs.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_dac.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_dma.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_dma2d.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_exti.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_fmc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_gpio.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_i2c.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_lptim.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_lpuart.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_opamp.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_pwr.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_rcc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_rng.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_rtc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_sdmmc.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_spi.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_swpmi.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_tim.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_usart.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_usb.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkHALDriverSrcstm32l4xx_ll_utils.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkCMSISDevicegccstartup_stm32l475xx.o
Compiling .pioenvsdisco_l475vg_iot01aFrameworkCMSISDevicesystem_stm32l4xx.o
Archiving .pioenvsdisco_l475vg_iot01alibFrameworkHALDriver.a
Archiving .pioenvsdisco_l475vg_iot01alibFrameworkCMSISDevice.a
Linking .pioenvsdisco_l475vg_iot01airmware.elf
Building .pioenvsdisco_l475vg_iot01airmware.bin
Checking size .pioenvsdisco_l475vg_iot01airmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   0.0% (used 36 bytes from 131072 bytes)
PROGRAM: [          ]   0.1% (used 1196 bytes from 1048576 bytes)
[SUCCESS] Took 34.56 seconds
Reading symbols from c:/Users/charafeddine/Documents/PlatformIO/Projects/STM32CubeProject/.pioenvs/disco_l475vg_iot01a/firmware.elf...
done.
PlatformIO Unified Debugger > http://bit.ly/pio-debug
PlatformIO: Initializing remote target...
GNU MCU Eclipse 64-bits Open On-Chip Debugger 0.10.0+dev-00392-gbe9ef0b0 (2018-01-12-15:03)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 500 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : tcl server disabled
Info : telnet server disabled
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : clock speed 480 kHz
Error: libusb_open() failed with LIBUSB_ERROR_NOT_FOUND
Error: open failed
in procedure 'init' 
in procedure 'ocd_bouncer'

.pioinit:12: Error in sourced command file:
Remote communication error.  Target disconnected.: Success.

The content of platformio.ini:

; 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
; https://docs.platformio.org/page/projectconf.html

[env:disco_l475vg_iot01a]
platform = ststm32
board = disco_l475vg_iot01a
framework = stm32cube

Source files to reproduce issue: main.h:

#ifndef MAIN_H
#define MAIN_H

#include "stm32l4xx_hal.h"

#define LED_PIN                                GPIO_PIN_5
#define LED_GPIO_PORT                          GPIOA
#define LED_GPIO_CLK_ENABLE()                  __HAL_RCC_GPIOA_CLK_ENABLE()

#endif // MAIN_H

main.c:

#include "main.h"

void LED_Init();

int main(void) 
{
  HAL_Init();
  LED_Init();

  while(1)
  {
    HAL_GPIO_TogglePin(LED_GPIO_PORT, LED_PIN);
    HAL_Delay(100);
  }
}

void LED_Init() 
{
  LED_GPIO_CLK_ENABLE();
  GPIO_InitTypeDef GPIO_InitStruct;
  GPIO_InitStruct.Pin = LED_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  HAL_GPIO_Init(LED_GPIO_PORT, &GPIO_InitStruct);
}

void SysTick_Handler(void) 
{
  HAL_IncTick();
}
Navis-Raven commented 6 years ago

To select the debug task, you can do also this (see below) and selecting one of the two options, and it will give exactly the same result:

image

Navis-Raven commented 6 years ago

I've just tried the same with an Adafruit HUZZAH32 (ESP-32) card with Arduino, and it gave the same result.

UPDATE However this cardboard necessites an excternal debug probe, and I've tested it without probe. Then without probe it's the same result.

Navis-Raven commented 6 years ago

Today I've tried with nRF52-DK with Arduino. Same problem

image

ivankravets commented 6 years ago

Did you install ST-Link USB driver? See http://docs.platformio.org/en/latest/plus/debug-tools/stlink.html

Navis-Raven commented 6 years ago

The link you gave me is dead image

ivankravets commented 6 years ago

Sorry, see updated link above.

Navis-Raven commented 6 years ago

Thanks, No I didn't installed the ST-LINK driver yet, I just followed the tutorials here: http://docs.platformio.org/en/latest/tutorials/index.html#id1

and I applied the tutorial for each of my STM32 Discovery and my nRF-52-DK cardboard. As you can see here there is no driver required in the tutorial image

Same thing with the nRF52-DK for which I had the same issue. image

When I saw that no driver is required in the tutorial I thought that platformio

Navis-Raven commented 6 years ago

Ok After installing ST-LINK driver (for STM32 Discovery IoT node), now it works with "PIO Debug (Skip Pre-Debug)" but not with "PIO Debug". The're is still one issue with one of the two modes

image

Navis-Raven commented 6 years ago

For nRF52-DK:

As previously said there is no indication in the initial tutorial to install any driver for nRF52-DK: http://docs.platformio.org/en/latest/tutorials/nordicnrf52/arduino_debugging_unit_testing.html

When trying to debug without pre-debug ("PIO Debug (Skip Pre-Debug)"), it tries to run CMSIS-DAP debug tool by default. I've tried to install it, but there is one issue with it's installer here: https://github.com/ARMmbed/mbed-cli/issues/733

So I modified platformio.ini in order to work as j-link debugger by adding debug_tool = jlink. This is platformio.ini content :

[env:nrf52_dk]
platform = nordicnrf52
board = nrf52_dk
framework = arduino
debug_tool = jlink

After this I started debugging "PIO Debug (Skip Pre-Debug)" and it worked. I didn't even have to do these steps (described here at: https://docs.platformio.org/en/latest/plus/debug-tools/jlink.html#drivers)

image

So since it works well without running InstDrivers.exe, for what InstDrivers.exe is used for ? Is it necessary ?

I think that the tutorial documentation should includes that the these drivers are prerequisites or at least it should says how to modify platformio.ini in order to have j-link debugger selected directly.

Now when I select "PIO Debug" (with pre-debug) this is the same problem as declared for Discovery IoT Node: this window is displayed: image

Thanks for your answers

ivankravets commented 6 years ago

Now when I select "PIO Debug" (with pre-debug) this is the same problem as declared for Discovery IoT Node: this window is displayed:

Fixed in https://github.com/platformio/platformio-core/commit/78c383eb683b05a16a82fc33957d1f52da525372

Please open IDE Terminal and type pio upgrade --dev.

Navis-Raven commented 6 years ago

Good news ! I saw also that the documentation has been upgraded !

Can you answer the question about the driver ? (see my previous comment)

So since it works well without running InstDrivers.exe, for what InstDrivers.exe is used for ? Is it necessary ?

ivankravets commented 6 years ago

InstDrivers.exe is attended for J-Link debug probe. if you installed these drives before, you don't need to install again.

Navis-Raven commented 6 years ago

@ivankravets , hummm strange I don't think I've installed them before in this PC and it is working anyway, except if InstDrivers installs something in the Nordic dev board

Navis-Raven commented 6 years ago

and why we can start debug session, if the drivers are not installed. this is strange.