[SOLVED] Freescale K60DX256xxx10 FlexNVM erase using JLinkGDBServer

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

  • [SOLVED] Freescale K60DX256xxx10 FlexNVM erase using JLinkGDBServer

    HW: MK60DX256xxx10 processor with SEGGER JLINK probe running on Ubuntu 12.

    My Intent is to erase the FlexNVM area of the chip (start address 0x10000000 - 0x1003FFFF)

    I am using JLinkGDBServer on LINUX via the following command line: JLInkGDBServer -x=Nitin.gdb -select -usb=S/N


    APPROACH 1: From SEGGER docs it seems straight forward. Inside my Nitin.gdb file I pasted "monitor flash device = MK60DX256xxx10" but that does NOT erase my FlexNVM at all. I dont know what this device selection does then ?

    APPROACH 2: Inside Nitin.gdb file, I used the following FlexNVM memory partition code: "monitor MemU8 0x40020007 = 0x80 (selecting Prog Partition mode)monitor MemU8 0x4002000A = 0x32 (EEPROM size 32K)
    monitor MemU8 0x4002000B = 0x03 (D-FLASH size 224K)
    monitor MemU8 0x40020000 = 0x80 (Execute the partition cmd)


    That did NOT work either, I read registers back and it seems flash registers are programmed properly but still FlexNVM is NOT erased.



    APPROACH 3: Inside Nitin.gdb file, I used the following Mass Erase: "monitor MemU8 0x40020007 = 0x44monitor MemU8 0x40020000 = 0x80"


    It MASS erases the chip, gets what I need but now I get error messages from the JLinkGDBServer saying core is confused because of mass erasing, some registers are not read and hence my loaded program DOES NOT work.


    Anybody out there has faced similar situation ?


    Idea is to just mass erase (including P-FLASH & FlexNVM) the chip using JLinkGDBServer on Linux without any errors





  • Hello,
    In other words can JLinkGDBServer execute "unlock kinetis" command ?
    After selecting the device by passing the command "monitor device = MK60DX256xxx10" to JLinkGDBServer,
    we'll handle erasing and, if necessary, unlocking the device automatically if a download is initiated.


    Best regards

    Niklas
    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.
  • Niklas,

    I was under the same impression too, but NO it is not true.
    I have some data manually stored in my device at FlexNVM area @ 0x1000000, I call "monitor flash device MK60DX256xxx10" followed by rest of the download sequence using JLinkGDBServer.

    After successful flashing reboot, I still see my data @ 0x1000000 ?

    That beats my purpose of calling that command.

    Thanks for looking into it.

    Here;s my GDB:

    target remote:2331
    monitor halt
    monitor flash device = MK60DX256xxx10
    load BLAH_BLAH_BLAH.srec
    monitor halt
    monitor reset
    monitor go
    quit

    The post was edited 1 time, last by N_Harish ().

  • Hi,

    In general, we recommend to pass the device to the J-Link GDB server on start up using command line parameter
    because for some devices, the J-Link DLL must know the device before any target communication has been performed (e.g. special init sequences) by the GDB server.
    The command line should look like:
    JLinkGDBServerCL.exe -select USB -device MK60DN512xxx10 -if SWD -speed 4000

    For clarification:
    - In general, selecting the device allows the J-Link DLL to perform flash download (select the correct flash algorithm) and device specific sequences.
    - For the MK60DN512xxx10, on connect the J-Link DLL checks if security is set, if so the DLL performs a unlock. When performing the unlock sequence, the
    device performs a mass erase.
    - Selecting the device does not perform a mass erase. Why should it? Only if a locked Kinetis device has been detected
    - If programming a new image and the correct device is selected, the J-Link DLL will erase the covered sectors and program them with the new image.

    I gave it a quick try under Windows (it should behave exactly the same as under Linux) and it works just fine.
    Flash is programmed successfully.


    Best regards
    Erik
    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.
  • Sorry to reopen this dialog again.

    Here is my JLINK GDB Server based GDB file running on Linux system :


    target remote:2331
    monitor halt
    monitor flash device = MK60DX256xxx10

    # Reset FSTAT Error Bits
    monitor MemU8 0x40020000 = 0x70

    # Let us go to FCCOB0 register (offset of 0x7) and select PROGRAM PARTITION COMMAND 0x80
    monitor MemU8 0x40020007 = 0x80

    # Let us go to FCCOB5 register (offset of 0xA) and select FLEXNVM_PARTITION COMMAND 0x03, Data Flash = 224 KB
    monitor MemU8 0x4002000A = 0x03

    # Let us go to FCCOB4 register (offset of 0xB) and select EEPROM_DATA_SET_SIZE COMMAND 0x32, EEPROM Backup Size = 32 KB
    monitor MemU8 0x4002000B = 0x32

    # Let us launch command sequence
    monitor MemU8 0x40020000 = 0x80

    # QUESTION: HOW CAN I VERIFY HERE THAT PARTITIONING IS SUCCESSFUL ? ? ?

    monitor sleep 2000
    monitor halt
    monitor reset

    # Load SREC
    load og2_prod_1dot7dot2.srec
    monitor halt
    monitor reset

    # I try to read back, but these registers which are EEPROM and FLASH partitioning codes are always 0
    monitor MemU8 0x4002000A
    monitor MemU8 0x4002000B

    monitor halt
    monitor regs
    monitor reset
    monitor go

    quit
  • All right here is the solution:


    target remote:2331
    monitor halt
    monitor flash device = MK60DX256xxx10

    # Reset FSTAT Error Bits
    monitor MemU8 0x40020000 = 0x70

    # Let us go to FCCOB0 register (offset of 0x7) and select PROGRAM PARTITION COMMAND 0x80
    monitor MemU8 0x40020007 = 0x80

    # Let us go to FCCOB5 register (offset of 0xA) and select FLEXNVM_PARTITION COMMAND 0x03, Data Flash = 224 KB
    monitor MemU8 0x4002000A = 0x03

    # Let us go to FCCOB4 register (offset of 0xB) and select EEPROM_DATA_SET_SIZE COMMAND 0x32, EEPROM Backup Size = 32 KB
    monitor MemU8 0x4002000B = 0x32

    # Let us launch command sequence
    monitor MemU8 0x40020000 = 0x80

    # Let us wait for FLASH controller to finish its job, give it 2 million years
    monitor sleep 2000

    #Let us restart K60
    monitor reset

    #Let us load REAL Main APP Code now
    load og2_prod_1dot7dot2.srec

    # Let us verify our change worked OR NOT from System Integration Module Register (SIM), K60 user manual Pg 314, Section 12.2.17
    # Also See Table 29-4, page 657/1801 for valid values being 0x20300, where bits 16-19 are for EEPROM & bits 8-11 are DEPART
    monitor MemU32 0x4004804C


    #Let us restart K60
    monitor reset
    monitor go

    #As Keira would say AAA DONE
    quit
  • # Let us verify our change worked OR NOT from System Integration Module Register (SIM), K60 user manual Pg 314, Section 12.2.17
    # Also See Table 29-4, page 657/1801 for valid values being 0x20300, where bits 16-19 are for EEPROM & bits 8-11 are DEPART
    monitor MemU32 0x4004804C

    The above command gives me the output of 0x99020300, which means FLASH/EEPROM are configured the way I wanted them, but is their a way to get return from the above statment and verify it inside GDB file itself ?

    For e.g., I want to run something like this inside GDB file:

    if ((monitor MemU32 0x4004804C) == 0x99020300)
    {
    print PASS:
    }
    else
    {
    print FAIL;
    }
  • First, good to hear that you are up and running.

    Regarding your question:
    I am not aware of such a functionality in the GDB server protocol but the J-Link SDK can be used to implement this.
    Further information regarding the J-Link SDK can be found here: segger.com/jlink-sdk.html


    Best regards
    Erik
    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,

    if you are using a gdb with built-in python support, than you can use this:

    Source Code

    1. python result = gdb.execute("monitor MemU32 0x4004804C", False, True)
    2. python print("PASS" if "Data = 0x99020300" in result else "FAIL")

    :!: This will only work as long as Segger doesn't change the output format of the MemU32 command!

    Tip: If you are using GCC ARM Embedded, than you need to use the arm-none-eabi-gdb-py binary instead of the arm-none-eabi-gdb binary.

    Best regards,
    Christoph Heitkamp