Downloading program into FLASH memory of SM470R1B1M

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Downloading program into FLASH memory of SM470R1B1M

    Hi!

    I've been trying to download a program into the flash memory by using the following gdb init script:


    #
    # connect to the J-Link gdb server
    #
    target remote localhost:2331
    #
    # Setup flash programming
    #
    monitor flash device = TMS470R1B1M
    monitor flash download = 1

    #monitor WorkRAM = <SAddr>-<EAddr>
    #monitor flash CFI = <SAddr>-<EAddr>


    #
    # Select target endianess
    #
    monitor endian big
    #
    # Set init JTAG speed to 30 kHz
    #
    monitor speed 30
    #
    # Reset the chip to get to a known state.
    #
    monitor reset
    #
    # CPU core initialization (to be done by user)
    #
    monitor DisableChecks

    monitor WriteU32 0xFFFFFFE0 0x00004007

    # 1 MB FLASH memory @ address 0
    # Mem fine base high reg 0
    monitor WriteU32 0xFFFFFE00 0x00000000
    # Mem fine base low reg 0
    monitor WriteU32 0xFFFFFE04 0x000000B0

    # Mem fine base high reg 1
    monitor WriteU32 0xFFFFFE08 0x00000000
    # Mem fine base low reg 1
    monitor WriteU32 0xFFFFFE0C 0x00000000

    # 64 kB SRAM memory @ address 0x400000
    # Mem fine base high reg 2
    monitor WriteU32 0xFFFFFE10 0x00000040
    # Mem fine base low reg 2
    monitor WriteU32 0xFFFFFE14 0x00000070

    # Mem fine base high reg 3
    monitor WriteU32 0xFFFFFE18 0x00000000
    # Mem fine base low reg 3
    monitor WriteU32 0xFFFFFE1C 0x00000000

    # Mem fine base high reg 4
    monitor WriteU32 0xFFFFFE20 0x00000080
    # Mem fine base low reg 4
    monitor WriteU32 0xFFFFFE24 0x00000010

    # Mem fine base low reg 0, activate memory map
    monitor WriteU32 0xFFFFFE04 0x000001B0

    monitor WriteU32 0xFFFFF724 0x80000000

    monitor memU32 0x0000FFE0
    monitor memU32 0x0000FFE4
    monitor memU32 0x0000FFE8
    monitor memU32 0x0000FFEC
    monitor WriteU32 0xFFFFFFDC 0x00000002
    monitor EnableChecks
    monitor speed 12000

    monitor WorkRAM = 0x400000-0x40FFFF
    #monitor flash CFI= 0x0-0x00FFFFF


    #
    # Setup GDB for faster downloads
    #
    set remote memory-write-packet-size 4096
    set remote memory-write-packet-size fixed
    monitor speed 12000
    file ADC_LCD_FLASH.out
    #monitor reset
    #break main
    load
    #go
    #continue

    The program is an IAR demo that works fine when running from the IAR environment. However, when I try to download it to FLASH by using the Segger GDB server, it fails to work at all.
    Do I have to do something "special" in order to write the program correctly into flash ? I'm pretty sure that I've set up the address mapping correctly as well as unlocked the memory module(s)

    All help will be appreciated ;)
  • Hi,

    the GDBInit looks good to me so far.

    However, when I try to download it to FLASH by using the Segger GDB server, it fails to work at all.

    Could you please be a bit more precise here?
    What error do you see?

    Note:
    currently, your last step is "load" which causes the J-Link DLL to cache the write until it is necessary to program the flash (for example if a reset is issued).


    Best regards
    Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello,

    Thanks for the answer, I turns out i did does indeed work. I must have been changing something else temporarily so that I wrongly suspected the init script!.
    However, I've now go a different problem. Single-stepping does not work. I load a program that is working fine when I simply run it. If i instead attempt to issue "si" (single-step) from gdb after loading and resetting, the GDB server complains:

    "Performing single step...
    ERROR: Failed to read current instruction.
    Connection to debugger closed !"

    This always happen after the first instruction i.e. stepping from the reset vector!

    Please help :)
  • Hi,

    We gave it a short try on the TMS470R1B1M IAR eval board and do not see any problems.
    Tested with V4.41h of the GDBServer. For GDBServer startup parameters before target connection, please see screenshot below.

    Please find also attached the sample project we used for testing.


    Best regards
    Alex
    Images
    • GDB.gif

      28.75 kB, 668×883, viewed 918 times
    • GDBServer.gif

      10.18 kB, 550×485, viewed 967 times
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Thanks Alex!

    I finally figured it out, I needed a software reset ( monitor reset 6) to be issued after the load in my gdbinit. Without it, insight/gdb would be confused when communicating with the segger gdbserver and complain about unknown/unparsed commands . The strange thing was that the first launch would succeed in flashing the chip, but the connection would then be lost. However, the second launch would allow normal debugging. In short, two launches were necessary to debug before the "soft reset method" was discovered! :P
  • Hi Dimitri,

    This is not how it is intended to work.
    The soft reset simply resets the CPU register values but does not perform a reset of any hardware components.
    It should also work with the normal reset (strategy 0) and in our tests it did.
    Did you also give the sample project we attached a try using the same setup as we did?


    Best regards
    Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.