Open gfmoore opened 3 years ago
serverType
. If you use sdcc
, serverType
is stm8-sdcc
, if you use iar
or cosmic
, serverType
is st7
.Well, I appreciate the reply, thankyou :)
Yes I eventually figured out that "I" had to compile to an elf file first. In my limited experience admittedly I have seen debugging in VS Code compile things as well. But then I program in JavaScript which is interpreted so ...
I think the issue is that the extension cannot communicate with the STM8S Discovery board through the built in USB. I suppose if I bought a STMlink v2 and wired it up it might work as is, but to work as is I need to figure out how to get the usb and on board debugger chip to communicate with the extension. Any ideas.
As a suggestion, it might be useful to less experienced ones to write some introductory material on how this extension is working so that newbies can get their head around what it is doing. It might then make a bit more sense. Just saying.
:)
Openocd will auto detect stlink device and other usb device !,
Here's how it connect (these processes are automated):
extension ==> stm8-gdb ==> openocd ==> [USB Interface] ==> STLink ==> STM8 MCU
STM8S Discovery board have a an embedded debugger ST-Link. So you only need connect it to your PC, and launch Debug, that's OK !
Uhmm. So does the extension automatically open the openocd? If I do openocd --version from a windows command line I get:
C:\Users\Gordon\Documents\Applications\STM8S\bin>openocd --version xPack OpenOCD, x86_64 Open On-Chip Debugger 0.11.0-00155-ge392e485e ( 2021-03-15-16:44) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html
My output ==================== Initialize ====================
==================== Connect ==================== SEND: set print elements 0
END: set width 0
[END]
Reading symbols from ./main.elf...
done.
END: target extended-remote localhost:3333 localhost:3333: No connection could be made because the target machine actively refused it. [END]
==================== Launch ====================
You can't do that when your target is `exec'
[END]
The program is not being run.
[END]
my launch.json
{ "version": "0.2.0", "configurations": [ { "type": "stm8-debug", "request": "launch", "name": "Launch Program", "serverType": "stm8-sdcc", "executable": ".\main.elf", "cpu": "STM8S105S6", "openOcdConfigs": [ "interface/stlink.cfg", "target/stm8s105.cfg" ] } ] }
I'm just wondering about the paths to the interface and target, let me check the PATH?
No checked path and made explicit
"openOcdConfigs": [
"C:\\Program Files\\xpack-openocd-0.11.0-1\\scripts\\interface\\stlink.cfg",
"C:\\Program Files\\xpack-openocd-0.11.0-1\\scripts\\target\\stm8s105.cfg"
I don't know anything about openOCD, but just for a laugh I did
openocd
C:\Users\Gordon\Documents\Applications\STM8S\bin>openocd xPack OpenOCD, x86_64 Open On-Chip Debugger 0.11.0-00155-ge392e485e (2021-03-15-16:44) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html embedded:startup.tcl:26: Error: Can't find openocd.cfg in procedure 'script' at file "embedded:startup.tcl", line 26 Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Error: Debug Adapter has to be specified, see "adapter driver" command embedded:startup.tcl:26: Error: in procedure 'script' at file "embedded:startup.tcl", line 26
That doesn't look good!
And indeed there isn't an openocd.cfg in scripts
Any thoughts ;)
Thanks to your active help I'm sure we can crack this and make this very helpful to other noobs as well.
Gordon
Use openocd v0.10.0, not v0.11.0
Maybe the new OpenOCD have bugs, when I developed this plugin, v0.11.0 was not existed.
Normally, it looks like this:
my launch.json:
{
"type": "stm8-debug",
"request": "launch",
"name": "openocd",
"serverType": "stm8-sdcc",
"executable": ".\\build\\Debug\\stm8s103f3_sdcc_quickstart.elf",
"cpu": "STM8S003F3",
"openOcdConfigs": [
"interface/stlink.cfg",
"target/stm8s003.cfg"
]
}
No joy
New openocd
C:\Users\Gordon\Documents\Applications\STM8S\bin>openocd --version
GNU MCU Eclipse OpenOCD, 32-bitOpen On-Chip Debugger 0.10.0+dev-00593-g23ad80df4 (2019-04-22-16:40)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
changed launch.json to
{
"version": "0.2.0",
"configurations": [
{
"type": "stm8-debug",
"request": "launch",
"name": "openocd",
"serverType": "stm8-sdcc",
"executable": "main.elf",
"cpu": "STM8S105S6",
"openOcdConfigs": [
"interface/stlink.cfg",
"target/stm8s105.cfg"
]
}
]
}
So there are two things that seem problematic.
The first is the localhost:3333: No connection could be made because the target machine actively refused it.
I turned firewall off, but no joy. Is the dev board running some kind of web server?
The second issue is You can't do that when your target is `exec'
Perhaps I am compiling the source incorrectly.
It's only a simple blinky, but so I could get some practice with Makefile s I split it into 2 src files main.c and delay.c and added a main.h
main.c
//Blink program for STM8S105v6 STM8S-Discovery board
#include "main.h" //Just testing makefile and external function use
#define CLK_CKDIVR *(unsigned char *) 0x50C6 //clock divider register CLK_CKDIVR
#define PD_ODR *(unsigned char *) 0x500F //port d data output latch register
#define PD_DDR *(unsigned char *) 0x5011 //port d data direction register
#define PD_CR1 *(unsigned char *) 0x5012 //port d control register 1
#define PD_CR2 *(unsigned char *) 0x5013 //port d control register 2
int main() {
CLK_CKDIVR = 0x00; //set clock to 16MHz
PD_ODR = 0x00; //turn all pins of port d to low
PD_DDR |= 1 << 0; //PD3 is now ouput - use an OR and bit shift to give 0x00000001
PD_CR1 |= 1 << 0; //PD3 is now pseudo open drain
while(1) { //turn pin on and off
PD_ODR ^= 1 << 0; //XOR with itself pin=0, for video he wants pd3 so did 1 << 3
delay(); //moved to an external function
}
}
delay.c
//Function to provide a delay
#include "main.h"
unsigned long int dlay; //int is 16bit in STM8, though an 8 bit micro (0-4095)
void delay(void) {
for (dlay = 0; dlay < 500000; dlay++) {}
return;
}
main.h
//header file to test Make
void delay(void);
The compile lines in my Makefile are
SRC := src
INC := include
BUILD := build
BIN := bin
CC := sdcc
CFLAGS := -lstm8 -mstm8 -I$(INC)
$(CC) -c $(SRC)/delay.c $(CFLAGS) -o $(BUILD)/
$(CC) $(SRC)/main.c $(BUILD)/delay.rel -I$(INC) -mstm8 --debug --out-fmt-elf
(I haven't figured out how to do the Makefile properly yet, but it works for my hex file well enough).
I think I would like to make sure the openocd is working.
I created a simple openocd.cfg file
source [find interface/stlink.cfg]
source [find target/stm8s105.cfg]
Then I did openocd from command line and got:
GNU MCU Eclipse OpenOCD, 32-bitOpen On-Chip Debugger 0.10.0+dev-00593-g23ad80df4 (2019-04-22-16:40)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1 kHz
srst_only separate srst_gates_jtag srst_open_drain connect_deassert_srst
Info : Listening on port 6666 for tcl connections
Error: couldn't bind telnet to socket on port 4444: No error
This seems similar to the error on VS Code
[SEND]: target extended-remote localhost:3333
localhost:3333: No connection could be made because the target machine actively refused it.
To me, it seems to be saying that it cannot communicate with the device using the SWIM interface through the built in STLink.
I suspect that I need to configure openocd a bit more. Sadly there is no board definition for the STM8S-discovery which is a shame and very surprising. I have looked all over the internet.
I have updated my compile using the information from the link you provided, but I think that should be the next problem to solve :)
regards, Gordon
My updated elf compile if needed. Some flags caused it to fail, not investigated yet. $(CC) -c $(SRC)/delay.c $(CFLAGS) -o $(BUILD)/ $(CC) $(SRC)/main.c $(BUILD)/delay.rel -I$(INC) --std-sdcc11 -mstm8 -lstm8 --debug --out-fmt-elf --all-callee-saves --debug --verbose --stack-auto --fverbose-asm --float-reent --no-peep -o $(BUILD)/$(TARGET).elf
Hi, I have a STM8S005 chip and a cheap ST-LINK v2 clone. First I had troubles to build my code with the necessary debug informations. Now I'm interrested wheter there is the possibility to start openocd automatically. If I start it manually the the plugin connects to local host through port 3333 and I'm able to debug my project. Because I was not able to set up openocd 0.10 to use my ST-LINK v2 clone (it complained about missing ability to use SWIM), I now use openocd 0.11. Because I can debug my program when manual starting openocd I guess there's something wrong with my configuration.
My launch.json looks as following: { "type": "stm8-debug", "request": "launch", "name": "openocd", "serverType": "stm8-sdcc", "interface": "stlink3", "cpu": "STM8S005K6", "executable": "build\Debug\Stm8_3.elf", "svdFile": "stm8s005k6.svd.json", "openOcdConfigs": [ "C:/c/openocd-0.11.0/scripts/interface/stlink-dap.cfg", "C:/c/openocd-0.11.0/scripts/target/STM8S005.cfg" ] } I think the "interface" and the "/interface/stlink-dap.cfg" doesn't fit together. The plugin suggests to use "rlink" or "stlink3" for "interface". However, my only successful attempt using SWIM was with "stlink-dap.cfg".
Any suggests? Thanks in advance.
I have an STM8S discovery board.
I have no idea what I am supposed to do.
Here is my launch.json
{ "version": "0.2.0", "configurations": [ { "type": "stm8-debug", "request": "launch", "name": "Launch Program", "serverType": "stm8-sdcc", "executable": ".\main.elf", "cpu": "STM8S105S6", "openOcdConfigs": [ "interface/stlink-v2.cfg", "target/stm8s105.cfg" ] } ] }
So what is serverType and what values can be used, should be used? When does sdcc create an .elf file and where is that to be found. I know sdcc creates all sorts of files, but from the command line I have not seen an elf ? I can create ihx files easily. What values can I put in for cpu
Here is my output:
==================== Initialize ====================
==================== Connect ==================== SEND: set print elements 0
END: set width 0
[END]
END: target extended-remote localhost:3333 localhost:3333: No connection could be made because the target machine actively refused it. [END]
==================== Launch ====================
[END]
[END]
And this hardly helps either except that it can't find an executable.
I really don't know why I waste so much time on partially documented, non working drivel. I am so glad it works for you and you wanted to share, but really it would have been better if you hadn't bothered unless you DOCUMENT things properly. Not everyone knows what's inside your head.
Thanks.
Gordon big :sigh