L’objectif est d’utiliser un poste de développement sous Ubuntu 12.04 pour programmer une carte cible ATMEL SAM4S.
Vous avez au moins besoin d’installer :
Atmel SAM-ICE est un émulateur JTAG conçu pour les microcontrôleurs ARM Atmel SAMA5, SAM3, SAM4, SAM7 et SAM9. Alimenté par le port USB, il intégre un mode compatible J-Link et supporte GDB en mode serveur.
À savoir : Le JTAG (Joint Test Action Group) est le nom de la norme IEEE 1149.1 intitulée « Standard Test Access Port and Boundary-Scan Architecture ». La technique de Boundary-Scan a été conçue pour faciliter et automatiser le test des cartes électroniques numériques. Elle consiste à donner un accès auxiliaire aux broches d’entrée-sortie des composants numériques fortement intégrés. La norme JTAG est utilisée pour remplacer les émulateurs de microprocesseurs (systèmes de débug sur carte remplaçant physiquement le composant), en donnant un accès direct à l’intérieur du processeur (points d’arrêt, lecture et écriture des registres internes, des mémoires internes et externes …) sans perturber ses interactions avec l’extérieur. On nomme cette technique ICE (In-Circuit Emulator) ou ICD (In-Circuit Debugger), et elle est omniprésente sur les microprocesseurs et microcontrôleurs modernes. Le bus JTAG est également utilisé pour programmer de nombreux microcontrôleurs (grâce à la capacité du JTAG de programmer la mémoire Flash) et pour débugger un microprocesseur. Le bus JTAG est un bus série synchrone.
Sous Linux, SAM-ICE est pris en charge par OpenOCD (Open On-Chip Debugger) ou J-Link SEGGER (https://www.segger.com/jlink-software.html).
$ dmesg
[613589.394792] usb 3-9.4.2: new full-speed USB device number 17 using xhci_hcd
[613589.412689] usb 3-9.4.2: New USB device found, idVendor=1366, idProduct=0101
[613589.412692] usb 3-9.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[613589.412693] usb 3-9.4.2: Product: J-Link
[613589.412694] usb 3-9.4.2: Manufacturer: SEGGER
[613589.412695] usb 3-9.4.2: SerialNumber: 000028010360
Prise en charge par udev :
$ sudo vim /etc/udev/rules.d/45-jlink.rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0101", MODE:="0666", SYMLINK+="jlink_%n"
Télécharger le paquet DEB J-Link version 64 bits sur le site de SEGGER https://www.segger.com/jlink-software.html
Installer le paquet logiciel :
$ sudo dpkg -i jlink_5.12.7_x86_64.deb
$ JLinkGDBServer -if JTAG -device ATSAM4S2B
Remarque : Même si il existe un version d’OpenOCD (la 0.7) dans les dépôts d’Ubuntu 12.04, il est conseillé d’installer la dernière version.
$ sudo apt-get -y install libusb-dev libusb-1.0-0-dev
$ sudo git clone git://git.code.sf.net/p/openocd/code openocd
$ cd openocd/
$ sudo ./bootstrap
$ sudo ./configure
$ sudo make
$ sudo make install
$ sudo cp /usr/local/share/openocd/contrib/99-openocd.rules /etc/udev/rules.d
Attention : Certain warnings (-Wshadow) sont configurés (-Werror) pour déclencher une erreur à la compilation. Cela peut être le cas de l’option -Wshadow. Vous pouvez retirer l’option -Wshadow ou -Werror des variables CFLAGS des Makefile (src/target/Makefile).
$ openocd --version
Open On-Chip Debugger 0.10.0-dev-00324-g12ff09f (2016-06-25-06:47)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
$ vim ~/.sam4s/openocd.cfg
telnet_port 4444
gdb_port 3333
source [find interface/jlink.cfg]
source [find board/atmel_sam4s_ek.cfg]
gdb_flash_program enable
$ openocd -f ~/Téléchargements/sam4s-ek-linux/openocd.cfg
Open On-Chip Debugger 0.10.0-dev-00324-g12ff09f (2016-06-25-06:47)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
adapter speed: 500 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Link ARM V8 compiled Aug 26 2015 15:08:21
Info : Hardware version: 8.00
Info : VTarget = 3.306 V
Info : clock speed 500 kHz
Info : JTAG tap: sam4.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : sam4.cpu: hardware has 6 breakpoints, 4 watchpoints
sam4.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x21000000 pc: 0x0000037c msp: 0x20004fa0
Info : DAP transaction stalled (WAIT) - slowing down
sam4.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x21000000 pc: 0x0000037c msp: 0x20004fa0
Il est maintenant possible d’y accéder par telnet :
$ telnet localhost 4444
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> reg
===== arm v7m registers
(0) r0 (/32)
> halt
> shutdown
$
...
$ openocd -f ~/Téléchargements/sam4s-ek-linux/openocd.cfg -c init -c halt -c "flash erase_address 0x00400000 0x100000" -c reset -c shutdown
Remarque :
0x100000 : la taille de la mémoire flash en notation hexadécimale, pour le SAM4S16C 1 Mo = 2 ^ 20 octets = 0x100000 octets.
Flasher un programme :
$ file led_flash.elf
led_flash.elf: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped
$ openocd -f ~/Téléchargements/sam4s-ek-linux/openocd.cfg -c init -c halt -c "flash write_image erase led_flash.elf" -c reset -c shutdown
L’objectif est d’utiliser un poste de développement sous Ubuntu 12.04 pour programmer une carte cible ATMEL SAM4S. Cela nécessite d’intsaller une chaine de compilation croisée pour ARM :
La procédure est décrite à cette adresse : http://gnuarmeclipse.github.io/toolchain/install/
$ sudo apt-get -y install lib32z1 lib32ncurses5 lib32bz2-1.0
$ sudo apt-get -y install ia32-libs
$ cd /usr/local
$ sudo wget -c https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q1-update/+download/gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2
$ sudo tar xjf gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2
$ /usr/local/gcc-arm-none-eabi-5_3-2016q1/bin/arm-none-eabi-gcc -v
...
gcc version 5.3.1 20160307 (release) [ARM/embedded-5-branch revision 234589] (GNU Tools for ARM Embedded Processors)
$ /usr/local/gcc-arm-none-eabi-5_3-2016q1/bin/arm-none-eabi-gcc
arm-none-eabi-gcc: fatal error: no input files
compilation terminated.
La chaîne de compilation croisée est prête à l’emploi.
ASF (Atmel® Software Framework) est une bibliothèque logicielle MCU pour une grande collection de systèmes embarqués : megaAVR, AVR XMEGA, AVR UC3 et dispositifs SAM. Il simplifie la programmation des microcontrôleurs en fournissant une couche d’abstraction pour le matériel du système embarqué. ASF est conçu pour être utilisé dans les phases d’évaluation, de prototypage, de conception et de production.
Remarque : ASF est intégré dans l’EDI (IDE) Atmel Studio mais il est aussi disponible pour les compilateurs GCC et IAR. Il est téléchargeable gratuitement.
Liens :
Télécharger l’archive asf-standalone-archive-3.31.0.46.zip et l’installer :
$ cd /usr/local
$ sudo unzip asf-standalone-archive-3.31.0.46.zip
$ sudo mv xdk-asf-3.31.0 asf
$ ls -l /usr/local/asf
total 140
-rw-r--r-- 1 root root 101855 avril 26 10:58 asf-releasenotes-3.31.0.pdf
drwxr-xr-x 8 root root 4096 avril 26 11:15 avr32
drwxr-xr-x 8 root root 4096 avril 26 11:16 common
drwxr-xr-x 6 root root 4096 avril 26 11:16 common2
drwxr-xr-x 6 root root 4096 avril 26 11:16 mega
-rw-r--r-- 1 root root 7046 avril 26 10:58 readme.txt
drwxr-xr-x 8 root root 4096 avril 26 11:16 sam
drwxr-xr-x 8 root root 4096 avril 26 11:17 sam0
drwxr-xr-x 21 root root 4096 avril 26 11:17 thirdparty
drwxr-xr-x 8 root root 4096 avril 26 11:18 xmega
Il existe une application de démonstration pour démarrer la programmation du kit Atmel SAM4S avec GCC dans :
$ ls -l /usr/local/asf/sam/applications/getting-started/sam4s16c_sam4s_ek/gcc/
-rw-r--r-- 1 root root 3,4K avril 26 11:33 asf.h
-rw-r--r-- 1 root root 6,6K avril 26 11:33 config.mk
-rw-r--r-- 1 root root 2,2K avril 26 11:33 Makefile
$ cp -r /usr/local/asf/sam/applications/getting-started/sam4s16c_sam4s_ek/gcc .
$ vim ./gcc/Makefile
...
MAKEFILE_PATH = /usr/local/asf/sam/utils/make/Makefile.sam.in
include $(MAKEFILE_PATH)
$ vim ./gcc/config.mk
...
# Path to top level ASF directory relative to this project directory.
PRJ_PATH = /usr/local/asf
...
$ make
make all PROJECT_TYPE=flash
...
text data bss dec hex filename
0x4230 0x86c 0x30e4 31616 7b80 getting-started_flash.elf
OBJDUMP getting-started_flash.lss
NM getting-started_flash.sym
OBJCOPY getting-started_flash.hex
OBJCOPY getting-started_flash.bin
...
// ou
$ make PROJECT_TYPE=flash
$ file getting-started_flash.elf
getting-started_flash.elf: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped
$ openocd -f interface/jlink.cfg -f board/atmel_sam4s_ek.cfg -c init -c halt -c "flash write_image erase getting-started_flash.elf" -c reset -c shutdown
Open On-Chip Debugger 0.10.0-dev-00324-g12ff09f (2016-06-25-06:47)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
adapter speed: 500 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Link ARM V8 compiled Aug 26 2015 15:08:21
Info : Hardware version: 8.00
Info : VTarget = 3.306 V
Info : clock speed 500 kHz
Info : JTAG tap: sam4.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : sam4.cpu: hardware has 6 breakpoints, 4 watchpoints
auto erase enabled
Info : sam4 does not auto-erase while programming (Erasing relevant sectors)
Info : sam4 First: 0x00000000 Last: 0x00000002
Info : Erasing sector: 0x00000000
Info : Erasing sector: 0x00000001
Info : Erasing sector: 0x00000002
wrote 24576 bytes from file getting-started_flash.elf in 1.336224s (17.961 KiB/s)
Info : JTAG tap: sam4.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
shutdown command invoked
Le code source de ce programme : /usr/local/asf/sam/applications/getting-started/main.c
Usage :
# On the computer, open and configure a terminal application
(e.g. HyperTerminal on Microsoft Windows) with these settings:
- 115200 bauds
- 8 bits of data
- No parity
- 1 stop bit
- No flow control
# Start the application.
# The LED(s) should start blinking on the board. In the terminal window, the
following text should appear (values depend on the board and chip used):
-- Getting Started Example xxx --
-- xxxxxx-xx
-- Compiled: xxx xx xxxx xx:xx:xx --
# Pressing and release button 1 should make one LED stop & restart blinking.
# If the button 2 available, pressing button 2 should make the other LED stop & restart blinking.
Relier un adaptateur USB/RS232 sur le port série UART J7. On peut maintenant utiliser un logiciel d’émulation de terminal sur le port série virtuel, au choix :
$ picocom -b 115200 /dev/ttyUSB0
$ screen /dev/ttyUSB0 115200
On lance picocom puis on fait un reset de la carte (bouton NRST) :
$ picocom -b 115200 /dev/ttyUSB0
picocom v1.4
port is : /dev/ttyUSB0
flowcontrol : none
baudrate is : 115200
parity is : none
databits are : 8
escape is : C-a
noinit is : no
noreset is : no
nolock is : no
send_cmd is : ascii_xfr -s -v -l10
receive_cmd is : rz -vv
Terminal ready
-- SAM4S-EK --
-- Compiled: Jun 26 2016 09:45:50 --
Configure system tick to get 1ms tick period.
Configure TC.
Configure buttons with debouncing.
Press USRPB1 to Start/Stop the blue LED D2 blinking.
Press USRPB2 to Start/Stop the green LED D3 blinking.
1 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 1 2 2 1 2 2 1 2 2 2 2 2 2 2 2 2 2
Remarque : on sort de picocom en utilisant la combinaison de touches Ctrl-A puis Ctrl-X.
On va créer un squelette pour pouvoir développer ses propres applications :
$ mkdir modele
$ cp /usr/local/asf/sam/applications/getting-started/sam4s16c_sam4s_ek/gcc/Makefile ./modele/
$ cp /usr/local/asf/sam/applications/getting-started/sam4s16c_sam4s_ek/gcc/config.mk ./modele/
$ vim ./modele/Makefile
...
MAKEFILE_PATH = /usr/local/asf/sam/utils/make/Makefile.sam.in
include $(MAKEFILE_PATH)
Dans config.mk, on ajoute les variables SRCS pour les sources de l’application et INCLUDE_PATH pour les fichiers headers :
$ vim ./gcc/config.mk
...
# Path to top level ASF directory relative to this project directory.
PRJ_PATH = /usr/local/asf
...
TARGET_FLASH = xxx_flash.elf
TARGET_SRAM = xxx_sram.elf
# List of C source files for application
SRCS = main.c
# List of include paths for application
INCLUDE_PATH = ./
CSRCS = \
common/services/clock/sam4s/sysclk.c \
common/services/serial/usart_serial.c \
common/utils/interrupt/interrupt_sam_nvic.c \
common/utils/stdio/read.c \
common/utils/stdio/write.c \
sam/boards/sam4s_ek/init.c \
sam/boards/sam4s_ek/led.c \
sam/drivers/pio/pio.c \
sam/drivers/pio/pio_handler.c \
sam/drivers/pmc/pmc.c \
sam/drivers/pmc/sleep.c \
sam/drivers/tc/tc.c \
sam/drivers/uart/uart.c \
sam/drivers/usart/usart.c \
sam/utils/cmsis/sam4s/source/templates/gcc/startup_sam4s.c \
sam/utils/cmsis/sam4s/source/templates/system_sam4s.c \
sam/utils/syscalls/gcc/syscalls.c \
${SRCS}
INC_PATH = \
common/boards \
common/services/clock \
common/services/gpio \
common/services/ioport \
common/services/serial \
common/services/serial/sam_uart \
common/utils \
common/utils/stdio/stdio_serial \
sam/applications/getting-started \
sam/applications/getting-started/sam4s16c_sam4s_ek \
sam/boards \
sam/boards/sam4s_ek \
sam/drivers/pio \
sam/drivers/pmc \
sam/drivers/tc \
sam/drivers/uart \
sam/drivers/usart \
sam/utils \
sam/utils/cmsis/sam4s/include \
sam/utils/cmsis/sam4s/source/templates \
sam/utils/header_files \
sam/utils/preprocessor \
thirdparty/CMSIS/Include \
thirdparty/CMSIS/Lib/GCC \
sam/applications/getting-started/sam4s16c_sam4s_ek/gcc \
${INCLUDE_PATH}
...
Attention : on n’oublie pas d’enlever le fichier sam/applications/getting-started/main.c de la liste des codes sources à compiler.
$ vim ./modele/main.c
#include <asf.h>
int main (void)
{
board_init();
sysclk_init();
return 0;
}
$ cd modele
$ make
On va créer un script run.sh pour flasher le programme sur la carte :
$ vim run.sh
#!/bin/bash
INTERFACE=jlink
BOARD=atmel_sam4s_ek
FORMAT="ELF 32-bit LSB executable"
OPENOCD=openocd
if [ $# -eq 1 ]
then
if !(test -f $1)
then
echo "Erreur fichier $1"
else
if [ ! -x "`which $OPENOCD 2>&-`" ]
then
echo "Erreur $OPENOCD absent"
else
file "$1" | grep -i "$FORMAT" > /dev/null 2>&1
if [ ${?} -eq "0" ]
then
$OPENOCD -f interface/$INTERFACE.cfg -f board/$BOARD.cfg -c init -c halt -c "flash write_image erase $1" -c reset -c shutdown
else
echo "Erreur format fichier $1"
fi
fi
fi
else
echo "Syntaxe : $(basename $0) fichier.elf"
echo ""
fi
$ ./run.sh
Syntaxe : run.sh fichier.elf
$ ./run.sh xxx_flash.elf
Open On-Chip Debugger 0.10.0-dev-00324-g12ff09f (2016-06-25-06:47)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
adapter speed: 500 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Link ARM V8 compiled Aug 26 2015 15:08:21
Info : Hardware version: 8.00
Info : VTarget = 3.306 V
Info : clock speed 500 kHz
Info : JTAG tap: sam4.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : sam4.cpu: hardware has 6 breakpoints, 4 watchpoints
sam4.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x00400538 msp: 0x20003928
auto erase enabled
Info : sam4 does not auto-erase while programming (Erasing relevant sectors)
Info : sam4 First: 0x00000000 Last: 0x00000000
Info : Erasing sector: 0x00000000
wrote 8192 bytes from file xxx_flash.elf in 0.541521s (14.773 KiB/s)
Info : JTAG tap: sam4.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Error: sam4.cpu -- clearing lockup after double fault
sam4.cpu: target state: halted
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x01000003 pc: 0x00400680 msp: 0xfffffed8
Polling target sam4.cpu failed, trying to reexamine
Info : sam4.cpu: hardware has 6 breakpoints, 4 watchpoints
shutdown command invoked
Lorsque la carte est mise sous tension, cela provoque un RESET qui déclenche l’exécution du gestionnaire d’interruption Reset_Handler()
. Le code de ce gestionnaire se trouve dans le fichier source /usr/local/asf/sam/utils/cmsis/sam4s/source/templates/gcc/startup_sam4s.c
. Il a pour rôle d’initialiser le microcontrôleur, de charger les bibliothèques C et d’appeler la fonction main()
.
La fonction main()
appelle généralement les fonctions board_init()
et sysclk_init()
:
board_init()
est définie dans le fichier source /usr/local/asf/sam/boards/sam4s_ek/init.c
et a pour rôle d’initialiser l’ensemble des composants de la carte de développement SAM4S-EK.sysclk_init()
est définie dans le fichier source /usr/local/asf/common/services/clock/sam4s/sysclk.c
(d’autres fonctions utilisées se situent dans /usr/local/asf/sam/utils/cmsis/sam4s/source/templates/system_sam4s.c
) et a pour rôle d’initialiser les horloges systèmes.Lire : Projet SAM4S-EK sous Linux
Pour programmer la carte Atmel à partir d’un EDI (ou IDE), le plus simple est d’utiliser Eclipse et ses plugins :
GNU ARM Eclipse est un projet open source qui comprend une famille de plugins Eclipse et les outils pour le développement multi-plateforme ARM.
Liens :
Télécharger : https://www.eclipse.org/downloads/download.php?file=/oomph/epp/mars/R2/eclipse-inst-linux64.tar.gz
Installer :
$ sudo mv eclipse-inst-linux64.tar.gz /usr/local
$ sudo tar zxvf eclipse-inst-linux64.tar.gz
$ sudo rm eclipse-inst-linux64.tar.gz
$ cd /usr/local/eclipse-installer
$ ./eclipse-inst
Installer les plugins : http://gnuarmeclipse.github.io/plugins/install/
~/eclipse/cpp-mars/eclipse/eclipse
Faire : New -> C Project
Créer un projet hello-world (ARM Cortex-M) :
Si vous avez installé le plugin GNU ARM Eclipse Packs Support (http://gnuarmeclipse.github.io/plugins/packs-manager/), Configurer la carte pour le projet : Project -> Properties -> C/C++ Build -> Settings
Fabriquer l’exécutable : Project -> Build All (Ctrl+B)
Tester avec J-Link : Run -> Run Configurations… puis cliquer sur Run
-> Import
Sélectionner le répertoire à importer (modele par exemple) :
Project -> Properties -> C/C++ Build -> Settings :
On commence par démarrer le serveur OpenOCD :
$ openocd -f ./openocd.cfg
Le fichier de configuration précise les options suivants :
$ cat openocd.cfg
telnet_port 4444
gdb_port 3333
source [find interface/jlink.cfg]
source [find board/atmel_sam4s_ek.cfg]
gdb_flash_program enable
Remarque : le port attribué à GDB est 3333.
On se connectera avec la commande gdb target remote localhost:3333
puis on exécutera monitor reset init
$ /usr/local/gcc-arm-none-eabi-5_3-2016q1/bin/arm-none-eabi-gdb -x "/usr/local/asf/sam/boards/sam4s_ek/debug_scripts/gcc/sam4s_ek_flash.gdb" -ex "reset" -readnow -se xxx_flash.elf
...
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x004008b0 in SystemCoreClockUpdate () at /usr/local/asf/sam/utils/cmsis/sam4s/source/templates/system_sam4s.c:133
133 SystemCoreClock = CHIP_FREQ_XTAL;
(gdb) monitor reset init
JTAG tap: sam4.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
sam4.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x004008b0 msp: 0x20003960
(gdb) load
Loading section .text, size 0x3d4c lma 0x400000
Loading section .ARM.exidx, size 0x8 lma 0x403d4c
Loading section .relocate, size 0x874 lma 0x403d54
Start address 0x400794, load size 17864
Transfer rate: 12 KB/sec, 5954 bytes/write.
(gdb) where
#0 Reset_Handler () at /usr/local/asf/sam/utils/cmsis/sam4s/source/templates/gcc/startup_sam4s.c:229
(gdb) step
Reset_Handler () at /usr/local/asf/sam/utils/cmsis/sam4s/source/templates/gcc/startup_sam4s.c:236
236 if (pSrc > pDest) {
(gdb) info break
No breakpoints or watchpoints.
(gdb) break main.c:57
Breakpoint 1 at 0x400b64: file main.c, line 57.
(gdb) continue
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.
Breakpoint 1, main () at main.c:61
61 puts("SAM4S-EK - BTS SN\r");
(gdb) watch i
Watchpoint 2: i
(gdb) print i
$1 = 0
...
(gdb) monitor reset init
JTAG tap: sam4.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
sam4.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00400794 msp: 0x20003950
(gdb) load
Loading section .text, size 0x3d4c lma 0x400000
Loading section .ARM.exidx, size 0x8 lma 0x403d4c
Loading section .relocate, size 0x874 lma 0x403d54
Start address 0x400794, load size 17864
Transfer rate: 12 KB/sec, 5954 bytes/write.
(gdb) c
Continuing.
Breakpoint 1, main () at main.c:61
61 puts("SAM4S-EK - BTS SN\r");
Remarque : le Makefile
utilisé fournit la règle debug_flash
pour démarrer gdb directement avec make debug_flash
.
You could then interrupt the GDB session to make the program break, type where to show the stack, list to show the code around the program counter, step through code, set breakpoints or watchpoints, and so on.
Vous pouvez alors utiliser les commandes :
where
pour afficher la pile (stack),list
pour afficher le code,step
pour exécuter en pas à pas, ou next
break
pour définir des points d’arrêt (breakpoints
) ou watch
pour des points de surveillance (watchpoints
)print
pour afficher le contenu de variablebt
, …Remarque : on peut aussi utiliser JLinkGDBServer
qui utilise le port 2331 par défaut de gdb
$ JLinkGDBServer -if JTAG -device ATSAM4S2B
Le logiciel SAM-BA est un ensemble d’outils pour la programmation des microcontrôleurs ARM (SAMA5, SAM3, SAM4, SAM7 et SAM9) fourni par Atmel.
Voir la mise en oeuvre de sam-ba.
rlogin
, telnet
, rcp
, ftp
et rsh
.