General Project Update

- Whitespace cleanup
- Recycled content of old wiki page.
pull/894/head
nightwalker-87 2020-03-24 21:11:38 +01:00
rodzic 562cd2496e
commit a09ef54cf5
7 zmienionych plików z 111 dodań i 135 usunięć

Wyświetl plik

@ -39,6 +39,7 @@ Currently known working combinations of programmers and targets are listed in [d
**Windows**: download [v1.6.0](https://github.com/texane/stlink/releases/tag/v1.6.0) from the releases page.
Windows pre-compiled binaries are available at http://www.emb4fun.de/archive/stlink/index.html (outdated, not recommended for use)
**macOS**: install [from homebrew](http://brewformulas.org/Stlink) or download [v1.6.0](https://github.com/texane/stlink/releases/tag/v1.6.0) from the releases page.

Wyświetl plik

@ -276,6 +276,42 @@ Example to read and write option bytes (currently writing only supported for STM
./st-flash --debug --reset --format binary --flash=128k write option_bytes_dump.bin 0x1FFF7800
```
## Installation of openOCD on Mac OS X with STlink-v2:
`sudo port install openocd +jlink +stlink +ft2232`
`/opt/local/bin/openocd --version`
> Open On-Chip Debugger 0.7.0 (2014-08-11-22:12)
`openocd -f /opt/local/share/openocd/scripts/interface/stlink-v2.cfg -f /opt/local/share/openocd/scripts/target/stm32f1x_stlink.cfg `
> Open On-Chip Debugger 0.8.0 (2014-08-11-15:36)
>
> Licensed under GNU GPL v2
>
> For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.html
>
> Info : This adapter doesn't support configurable speed
>
> Info : STLINK v2 JTAG v21 API v2 SWIM v4 VID 0x0483 PID 0x3748
>
> Info : using stlink api v2
>
> Info : Target voltage: 3.244269
>
> Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
and connecting to the server through telnet yields a successful installation
`telnet localhost 4444`
> Connected to localhost.
>
> Escape character is '^]'.
>
> Open On-Chip Debugger
FAQ
===
@ -292,6 +328,68 @@ Q: Load command does not work in GDB.
A: Some people report XML/EXPAT is not enabled by default when compiling GDB. Memory map parsing thus fail. Use --enable-expat.
Q: How can I install stlink and flash binaries on Mac OS X ?
A: Installed on Mac OS X 10.9.4 with ports method,
however STlink v2 does not seem to work with libusb if you upgrade to the newest firmware !!
Only older firmware on STlink v2 works.
[https://coderwall.com/p/oznj_q](https://coderwall.com/p/oznj_q)
`sudo port install libusb automake autoconf pkgconfig`
`aclocal --force -I /opt/local/share/aclocal`
`git clone https://github.com/texane/stlink.git stlink-utility`
`cd stlink-utility`
`./autogen.sh`
`./configure`
`make`
Then trying to flash the image with STLINK v2 :
`./st-flash write ~/Downloads/irq.bin 0x8000000`
> libusb_handle_events() timeout
>
> [!] send_recv
ST-Link/V2 debugger with downgraded V2.14.3 firmware:
https://drive.google.com/folderview?id=0Bzv7UpKpOQhnbXJVVEg4VUo2M1k
After downgrading the firmware, flashing works as described here:
http://community.spark.io/t/how-to-flash-a-brand-new-freshly-soldered-stm32f103-chip/3906
`./st-flash write ~/Downloads/irq.bin 0x8000000`
> 2014-08-11T23:14:52 INFO src/stlink-common.c: Loading device parameters....
>
> 2014-08-11T23:14:52 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410
>
> 2014-08-11T23:14:52 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in
> pages of 1024 bytes
>
> 2014-08-11T23:14:52 INFO src/stlink-common.c: Attempting to write 24904 (0x6148) bytes to stm32 address: 134217728
> (0x8000000)
>
> Flash page at addr: 0x08006000 erased
>
> 2014-08-11T23:14:53 INFO src/stlink-common.c: Finished erasing 25 pages of 1024 (0x400) bytes
>
> 2014-08-11T23:14:53 INFO src/stlink-common.c: Starting Flash write for VL/F0 core id
>
> 2014-08-11T23:14:53 INFO src/stlink-common.c: Successfully loaded flash loader in sram 24/24 pages written
>
> 2014-08-11T23:14:54 INFO src/stlink-common.c: Starting verification of write complete
>
> 2014-08-11T23:14:54 INFO src/stlink-common.c: Flash written and verified! jolly good!
Notes
=====

Wyświetl plik

@ -1,108 +0,0 @@
Welcome to the stlink wiki! (Archived: 2014-08-11)
Misc:
Windows pre-compiled binaries are available at http://www.emb4fun.de/archive/stlink/index.html
FAQ:
Q: Where can I get help? Is there a forum or maybe a mailing list?
A: todo
Q: How can I install stlink and flash binaries on Mac OS X ?
A: **20140811: ** installed on Mac OS X 10.9.4 with ports method, however STlink v2 does not seem to work with libusb if you upgrade to the newest firmware !! Only older firmware on STlink v2 works.
[https://coderwall.com/p/oznj_q](https://coderwall.com/p/oznj_q)
`sudo port install libusb automake autoconf pkgconfig`
`aclocal --force -I /opt/local/share/aclocal`
`git clone https://github.com/texane/stlink.git stlink-utility`
`cd stlink-utility`
`./autogen.sh`
`./configure`
`make`
Then trying to flash the image with STLINK v2 :
`./st-flash write ~/Downloads/irq.bin 0x8000000`
> libusb_handle_events() timeout
>
> [!] send_recv
After downgrading the firmware, flashing works
ST-Link/V2 debugger with downgraded V2.14.3 firmware:
https://drive.google.com/folderview?id=0Bzv7UpKpOQhnbXJVVEg4VUo2M1k
as described here:
http://community.spark.io/t/how-to-flash-a-brand-new-freshly-soldered-stm32f103-chip/3906
`./st-flash write ~/Downloads/irq.bin 0x8000000`
> 2014-08-11T23:14:52 INFO src/stlink-common.c: Loading device parameters....
>
> 2014-08-11T23:14:52 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410
>
> 2014-08-11T23:14:52 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in
> pages of 1024 bytes
>
> 2014-08-11T23:14:52 INFO src/stlink-common.c: Attempting to write 24904 (0x6148) bytes to stm32 address: 134217728
> (0x8000000)
>
> Flash page at addr: 0x08006000 erased
>
> 2014-08-11T23:14:53 INFO src/stlink-common.c: Finished erasing 25 pages of 1024 (0x400) bytes
>
> 2014-08-11T23:14:53 INFO src/stlink-common.c: Starting Flash write for VL/F0 core id
>
> 2014-08-11T23:14:53 INFO src/stlink-common.c: Successfully loaded flash loader in sram 24/24 pages written
>
> 2014-08-11T23:14:54 INFO src/stlink-common.c: Starting verification of write complete
>
> 2014-08-11T23:14:54 INFO src/stlink-common.c: Flash written and verified! jolly good!
Installation of openOCD on Mac OS X with STlink-v2 has been successful:
`sudo port install openocd +jlink +stlink +ft2232`
`/opt/local/bin/openocd --version`
> Open On-Chip Debugger 0.7.0 (2014-08-11-22:12)
`openocd -f /opt/local/share/openocd/scripts/interface/stlink-v2.cfg -f /opt/local/share/openocd/scripts/target/stm32f1x_stlink.cfg `
> Open On-Chip Debugger 0.8.0 (2014-08-11-15:36)
>
> Licensed under GNU GPL v2
>
> For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.html
>
> Info : This adapter doesn't support configurable speed
>
> Info : STLINK v2 JTAG v21 API v2 SWIM v4 VID 0x0483 PID 0x3748
>
> Info : using stlink api v2
>
> Info : Target voltage: 3.244269
>
> Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
and connecting to the server through telnet yields a successful installation
`telnet localhost 4444`
> Connected to localhost.
>
> Escape character is '^]'.
>
> Open On-Chip Debugger

Wyświetl plik

@ -31,4 +31,3 @@ struct flash_opts
int flash_get_opts(struct flash_opts* o, int ac, char** av);
#endif // STLINK_FLASH_H_

Wyświetl plik

@ -904,9 +904,9 @@ int stlink_load_device_params(stlink_t *sl) {
sl->sram_size, sl->sram_size / 1024, sl->flash_size, sl->flash_size / 1024,
(unsigned int)sl->flash_pgsz);
#else
ILOG("%s: %d KiB SRAM, %d KiB flash in %d %s pages.\n",
params->description, sl->sram_size / 1024, sl->flash_size / 1024,
(sl->flash_pgsz < 1024)? sl->flash_pgsz : sl->flash_pgsz/1024,
ILOG("%s: %d KiB SRAM, %d KiB flash in %d %s pages.\n",
params->description, sl->sram_size / 1024, sl->flash_size / 1024,
(sl->flash_pgsz < 1024)? sl->flash_pgsz : sl->flash_pgsz/1024,
(sl->flash_pgsz < 1024)? "byte" : "KiB");
#endif
return 0;
@ -1905,7 +1905,7 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr)
/* clear the pg bit */
clear_flash_cr_pg(sl);
/* set the page erase bit */
set_flash_cr_per(sl);
@ -2855,7 +2855,7 @@ static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_
stlink_read_debug32(sl, addr+4, &val);
WLOG("2nd option bytes is 0x%08x\n",val);
}
}
}
/* Reload options */
stlink_read_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val);

Wyświetl plik

@ -164,7 +164,9 @@ int main(int ac, char** av)
goto on_error;
}
}
else if (o.addr == STM32_G0_OPTION_BYTES_BASE || o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE || o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE + 4){
else if (o.addr == STM32_G0_OPTION_BYTES_BASE ||
o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE ||
o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE + 4){
err = stlink_fwrite_option_bytes(sl, o.filename, o.addr);
if (err == -1)
{
@ -219,7 +221,7 @@ int main(int ac, char** av)
err = stlink_read_option_bytes_f4(sl,&option_byte);
printf("%x\n",option_byte);
}else{
printf("This format is available for STM32F2 and STM32F4 Only\n");
printf("This format is available for STM32F2 and STM32F4 only\n");
}
}else{
if ((o.addr >= sl->flash_base) && (o.size == 0) &&

Wyświetl plik

@ -6,22 +6,19 @@
static bool starts_with(const char * str, const char * prefix) {
size_t n = strlen(prefix);
if(strlen(str) < n) return false;
if (strlen(str) < n) return false;
return (0 == strncmp(str, prefix, n));
}
int flash_get_opts(struct flash_opts* o, int ac, char** av)
{
int flash_get_opts(struct flash_opts* o, int ac, char** av) {
bool serial_specified = false;
// defaults
memset(o, 0, sizeof(*o));
o->log_level = STND_LOG_LEVEL;
// options
while(ac >= 1) {
if (strcmp(av[0], "--version") == 0) {
printf("v%s\n", STLINK_VERSION);
@ -44,18 +41,15 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av)
else {
serial = av[0] + strlen("--serial=");
}
/** @todo This is not really portable, as strlen really returns size_t we need to obey and not cast it to a signed type. */
int j = (int)strlen(serial);
int length = j / 2; //the length of the destination-array
int length = j / 2; // the length of the destination-array
if(j % 2 != 0) return -1;
for(size_t k = 0; j >= 0 && k < sizeof(o->serial); ++k, j -= 2) {
char buffer[3] = {0};
memcpy(buffer, serial + j, 2);
o->serial[length - k] = (uint8_t)strtol(buffer, NULL, 16);
}
serial_specified = true;
}
else if (strcmp(av[0], "--area") == 0 || starts_with(av[0], "--area=")) {
@ -92,7 +86,6 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av)
else {
format = av[0] + strlen("--format=");
}
if (strcmp(format, "binary") == 0)
o->format = FLASH_FORMAT_BINARY;
else if (strcmp(format, "ihex") == 0)
@ -132,7 +125,6 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av)
}
// command and (optional) device name
while(ac >= 1) { // looks like for stlinkv1 the device name and command may be swaped - check both positions in all cases
if (strcmp(av[0], "erase") == 0) {
if (o->cmd != FLASH_CMD_NONE) return -1;
@ -174,32 +166,26 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av)
case FLASH_CMD_READ: // expect filename, addr and size
if((o->area == FLASH_OPTION_BYTES) &&(ac == 0)) break;
if (ac != 3) return -1;
o->filename = av[0];
o->addr = (uint32_t) strtoul(av[1], &tail, 16);
if(tail[0] != '\0') return -1;
o->size = strtoul(av[2], &tail, 16);
if(tail[0] != '\0') return -1;
break;
case FLASH_CMD_WRITE:
if(o->area == FLASH_OPTION_BYTES){
if(ac != 1) return -1;
o->val = (uint32_t)strtoul(av[0], &tail, 16);
}
else if(o->format == FLASH_FORMAT_BINARY) { // expect filename and addr
if (ac != 2) return -1;
o->filename = av[0];
o->addr = (uint32_t) strtoul(av[1], &tail, 16);
if(tail[0] != '\0') return -1;
}
else if(o->format == FLASH_FORMAT_IHEX) { // expect filename
if (ac != 1) return -1;
o->filename = av[0];
}
else {
@ -211,9 +197,7 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av)
}
// some constistence checks
if(serial_specified && o->devname != NULL) return -1; // serial not supported for v1
return 0;
}