This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Flashing XC886 using ULINK2

I would like to automate flashing process for my Infineon XC886 devices.


Currently, I use ULINK2 and I connect to my board via JTAG
https://developer.arm.com/documentation/101407/0540/Command-Line/Program-Flash-Example
and then I call the UV4.exe via command line. This command opens up Keil uVision5 and flashes the application to my MCU. This process works but is not convenient for production since it opens up Keil application everytime I flash my devices.

Can I use uv4.exe in headless mode (not opening application) or should I use different tool/method to flash my devices? Perhaps someone could suggest an alternative?


  • The uv4 command line option -j0 hides the µVision GUI, and messages are suppressed.

         https://www.keil.com/support/man/docs/uv4/uv4_commandline.asp

    Related:

       "Test automation with MDK and ULINKplus"

       https://developer.arm.com/documentation/kan307/latest/ 

  • Thanks. That is useful information, I had this doc opened before but somehow missed the -j0 part. I have been able to program the device without opening GUI, however that is still not ideal for me. Since messages are suppressed there is no way for me to confirm whether the flashing has been been successful.

    It would be ideal that after the succesfull programming it would print or return something for me to be able to determine whether some kind of error has occurred or everything executed properly.

  • I have been able to achieve this by simply running the command via Python and reading the log file in real time as the log file is being written to.

    from subprocess import Popen, PIPE, STDOUT
    import os
    import re
    import time
    import threading
    
    
    
    def log_subprocess_output(pipe):
        for line in iter(pipe.readline, b''): # b'\n'-separated lines
            print(line)
    
    KEIL_EXE_path = 'C:/Keil_v5/UV4/UV4.exe'
    LOG_FILE_PATH = 'test_log.txt'
    
    
    
    
    
    def tail_f(filename):
        with open(filename, 'r') as f:
            while True:
                line = f.readline()
                if line:
                    print(line, end='')  # Print the new line
                else:
                    time.sleep(0.1)  # Wait a bit before checking for new data
    
    process = Popen([KEIL_EXE_path, '-f', 'test.uvproj', '-j0', '-l', LOG_FILE_PATH], stdout=PIPE, stderr=STDOUT)
    
    # Run tail_f in a separate thread to print log file in real-time
    log_thread = threading.Thread(target=tail_f, args=(LOG_FILE_PATH,))
    log_thread.start()
    
    # Wait for the process to finish
    process.wait()
    
    # Join the log thread
    log_thread.join()
    


    The above script allows me to flash the device without running GUI and monitor the result

  • Thanks for sharing your solution, Lukas