[SOLVED] APM32F103VC MINI and J-Link

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

  • [SOLVED] APM32F103VC MINI and J-Link

    Some days ago I bought an APM32F103VC MINI board. I created a small application (led blinking) and tried to download it to the board (JLink_V794i) without success.
    The debugger (SEGGER J-Link) from eclipse does not work and J-Link (command line) says ‘Writing target memory failed.’.
    The board is brand new and I tried the same configuration on both Linux and Windows 10.

    The application is based on the ‘APM32F10x_SDK_V1.8\Examples\GPIO\GPIO_Toggle’ example (I only changed the linker script to match the MCU on my board).

    Memory is not write-protected, I checked.

    Any ideas?
  • Could you please give it a quick try using J-Link Commander and send us a screenshot of the entire J-Link Commander output?
    https://wiki.segger.com/J-Link_Commander#Perform_flash_download
    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.
  • First of all, thank you for taking the time to look into this !


    1/ Now here is the JLink session:
    ---
    Please specify device / core. <Default>: APM32F103VC
    Type '?' for selection dialog
    Device>APM32F103VC
    Please specify target interface:
    J) JTAG (Default)
    S) SWD
    T) cJTAG
    TIF>j
    Device position in JTAG chain (IRPre,DRPre) <Default>: -1,-1 => Auto-detect
    JTAGConf>
    Specify target interface speed [kHz]. <Default>: 4000 kHz
    Speed>
    Device "APM32F103VC" selected.


    Connecting to target via JTAG
    InitTarget() start
    Check if Flash is read protected.
    InitTarget() end - Took 3.11ms
    TotalIRLen = 9, IRPrint = 0x0011
    JTAG chain detection found 2 devices:
    #0 Id: 0x4BA00477, IRLen: 04, CoreSight JTAG-DP
    #1 Id: 0x06414B47, IRLen: 05, APM32 Boundary Scan
    DPv0 detected
    Scanning AP map to find all available APs
    AP[1]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x24770011)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x412FC231. Implementer code: 0x41 (ARM)
    Found Cortex-M3 r2p1, Little endian.
    FPUnit: 6 code (BP) slots and 2 literal slots
    CoreSight components:
    ROMTbl[0] @ E00FF000
    [0][0]: E000E000 CID B105E00D PID 000BB000 SCS
    [0][1]: E0001000 CID B105E00D PID 003BB002 DWT
    [0][2]: E0002000 CID B105E00D PID 002BB003 FPB
    [0][3]: E0000000 CID B105E00D PID 003BB001 ITM
    [0][4]: E0040000 CID B105900D PID 003BB923 TPIU-Lite
    [0][5]: E0041000 CID B105900D PID 003BB924 ETM-M3
    Memory zones:
    Zone: "Default" Description: Default access mode
    Cortex-M3 identified.
    J-Link>LoadFile C:\Users\XXXXX\eclipse-workspace\APM32F103VC_MINI_1\Debug\APM32F103VC_MINI_1.elf
    'loadfile': Performing implicit reset & halt of MCU.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    Downloading file [C:\Users\XXXXX\eclipse-workspace\APM32F103VC_MINI_1\Debug\APM32F103VC_MINI_1.elf]...
    Writing target memory failed.
    J-Link>
    ---

    2/ Here is the log file:
    ---
    T0604 249:461.856 SEGGER J-Link V7.94i Log File
    T0604 249:462.656 DLL Compiled: Feb 7 2024 17:08:52
    T0604 249:462.688 Logging started @ 2024-02-17 08:31
    T0604 249:462.704 Process: C:\Program Files\SEGGER\JLink_V794i\JLink.exe
    T0604 249:462.736 - 249462.736ms
    T0604 252:262.432 JLINK_Reset()
    T0604 252:262.528 CPU_WriteMem(4 bytes @ 0xE000EDF0)
    T0604 252:262.960 CPU_WriteMem(4 bytes @ 0xE000EDFC)
    T0604 252:263.760 Reset: Halt core after reset via DEMCR.VC_CORERESET.
    T0604 252:264.160 Reset: Reset device via AIRCR.SYSRESETREQ.
    T0604 252:264.240 CPU_WriteMem(4 bytes @ 0xE000ED0C)
    T0604 252:316.512 CPU_ReadMem(4 bytes @ 0xE000EDF0)
    T0604 252:317.056 CPU_ReadMem(4 bytes @ 0xE000EDF0)
    T0604 252:318.032 CPU_WriteMem(4 bytes @ 0xE000EDFC)
    T0604 252:324.608 CPU_ReadMem(4 bytes @ 0xE000EDF0)
    T0604 252:327.328 CPU_WriteMem(4 bytes @ 0xE000EDFC)
    T0604 252:327.728 CPU_WriteMem(4 bytes @ 0xE0001028)
    T0604 252:328.192 CPU_WriteMem(4 bytes @ 0xE0001038)
    T0604 252:328.608 CPU_WriteMem(4 bytes @ 0xE0001048)
    T0604 252:328.912 CPU_WriteMem(4 bytes @ 0xE0001058)
    T0604 252:329.312 CPU_WriteMem(4 bytes @ 0xE0002000)
    T0604 252:329.648 CPU_ReadMem(4 bytes @ 0xE000EDFC)
    T0604 252:329.952 CPU_ReadMem(4 bytes @ 0xE0001000)
    T0604 252:330.272 - 67.855ms
    T0604 252:330.288 JLINK_Halt()
    T0604 252:330.320 - 0.012ms returns 0x00
    T0604 252:330.496 JLINK_ExecCommand("SetVerifyRAMDownload = 1", ...).
    T0604 252:330.528 - 0.002ms returns 0x00
    T0604 252:330.528 JLINK_DownloadFile()
    T0604 252:330.704 Data: F8 B5 00 BF F8 BC 08 BC 9E 46 70 47 08 B5 07 4B ...
    T0604 252:330.720 CPU_WriteMem(1020 bytes @ 0x00008000)
    T0604 252:337.760 CPU_ReadMem(1020 bytes @ 0x00008000)
    T0604 252:344.704 - 14.181ms returns 0xFFFFFEF2
    T0604 252:344.736 JLINK_ExecCommand("SetVerifyRAMDownload = 0", ...).
    T0604 252:344.752 - 0.001ms returns 0x01
    T0604 275:561.472 JLINK_IsOpen()
    T0604 275:561.504 - 0.021ms returns 0x01
    T0604 275:566.880 JLINK_Close()
    T0604 275:567.360 CPU_ReadMem(4 bytes @ 0xE0001000)
    T0604 275:567.712 CPU_WriteMem(4 bytes @ 0xE0001004)
    T0604 275:580.640 - 13.784ms
    T0604 275:580.672
    T0604 275:580.672 Closed
    ---

    I have to mention that I've tried both SWD and JTAG but to no avail
    But I could successfully erase the chip ! ;)