Skip to main content
LGeor.2
Associate
April 4, 2021
Question

STM8S005K6 SWIM PROG error [42004]: Memory write error

  • April 4, 2021
  • 10 replies
  • 6865 views

Program memory write stopped working for me. I tried with two STM8S005K6 chips. And everything works fine if I use some other STM8 chip.

Getting below error when trying using STVP.

Error : Programming failed

Error : Problem while trying to Reset swim and device. Apply a Power On Reset

Error : < PROGRAM MEMORY programming failed.

And below error when trying through IAR compiler.

Sun Apr 04, 2021 14:16:28: Failed to write chunk with size 1024 at address 0x8480: SWIM PROG error [42004]: Memory write error 

DATA MEMORY and OPTION BYTE write is working perfectly. PROGRAM MEMORY read is working but NOT WRITE.

    This topic has been closed for replies.

    10 replies

    RAhuj.11
    Associate
    April 5, 2021

    Have you connected any capacitor at VCAP pin? Try the same and reprogram.

    LGeor.2
    LGeor.2Author
    Associate
    April 5, 2021

    Yes, I do have 0.1uF.

    LGeor.2
    LGeor.2Author
    Associate
    April 5, 2021

    OH looks like I need to use 1uF.

    RAhuj.11
    Associate
    April 5, 2021

    did that solve your problem?

    LGeor.2
    LGeor.2Author
    Associate
    April 5, 2021

    I don't have 1uF with me now. I will test it later and update.

    LGeor.2
    LGeor.2Author
    Associate
    April 7, 2021

    I tried connecting 1uF capacitor, but it doesn't solve the problem.

    RAhuj.11
    Associate
    April 9, 2021

    Check the datasheet/programming manual of the device, where the suitable value for the VCAP is given.

    I am using below circuit with my STM8S105C6 device. VCAP 680nF (recommended 480nF to 3300nF) and I am able to program it a couple to times.

    Currently I am also facing same issue. Once it gets programmed, I can reprogram it multiple times but as I remove and reconnect the ST-Link, it is throwing same error.

    Still trying to figure out what's wrong here. :\ :(

    0693W000008yfs6QAA.png

    LGeor.2
    LGeor.2Author
    Associate
    April 9, 2021

    For me it is not worked after that. I have 2 target boards. Both was working fine on the first day and I programmed continuously atleast 15 times without any problems. After that this problem happened and never worked after that. The 2nd board also stopped working at the same time.

    I tried replacing the 0.1uF Vcap to 1uF, that also didn't worked. Below are my next steps.

    1. Try with 1uF ceramic capacitor (currently I tried with electrolytic capacitor).
    2. Try with 680nF and other values ceramic capacitors.
    3. Remove the 0.1uF capacitor in the NRST line.

    LGeor.2
    LGeor.2Author
    Associate
    April 11, 2021

    I tried these, it is not solving the issue. For me it is working sometimes. Like out of 20 times it will work once.

    November 12, 2022

    I have been facing a similar issue on STM8S003F3 using STLINK V2. Failed to write chunk with size 128 at address 0x8000: SWIM PROG error [42004]: Memory write error.

    Failed to load debugee: ...\new_project.out . I have to plug over and over again for it to work. I really thing that the problem could be with the STLINK , but not sure.