OpenOCD partially programming flash.

Hi,

I am using the Eclipse/GDB/OpenOCD OlimexJtagTiny toolchain.

I was “successfully” programming and debugging until my program got bigger than 4K now I get a locations 0 to 0x0FFF programmed correctly and 0x1000 to 0x110F with garbage and locations higher than that programmed correctly.

I know the chip is not faulty because I can program it with Flash Magic.

Also, when I put the target board (an Olimex LPC-P2103 ) back on the Jtag Tiny and run the Eclipse OpenOCD and then debugger ,which is supposed to reprogram the Flash, the program is not corrupted. This means that the OpenOCD is not programming locations 0x1000 to 0x110F.

Anybody got any clues?

setup, config, debug log?

Cheers

Spen

Hi Spen,

I’m very much a beginner at this ARM stuff I hope this is what you were asking about

I’m using Eclipse Ganymede

OpenOCD is r717

My OpenOCD config file:

 #daemon configuration
 telnet_port 4444
 gdb_port 3333 

 #interface
 interface ft2232
 ft2232_device_desc "Olimex OpenOCD JTAG TINY A"
 ft2232_layout "olimex-jtag"
 ft2232_vid_pid 0x15BA 0x0004
 jtag_speed 10
 
 jtag_nsrst_delay 333 
 jtag_ntrst_delay 333
 

 #use combined on interfaces or targets that can't set TRST/SRST separately
 reset_config trst_and_srst combined

 #jtag scan chain
 #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
 jtag_device 4 0x1 0xf 0xe

 #target configuration
 daemon_startup reset

 #target <type> <startup mode>
 #target arm7tdmi <endianness> <reset mode> <chainpos> <variant>
 target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4
 run_and_halt_time 0 30

 #target
 working_area 0 0x40000000 0x4000 nobackup

 #flash configuration
 flash bank lpc2000 0x0 0x8000 0 0 0 lpc2000_v2 14765 calc_checksum

# For more information about the configuration files, take a look at:
# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger

I tell the OpenOCD to program using GDB Hardware Debugging

Using this in the Debug Configuration \Startup window:

target remote localhost:3333

monitor sleep 500

monitor poll

monitor flash probe 0

monitor flash erase 0 0 0

monitor flash write_binary 0 main.bin 0x0

monitor reset run

monitor sleep 500

monitor soft_reset_halt

monitor arm7_9 force_hw_bkpts enable

symbol-file main.out

thbreak main

continue

