Serial Wire (over raspberrypi) Debug Server is a server application that runs on the RPi and interacts with the target microcontroller over Serial Wire Debug (SWD)

Once installed, the server runs as a daemon in the background and is automatically started when the RPi is powered up.

Installation

Download the SWorD Server for Raspberry Pi zip package see here how to install.

Usage

The server runs as a daemon in the background so you should not need to interact with it.

Starting and Stopping the daemon

The system runs under the control of systemd. To start and stop:

pi@RPI4Programmer:~ $ sudo systemctl start SWorDServer 
pi@RPI4Programmer:~ $ sudo systemctl stop SWorDServer 

The systemd control script for the daemon is:

/etc/systemd/system/SWorDServer.service

If you make modifications to this file i.e. to add/remove command line options then you will need to reload the script before restarting the daemon

pi@RPI4Programmer:~ $ sudo systemctl daemon-reload
pi@RPI4Programmer:~ $ sudo systemctl restart SWorDServer

Configuration

The servers config files etc are stored under

/etc/SWorDServer

The server config file is:

/etc/SWorDServer/conf/app.conf

Any changes to this file will require a restart of the server (daemon) to take effect.

Command Line Options

The default command line for the server :

swordserver /appname:SWorDServer

And this is the default command line used when running under systemd via the script SWorDServer.service. This starts up the server and switches it to run in the background using configuration from /etc/SWorDServer.

There are a number of command line options:

-appname:<name>

Directs the server to the location in the file system where its configuration data etc resides: /etc/<name>

-foreground

Allows the application to be run in the foreground from a shell. To stop the daemon and run in the foreground type:

pi@RPI4Programmer:~ $ sudo systemctl stop SWorDServer 
pi@RPI4Programmer:~ $ swordserver -appname:SWorDServer -foreground -loglevel:5

As can be seen this is usually used in conjuction with the loglevel option so that the application logs to the screen so its operation can be monitored in realtime.

-loglevel:<level>

Controls whether the application logs or not. a value of 0 (default) means no logging and a value of 5 means full logging.

On the RPi, log files are generated in:

/var/log/SWorDServer

Log files are managed by the server and are automatically deleted.

Troubleshooting

Check if the daemon is running

From a shell type the command below and you should see output similar to below:

pi@RPI4Programmer:~ $ ps -A | grep -i sword
1089  ?         00:03:54 swordserver
pi@RPI4Programmer:~ $ 

This shows that the server is running with a PID of 1089

If it is not running then restart

Other issues

Many other issues can occur and probably the best way to see what is happening is to run the server in the foreground with logging turned on

pi@RPI4Programmer:~ $ sudo systemctl stop SWorDServer 
pi@RPI4Programmer:~ $ swordserver -appname:SWorDServer -foreground -loglevel:5

The operation of the server can then be viewed in realtime and hopefully a hint to the problem will be visible. even though the server is logging to the screen, the same information will also been sent to the log files.

%d bloggers like this: