The binary kernel image can be downloaded directly onto the SoC through the chip's JTAG connector using either an ST Micro Connect 1 or an ST Micro Connect 2. This requires a program (GDB) to run on the host machine which transfers the kernel code through the ST Micro Connect into the memory of the target board.
It is possible to use GDB, the GNU project debugger, to connect to the ST Micro Connect across Ethernet, configure some basic functionality on the target board, and download the kernel to be run.
The STLinux distribution provides:
The 2.2 and 2.3 distributions do not require any additional tools from the ST40 Micro Toolset. However, for ST200 cores, the ST200 Micro Toolset is required to attach a debugger to the cores.
The ST40 Micro Toolset provides the sh4gdb program and the ST200 Micro Toolset provides the st200gdb program.
Note: sh4gdb and st200gdb are the only elements of the bare machine toolset needed for developing Linux applications. The compilers, libraries and associated tools of the bare machine toolset are not used. Instead, use the tools provided with the Linux distribution.
The Micro Toolsets are provided as part of the ST Micro Connect packages or can be obtained individually.
Although it is possible to use sh4-linux-gdb directly, many users find it easier to use the st40load_gdb wrapper script which uses sh4-linux-gdb as the underlying download mechanism.
Note: A wrapper script is also provided for st200gdb. It is identical to the ST40 specific script described below, replacing st40 with st200.
The st40load_gdb script accepts a subset of the arguments of st40load, as follows:
| st40load_gdb switch | Description |
|---|---|
| -b <kernel> | specify the kernel ELF file to download |
| -c <command> | is the GDB command to be executed to initialize the registers of the target. This command is usually given the same name as the target board. |
| -n | do not start running automatically. Enter interactive mode after loading the kernel |
| -t <target> | the name or IP address of the ST Micro Connect |
| -z <address>, <filename> | used to download a ramdisk image. <address> is the address where the ramdisk should be loaded, <filename> is the ramdisk image file. |
| -- <arguments> | any remaining arguments are passed to the Linux kernel as the kernel's command line. |
The syntax for resetting a board using target packs is
(gdb) sh4tp <ST_MICRO_CONNECT>:<BOARD_NAME>:st40
Where
<ST_MICRO_CONNECT> is either the name or the IP address of the ST Micro Connect being used, and <BOARD_NAME> is taken from the list of default supported boards provided by the ST Micro Connect toolset which can be found in the /opt/STM/STLinux-X.X/host/stmc/targetpacks/boards directory:
host% ls /opt/STM/STLinux-X.X/host/stmc/targetpacks/boards
mb390 mb421 mb424 mb442 mb519 mb548 mb618 mb671 mb704 sti7200board
mb282 mb411 mb422 mb435 mb448 mb521 mb602 mb628 mb680 st20board stx710xboard#!/bin/bash BOARD=<name> # The board name taken from the list in # /opt/STM/STLinux-X.X/host/stmc/targetpacks/boards CONNECT=sh4tp # GDB command used to link GDB with targetpack libraries JEI=<name>:$BOARD:st40 # Name of the ST MicroConnect TARGETIP=nnn.nnn.nnn.nnn # IP address to be given to the target SERVERIP=nnn.nnn.nnn.nnn # IP address of your NFS server GWIP=nnn.nnn.nnn.nnn # IP address of your network gateway NETMASK=nnn.nnn.nnn.nnn # Local network subnet mask NAME=jim # Initial hostname for the target AUTOCONF=off # Try to determine addresses automatically? # Root of target's file system SERVERDIR=/opt/STM/STLinux-X.X/devkit/sh4/target # Kernel image KERNEL=$SERVERDIR/boot/vmlinux st40load_gdb \ -t $JEI \ -b $KERNEL \ -c $CONNECT \ -- \ console=ttyAS0 \ root=/dev/nfs \ nfsroot=$SERVERIP:$SERVERDIR \ ip=$TARGETIP::$GWIP:$NETMASK:$NAME::$AUTOCONF \ mem=32m
#!/bin/bash JEI=<name> # Name of the ST MicroConnect TARGETIP=nnn.nnn.nnn.nnn # IP address to be given to the target SERVERIP=nnn.nnn.nnn.nnn # IP address of your NFS server GWIP=nnn.nnn.nnn.nnn # IP address of your network gateway NETMASK=nnn.nnn.nnn.nnn # Local network subnet mask NAME=jim # Initial hostname for the target AUTOCONF=off # Try to determine addresses automatically? # Root of target's file system SERVERDIR=/opt/STM/ST40Linux-2.3/devkit/sh4/target # Kernel image KERNEL=$SERVERDIR/boot/vmlinux st40load_gdb \ -t $JEI \ -b $KERNEL \ -c $CONNECT \ -- \ console=ttyAS0 \ root=/dev/nfs \ nfsroot=$SERVERIP:$SERVERDIR \ ip=$TARGETIP::$GWIP:$NETMASK:$NAME::$AUTOCONF \ mem=32m
Note: There must be no "white space" characters after the "\" character at the ends of these lines.
This st40load_gdb script is included in the stlinux20-cross-sh4-st40load.gdb RPM package, and is installed in the same directory as the Linux cross compiler. The parameters (for example JEI=<name>) must be tailored to fit your setup before the script is executed. In particular the root file system (SERVERDIR=) must match the file system name used in Preparing the root file system and Setting up the NFS server.