This is what appears in the console. I saw somewhere how to do a proper log. I see the console getting cleared a couple of times when I launch the debug session so a lot goes on that I don’t see

  • 1-gdb-set confirm off

    1^done

    (gdb)

    2-gdb-set width 0

    2^done

    (gdb)

    3-gdb-set height 0

    3^done

    (gdb)

    4-interpreter-exec console echo

    4^done

    (gdb)

    5-gdb-show prompt

    5^done,value="(gdb) "

    (gdb)

    6-gdb-set new-console on

    &“No symbol "new" in current context.\n”

    6^error,msg=“No symbol "new" in current context.”

    (gdb)

    7 target remote localhost:3333

    No symbol “new” in current context.

    &“target remote localhost:3333\n”

    target remote localhost:3333

    ~“0x00000200 in main () at main.c:137\n”

    0x00000200 in main () at main.c:137

    &“137\tmain.c: No such file or directory.\n”

    ~“\tin main.c\n”

    in main.c

    137 main.c: No such file or directory.

    7^done

    8 target remote localhost:3333

    (gdb)

    target remote localhost:3333

    &“target remote localhost:3333\n”

    ~“0x00000200 in main () at main.c:137\n”

    0x00000200 in main () at main.c:137

    ~“137\tin main.c\n”

    137 in main.c

    8^done

    (gdb)

    9 monitor sleep 500

    &“monitor sleep 500\n”

    monitor sleep 500

    9^done

    (gdb)

    10 monitor poll

    &“monitor poll\n”

    monitor poll

    @“target state: halted\n”

    @“target halted in ARM state due to debug request, current mode: System\n”

    @“cpsr: 0x6000001f pc: 0x00000200\n”

    10^done

    (gdb)

    11 monitor flash probe 0

    &“monitor flash probe 0\n”

    monitor flash probe 0

    @“flash ‘lpc2000’ found at 0x00000000\n”

    11^done

    (gdb)

    12 monitor flash erase 0 0 0

    &“monitor flash erase 0 0 0\n”

    monitor flash erase 0 0 0

    @“Command erase not found\n”

    12^done

    (gdb)

    13 monitor flash write_binary 0 main.bin 0x0

    &“monitor flash write_binary 0 main.bin 0x0\n”

    monitor flash write_binary 0 main.bin 0x0

    monitor reset run

    @“Command write_binary not found\n”

    13^done

    (gdb)

    14 monitor reset run

    &“monitor reset run\n”

    @“JTAG device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)\n”

    14^done

    (gdb)

    15 monitor sleep 500

    monitor sleep 500

    &“monitor sleep 500\n”

    15^done

    (gdb)

    16 monitor soft_reset_halt

    monitor soft_reset_halt

    &“monitor soft_reset_halt\n”

    @“requesting target halt and executing a soft reset\n”

    16^done

    (gdb)

    17 monitor arm7_9 force_hw_bkpts enable

    monitor arm7_9 force_hw_bkpts enable

    &“monitor arm7_9 force_hw_bkpts enable\n”

    @“force hardware breakpoints enabled\n”

    17^done

    (gdb)

    18 symbol-file main.out

    symbol-file main.out

    &“symbol-file main.out\t\n”

    main.out: No such file or directory.

    &“main.out: No such file or directory.\n”

    18^error,msg=“main.out: No such file or directory.”

    (gdb)

    19 thbreak main

    thbreak main

    &“thbreak main\n”

    ~“Hardware assisted breakpoint 1 at 0xe8: file main.c, line 81.\n”

    Hardware assisted breakpoint 1 at 0xe8: file main.c, line 81.

    19^done

    (gdb)

    20 continue

    continue

    &“continue\n”

    ~“main () at main.c:81\n”

    main () at main.c:81

    ~“81\tin main.c\n”

    81 in main.c

    20^done

    (gdb)

    21 restore L:\ELEC\Pollen\Sprayer\Arm\SprayerGanymede\Sprayer\main.out 0x

    restore L:\ELEC\Pollen\Sprayer\Arm\SprayerGanymede\Sprayer\main.out 0x

    Invalid number “0x”.

    &“restore L:\\ELEC\\Pollen\\Sprayer\\Arm\\SprayerGanymede\\Sprayer\\main.out 0x\n”

    &“Invalid number "0x".\n”

    21^error,msg=“Invalid number "0x".”

    (gdb)

    22-break-list

    22^done,BreakpointTable={nr_rows=“0”,nr_cols=“6”,hdr=[{width=“7”,alignment=“-1”,col_name=“number”,colhdr=“Num”},{width=“14”,alignment=“-1”,col_name=“type”,colhdr=“Type”},{width=“4”,alignment=“-1”,col_name=“disp”,colhdr=“Disp”},{width=“3”,alignment=“-1”,col_name=“enabled”,colhdr=“Enb”},{width=“10”,alignment=“-1”,col_name=“addr”,colhdr=“Address”},{width=“40”,alignment=“2”,col_name=“what”,colhdr=“What”}],body=}

    (gdb)

    23 info proc

    &“info proc\n”

    &“Undefined info command: "proc". Try "help info".\n”

    23^error,msg=“Undefined info command: "proc". Try "help info".”

    (gdb)

    24 info program

    &“info program\n”

    ~“Debugging a target over a serial line.\n”

    ~“Program stopped at 0xe8.\n”

    ~“It stopped at a breakpoint that has since been deleted.\n”

    ~“Type "info stack" or "info registers" for more information.\n”

    24^done

    (gdb)

    25 info threads

    &“info threads\n”

    &“warning: RMT ERROR : failed to get remote thread list.\n”

    25^done

    (gdb)

    26-stack-info-depth

    26^done,depth=“1”

    (gdb)

    27-stack-list-frames 0 1

    27^done,stack=[frame={level=“0”,addr=“0x000000e8”,func=“main”,file=“main.c”,line=“81”}]

    (gdb)

    28-data-list-changed-registers

    28^done,changed-registers=[“0”,“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,“10”,“11”,“12”,“13”,“14”,“15”,“16”,“17”,“18”,“19”,“20”,“21”,“22”,“23”,“24”,“25”]

    29 info sharedlibrary

    (gdb)

    &“info sharedlibrary\n”

    ~“No shared libraries loaded at this time.\n”

    29^done

    (gdb)

    30-environment-directory L:/ELEC/Pollen/Sprayer/Arm/SprayerGanymede/Sprayer L:/ELEC/Pollen/Sprayer/Arm/SprayerGanymede/Sprayer/.settings

    30^done,source-path=“L:/ELEC/Pollen/Sprayer/Arm/SprayerGanymede/Sprayer;L:/ELEC/Pollen/Sprayer/Arm/SprayerGanymede/Sprayer/.settings;$cdir;$cwd”

    (gdb)

    31-data-list-register-names

    31^done,register-names=[“r0”,“r1”,“r2”,“r3”,“r4”,“r5”,“r6”,“r7”,“r8”,“r9”,“r10”,“r11”,“r12”,“sp”,“lr”,“pc”,“f0”,“f1”,“f2”,“f3”,“f4”,“f5”,“f6”,“f7”,“fps”,“cpsr”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”,“”]

    (gdb)

    32

    &“\n”

    32^done

    (gdb)

    33-data-disassemble -f main.c -l 81 -n 100 – 1

    33^done,asm_insns=[src_and_asm_line={line=“69”,file=“main.c”,line_asm_insn=[{address=“0x000000d8”,func-name=“main”,offset=“0”,inst=“mov\tr12, sp”},{address=“0x000000dc”,func-name=“main”,offset=“4”,inst="push\t{r11,


  • [/list]

    I chopped a whole lot of stuff from the bottom of this.

    Thanks

    Oops.

    Looking at the console contents I just posted I see the flash erase and flash write_binary commands are not understood.

    I’ll try to work out what I’m supposed to be doing.

    further progress:

    I needed to change: flash erase to flash erase_sector

    and flash write_binary to flash write_image

    So now the flash erase_sector worked but the flash write_image results in:

    Debug:   406 68923 command.c:432 command_run_line(): flash write_image 0 main.bin 0x0
    Debug:   407 68923 command.c:387 find_and_run_command(): Command failed with error code -1401
    

    I can’t find any list to tell me what error code -1401 means.

    Thanks

    the error means the image type is unknown, probably due to the incorrect commandline.

    write_image does not need the flash bank info - it will find the correct bank from the address.

    flash write_image main.bin 0

    should work, and to erase the device aswell try

    flash write_image erase main.bin 0

    Cheers

    Spen

    :smiley:

    Thanks Spen,

    I changed the command to:

    flash write_image erase main.bin 0

    and I’m back in business. :smiley: