EmbDev.net

Forum: ARM programming with GCC/GNU tools openocd target program issue


von new k. (Company: hobby) (zb34111)


Rate this post
useful
not useful
Hi Folks,

I had a problem download binary file to target using openocd-usb-tiny-h 
tool. Here is my tool configuration including:
olimex-arm-usb-tiny-h.cfg
makefile
AT91SAM7S256-PROGRAM.CFG
script.ocd
DEMO_at91sam7_blink_ram.cmd for link.

It report successful  programming. then I start the demon with
openocd.exe -s c:/gccfd/openocd/share/openocd/scripts -f 
interface/olimex-arm-usb-tiny-h.cfg   -f 
C:\gccfd\projects\sam9-l9260-blink\project.cfg -d

but when I use command "mdw 0x0 256" to check memory content at address 
0x0, I found the content does not match the binary file main.bin display 
in ultraedit.  I don't know what's wrong with the download, is there 
anything wrong in my configuratoin file or command line.  Thank you for 
your help.

Best regards.

Following is the details of my configuratoin files,

olimex-arm-usb-tiny-h.cfg  is

interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG ARM-USB-TINY-H"
ft2232_layout olimex-jtag
ft2232_vid_pid 0x15ba 0x002a


makefile is

NAME   = demo_at91sam7_blink_ram
# Tool suffix when cross-compiling
CROSS_COMPILE = arm-none-eabi-
# variables
CC      = $(CROSS_COMPILE)gcc
LD      = $(CROSS_COMPILE)ld -v
AR      = $(CROSS_COMPILE)ar
AS      = $(CROSS_COMPILE)as
CP      = $(CROSS_COMPILE)objcopy
OD    = $(CROSS_COMPILE)objdump
CFLAGS  = -I./ -c -fno-common -O0 -g
AFLAGS  = -ahls -mapcs-32 -o crt.o
LFLAGS  =  -Map main.map -Tdemo_at91sam7_blink_ram.cmd
CPFLAGS = --output-target=binary
ODFLAGS  = -x --syms
OBJECTS = crt.o  main.o timerisr.o timersetup.o isrsupport.o 
lowlevelinit.o blinker.o
#OPENOCD VARIABLES
OPENOCD = C:\gccfd\openocd\bin\openocd.exe
OPENOCD_CFG = C:\gccfd\projects\my1st\AT91SAM7S256-PROGRAM.CFG
OPENOCD_ADPT = 
C:\gccfd\openocd\share\openocd\scripts\interface\olimex-arm-usb-tiny-h.c 
fg
# make target called by Eclipse (Project -> Clean ...)
clean:
  -rm $(OBJECTS) crt.lst main.lst main.out main.bin main.hex main.map 
main.dmp
# program target called  by eclipse (project -> program)
program: main.bin
  @echo  "Flash Programming with OpenOCD..."
  $(OPENOCD) -d -f$(OPENOCD_ADPT) -f$(OPENOCD_CFG)
  @echo  "Flash Programming Finished"
#make target called by Eclipse  (Project -> Build Project)
all:  main.out
  @ echo "...copying"
  $(CP) $(CPFLAGS) main.out main.bin
  $(OD) $(ODFLAGS) main.out > main.dmp
main.out: $(OBJECTS) demo_at91sam7_blink_ram.cmd
  @ echo "..linking"
  $(LD) $(LFLAGS) -o main.out $(OBJECTS) libc.a  libm.a libgcc.a
crt.o: crt.s
  @ echo ".assembling"
  $(AS) $(AFLAGS) crt.s > crt.lst
main.o: main.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) main.c
timerisr.o: timerisr.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) timerisr.c
lowlevelinit.o: lowlevelinit.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) lowlevelinit.c
timersetup.o: timersetup.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) timersetup.c
isrsupport.o: isrsupport.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) isrsupport.c
blinker.o: blinker.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) blinker.c

AT91SAM7S256-PROGRAM.CFG is

jtag_rclk 3
reset_config srst_only srst_pulls_trst
# jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x3 -irmask 0x3 
-expected-id $_CPUTAPID
jtag newtap at91sam7s256 cpu -irlen 4 -ircapture 0x1 -irmask 0xf 
-expected-id 0x0
scan_chain
set _TARGETNAME at91sam7s256.cpu
target create $_TARGETNAME arm7tdmi -endian little -chain-position 
$_TARGETNAME -variant arm7tdmi
$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x00200000 
-work-area-size 0x4000 -work-area-backup 0
$_TARGETNAME configure -event reset-init {
        soft_reset_halt
        # RSTC_CR : Reset peripherals
        mww 0xfffffd00 0xa5000004
        # disable watchdog
  mww 0xfffffd44 0x00008000
  # enable user reset
  mww 0xfffffd08 0xa5000001
  # CKGR_MOR : enable the main oscillator
  mww 0xfffffc20 0x00000601
  sleep 10
  # CKGR_PLLR: 96.1097 MHz
  mww 0xfffffc2c 0x00481c0e
  sleep 10
  # PMC_MCKR : MCK = PLL / 2 ~= 48 MHz
  mww 0xfffffc30 0x00000007
  sleep 10
  # MC_FMR: flash mode (FWS=1,FMCN=73)
  mww 0xffffff60 0x00490100
  sleep 100
}
init
reset halt
script script.ocd

Script.ocd is

armv4_5 core_state arm
mww 0xffffff00 0x00000001
mww 0xffffff60 0x00320100
mww 0xfffffd44 0xa0008000
mww 0xfffffc20 0xa0000601
wait_halt 100
mww 0xfffffc2c 0x00480a0e
wait_halt 200
mww 0xfffffc30 0x7
wait_halt 100
mww 0xfffffd08 0xa5000401
wait_halt 100
load_image main.bin 0x0 bin
reset halt
shutdown

link file DEMO_at91sam7_blink_ram.cmd is

ENTRY(_vec_reset)

/* specify the AT91SAM7S256 memory areas  */
MEMORY
{
flash  : ORIGIN = 0,          LENGTH = 256K    /* FLASH EPROM    */
/*  ram    : ORIGIN = 0x00200000, LENGTH = 64K  */    /* static RAM area 
*/
ram    : ORIGIN = 0x0,      LENGTH = 64K      /* static RAM area  */
}


/* define a global symbol _stack_end  (see analysis in annotation above) 
*/
_stack_end = 0xFFFC;

/* now define the output sections  */
SECTIONS
{
  . = 0;                /* set location counter to address zero  */

  .text :                /* collect all sections that should go into 
FLASH after startup  */
  {
    *(.text)            /* all .text sections (code)  */
    *(.rodata)            /* all .rodata sections (constants, strings, 
etc.)  */
    *(.rodata*)            /* all .rodata* sections (constants, strings, 
etc.)  */
    *(.glue_7)            /* all .glue_7 sections  (no idea what these 
are) */
    *(.glue_7t)            /* all .glue_7t sections (no idea what these 
are) */
    _etext = .;            /* define a global symbol _etext just after 
the last code byte */
  } >ram                      /* put all the above into RAM */
/*  } >flash    */
  .data :                /* collect all initialized .data sections that 
go into RAM  */
  {
    _data = .;            /* create a global symbol marking the start of 
the .data section  */
    *(.data)            /* all .data sections  */
    _edata = .;            /* define a global symbol marking the end of 
the .data section  */
  } >ram                    /* put all the above into RAM */

  .bss :                /* collect all uninitialized .bss sections that 
go into RAM  */
  {
    _bss_start = .;          /* define a global symbol marking the start 
of the .bss section */
    *(.bss)              /* all .bss sections  */
  } >ram                /* put all the above in RAM (it will be cleared 
in the startup code */

  . = ALIGN(4);            /* advance location counter to the next 
32-bit boundary */
  _bss_end = . ;            /* define a global symbol marking the end of 
the .bss section */
}
  _end = .;              /* define a global symbol marking the end of 
application RAM */



After that I use

von M. G. (Company: N/A) (gam01hr)


Rate this post
useful
not useful
Check your load script functionality step by step manually.
I used "arm-none-eabi-gdb" from command line to connect to the openOCD 
and typed each command separately. You can also watch/modify openOCD 
commands/responses by "telnet localhost 4444" command.
For target chip STM32F103, for me works:
target remote localhost:3333
monitor soft_reset_halt
monitor soft_reset_halt
monitor soft_reset_halt
monitor reset halt
load
monitor soft_reset_halt
break main
continue

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.