Forum: Mikrocontroller und Digitale Elektronik AT91SAM7S256 und OpenOCD


von ARM-Einsteiger (Gast)


Lesenswert?

Hallo.

Ich versuche momentan einen Einstieg in die ARM-Programmierung zu 
finden.
Angefangen hab ich mit der WinARM-Umgebung. Doch das Flashen des 
Controllers mittels Wiggler-Nachbau funktioniert noch nicht so ganz.
Der Compiler erzeugt problemlos die main.bin doch beim flashen 
"verrennt" sich OpenOCD irgendwo. Es werden lediglich folgende Zeilen 
angezeigt:
1
C:\Programme\openocd\bin\openocd-pp.exe -f at91sam7s_flash.cfg
2
Info:    openocd.c:86 main(): Open On-Chip Debugger (2007-04-16 19:30 CEST)
3
Warning: parport.c:372 parport_init(): No parport port specified, using default '0x378' (LPT1)

Anschließend hängt OpenOCD und erzeugt eine CPU-Auslastung von 100%
Im Makefile rufe ich OpenOCD wie folgt auf (lt. beschreibung des 
Tutorials auf dieser Seite):
1
# OpenOCD Flags
2
OPENOCDFLAGS = -f at91sam7s_flash.cfg
3
4
INSIGHT = arm-elf-insight
5
OPENOCD = C:\Programme\openocd\bin\openocd-pp.exe
6
KILLALL = killall
7
8
# Program the device.
9
program: $(TARGET).bin
10
ifeq ($(RUN_MODE),ROM_RUN)
11
   $(OPENOCD) $(OPENOCDFLAGS)
12
endif
13
14
debug: begin insight end
15
16
insight:
17
ifeq ($(RUN_MODE),RAM_RUN)
18
  $(OPENOCD) & $(INSIGHT) $(TARGET).elf -ex "target remote localhost:3333" -ex "monitor arm7_9 sw_bkpts enable" -ex "load"
19
  $(KILLALL) $(OPENOCD)
20
else
21
  $(OPENOCD) & $(INSIGHT) $(TARGET).elf -ex "target remote localhost:3333" -ex "monitor arm7_9 force_hw_bkpts enable"
22
  $(KILLALL) $(OPENOCD)
23
endif

at91sam7s_flash.cfg:
1
#daemon configuration
2
telnet_port 4444
3
gdb_port 3333
4
daemon_startup reset
5
6
#interface
7
interface parport
8
parport_port /dev/parport0
9
parport_cable wiggler
10
jtag_speed 0
11
#reset_config trst_and_srst|trst_only|srst_only srst_pulls_trst|trst_pulls_srst|combined
12
reset_config srst_only
13
14
#jtag scan chain
15
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
16
jtag_device 4 0x1 0xf 0xe
17
18
#target configuration
19
#target <type> <endianness> <startup mode> <chainpos> <variant>
20
target arm7tdmi little run_and_init 0 
21
run_and_halt_time 0 30
22
23
#working_area 0 0x200000 0x4000 nobackup
24
flash bank at91sam7 0 0 0 0 0
25
target_script 0 reset at91sam7_flash.script

und noch das Script at91sam7_flash.script:
1
# 
2
# The following commands will be executed on
3
# reset (because of run_and_init in the config-file)
4
# - halt target
5
# - init ecr
6
# - flash content of file main.bin into target-memory
7
# - shutdown openocd
8
#
9
# created by Martin Thomas 
10
# http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
11
# based on information from Dominic Rath 
12
#
13
14
halt
15
sleep 10
16
17
# Init - taken form the script openocd_at91sam7_ecr.script 
18
mww 0xfffffd44 0x00008000  # disable watchdog
19
mww 0xfffffd08 0xa5000001  # enable user reset
20
mww 0xfffffc20 0x00001001  # CKGR_MOR : enable the main oscillator
21
sleep 10
22
mww 0xfffffc2c 0x000A2A01   # CKGR_PLLR: 100.000 MHz
23
sleep 10
24
mww 0xfffffc30 0x0000000B  # PMC_MCKR : MCK = PLL / 4 = 25 MHz
25
sleep 10
26
mww 0xffffff60 0x003c0100  # MC_FMR: flash mode (FWS=1,FMCN=60)
27
# arm7_9 force_hw_bkpts enable  # program resides in flash
28
29
# AT91SAM7 flash command-"batch"
30
# adapted by Martin Thomas based on information from Dominic Rath - Thanks
31
arm7_9 dcc_downloads enable
32
sleep 10
33
poll
34
flash probe 0
35
flash write 0 main.bin 0x0
36
reset run
37
sleep 10
38
shutdown



Seltsam ist, dass ich mit OpenOCD anfangs auf den Chip zugreifen und so 
die Peripherie (USART ;) ) mittels Memory-Writes initialisieren konnte. 
(Das ist mit folgendem Configfile und debuggen mittels arm-elf-gdb und 
OpenOCD passiert)
1
#define our ports
2
telnet_port 4444
3
gdb_port 3333
4
5
#commands specific to the Amontec JTAGKey
6
interface parport
7
parport_port 0x378
8
parport_cable wiggler
9
jtag_speed 0
10
jtag_nsrst_delay 200
11
jtag_ntrst_delay 200
12
13
#reset_config <signals> [combination] [trst_type] [srst_type]
14
reset_config srst_only srst_pulls_trst
15
16
#jtag_device <IR length> <IR capture> <IR mask> <IDCODE instruction>
17
jtag_device 4 0x1 0xf 0xe
18
19
#daemon_startup <'attach'|'reset'>
20
daemon_startup reset
21
22
#target <type> <endianess> <reset_mode> <jtag#> [variant]
23
target arm7tdmi little run_and_init 0 arm7tdmi
24
25
#run_and_halt_time <target#> <time_in_ms>
26
run_and_halt_time 0 30


Anschließend konnte ich einmal in sagenhaften 29 secunden 13KB ins Flash 
schreiben und seitdem funktioniert nix mehr. Verbinden kann ich noch, 
aber 'halt'en des Cores scheitert. Mittels GDB kann ich überhaupt nicht 
mehr zu OpenOCD Verbinden und mittels Telnet funktioniert es nur 
teilweise (sämtliche Halt-Versuche scheitern im Timeout oder 'hängen' 
von OpenOCD.


Was kann ich tun, um aus dem Dilemma zu entkommen? Wie kann ich einfach 
und zuverlässig den Flash oder das RAM beschreiben?
Wie sehen eure Config-Files aus (zur Orientierung)?

Vielen Dank für Eure Hilfe

von ARM-Einsteiger (Gast)


Lesenswert?

Nachtrag: Irgendwie isses seltsam... starte ich den Rechner neu, 
funktionierts genau einmal und danach nicht mehr. Es funktioniert einmal 
bis zum aufhängen, dann liegt OpenOCD flach. Ich hab auch alle Prozesse 
von der openocd-pp.exe gekillt, aber es hat nix gebracht. ich schätze 
mal, dass das ein Bug ist. Sonst scheint der Chip zu funktionieren.
Auch seltsam ist das Ergebnis des Downloads vom Chip. Ein Versuch war, 
dass ich die 256KB runterziehe aber er bricht bei etwa 52KB mit der 
Meldung "ungültiger Hex-wert 116" (in der Art) zu Telnet hin ab und 
Openocd gibt in sein Log bald 100 mal "ungültiges Zeichen: 0x??" und ?? 
war meist im ASCII-Bereich. Irgendwie bin ich jetz total verwirrt.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.