Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install st-link on raspberry pi
@holla2040

This comment has been minimized.

Copy link

@holla2040 holla2040 commented Apr 29, 2019

Thanks, worked on first try!

@speedyzerotwo

This comment has been minimized.

Copy link

@speedyzerotwo speedyzerotwo commented Sep 21, 2019

Performing Test C_SUPPORTS_WMISSING_VARIABLE_DECLARATIONS failed...

@opertechnic

This comment has been minimized.

Copy link

@opertechnic opertechnic commented Mar 25, 2020

[RELEASE]
Scanning dependencies of target stlink-static
[ 3%] Building C object CMakeFiles/stlink-static.dir/src/chipid.c.o
[ 6%] Building C object CMakeFiles/stlink-static.dir/src/common.c.o
[ 10%] Building C object CMakeFiles/stlink-static.dir/src/usb.c.o
/stlink/stlink-repo/src/usb.c: In function ‘_stlink_usb_version’:
/stlink/stlink-repo/src/usb.c:192:18: error: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘int’} and ‘uint32_t’ {aka ‘unsigned int’} [-Werror=sign-compare]
if (size != rep_len) {
^~
cc1: all warnings being treated as errors
make[3]: *** [CMakeFiles/stlink-static.dir/build.make:89: CMakeFiles/stlink-static.dir/src/usb.c.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:73: CMakeFiles/stlink-static.dir/all] Error 2
make[1]: *** [Makefile:152: all] Error 2
make: *** [Makefile:28: release] Error 2

@rvhaasen

This comment has been minimized.

Copy link

@rvhaasen rvhaasen commented Apr 7, 2020

I had the same problem with building the code.
After having changed the type of 2 variables size and rep_len to int32_t (in src/usb.c) the build process succeeded.

int _stlink_usb_version(stlink_t sl) {
struct stlink_libusb * const slu = sl->backend_data;
unsigned char
const data = sl->q_buf;
unsigned char* const cmd = sl->c_buf;
// ssize_t size;
// uint32_t rep_len = 6;
int32_t size;
int32_t rep_len = 6;

@FarzinBenam

This comment has been minimized.

Copy link

@FarzinBenam FarzinBenam commented Aug 2, 2020

Thank you.

@Joypacharya

This comment has been minimized.

Copy link

@Joypacharya Joypacharya commented Nov 9, 2020

Hello Sir,
Thank for sharing the command for install stlink in raspberry pi
but I am facing issue while writing the .bin file into my controller Stm32f103cB.
Here the command for execution,
sudo st-flash --flash=128k write /home/pi/Desktop/Spell/Bootloader.bin 0x08000000

the outcome -->

st-flash 1.6.1-109-g781557d
2020-11-09T17:40:59 INFO common.c: F1xx Medium-density: 20 KiB SRAM, 128 KiB flash in at least 1 KiB pages.
file /home/pi/Desktop/Spell/Bootloader.bin md5 checksum: 4636419d5875ac7103da4e6dc66c566, stlink checksum: 0x0006b357
2020-11-09T17:40:59 INFO common.c: Attempting to write 4572 (0x11dc) bytes to stm32 address: 134217728 (0x8000000)
2020-11-09T17:41:00 INFO common.c: Flash page at addr: 0x08000000 erased
2020-11-09T17:41:00 INFO common.c: Flash page at addr: 0x08000400 erased
2020-11-09T17:41:00 INFO common.c: Flash page at addr: 0x08000800 erased
2020-11-09T17:41:00 INFO common.c: Flash page at addr: 0x08000c00 erased
2020-11-09T17:41:00 INFO common.c: Flash page at addr: 0x08001000 erased
2020-11-09T17:41:00 INFO common.c: Finished erasing 5 pages of 1024 (0x400) bytes
2020-11-09T17:41:00 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2020-11-09T17:41:00 INFO flash_loader.c: Successfully loaded flash loader in sram
5/5 pages written
2020-11-09T17:41:00 INFO common.c: Starting verification of write complete
2020-11-09T17:41:00 ERROR common.c: Verification of flash failed at offset: 0
stlink_fwrite_flash() == -1

I hope anyone helps me resolve my problem,

@rvhaasen

This comment has been minimized.

Copy link

@rvhaasen rvhaasen commented Nov 10, 2020

Because I could not erase the read-only protection bits with st-link, I switched to openocd. It installed fine on RP ( using apt-install ) and works fine: erasing, resetting read-only protection fuses, and flashing an image. Thats all I need.
The GUI version of st-link can reset the protection bits. I could however not find how to do this from the commandline version of st-link. If somebody knows if and how this can be done I would be happy to hear it.

@Erol444

This comment has been minimized.

Copy link

@Erol444 Erol444 commented Dec 3, 2020

@Joypacharya I had a similar problem:

EraseFlash - Sector:0x4 Size:0x20000 2020-12-03T13:14:56 INFO common.c: Flash page at addr: 0x08020000 er                                                                                             ased
EraseFlash - Sector:0x5 Size:0x40000 2020-12-03T13:14:58 INFO common.c: Flash page at addr: 0x08040000 er                                                                                             ased
2020-12-03T13:14:58 INFO common.c: Finished erasing 6 pages of 262144 (0x40000) bytes
2020-12-03T13:14:58 INFO common.c: Starting Flash write for F2/F4/F7/L4
2020-12-03T13:14:58 INFO flash_loader.c: Successfully loaded flash loader in sram
enabling 32-bit flash writes
size: 32768
2020-12-03T13:14:59 ERROR flash_loader.c: flash loader run error
2020-12-03T13:14:59 ERROR common.c: stlink_flash_loader_run(0x8000000) failed! == -1
stlink_fwrite_flash() == -1

I had the st-link version st-flash 1.6.1-115-g8560f93-dirty (st-flash --version). I tried to checkout to version 1.6 and it worked!
Steps:

  • after cloning the repo, checkout to stlink version 1.6 sudo git checkout 6aa08a6
  • sudo make

I hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment