[ABANDONED] Cypress and J-Link Commander

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

  • [ABANDONED] Cypress and J-Link Commander

    Hi Segger Team,

    I wanted to use the Segger J-Link Base Compact in combination with the J-Link Commander Software for automatic programming of the Cypress CY8C4245AXI-483.
    Since user data is stored in flash and I have to program the controller 2 times with different software, I have to read the user data before programming, save it and then write it back.

    Therefore, I encountered a few problems.
    For the problems described below, the J-Link Commander V7.58d software was used.

    First, I tried programming with a Commander script that looked like this:

    Source Code

    1. si SWD
    2. speed 4000
    3. device CY8C4245XXX
    4. connect
    5. eoe 1
    6. savebin C:\UserData.bin 0x00007F00 0x80
    7. eoe 0
    8. erase
    9. loadfile C:\Software.hex
    10. loadfile C:\UserData.bin 0x00007F00
    11. r
    12. go
    13. exit
    Display All




    But this doesn't always work. Sometimes the savebin command has the error message:

    Source Code

    1. Opening binary file for writing... [C:\UserData.bin]
    2. Could not open file for writing.
    That wouldn't be so bad, unfortunately the data area to be read is deleted on the controller in this case.

    1) Why can the command savebin sometimes not open the file to be written?
    2) Why is the data on the controller deleted in the event of an error?


    Second thing I noticed the r command isn't working properly.
    The Controller doesn't Reset only the following massage is printed:

    Source Code

    1. Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
    2. ResetTarget() start
    3. Executing ResetTarget()
    4. BL reset: Timeout while waiting for CPU to halt after reset. Manually halting CPU.

    I tried to use RSettyp 2, but i can't see a resetpulse on the oscilloscope.

    3) Why doesn't command r reset the CY8C4245AXI-483?
    4) Why doesn't RSettyp 2 use the Resetpin?


    Next, I tried using a Commander-Script which looked as the following:

    Source Code

    1. int hpres;
    2. int HandleBeforeFlashProg(void) {
    3. hpres = JLINK_MEM_Preserve(0x7F00, 0x80);
    4. }
    5. int HandleAfterFlashProg(void) {
    6. JLINK_MEM_Restore(hpres);
    7. }

    JLINK_MEM_Preserve works fine but JLINK_MEM_Restore just doesn't write the data back.

    5) Why doesn't JLINK_MEM_Restore work with the CY8C4245AXI-483?


    Then, I tried reading the area to be backed up with the mem8 command, which works fine.
    But for this I had to save the output somehow with the help of an external program.
    So I wrote a program that generates 2 pipes with CreatePipe() and connects them with CreateProcessA() to the J-Link Commander.
    Now the input/output should run via stdin and stdout.
    But somehow it seems that printf(), of the J-Link Commander, uses a buffer when using stdout.

    6) Is it possible to disable the buffer of printf() in J-Link Commander so that stdin/out can be used?
    -> setvbuf(stdout, (char*)NULL, _IONBF, 0);
    Disable buffering on redirected stdout Pipe (Win32 API, C++)


    Hope someone could help me.

    Kind regards Jonatan