This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM623: Debug UART Issue During Keywriter Usage

Part Number: AM623

Hi TI experts,

Test step:

1. use this command to generate empty cert:
    ./gen_keywr_cert.sh -t tifek/ti_fek_public.pem

2.build keywriter

3.In dfu mode , download keywriter to device

4.get debug log and M4 log

Result:

1.The debug uart sometimes stop during keywriter test.    failed:18/ 100

2.The M4 log seems good  failed:0/100.

test.7z: test_python, keywriter_image, logs

success log: we use "TI bootloader done" to check keywriter done

Starting Keywriting
Enabled VPP
call keywriter_processKeyConfig()
keys Certificate found: 0x43c18000 
Keywriter Debug Response:0x0 
Keywriter status:0x0 
Success Programming Keys 
remove VPP
TI bootloader done

failed log:

Starting Keywriting
Enabled VPP
call keywriter_processKeyConfig()
keys Certificate found: 0x43c18000
Keywriter Debug Response:0x0
Keywriter status:0x0

Is this problem also related to i2371?

Best regards,

Andy

  • It seems the test.7z upload failed.
    The test python:

    import threading
    import datetime
    import serial # pip install pyserial
    import subprocess
    import time
    import os
    
    TIMEOUT = 7
    if not os.path.exists("log"):
        os.makedirs("log")
    
    # get log number
    logs = sorted([f for f in os.listdir("log") if f.endswith(".txt")], key=lambda x: int(x.split('_')[0]))
    if logs:
        latest_log_number = int(logs[-1].split('_')[0])
        current_log_number = latest_log_number + 1
    else:
        current_log_number = 1
    
    timestamp = str(current_log_number)
    log_done_event = threading.Event()
    
    def read_serial_usb0(port_name):
        filename = f"log/{timestamp}_{port_name.split('/')[-1]}.txt"
        ser = serial.Serial(port_name, 115200)
        with open(filename, 'w') as f:
            while True:
                line = ser.readline().decode('utf-8').strip()
                f.write(line + "\n")
                f.flush()
                if "TI bootloader done" in line:
                    log_done_event.set()
                    break
    
    def read_serial_usb1(port_name):
        filename = f"log/{timestamp}_{port_name.split('/')[-1]}.txt"
        ser = serial.Serial(port_name, 115200)
        keyrev_count = 0
        with open(filename, 'w') as f:
            while True:
                line = ser.readline().decode('utf-8').strip()
                f.write(line + "\n")
                f.flush()
                # the last info will include 2 "keyrev" string, after recvie them, end the function
                if "keyrev" in line:
                    keyrev_count += 1 
                if keyrev_count == 2:
                    break
    
    
    def dfu_task():
        # dfu download
        subprocess.run(["sudo", "dfu-util", "-c", "1", "-i", "0", "-a", "bootloader", "-D", "1_tiboot3_keywriter.bin"])
    
        # wait for TI bootloader , if timeout:rename log files
        flag = log_done_event.wait(TIMEOUT)
        print("sleep 1")
        time.sleep(1)
        print("dfu_task end")
        if not flag:  # timeout
            for port_suffix in ["ttyUSB0", "ttyUSB1"]:
                try:
                    old_filename = f"log/{timestamp}_{port_suffix}.txt"
                    new_filename = f"log/{timestamp}_{port_suffix}.timeout.txt"
                    os.rename(old_filename, new_filename)
                except:
                    print(f"Error renaming file {old_filename}")
            exit(1)
    
    # dfu-util -l to check device status
    result = subprocess.run(["sudo", "dfu-util", "-l"], capture_output=True, text=True)
    if "bootloader" not in result.stdout:
        print("DFU device not found!")
        exit(1)
    
    thread_debug_uart = threading.Thread(target=read_serial_usb0, args=("/dev/ttyUSB0",))
    thread_m4_uart = threading.Thread(target=read_serial_usb1, args=("/dev/ttyUSB1",))
    thread_dfu = threading.Thread(target=dfu_task)
    
    thread_debug_uart.start()
    thread_m4_uart.start()
    thread_dfu.start()
    
    print("wait for join")
    thread_debug_uart.join()
    print("thread_debug_uart join done")
    thread_m4_uart.join()
    print("thread_m4_uart join done")
    thread_dfu.join()
    print("thread_dfu join done")
    
    

    M4 log:

    0x409031
    0x800023
    #
    # Decrypting extensions..
    #
    MPK Options:  0x0
    MEK Options:  0x0
    MPK Opt P1:  0x0
    MPK Opt P2:  0x0
    MEK Opt   :  0x0
    SMPKH extension disabled
    SMEK extension disabled
    EXT OTP extension disabled
    MSV extension disabled
    
    KEY CNT extension disabled
    
    KEY REV extension disabled
    
    SWREV extension disabled
    
    FW CFG REV extension disabled
    
    * KEYWR VERSION:  0x20000
    
    #
    # Programming Keys..
    #
    
    * MSV:
    [u32] bch + msv:  0x0
    MSV extension disabled
    [u32] bch + msv:  0x0
    
    * SWREV:
    [u32] SWREV-SBL:  0x1
    [u32] SWREV-SYSFW  :  0x1
    SWREV extension disabled
    [u32] SWREV-SBL:  0x1
    [u32] SWREV-SYSFW  :  0x1
    
    * FW CFG REV:
    [u32] SWREV-FW-CFG-REV:  0x1
    SWREV SEC BCFG extension disabled
    [u32] SWREV-FW-CFG-REV:  0x1
    
    * EXT OTP:
    EXT OTP extension disabled
    
    * BMPKH, BMEK:
    BMPKH extension disabled
    BMEK extension disabled
    
    * SMPKH, SMEK:
    SMPKH extension disabled
    SMEK extension disabled
    
    * KEYCNT:
    [u32] keycnt:  0x0
    KEY CNT extension disabled
    [u32] keycnt:  0x0
    
    * KEYREV:
    [u32] keyrev:  0x0
    KEY REV extension disabled
    [u32] keyrev:  0x0
    

  • Hello Andy,
    1/. can we build a dry-run version of "tiboot3.bin":
    - comment off "keywriter_setVpp();" to turn off “VPP”
    - it is ok to generate a one-shot key programming blob certificate
    - ignore the return error from "status = Sciclient_service(&reqParam, &respParam);" as VPP is "OFF"

    2/. Can we test the dry-run version of "tiboot3.bin" from UART boot, and any other boot mode available on your board?

    Best,
    -Hong

  • Hi Hong,

    1.I would like to utilize the same version of tibbo3.bin while also disconnecting the "vpp enable pin" and "vpp pin".


    2.Our board supports three boot modes: emmc, sd-card, and dfu. However, enabling the uart boot mode requires waiting for hardware modifications to be made to the board configuration.

    Once the HW completes the uart boot mode setup, I will proceed with the test."

    Best regards,

    Andy

  • Hello Andy,
    Let us know how test going once HW modification is done on your board.
    Best,
    -Hong

  • Hi Hong,

    1.It seems the command in user guide missing the "-f" part

    User guide 4.1.1 : Run: python3 ../../../../../tools/boot/uart_bootloader.py -p "/dev/ttyUSB0" -b
    <path_to_tiboot3.bin>

    andyyu@AndyYu-Server:/opt/ecs/board-support/otp-security/mcu_plus_sdk_am62x_08_06_00_18/source/security/tifs/sbl_keywriter/tools$ python3 ../../../../../tools/boot/uart_bootloader.py -p "/dev/ttyUSB0" -b empty_tiboot3_keywriter.bin 
    [ERROR] Provide path to an appimage binary to be sent via UART with option -f or --file=, , use -h option to see detailed help !!!
    

    2. I use "-f empty_tiboot3_keywriter.bin" to test twice, log as below:

    andyyu@AndyYu-Server:/opt/ecs/board-support/otp-security/mcu_plus_sdk_am62x_08_06_00_18/source/security/tifs/sbl_keywriter/tools$ python3 ../../../../../tools/boot/uart_bootloader.py -p "/dev/ttyUSB0" -b empty_tiboot3_keywriter.bin  -f empty_tiboot3_keywriter.bin
    Sending the UART bootloader empty_tiboot3_keywriter.bin ...
    Sending empty_tiboot3_keywriter.bin:  23%|█████████████████████████████                                                                                               | 64827/276123 [00:07<00:19, 10727.49bytes/s]send error: expected ACK; got b'\x18' for block 63
    Sending empty_tiboot3_keywriter.bin:  24%|█████████████████████████████▌                                                                                              | 65856/276123 [00:07<00:19, 10727.49bytes/s]send error: expected ACK; got b'\x18' for block 63
    Sending empty_tiboot3_keywriter.bin:  24%|██████████████████████████████                                                                                              | 66885/276123 [00:07<00:18, 11032.68bytes/s]send error: expected ACK; got b'0' for block 63
    Sending empty_tiboot3_keywriter.bin:  25%|██████████████████████████████▍                                                                                             | 67914/276123 [00:07<00:18, 11032.68bytes/s]send error: expected ACK; got b'2' for block 63
    Sending empty_tiboot3_keywriter.bin:  25%|██████████████████████████████▉                                                                                             | 68943/276123 [00:07<00:18, 11179.05bytes/s]send error: expected ACK; got b'0' for block 63
    Sending empty_tiboot3_keywriter.bin:  25%|███████████████████████████████▍                                                                                            | 69972/276123 [00:07<00:18, 11179.05bytes/s]send error: expected ACK; got b'0' for block 63
    Sending empty_tiboot3_keywriter.bin:  26%|███████████████████████████████▉                                                                                            | 71001/276123 [00:08<00:18, 11283.83bytes/s]send error: expected ACK; got b'0' for block 63
    Sending empty_tiboot3_keywriter.bin:  26%|████████████████████████████████▎                                                                                           | 72030/276123 [00:08<00:18, 11283.83bytes/s]send error: expected ACK; got b'0' for block 63
    Sending empty_tiboot3_keywriter.bin:  26%|████████████████████████████████▊                                                                                           | 73059/276123 [00:08<00:17, 11361.60bytes/s]send error: expected ACK; got b'0' for block 63
    Sending empty_tiboot3_keywriter.bin:  27%|█████████████████████████████████▎                                                                                          | 74088/276123 [00:08<00:17, 11361.60bytes/s]send error: expected ACK; got b'0' for block 63
    Sending empty_tiboot3_keywriter.bin:  27%|█████████████████████████████████▋                                                                                          | 75117/276123 [00:08<00:17, 11412.82bytes/s]send error: expected ACK; got b'0' for block 63
    send error: NAK received 11 times, aborting.
    Sending empty_tiboot3_keywriter.bin:  27%|█████████████████████████████████▋                                                                                          | 75119/276123 [00:08<00:17, 11412.82bytes/s]
    [ERROR] XMODEM send failed, no response OR incorrect response from EVM OR cancelled by user,
            Power cycle EVM and run this script again !!!
    andyyu@AndyYu-Server:/opt/ecs/board-support/otp-security/mcu_plus_sdk_am62x_08_06_00_18/source/security/tifs/sbl_keywriter/tools$ python3 ../../../../../tools/boot/uart_bootloader.py -p "/dev/ttyUSB0" -b empty_tiboot3_keywriter.bin  -f empty_tiboot3_keywriter.bin
    Sending the UART bootloader empty_tiboot3_keywriter.bin ...
    Sending empty_tiboot3_keywriter.bin:   0%|                                                                                                                                           | 0/276123 [00:00<?, ?bytes/s]send error: expected NAK, CRC, EOT or CAN; got b'\x00'
    Sent bootloader empty_tiboot3_keywriter.bin of size 276123 bytes in 25.93s.                                                                                                                                        
    
    Sending the application empty_tiboot3_keywriter.bin ...
    Sending empty_tiboot3_keywriter.bin:   0%|                                                                                                                                           | 0/276123 [00:00<?, ?bytes/s]send error: expected NAK, CRC, EOT or CAN; got b'\r'
    send error: expected NAK, CRC, EOT or CAN; got b'\n'
    send error: expected NAK, CRC, EOT or CAN; got b'S'
    send error: expected NAK, CRC, EOT or CAN; got b't'
    send error: expected NAK, CRC, EOT or CAN; got b'a'
    send error: expected NAK, CRC, EOT or CAN; got b'r'
    send error: expected NAK, CRC, EOT or CAN; got b't'
    send error: expected NAK, CRC, EOT or CAN; got b'i'
    send error: expected NAK, CRC, EOT or CAN; got b'n'
    send error: expected NAK, CRC, EOT or CAN; got b'g'
    send error: expected NAK, CRC, EOT or CAN; got b' '
    send error: error_count reached 10, aborting.
    Sending empty_tiboot3_keywriter.bin:   0%|                                                                                                                                | 2/276123 [00:01<90:30:24,  1.18s/bytes]
    [ERROR] XMODEM send failed, no response OR incorrect response from EVM OR cancelled by user,
            Power cycle EVM and run this script again !!!
    

    Best regards,

    Andy

  • Hello Andy,
    I'd recommend to run UART boot test using a "working" tiboot3.bin, either from u-boot build from Linux SDK or SBL example from MCU+SDK.
    This is to check out UART boot mode with the new HW mod on UART on your board.
    Once UART boot mode is verified, then check OTP KW build "tiboot3.bin"
    Best,
    -Hong

  • Hi Hong,

    1.I prepare a "working" tiboot3.bin, I check this tiboot3.bin by sd card boot.

    2.I prepare MCU+SDK example hello_world_cpp

    3.I download tibbot3.bin and hello world app:
    python3 ../../../../../tools/boot/uart_bootloader.py -p "/dev/ttyUSB0" -b ./hsfs_tiboot3.bin -f hello_world_cpp.release.appimage.hs_fs

    log as below:

    mcu_plus_sdk_am62x_08_06_00_18/examples/hello_world_cpp/am62x-sk/m4fss0-0_nortos/ti-arm-clang

    andyyu@AndyYu-Server:/opt/ecs/board-support/otp-security/mcu_plus_sdk_am62x_08_06_00_18/source/security/tifs/sbl_keywriter/tools$ python3 ../../../../../tools/boot/uart_bootloader.py -p "/dev/ttyUSB0" -b ./hsfs_tiboot3.bin -f hello_world_cpp.release.appimage.hs_fs 
    Sending the UART bootloader ./hsfs_tiboot3.bin ...
    Sending ./hsfs_tiboot3.bin:   0%|                                                                                                                                                    | 0/334947 [00:00<?, ?bytes/s]send error: expected NAK, CRC, EOT or CAN; got b'\x00'
    Sent bootloader ./hsfs_tiboot3.bin of size 334947 bytes in 31.49s.                                                                                                                                                 
    
    Sending the application hello_world_cpp.release.appimage.hs_fs ...
    Sending hello_world_cpp.release.appimage.hs_fs:   0%|                                                                                                                                 | 0/24605 [00:00<?, ?bytes/s]send error: expected NAK, CRC, EOT or CAN; got b'\r'
    send error: expected NAK, CRC, EOT or CAN; got b'\n'
    send error: expected NAK, CRC, EOT or CAN; got b'U'
    send error: expected NAK, CRC, EOT or CAN; got b'-'
    send error: expected NAK, CRC, EOT or CAN; got b'B'
    send error: expected NAK, CRC, EOT or CAN; got b'o'
    send error: expected NAK, CRC, EOT or CAN; got b'o'
    send error: expected NAK, CRC, EOT or CAN; got b't'
    send error: expected NAK, CRC, EOT or CAN; got b' '
    send error: expected NAK, CRC, EOT or CAN; got b'S'
    send error: expected NAK, CRC, EOT or CAN; got b'P'
    send error: error_count reached 10, aborting.
    Sending hello_world_cpp.release.appimage.hs_fs:   0%|                                                                                                                         | 2/24605 [00:00<16:16, 25.19bytes/s]
    [ERROR] XMODEM send failed, no response OR incorrect response from EVM OR cancelled by user,
            Power cycle EVM and run this script again !!!
    

    Did I do anything wrong?

    Best regards,

    Andy

  • Hello Andy,
    For OTP key programming,
    - "tiboot3.bin" is needed, and it can be booted from any boot mode, i.e. UART boot mode as noted in "4.1 UART boot" of the user guide.
    - there's no need for APP, like "hello world"...
    Best,
    -Hong