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

Cannot connect to STM32VL under Linux #679

Closed
cedricboudinet opened this issue Mar 6, 2018 · 10 comments · Fixed by #918
Closed

Cannot connect to STM32VL under Linux #679

cedricboudinet opened this issue Mar 6, 2018 · 10 comments · Fixed by #918

Comments

@cedricboudinet
Copy link
Contributor

cedricboudinet commented Mar 6, 2018

Hello

I am trying to connect to a STM32VL discovery board (STM32F100RBT6B) under Debian 9 32bits.
Unfortunately, st-info seems to be unable to detect the board:

$ st-info --probe
Found 0 stlink programmers

But the board is connected:
$ lsusb
Bus 002 Device 004: ID 0483:3744 STMicroelectronics STLINK Pseudo disk

I checked st-info with a STM32F407 discovery board (STLINK/V2) and it works.

Does it mean that stlink for STLINK/V1 is not working under Linux or am I doing something wrong?

Regards
Cedric

@xor-gate
Copy link
Member

xor-gate commented Mar 6, 2018

I think the stlink v1 programmers are claimed by the kernel and for normal users it is with the default permissions possible to detach the kernel driver for the emulated disk drive and send raw programming commands. Not much people use the stlinkv1 but this is what I found: https://github.com/texane/stlink/blob/ba898b1c9c75800b566e8b1983ff7643e104a994/src/sg.c#L62-L74

@cedricboudinet
Copy link
Contributor Author

/etc/modprobe.d/stlink_v1.conf has been automatically installed and seems to be taken into account.
When I plug the card, dmesg gives:
[ 5290.649419] usb 2-1.2: USB disconnect, device number 5
[ 5293.944538] usb 2-1.2: new full-speed USB device number 6 using ehci-pci
[ 5294.061008] usb 2-1.2: New USB device found, idVendor=0483, idProduct=3744
[ 5294.061021] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 5294.061027] usb 2-1.2: Product: STM32 STLink
[ 5294.061033] usb 2-1.2: Manufacturer: STMicroelectronics
[ 5294.061038] usb 2-1.2: SerialNumber: Pÿn�PgRUG�\xffffffc2\xffffff87
[ 5294.061774] usb-storage 2-1.2:1.0: USB Mass Storage device detected
[ 5294.061958] usb-storage 2-1.2:1.0: device ignored

I think that the last line means that the device is not mounted as a mass storage.

I just tried something else: I connected the board and launched st-util: it manages to connect.
It seems the issue is only with st-info.

@cedricboudinet
Copy link
Contributor Author

STLINK/V1 is ignored in stlink_probe_usb_devs (https://github.com/texane/stlink/blob/b69c1d51b03a4345c4d478ac1d8c2088002cd36a/src/usb.c#L976 and https://github.com/texane/stlink/blob/b69c1d51b03a4345c4d478ac1d8c2088002cd36a/src/usb.c#L1000).
I changed the test to make it took into account but then the stlink_print_info output seems to be broken (e.g. for openocd and serial). Should the display be adapted to the stlink version ?

@Nightwalker-87 Nightwalker-87 modified the milestones: General, Feedback required Feb 19, 2020
@Nightwalker-87 Nightwalker-87 self-assigned this Feb 21, 2020
@Nightwalker-87 Nightwalker-87 removed their assignment Mar 21, 2020
@Nightwalker-87
Copy link
Member

This was reported using Release v1.5.0. As this ticket has not seen any further activity since, we need someone with a ST-Link-v1 programmer (PID: 3744, STLINK_USB_PID_STLINK) to test this again with st-info.
@cedricboudinet: I find that you keep maintaining a fork of this project. Is the related hardware still present and are you able to test?

@Nightwalker-87 Nightwalker-87 modified the milestones: Old issues, v1.5.1 Apr 9, 2020
@cedricboudinet
Copy link
Contributor Author

cedricboudinet commented Apr 9, 2020

@Nightwalker-87 I am not able right now be because of the Covid. The card is in my office and it is still working.

@grevaillot
Copy link
Collaborator

I've got an stm32f100 discovery somewhere, I think it match that descrption, i'll check

@Nightwalker-87
Copy link
Member

@cedricboudinet: That does not matter, we have time. Good to hear though the hardware is still available.
@grevaillot: 8-) 👍

@grevaillot
Copy link
Collaborator

ok, i just tested a clean develop branch build 👍

% lsusb|grep ST
Bus 002 Device 035: ID 0483:3744 STMicroelectronics ST-LINK/V1

erase works,

% ./build/Release/bin/st-flash erase
st-flash 1.6.0-145-g38c8b8b
2020-04-09T14:52:11 INFO common.c: F1xx Value Line: 8 KiB SRAM, 128 KiB flash in 1 KiB pages.
Mass erasing

full flash write is ok

% ./build/Release/bin/st-flash write /tmp/saved.bin 0x8000000
st-flash 1.6.0-145-g38c8b8b
2020-04-09T14:56:17 INFO common.c: F1xx Value Line: 8 KiB SRAM, 128 KiB flash in 1 KiB pages.
2020-04-09T14:56:17 INFO common.c: Attempting to write 131072 (0x20000) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x0801fc00 erased
2020-04-09T14:56:20 INFO common.c: Finished erasing 128 pages of 1024 (0x400) bytes
2020-04-09T14:56:20 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2020-04-09T14:56:20 INFO flash_loader.c: Successfully loaded flash loader in sram
128/128 pages written
2020-04-09T14:56:28 INFO common.c: Starting verification of write complete
2020-04-09T14:56:31 INFO common.c: Flash written and verified! jolly good!

but probe fails ..

% ./build/Release/bin/st-info --probe
Found 0 stlink programmers

@grevaillot
Copy link
Collaborator

Interesting, having a second stlink connected makes it probe the v1:

% ./build/Release/bin/st-info --probe
Found 1 stlink programmers
serial:
hla-serial: ""
flash: 131072 (pagesize: 1024)
sram: 8192
chipid: 0x0420
descr: F1xx Value Line

the stlink_probe() is filtering out the stlink v1 usb pid (pid is missing). But then, the usb open stuff takes care of the v1 first, and probe succeed. That part of code need some care regarding the usb pid checks, this does not really look aligned.

@Nightwalker-87
Copy link
Member

Does not look good to me either, it should be working in any combination and method applied. This is a bug.

@Nightwalker-87 Nightwalker-87 linked a pull request Apr 10, 2020 that will close this issue
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Apr 14, 2020
@Nightwalker-87 Nightwalker-87 moved this to Done in Release v1.6.1 Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants