GDB doesn't correctly flash mx29lv160db nor flash

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

    • GDB doesn't correctly flash mx29lv160db nor flash

      Hi,

      I had a confusing failure. I am using Linux based command line jlink server for a at91m4800 arm7tdmi soc.

      Here is what the server says when staring up:

      Source Code

      1. SEGGER J-Link GDB Server V6.32 Command Line Version
      2. JLinkARM.dll V6.32 (DLL compiled Apr 20 2018 17:34:47)
      3. Command line: -device AT91M40800 -scriptfile /opt/SEGGER/JLink/Devices/ATMEL/AT91M40800.JLinkScript
      4. -----GDB Server start settings-----
      5. GDBInit file: none
      6. GDB Server Listening port: 2331
      7. SWO raw output listening port: 2332
      8. Terminal I/O port: 2333
      9. Accept remote connection: yes
      10. Generate logfile: off
      11. Verify download: off
      12. Init regs on start: off
      13. Silent mode: off
      14. Single run mode: off
      15. Target connection timeout: 0 ms
      16. ------J-Link related settings------
      17. J-Link Host interface: USB
      18. J-Link script: /opt/SEGGER/JLink/Devices/ATMEL/AT91M40800.JLinkScript
      19. J-Link settings file: none
      20. ------Target related settings------
      21. Target device: AT91M40800
      22. Target interface: JTAG
      23. Target interface speed: 4000kHz
      24. Target endian: little
      Display All



      And then I use command line gdb:

      Source Code

      1. GNU gdb (GNU Tools for Arm Embedded Processors 7-2018-q3-update) 8.1.0.20180315-git
      2. Copyright (C) 2018 Free Software Foundation, Inc.

      The debugger works ok, but cannot flash the second 8k page in the nor flash. I use 2 bootstrap 8k sectors and then the main program starts at the first 64K segment.

      The failure is gdb cannot erase the page. If I use the windows jlink tool I can erase the device and then load the program. So it can write, but not erase. I am telling gdb that it is a cfi flash so it should know the layout of the flash.

      Here is my .gdbinit:

      Source Code

      1. set auto-load safe-path /
      2. # Connect to the GDB Server
      3. target extended-remote :2331
      4. file thumb/hlm_flash.elf
      5. monitor reset
      6. monitor halt
      7. monitor endian little
      8. monitor speed auto
      9. monitor flash device mx29lv320e
      10. #Cancel reset remapping
      11. set *((int *) 0xFFE00020) = 0x00000001
      12. #//enable A0..A21
      13. set *((int *) 0xFFE00024) = 0x00000005
      14. #CS0 @ 0x1000000
      15. set *((int *) 0xFFE00000) = 0x0100253D
      16. #RAM at 0x02000000
      17. set *((int *) 0xFFE00004) = 0x02002121
      18. #CAN at 0x03000000
      19. set *((int *) 0xFFE00008) = 0x0300252E
      20. #ispLSI at 0x04000000
      21. set *((int *) 0xFFE0000C) = 0x0400252E
      22. #disable all interrupts
      23. set *((int *) 0xFFFFF124) = 0xFFFFFFFF
      24. #Enable, EBI_MCR: ALE, DRP
      25. set *((int *) 0xFFE00024) = 0x00000006
      26. #Remap Command is this needed again?
      27. set *((int *) 0xFFE00020) = 0x00000001
      28. monitor flash breakpoints = 1
      29. monitor workram = 0x00000000-0x00001FFF
      30. monitor flash cfi 0x01000000-0x013FFFFF
      31. monitor reg pc = 0x1004448
      32. set $pc=0x1004448
      33. set input-radix 0x10
      34. set output-radix 0x10
      35. set disassemble-next-line on
      Display All
      I use the gdb "load" command to load a file into flash. It fails every time to erase the second page of flash in the bootstrap. Is this a known problem?
    • Hello,

      Thank you for your inquiry.
      Per supported devices list the AT91M40800 external Flash is only supported as parallel CFI compliant Flash.
      So you have to make sure that the target specific initialization for the Flash controller is executed correctly.
      A JLinkScript file can be used for such a task.

      Best regards,
      Nino
      Please read the forum rules before posting: Forum Rules

      Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
      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 contact us per e-mail.
      Alternatively our support system can be used as well: segger.com/ticket/
    • I do start gdb with a jlink script. Maybe I am doing something wrong.

      I start the server with JLinkGDBServerCLExe -device AT91M40800 -scriptfile /opt/SEGGER/JLink/Devices/ATMEL/AT91M40800.JLinkScript Remember this is on Ubuntu and gdb generally works, just LOAD does not work on my flash setup.

      Here is my jlinkscript. Note lots of lines commented out.

      Source Code

      1. /*********************************************************************
      2. *
      3. * SEGGER J-Link ARM Setup File - Generated by J-Flash V6.18c
      4. *
      5. * Syntax:
      6. *
      7. * SetJTAGSpeed(Speed); : Sets the JTAG speed [kHz], (0 = Auto, 0xFFFF = Adaptive)
      8. * Delay(Delay); : Waits a given time [msec]
      9. * DisableMMU(RAMAddr); : Disables the MMU
      10. * DisableChecks(); : Disables mode check after read operations
      11. * EnableChecks(); : Enables mode check after read operations
      12. * Go(); : Starts the core
      13. * Halt(); : Halts the core
      14. *
      15. * Reset(Delay); : Resets the target (normal)
      16. * ResetWP(); : Resets the target (using watchpoint)
      17. * ResetDBGRQ(); : Resets the target (using DBGRQ)
      18. * ResetBP0(Delay); : Resets the target (using breakpoint @ addr 0)
      19. * ResetADI(); : Resets the target (using ADI software reset)
      20. *
      21. * Read8 (Addr); : Reads a 8/16/32 bit value,
      22. * Read16(Addr); : Addr = address to read (as hex value)
      23. * Read32(Addr); :
      24. *
      25. * Verify8 (Addr, Data); : Verifies a 8/16/32 bit value,
      26. * Verify16(Addr, Data); : Addr = address to verify (as hex value)
      27. * Verify32(Addr, Data); : Data = data to verify (as hex value)
      28. *
      29. * Write8 (Addr, Data); : Writes a 8/16/32 bit value,
      30. * Write16(Addr, Data); : Addr = address to write (as hex value)
      31. * Write32(Addr, Data); : Data = data to write (as hex value)
      32. *
      33. * WriteVerify8 (Addr, Data); : Writes and verifies a 8/16/32 bit value,
      34. * WriteVerify16(Addr, Data); : Addr = address to write (as hex value)
      35. * WriteVerify32(Addr, Data); : Data = data to write (as hex value)
      36. *
      37. * WriteRegister(Reg, Data); : Writes a register
      38. * WriteJTAG_IR(Cmd); : Writes the JTAG instruction register
      39. * WriteJTAG_DR(nBits, Data); : Writes the JTAG data register
      40. *
      41. * VarAND(Data); : VAR = VAR AND Data
      42. * VarOR (Data); : VAR = VAR OR Data
      43. * VarXOR(Data); : VAR = VAR XOR Data
      44. * VarBEQ(Index); : Execute branch
      45. *
      46. * VarWrite8 (Addr); : Writes the value of VAR as 8/16/32 bit value,
      47. * VarWrite16(Addr); : Addr = address to write (as hex value)
      48. * VarWrite32(Addr); :
      49. *
      50. **********************************************************************
      51. */
      52. void InitTarget(void) {
      53. Report("J-Link script: Steve's test J-Link script");
      54. JTAG_Reset();
      55. //SetJTAGSpeed(30);
      56. //Reset(0, 0);
      57. JLINK_MEM_WriteU32(0xFFE00020, 0x00000001); //Cancel reset remapping
      58. JLINK_MEM_WriteU32(0xFFE00024, 0x00000005); //enable A0..A21
      59. JLINK_MEM_WriteU32(0xFFE00000, 0x01002529); // CS0 @ 0x1000000
      60. JLINK_MEM_WriteU32(0xFFE00004, 0x02002121); //RAM at 0x02000000
      61. JLINK_MEM_WriteU32(0xFFE00008, 0x0300252E); //CAN at 0x03000000
      62. JLINK_MEM_WriteU32(0xFFE0000C, 0x0400252E); //ispLSI at 0x04000000
      63. JLINK_MEM_WriteU32(0xFFFFF124, 0xFFFFFFFF); //disable all interrupts
      64. JLINK_MEM_WriteU32(0xFFE00024, 0x00000005); //Enable, EBI_MCR: ALE, DRP
      65. //1 0 1 A20, A21 4M Bytes CS4, CS5 EBI_ALE_4M
      66. JLINK_MEM_WriteU32(0xFFE00020, 0x00000001); // Remap Command
      67. //SetJTAGSpeed(4000);
      68. //unlock flash
      69. //JLINK_MEM_WriteU16(0x01000000, 0x50); // clear status bits
      70. //JLINK_MEM_WriteU16(0x01000000, 0x60); // unlock cmd
      71. //JLINK_MEM_WriteU16(0x01000000, 0xd0); // set page addr unlock cmd
      72. //JLINK_MEM_WriteU16(0x01002000, 0x60); // unlock cmd
      73. //JLINK_MEM_WriteU16(0x01002000, 0xd0); // set page addr unlock cmd
      74. //JLINK_MEM_WriteU16(0x01004000, 0x60); // unlock cmd
      75. //JLINK_MEM_WriteU16(0x01004000, 0xd0); // set page addr unlock cmd
      76. //JLINK_MEM_WriteU16(0x01006000, 0x60); // unlock cmd
      77. //JLINK_MEM_WriteU16(0x01006000, 0xd0); // set page addr unlock cmd
      78. //JLINK_MEM_WriteU16(0x01008000, 0x60); // unlock cmd
      79. //JLINK_MEM_WriteU16(0x01008000, 0xd0); // set page addr unlock cmd
      80. //JLINK_MEM_WriteU16(0x0100a000, 0x60); // unlock cmd
      81. //JLINK_MEM_WriteU16(0x0100a000, 0xd0); // set page addr unlock cmd
      82. //JLINK_MEM_WriteU16(0x0100c000, 0x60); // unlock cmd
      83. //JLINK_MEM_WriteU16(0x0100c000, 0xd0); // set page addr unlock cmd
      84. //JLINK_MEM_WriteU16(0x01010000, 0x60); // unlock cmd
      85. //JLINK_MEM_WriteU16(0x01010000, 0xd0); // set page addr unlock cmd
      86. //JLINK_MEM_WriteU16(0x01020000, 0x60); // unlock cmd
      87. //JLINK_MEM_WriteU16(0x01020000, 0xd0); // set page addr unlock cmd
      88. }
      89. /*********************************************************************
      90. *
      91. * ConfigTargetSettings
      92. */
      93. int ConfigTargetSettings(void) {
      94. Report("J-Link script: Steve's ConfigTargetSettings");
      95. JLINK_ExecCommand("SetCFIFlash 0x01000000-0x013FFFFF");
      96. JLINK_ExecCommand("SetWorkRAM 0x00000000-0x00001FFF");
      97. return 0;
      98. }
      Display All
    • Hello,

      Please understand that CFi init is user responsibility and leaves our regular support scope so we can't offer assistance in this case.
      Generally the ConfigTargetSettings looks correct if the addresses are correct.
      For the target specific CFI init we suggest contacting Atmel/Microchip support.

      Best regards,
      Nino
      Please read the forum rules before posting: Forum Rules

      Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
      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 contact us per e-mail.
      Alternatively our support system can be used as well: segger.com/ticket/
    • If by CFI init you mean the initialization done in Jlinkscript for the memory addresses, then I know it works because gdb can use it to look at memories and jflash can use it to flash the memories.

      Is there a gdbserver log somewhere to give some indication of what the problem is?

      If the server does a reset then the memory map changes and accessing the nor flash will be at different processor addresses (an at91xxx quirk). I have no way to know what the server does and assumes when it is doing the "load" gdb command. The terminal stuff printed by gdbserver does not show any problems.

      The problem is that the gdbserver is not using the correct flash page size of the nor flash (which is a bottom boot configured device). This information is available in the nor flash cfi data. I don't see how atmel can help a failure in the Segger gdbserver?

      Steve