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.

MCU-PLUS-SDK-AM243X: AM243x-EVM Unable to flash SOC initialization binary

Part Number: MCU-PLUS-SDK-AM243X
Other Parts Discussed in Thread: UNIFLASH

Am trying to setup AM243x-EVM to run SDK examples. 
I have sticker PROC101C(005) on eval kit.
I'm using SDK version 09_00_00_35
I'm using CCS version 12.4.0

Unable to pass EVM setup step step:

https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/EVM_SETUP_PAGE.html#autotoc_md32

This is error message:
"

C:\ti\mcu_plus_sdk_am243x_09_00_00_35\tools\boot>python uart_uniflash.py -p COM16 --cfg=sbl_prebuilt/am243x-evm/default_sbl_null.cfg

Parsing config file ...
Parsing config file ... SUCCESS. Found 2 command(s) !!!

Executing command 1 of 2 ...
Found flash writer ... sending sbl_prebuilt/am243x-evm/sbl_uart_uniflash.release.hs_fs.tiimage
Sending sbl_prebuilt/am243x-evm/sbl_uart_uniflash.release.hs_fs.tiimage: 0%|▍ | 1029/317925 [00:01<06:49, 774.47bytes/s]
[ERROR] XMODEM send failed, no response OR incorrect response from EVM OR cancelled by user,
Power cycle EVM and run this script again !!!

"

This is the SocId_parser output showing I have HSFS device.

"
C:\ti\mcu_plus_sdk_am243x_09_00_00_35\tools\boot\socid_parser>python uart_boot_socid.py -d am64x --string="02000000011a0000616d3634780000000000000048534653000002000000020002a6000000000000b018658ad99dc903c8c9bfb27b12751099920a042ad1dfea7b7ba57369f15546de285edde6a7b39a8bdc40a27b237f8fb1e57f245e80b929c1e28b024aa2ecc6ad0bc40b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038eade9742133567ea39fbb688eccb0ae78d08d3e9b484508021b21e407744bd"
-----------------------
SoC ID Header Info:
-----------------------
NumBlocks : 2
-----------------------
SoC ID Public ROM Info:
-----------------------
SubBlockId : 1
SubBlockSize : 26
DeviceName : am64x
DeviceType : HSFS
DMSC ROM Version : [0, 2, 0, 0]
R5 ROM Version : [0, 2, 0, 0]
-----------------------
SoC ID Secure ROM Info:
-----------------------
Sec SubBlockId : 2
Sec SubBlockSize : 166
Sec Prime : 0
Sec Key Revision : 0
Sec Key Count : 0
Sec TI MPK Hash : b018658ad99dc903c8c9bfb27b12751099920a042ad1dfea7b7ba57369f15546de285edde6a7b39a8bdc40a27b237f8fb1e57f245e80b929c1e28b024aa2ecc6
Sec Cust MPK Hash : ad0bc40b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Sec Unique ID : 38eade9742133567ea39fbb688eccb0ae78d08d3e9b484508021b21e407744bd
"


  • Hi Daryl,

    You are using the correct images according to the device type so the procedure should not ideally fail. Can you please let me know if it is failing randomly or each time on multiple attempts.

    Thanks!

  • Hi Prashant, 
    It fails every time. Tried several power cycles etc.
    I know I am in UART boot mode correctly because I see the 'C' printed out when I have terminal connected.
    Thanks, 
    Daryl

  • Hi Daryl,

    Can you please try sending the sbl_uart_uniflash.release.hs_fs.tiimage using Teraterm and see if it is able to send successfully?

    Teraterm: File -> Transfer -> XMODEM -> Send -> Path to sbl_uart_uniflash.release.hs_fs.tiimage

    Regards,

    Prashant

  • Yes, that XMODEM send via teraterm successfully sends.
    SBL isn't updated by this it seems though?
    Does this mean I have a python problem?

  • Some additional debug info I missed before:

    C:\ti\mcu_plus_sdk_am243x_09_00_00_35\tools\boot>python uart_uniflash.py -p COM16 --cfg=sbl_prebuilt/am243x-evm/default_sbl_null.cfg

    this has this info when it errors out:

    | 132/317925 [00:00<10:51, 487.81bytes/s]

    This indicates xmodem sent 132 bytes before error occurs...


  • If I modify the uart_uniflash.py at this line:
    modem = XMODEM1k(getc, putc)
    #modem = XMODEM(getc, putc)

    To use XMODEM module instead of XMODEM 1k that's what causes this difference:

    XMODEM 
    | 132/317925 [00:00<10:51, 487.81bytes/s]

    XMODEM1k
    | 1029/317925 [00:00<01:28, 3570.20bytes/s]

  • Hi Daryl,

    Please use the default XMODEM1k protocol only.

    Are you making sure that the UART port is not connected anywhere before trying the flashing procedure with the python script?

    Regards,

    Prashant

  • Yes, I'm sure it is not connected to anywhere. The UART works in other cases if tried.
    The fact that it successfully sends 1029 bytes before erroring out is odd. Is that some clue?

  • Can I ship this dev kit back and get another one free of charge that works?

  • Can I ship this dev kit back and get another one free of charge that works?

    The board is working fine as XMODEM send via Teraterm is successful. It's just that something is wrong in the setup when uart_uniflash.py is tried out.

    Can you please try the following modified `uart_uniflash.py` which has the debug logging enabled

    import os
    import sys
    import time
    import shlex
    import struct
    import argparse
    
    try:
        import serial
        from tqdm import tqdm
        from xmodem import XMODEM, XMODEM1k
    except ImportError:
        print('[ERROR] Dependant modules not installed, use below pip command to install them. MAKE sure proxy for pip is setup if needed.')
        print('')
        print('python -m pip install pyserial tqdm xmodem --proxy={http://your proxy server:port or leave blank if no proxy}')
        sys.exit(2)
    
    import logging
    logging.basicConfig(level=logging.DEBUG)
    
    ERROR_BAD_ARGS      = 1
    ERROR_BAD_PORT      = 2
    ERROR_BAD_RESPONSE  = 3
    
    CONST_KB = 1024
    CONST_MB = CONST_KB * CONST_KB
    
    BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES                   = CONST_MB # This has to be a 256 KB aligned value, because flash writes will be block oriented
    BOOTLOADER_UNIFLASH_HEADER_SIZE                      = 32 # 32 B
    
    BOOTLOADER_UNIFLASH_FILE_HEADER_MAGIC_NUMBER         = 0x46554C42 # BLUF
    BOOTLOADER_UNIFLASH_RESP_HEADER_MAGIC_NUMBER         = 0x52554C42 # BLUR
    
    BOOTLOADER_UNIFLASH_OPTYPE_FLASH                     = 0xF0
    BOOTLOADER_UNIFLASH_OPTYPE_FLASH_VERIFY              = 0xF1
    BOOTLOADER_UNIFLASH_OPTYPE_FLASH_XIP                 = 0xF2
    BOOTLOADER_UNIFLASH_OPTYPE_FLASH_VERIFY_XIP          = 0xF3
    BOOTLOADER_UNIFLASH_OPTYPE_FLASH_TUNING_DATA         = 0xF4
    BOOTLOADER_UNIFLASH_OPTYPE_FLASH_ERASE               = 0xFE
    BOOTLOADER_UNIFLASH_OPTYPE_EMMC_FLASH                = 0xF5
    BOOTLOADER_UNIFLASH_OPTYPE_EMMC_VERIFY               = 0xF6
    
    BOOTLOADER_UNIFLASH_STATUSCODE_SUCCESS                = 0x00000000
    BOOTLOADER_UNIFLASH_STATUSCODE_MAGIC_ERROR            = 0x10000001
    BOOTLOADER_UNIFLASH_STATUSCODE_OPTYPE_ERROR           = 0x20000001
    BOOTLOADER_UNIFLASH_STATUSCODE_FLASH_ERROR            = 0x30000001
    BOOTLOADER_UNIFLASH_STATUSCODE_FLASH_VERIFY_ERROR     = 0x40000001
    BOOTLOADER_UNIFLASH_STATUSCODE_FLASH_ERASE_ERROR      = 0x50000001
    
    optypewords = {
        "flash" : BOOTLOADER_UNIFLASH_OPTYPE_FLASH,
        "flashverify" : BOOTLOADER_UNIFLASH_OPTYPE_FLASH_VERIFY,
        "flash-xip" : BOOTLOADER_UNIFLASH_OPTYPE_FLASH_XIP,
        "flashverify-xip" : BOOTLOADER_UNIFLASH_OPTYPE_FLASH_VERIFY_XIP,
        "flash-phy-tuning-data" : BOOTLOADER_UNIFLASH_OPTYPE_FLASH_TUNING_DATA,
        "erase" : BOOTLOADER_UNIFLASH_OPTYPE_FLASH_ERASE,
        "flash-emmc":BOOTLOADER_UNIFLASH_OPTYPE_EMMC_FLASH,
        "flashverify-emmc":BOOTLOADER_UNIFLASH_OPTYPE_EMMC_VERIFY,
    }
    
    statuscodes = {
        BOOTLOADER_UNIFLASH_STATUSCODE_SUCCESS : "[STATUS] SUCCESS !!!\n",
        BOOTLOADER_UNIFLASH_STATUSCODE_MAGIC_ERROR : "[STATUS] ERROR: Incorrect magic number in file header !!!\n",
        BOOTLOADER_UNIFLASH_STATUSCODE_OPTYPE_ERROR : "[STATUS] ERROR: Invalid file operation type sent !!!\n",
        BOOTLOADER_UNIFLASH_STATUSCODE_FLASH_ERROR : "[STATUS] ERROR: Flashing failed !!!\n",
        BOOTLOADER_UNIFLASH_STATUSCODE_FLASH_VERIFY_ERROR : "[STATUS] ERROR: Flash verify failed !!!\n",
        BOOTLOADER_UNIFLASH_STATUSCODE_FLASH_ERASE_ERROR : "[STATUS] ERROR: Flash erase failed !!!\n",
    }
    
    TMP_SUFFIX = ".tmp"
    
    g_script_description = '''
    MCU+SDK utility script to flash images to device flash.
    '''
    
    g_cfg_file_description = '''
    Configuration file which has a list of files with
    options for flashing. This should be given as option=value pairs
    separated by space just like in command line. Only give the long
    options in the config file i.e --flash-offset=0x80000 and not -o 0x80000
    
    Example, below can be a line in the config file, myconfig.cfg
    --file=am64x-evm/sbl_ospi.release.tiimage --operation=flash --flash-offset=0x0
    
    and then the script can be called:
    python uart_uniflash.py -p <COM port> --cfg=myconfig.cfg
    '''
    
    def open_serial_port(serial_port, baudrate, timeout=60):
        ser = None
        try:
            ser = serial.Serial(port=serial_port, baudrate=baudrate, timeout=timeout)
        except serial.serialutil.SerialException:
            print('[ERROR] Serial port [' + serial_port + '] not found or not accessible !!!')
            sys.exit(ERROR_BAD_PORT)
        return ser
    
    def close_serial_port(ser):
        ser.close()
    
    def get_numword(s):
        numword = None
        if(s.startswith('0x')):
            numword = int(s, 16)
        else:
            numword = int(s, 10)
        return numword
    
    # Add the file header with metadata to the file to be sent. Expects a validated linecfg
    def create_temp_file(linecfg):
        '''
        File header struct used in the target side :
    
        typedef struct Bootloader_UniflashFileHeader_s
        {
            uint32_t magicNumber;
            /* BOOTLOADER_UNIFLASH_FILE_HEADER_MAGIC_NUMBER */
    
            uint32_t operationTypeAndFlags;
            /* LSByte - Operation Type:flash, verify flash or erase */
    
            uint32_t offset;
            /* Offset to flash, verify flash or erase flash */
    
            uint32_t eraseSize;
            /* Size of flash to erase */
    
            uint32_t actualFileSize;
            /* Size of the file sent. This is needed because xmodem returns a padded file size */
    
            uint32_t rsv1;
            uint32_t rsv2;
            uint32_t rsv3;
            /* Reserved */
        } Bootloader_UniflashFileHeader;
    
        So we need to use same struct to pack in python
        '''
        file_header_str = '<LLLLLLLL'
    
        if(linecfg.optype in ("erase", "flash-phy-tuning-data")):
            # No separate file required
            tempfilename = "{}_command".format(linecfg.optype)
        else:
            tempfilename = linecfg.filename + TMP_SUFFIX
    
        f = open(tempfilename, "wb")
    
        # Construct the header now, first define the reserved word
        rsv_word = 0xDEADBABE
    
        # Determine the offset if applicable
        offset_val = rsv_word
        if(linecfg.optype not in ("flash-xip", "flashverify-xip", "flash-phy-tuning-data")):
            offset_val = get_numword(linecfg.offset)
    
        # Determine the erase size if applicable
        erase_size_val = rsv_word
        if(linecfg.optype in ("erase")):
            erase_size_val = get_numword(linecfg.erase_size)
    
        # Determine the actual file size if applicable, no original file in case of erase or phy tuning
        actual_file_size = 0
        if(linecfg.optype not in ("erase","flash-phy-tuning-data")):
            actual_file_size = os.path.getsize(linecfg.filename)
    
        file_header = struct.pack(file_header_str,
                                  BOOTLOADER_UNIFLASH_FILE_HEADER_MAGIC_NUMBER,
                                  optypewords[linecfg.optype],
                                  offset_val,
                                  erase_size_val,
                                  actual_file_size,
                                  rsv_word, rsv_word, rsv_word
                                 )
    
        # Write header to file
        f.write(file_header)
    
        # No original file in case of erase or phy tuning
        if(linecfg.optype not in ("erase","flash-phy-tuning-data")):
            # copy the original file to this file
            original_file = open(linecfg.filename, "rb")
            f.write(original_file.read())
            original_file.close()
    
        f.close()
    
        return tempfilename
    
    # Parse response header sent from EVM
    def parse_response_evm(filename):
        f = open(filename, "rb")
        resp_bytes = f.read(16)
        f.close()
    
        status = None
    
        resp_magic = int.from_bytes(resp_bytes[0:4], 'little')
        resp_status = int.from_bytes(resp_bytes[4:8], 'little')
    
        if(resp_magic == BOOTLOADER_UNIFLASH_RESP_HEADER_MAGIC_NUMBER):
            if resp_status in statuscodes.keys():
                status = statuscodes[resp_status]
            else:
                status = "[ERROR] Invalid status code in response !!!"
        else:
            status = "[ERROR] Incorrect magic number in Response Header !!!"
    
        return status
    
    # Sends the file to EVM via xmodem, receives response from EVM and returns the response status
    def xmodem_send_receive_file(filename, serialport, baudrate=115200, get_response=True, read_timeout=60):
        status = False
        timetaken = 0
        if not os.path.exists(filename):
            print('[ERROR] File [' + filename + '] not found !!!')
            sys.exit(ERROR_BAD_ARGS)
    
        stream = open(filename, 'rb')
    
        # bar = tqdm(total=os.path.getsize(filename), unit="bytes", leave=False, desc="Sending {}".format(filename.replace(TMP_SUFFIX, "")))
    
        ser = open_serial_port(serialport, baudrate, timeout=read_timeout)
    
        def getc(size, timeout=1):
            return ser.read(size) or None
    
        def putc(data, timeout=1):
            # bar.update(len(data))
            # bar.refresh()
            return ser.write(data)
    
        try:
            modem = XMODEM1k(getc, putc)
            tstart = time.time()
            status = modem.send(stream, quiet=True,  timeout=10, retry=10)
            tstop = time.time()
            timetaken = round(tstop-tstart, 2)
        except Exception as e:
            status = False
            print(e)
    
        stream.close()
    
        if( status is False ) :
            print("")
            print ("[ERROR] XMODEM send failed, no response OR incorrect response from EVM OR cancelled by user,")
            print ("Power cycle EVM and run this script again !!!")
            sys.exit(ERROR_BAD_RESPONSE)
    
        resp_status = 0
    
        # Don't do the receive if get_response is False
        if(get_response):
            respfilename = "resp.dat"
            try:
                respfile = open(respfilename, "wb")
                status = modem.recv(respfile, quiet=True, timeout=2000)
                respfile.close()
                resp_status = parse_response_evm(respfilename)
                os.remove(respfilename)
            except:
                status = None
            if( status is None ) :
                print("")
                print ("[ERROR] XMODEM recv failed, no response OR incorrect response from EVM OR cancelled by user,")
                print ("Power cycle EVM and run this script again !!!")
                sys.exit(ERROR_BAD_RESPONSE)
    
        close_serial_port(ser)
    
        # bar.close()
    
        return resp_status, timetaken
    
    def send_file_by_parts(l_cfg, s_port):
        orig_f_name = l_cfg.filename
        orig_offset = l_cfg.offset
    
        f = open(orig_f_name, "rb")
        f_bytes = f.read()
        f.close()
    
        num_parts   = int(len(f_bytes) / BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES)
        remain_size = len(f_bytes) % BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES
        total_time_taken = 0
    
    
        for i in range(0, num_parts):
    
            start = i*BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES
            end = start+BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES
    
            part_data = f_bytes[start:end]
            part_filename = orig_f_name + ".part{}".format(i+1)
            # make the partial file
            f = open(part_filename, "wb")
            f.write(part_data)
            f.close()
    
            # temporarily change this to the partial filename
            l_cfg.filename = part_filename
            l_cfg.offset = hex(get_numword(orig_offset) + i*BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES)
    
            # send the partial file normally
            tempfilename = create_temp_file(l_cfg)
            status, timetaken = xmodem_send_receive_file(tempfilename, s_port)
            total_time_taken += timetaken
    
            # delete the temporary file
            os.remove(part_filename)
            os.remove(tempfilename)
    
        # Send the last part, if there were residual bytes
        if(remain_size > 0):
            start = num_parts*BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES
            # Read till the end of original file
            part_data = bytearray(f_bytes[start:])
            padding = 256 - (remain_size % 256) # page size adjustment
            # there should be a better way :)
            for i in range(0, padding):
                part_data.append(0)
            part_filename = orig_f_name + ".part{}".format(num_parts+1)
    
            # make the partial file
            f = open(part_filename, "wb")
            f.write(part_data)
            f.close()
    
            # temporarily change this to the partial filename
            l_cfg.filename = part_filename
            l_cfg.offset = hex(get_numword(orig_offset) + num_parts*BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES)
    
            # send the partial file normally
            tempfilename = create_temp_file(l_cfg)
            status, timetaken = xmodem_send_receive_file(tempfilename, s_port)
            total_time_taken += timetaken
    
            # delete the temporary file
            os.remove(part_filename)
            os.remove(tempfilename)
    
        # revert back the original filename and offset
        l_cfg.filename = orig_f_name
        l_cfg.offset = orig_offset
    
        return status, total_time_taken
    
    def main(argv):
        serialport = None
        config_file = None
        cmd_flash_writer_found = False
        ops_invalid = False
    
        cmdlinecfg = LineCfg(cfg_src="cmd")
    
        my_parser = argparse.ArgumentParser(description=g_script_description)
        my_parser.add_argument('-p', '--serial-port', required=True, help="[Mandatory argument] Serial port to use for the transfer. COM3, COM4 etc if on windows and /dev/ttyUSB1,/dev/ttyUSB2 etc if on linux.")
        my_parser.add_argument('-f', '--file', required=False, help="Filename to send for an operation. Not required if using config mode (--cfg)")
        my_parser.add_argument('-o', '--flash-offset', required=False, help="Offset (in hexadecimal format starting with a 0x) at which the flash/verify flash is to be done. Not required if using config mode (--cfg)")
        my_parser.add_argument('--operation', required=False, help='Operation to be done on the file => "flash" or "flashverify" or "erase" or "flash-xip" or "flashverify-xip" or "flash-phy-tuning-data" or "flash-emmc" or "flashverify-emmc". Not required if using config mode (--cfg)')
        my_parser.add_argument('--flash-writer', required=False, help="Special option. This will load the sbl_uart_uniflash binary which will be booted by ROM. Other arguments are irrelevant and hence ignored when --flash-writer argument is present. Not required if using config mode (--cfg)")
        my_parser.add_argument('--erase-size', required=False, help='Size of flash to erase. Only valid when operation is "erase"')
        my_parser.add_argument('--cfg', required=False, help=g_cfg_file_description)
        my_parser.add_argument('--chunk-size-kb', required=False, default=CONST_KB, help="Size of the receive buffer in multiples of KB. Defaults to 1024")
    
        args = my_parser.parse_args()
        
        global BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES
        BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES = CONST_KB * int(args.chunk_size_kb)
    
        serialport = args.serial_port
        config_file = args.cfg
        cmdlinecfg.filename = args.file
        cmdlinecfg.offset = args.flash_offset
        cmdlinecfg.optype = args.operation
        cmdlinecfg.flashwriter = args.flash_writer
        cmdlinecfg.erase_size = args.erase_size
    
        if(config_file != None):
            # Check if file exists
            if not os.path.exists(config_file):
                print('[ERROR] Configuration file [' + config_file + '] not found !!!')
                sys.exit(ERROR_BAD_ARGS)
    
            print("")
            print("Parsing config file ...")
            filecfg = FileCfg(config_file)
            parse_status = filecfg.parse()
    
            if(parse_status != 0):
                print(parse_status)
                sys.exit(ERROR_BAD_ARGS)
            else:
                # No errors, can proceed to flash
                print("Parsing config file ... SUCCESS. Found {} command(s) !!!".format(len(filecfg.cfgs)))
                print("")
    
                if(filecfg.flash_writer_index != None):
                    # Found flash writer, flash it
                    cfg_flash_writer_file = filecfg.cfgs[filecfg.flash_writer_index].flashwriter
                    print("Executing command {} of {} ...".format(1, len(filecfg.cfgs)))
                    print("Found flash writer ... sending {}".format(cfg_flash_writer_file))
                    status, timetaken = xmodem_send_receive_file(cfg_flash_writer_file, serialport, get_response=False)
                    print("Sent flashwriter {} of size {} bytes in {}s.".format(cfg_flash_writer_file, os.path.getsize(cfg_flash_writer_file), timetaken))
                    print("")
    
                # loop through cfgs and lines, skip the process for flashwriter
                for i in range(0, len(filecfg.cfgs)):
                    if(i != filecfg.flash_writer_index):
                        line = filecfg.lines[i]
                        linecfg = filecfg.cfgs[i]
                        print("Executing command {} of {} ...".format(i+1, len(filecfg.cfgs)))
                        print("Command arguments : {}".format(line.rstrip('\n')))
                        # Check if the size of application image is larger than buffer size in target side.
                        f_size = 0
                        if linecfg.filename is not None:
                            f_size = os.path.getsize(linecfg.filename)
    
                        if((f_size + BOOTLOADER_UNIFLASH_HEADER_SIZE >= BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES) and (linecfg.optype in ["flash", "flashverify"])):
                            # Send by parts
                            status, timetaken = send_file_by_parts(linecfg, serialport)
                        else:
                            # Send normally
                            tempfilename = create_temp_file(linecfg)
                            status, timetaken = xmodem_send_receive_file(tempfilename, serialport, get_response=True)
    
                        orig_filename = linecfg.filename
                        if(linecfg.optype == "erase"):
                            print("Sent flash erase command.")
                        elif(linecfg.optype == "flash-phy-tuning-data"):
                            print("Sent flash phy tuning data in {}s.".format(timetaken))
                        else:
                            print("Sent {} of size {} bytes in {}s.".format(orig_filename, os.path.getsize(orig_filename), timetaken))
                        print(status)
                        # Delete the tempfile if it exists
                        if(os.path.exists(tempfilename)):
                            os.remove(tempfilename)
    
                print("All commands from config file are executed !!!")
    
        else:
            # Validate the cmdline config
            status = cmdlinecfg.validate()
            if(status != 0):
                print(status)
                if(cmdlinecfg.exit_now == True):
                    sys.exit(ERROR_BAD_ARGS)
            # If flash writer was found, send it first
            if(cmdlinecfg.found_flashwriter_cmd == True):
                print("Found flash writer ... sending {}".format(cmdlinecfg.flashwriter))
                status, timetaken = xmodem_send_receive_file(cmdlinecfg.flashwriter, serialport, get_response=False)
                print("Sent flashwriter {} of size {} bytes in {}s.".format(cmdlinecfg.flashwriter, os.path.getsize(cmdlinecfg.flashwriter), timetaken))
                print("")
    
            if(cmdlinecfg.ops_invalid == False):
                # Check if the size of application image is larger than buffer size in target side.
                f_size = 0
                if cmdlinecfg.filename is not None:
                    f_size = os.path.getsize(cmdlinecfg.filename)
    
                if((f_size + BOOTLOADER_UNIFLASH_HEADER_SIZE >= BOOTLOADER_UNIFLASH_BUF_SIZE_BYTES) and (cmdlinecfg.optype in ["flash", "flashverify"])):
                    # Send by parts
                    status, timetaken = send_file_by_parts(cmdlinecfg, serialport)
                else:
                    # Send normally
                    tempfilename = create_temp_file(cmdlinecfg)
                    status, timetaken = xmodem_send_receive_file(tempfilename, serialport)
                    # Delete the tempfile if it exists
                    if(os.path.exists(tempfilename)):
                        os.remove(tempfilename)
    
                orig_filename = cmdlinecfg.filename
                if(cmdlinecfg.optype == "erase"):
                    print("Sent flash erase command.")
                elif(cmdlinecfg.optype == "flash-phy-tuning-data"):
                    print("Sent flash phy tuning data in {}s.".format(timetaken))
                else:
                    print("Sent {} of size {} bytes in {}s.".format(orig_filename, os.path.getsize(orig_filename), timetaken))
                print(status)
    
    # Class definitions used
    class LineCfg():
        def __init__(self, line=None, filename=None, optype=None, offset=None, erase_size=None, flashwriter=None, cfg_src="cfg"):
            self.line = line
            self.filename = filename
            self.optype = optype
            self.offset = offset
            self.flashwriter = flashwriter
            self.erase_size = erase_size
            self.found_flashwriter_cmd = False
            self.ops_invalid = False
            self.cfg_src = cfg_src
            self.exit_now = False
    
        # Takes a string of comma separated key=value pairs and parses into a dictionary
        def parse_to_dict(self, config_string):
            config_dict = dict()
            splitter = shlex.shlex(config_string, posix=True)
            splitter.commenters="#"
            splitter.whitespace = ' '
            splitter.whitespace_split = True
    
            for key_value_pair in splitter:
                kv = key_value_pair.strip()
                if not kv:
                    continue
                kv_t = kv.split('=', 1)
                if(len(kv_t)==1):
                    #error, no value
                    pass
                else:
                    config_dict[kv_t[0]] = kv_t[1]
    
            return config_dict
    
        def validate(self):
            status = 0
            optypes = list(optypewords.keys())
            # Check if called by config file parser or direct command line
            if(self.line!=None and self.cfg_src=="cfg"):
                # Called from config_file
                config_dict = self.parse_to_dict(self.line)
    
                if not config_dict:
                    status = "invalid_line"
                else:
                    # check for flashwriter
                    if "--flash-writer" not in config_dict.keys():
                        # it is okay not to have a flashwriter, in this case
                        # user is expected to have flashed the flashwriter upfront
                        # Check for other arguments
                        # check if file is present
                        if "--operation" not in config_dict.keys():
                            status = "[ERROR] No file operation specified !!!"
                            return status
                        else:
                            self.optype = config_dict["--operation"]
    
                        if(self.optype == "flash" or self.optype == "flashverify" or self.optype == "erase" or self.optype == "flash-emmc" or\
                            self.optype == "flashverify-emmc"):
                            if "--flash-offset" not in config_dict.keys():
                                status = "[ERROR] Operation selected was {}, but no offset provided !!!".format(self.optype)
                                return status
                            else:
                                self.offset = config_dict["--flash-offset"]
    
                        if(self.optype == "flash" or self.optype == "flashverify" or self.optype == "flash-xip" or self.optype == "flashverify-xip" or\
                            self.optype == "flash-emmc" or self.optype == "flashverify-emmc"):
                            if "--file" not in config_dict.keys():
                                status = "[ERROR] Operation selected was {}, but no filename provided !!!".format(self.optype)
                                return status
                            else:
                                self.filename = config_dict["--file"]
    
                        if(self.optype == "erase"):
                            if "--erase-size" not in config_dict.keys():
                                status = "[ERROR] Operation selected was {}, but no erase size provided !!!".format(self.optype)
                                return status
                            else:
                                self.erase_size = config_dict["--erase-size"]
    
                        #No errors in parsing, now validate params to the extent possible
    
                        if(self.optype not in ("erase", "flash-phy-tuning-data")):
                            try:
                                f = open(self.filename)
                            except FileNotFoundError:
                                status = "[ERROR] File not found !!!"
                                return status
    
                        if(self.optype not in optypes):
                            status = "[ERROR] Invalid File Operation type !!!"
                            return status
    
                    else:
                        # we have a flash writer argument, other arguments are moot
                        self.flashwriter = config_dict["--flash-writer"]
    
                        try:
                            f = open(self.flashwriter)
                        except FileNotFoundError:
                            status = "[ERROR] Flashwriter file not found !!!"
                            return status
    
            elif(self.line==None and self.cfg_src=="cmd"):
                # Called from main, with cmd line arguments
                # We have the filename, optype etc already filled
                if(self.flashwriter != None):
                    self.found_flashwriter_cmd = True
                else:
                    self.found_flashwriter_cmd = False
    
                if(self.optype == None):
                    # mandatory arg. If no flashwriter, caller should exit now
                    self.ops_invalid = True
                    self.exit_now = not self.found_flashwriter_cmd
                    if(self.found_flashwriter_cmd == False):
                        status = "[ERROR] No operation type mentioned !!!"
                        return status
                    else:
                        pass
                else:
                    if((self.optype == "flash" or self.optype == "flashverify" or self.optype == "erase" or self.optype == "flashverify-emmc") and (self.offset == None)):
                        self.ops_invalid = True
                        self.exit_now = not self.found_flashwriter_cmd
                        # flash/verify flash/erase, but no offset given. exit with help if no flashwriter
                        if(self.found_flashwriter_cmd == False):
                            status = "[ERROR] Operation selected was {}, but no offset was provided !!!".format(self.optype)
                            return status
                        else:
                            pass
    
                    if((self.optype == "flash" or self.optype == "flashverify" or self.optype == "flash-xip" or self.optype == "flashverify-xip" or self.optype == "flashverify-emmc") and (self.filename == None)):
                        self.ops_invalid = True
                        self.exit_now = not self.found_flashwriter_cmd
                        # flash/verify flash/erase, but no filename given. exit with help if no flashwriter
                        if(self.found_flashwriter_cmd == False):
                            status = "[ERROR] Operation selected was {}, but no filename was provided !!!".format(self.optype)
                            return status
                        else:
                            pass
    
                    if(self.optype == "erase" and self.erase_size == None):
                        self.ops_invalid = True
                        self.exit_now = not self.found_flashwriter_cmd
                        # erase command found, but no erase size given. exit with help if no flashwriter
                        if(self.found_flashwriter_cmd == False):
                            status = "[ERROR] Operation selected was {}, but no erase size was provided !!!".format(self.optype)
                            return status
                        else:
                            pass
    
                    if(self.optype not in optypes):
                        self.ops_invalid = True
                        self.exit_now = not self.found_flashwriter_cmd
                        # erase command found, but no erase size given. exit with help if no flashwriter
                        if(self.found_flashwriter_cmd == False):
                            status = "[ERROR] Invalid File Operation type !!!"
                            return status
                        else:
                            pass
                    if(self.optype not in ("erase", "flash-phy-tuning-data")):
                        try:
                            f = open(self.filename)
                        except FileNotFoundError:
                            self.ops_invalid = True
                            self.exit_now = not self.found_flashwriter_cmd
                            # erase command found, but no erase size given. exit with help if no flashwriter
                            if(self.found_flashwriter_cmd == False):
                                status = "[ERROR] File not found !!!"
                                return status
                            else:
                                pass
            else:
                # Should not hit this
                status = -1
            return status
    
    class FileCfg():
        def __init__(self, filename=None):
            self.filename = filename
            self.lines = list()
            self.cfgs = list()
            self.errors = list()
            self.flash_writer_index = None
    
        def parse(self):
            f = open(self.filename, "r")
            lines = f.readlines()
            f.close()
            parse_status = 0
            linecount = 0
            found_fw = False
            valid_cfg_count = 0
    
            for line in lines:
                linecfg = LineCfg(line=line)
                status = linecfg.validate()
    
                if(status != 0 and status != "invalid_line"):
                    self.errors.append("[ERROR] Parsing error found on line {} of {}\n{}\n".format(linecount+1, self.filename, status))
                else:
                    if(status != "invalid_line"):
                        if(linecfg.flashwriter != None):
                            if(found_fw == True):
                                # error, another instance of flashwriter found
                                flash_writer_error_msg = "[ERROR] Redefinition of flash writer !!!"
                                self.errors.append("[ERROR] Parsing error found on line {} of {}\n{}\n".format(linecount+1, self.filename, flash_writer_error_msg))
                            else:
                                found_fw = True
                                self.cfgs.append(linecfg)
                                self.lines.append(line.rstrip('\n'))
                                self.flash_writer_index = valid_cfg_count
                                valid_cfg_count += 1
                        else:
                            self.cfgs.append(linecfg)
                            self.lines.append(line.rstrip('\n'))
                            valid_cfg_count += 1
                linecount += 1
    
            if(len(self.errors) > 0):
                # Some commands have errors
                parse_status = "Parsing config file ... ERROR. {} error(s).\n\n".format(len(self.errors)) + "\n".join(self.errors)
    
            return parse_status
    
    if __name__ == "__main__":
        main(sys.argv[1:])
        

  • C:\ti\mcu_plus_sdk_am243x_09_00_00_35\tools\boot>python uart_uniflash.py -p COM16 --cfg=sbl_prebuilt/am243x-evm/default_sbl_null.cfg
    
    Parsing config file ...
    Parsing config file ... SUCCESS. Found 2 command(s) !!!
    
    Executing command 1 of 2 ...
    Found flash writer ... sending sbl_prebuilt/am243x-evm/sbl_uart_uniflash.release.hs_fs.tiimage
    DEBUG:xmodem.XMODEM:Begin start sequence, packet_size=1024
    DEBUG:xmodem.XMODEM:16-bit CRC requested (CRC).
    DEBUG:xmodem.XMODEM:send: block 1
    DEBUG:xmodem.XMODEM:send: block 2
    DEBUG:xmodem.XMODEM:send: block 3
    DEBUG:xmodem.XMODEM:send: block 4
    DEBUG:xmodem.XMODEM:send: block 5
    DEBUG:xmodem.XMODEM:send: block 6
    DEBUG:xmodem.XMODEM:send: block 7
    DEBUG:xmodem.XMODEM:send: block 8
    DEBUG:xmodem.XMODEM:send: block 9
    DEBUG:xmodem.XMODEM:send: block 10
    DEBUG:xmodem.XMODEM:send: block 11
    DEBUG:xmodem.XMODEM:send: block 12
    DEBUG:xmodem.XMODEM:send: block 13
    DEBUG:xmodem.XMODEM:send: block 14
    DEBUG:xmodem.XMODEM:send: block 15
    DEBUG:xmodem.XMODEM:send: block 16
    DEBUG:xmodem.XMODEM:send: block 17
    DEBUG:xmodem.XMODEM:send: block 18
    DEBUG:xmodem.XMODEM:send: block 19
    DEBUG:xmodem.XMODEM:send: block 20
    DEBUG:xmodem.XMODEM:send: block 21
    DEBUG:xmodem.XMODEM:send: block 22
    DEBUG:xmodem.XMODEM:send: block 23
    DEBUG:xmodem.XMODEM:send: block 24
    DEBUG:xmodem.XMODEM:send: block 25
    DEBUG:xmodem.XMODEM:send: block 26
    DEBUG:xmodem.XMODEM:send: block 27
    DEBUG:xmodem.XMODEM:send: block 28
    DEBUG:xmodem.XMODEM:send: block 29
    DEBUG:xmodem.XMODEM:send: block 30
    DEBUG:xmodem.XMODEM:send: block 31
    DEBUG:xmodem.XMODEM:send: block 32
    DEBUG:xmodem.XMODEM:send: block 33
    DEBUG:xmodem.XMODEM:send: block 34
    DEBUG:xmodem.XMODEM:send: block 35
    DEBUG:xmodem.XMODEM:send: block 36
    DEBUG:xmodem.XMODEM:send: block 37
    DEBUG:xmodem.XMODEM:send: block 38
    DEBUG:xmodem.XMODEM:send: block 39
    DEBUG:xmodem.XMODEM:send: block 40
    DEBUG:xmodem.XMODEM:send: block 41
    DEBUG:xmodem.XMODEM:send: block 42
    DEBUG:xmodem.XMODEM:send: block 43
    DEBUG:xmodem.XMODEM:send: block 44
    DEBUG:xmodem.XMODEM:send: block 45
    DEBUG:xmodem.XMODEM:send: block 46
    DEBUG:xmodem.XMODEM:send: block 47
    DEBUG:xmodem.XMODEM:send: block 48
    DEBUG:xmodem.XMODEM:send: block 49
    DEBUG:xmodem.XMODEM:send: block 50
    DEBUG:xmodem.XMODEM:send: block 51
    DEBUG:xmodem.XMODEM:send: block 52
    DEBUG:xmodem.XMODEM:send: block 53
    DEBUG:xmodem.XMODEM:send: block 54
    DEBUG:xmodem.XMODEM:send: block 55
    DEBUG:xmodem.XMODEM:send: block 56
    DEBUG:xmodem.XMODEM:send: block 57
    DEBUG:xmodem.XMODEM:send: block 58
    DEBUG:xmodem.XMODEM:send: block 59
    DEBUG:xmodem.XMODEM:send: block 60
    DEBUG:xmodem.XMODEM:send: block 61
    DEBUG:xmodem.XMODEM:send: block 62
    DEBUG:xmodem.XMODEM:send: block 63
    DEBUG:xmodem.XMODEM:send: block 64
    DEBUG:xmodem.XMODEM:send: block 65
    DEBUG:xmodem.XMODEM:send: block 66
    DEBUG:xmodem.XMODEM:send: block 67
    DEBUG:xmodem.XMODEM:send: block 68
    DEBUG:xmodem.XMODEM:send: block 69
    DEBUG:xmodem.XMODEM:send: block 70
    DEBUG:xmodem.XMODEM:send: block 71
    DEBUG:xmodem.XMODEM:send: block 72
    DEBUG:xmodem.XMODEM:send: block 73
    DEBUG:xmodem.XMODEM:send: block 74
    DEBUG:xmodem.XMODEM:send: block 75
    DEBUG:xmodem.XMODEM:send: block 76
    DEBUG:xmodem.XMODEM:send: block 77
    DEBUG:xmodem.XMODEM:send: block 78
    DEBUG:xmodem.XMODEM:send: block 79
    DEBUG:xmodem.XMODEM:send: block 80
    DEBUG:xmodem.XMODEM:send: block 81
    DEBUG:xmodem.XMODEM:send: block 82
    DEBUG:xmodem.XMODEM:send: block 83
    DEBUG:xmodem.XMODEM:send: block 84
    DEBUG:xmodem.XMODEM:send: block 85
    DEBUG:xmodem.XMODEM:send: block 86
    DEBUG:xmodem.XMODEM:send: block 87
    DEBUG:xmodem.XMODEM:send: block 88
    DEBUG:xmodem.XMODEM:send: block 89
    DEBUG:xmodem.XMODEM:send: block 90
    DEBUG:xmodem.XMODEM:send: block 91
    DEBUG:xmodem.XMODEM:send: block 92
    DEBUG:xmodem.XMODEM:send: block 93
    DEBUG:xmodem.XMODEM:send: block 94
    DEBUG:xmodem.XMODEM:send: block 95
    DEBUG:xmodem.XMODEM:send: block 96
    DEBUG:xmodem.XMODEM:send: block 97
    DEBUG:xmodem.XMODEM:send: block 98
    DEBUG:xmodem.XMODEM:send: block 99
    DEBUG:xmodem.XMODEM:send: block 100
    DEBUG:xmodem.XMODEM:send: block 101
    DEBUG:xmodem.XMODEM:send: block 102
    DEBUG:xmodem.XMODEM:send: block 103
    DEBUG:xmodem.XMODEM:send: block 104
    DEBUG:xmodem.XMODEM:send: block 105
    DEBUG:xmodem.XMODEM:send: block 106
    DEBUG:xmodem.XMODEM:send: block 107
    DEBUG:xmodem.XMODEM:send: block 108
    DEBUG:xmodem.XMODEM:send: block 109
    DEBUG:xmodem.XMODEM:send: block 110
    DEBUG:xmodem.XMODEM:send: block 111
    DEBUG:xmodem.XMODEM:send: block 112
    DEBUG:xmodem.XMODEM:send: block 113
    DEBUG:xmodem.XMODEM:send: block 114
    DEBUG:xmodem.XMODEM:send: block 115
    DEBUG:xmodem.XMODEM:send: block 116
    DEBUG:xmodem.XMODEM:send: block 117
    DEBUG:xmodem.XMODEM:send: block 118
    DEBUG:xmodem.XMODEM:send: block 119
    DEBUG:xmodem.XMODEM:send: block 120
    DEBUG:xmodem.XMODEM:send: block 121
    DEBUG:xmodem.XMODEM:send: block 122
    DEBUG:xmodem.XMODEM:send: block 123
    DEBUG:xmodem.XMODEM:send: block 124
    DEBUG:xmodem.XMODEM:send: block 125
    DEBUG:xmodem.XMODEM:send: block 126
    DEBUG:xmodem.XMODEM:send: block 127
    DEBUG:xmodem.XMODEM:send: block 128
    DEBUG:xmodem.XMODEM:send: block 129
    DEBUG:xmodem.XMODEM:send: block 130
    DEBUG:xmodem.XMODEM:send: block 131
    DEBUG:xmodem.XMODEM:send: block 132
    DEBUG:xmodem.XMODEM:send: block 133
    DEBUG:xmodem.XMODEM:send: block 134
    DEBUG:xmodem.XMODEM:send: block 135
    DEBUG:xmodem.XMODEM:send: block 136
    DEBUG:xmodem.XMODEM:send: block 137
    DEBUG:xmodem.XMODEM:send: block 138
    DEBUG:xmodem.XMODEM:send: block 139
    DEBUG:xmodem.XMODEM:send: block 140
    DEBUG:xmodem.XMODEM:send: block 141
    DEBUG:xmodem.XMODEM:send: block 142
    DEBUG:xmodem.XMODEM:send: block 143
    DEBUG:xmodem.XMODEM:send: block 144
    DEBUG:xmodem.XMODEM:send: block 145
    DEBUG:xmodem.XMODEM:send: block 146
    DEBUG:xmodem.XMODEM:send: block 147
    DEBUG:xmodem.XMODEM:send: block 148
    DEBUG:xmodem.XMODEM:send: block 149
    DEBUG:xmodem.XMODEM:send: block 150
    DEBUG:xmodem.XMODEM:send: block 151
    DEBUG:xmodem.XMODEM:send: block 152
    DEBUG:xmodem.XMODEM:send: block 153
    DEBUG:xmodem.XMODEM:send: block 154
    DEBUG:xmodem.XMODEM:send: block 155
    DEBUG:xmodem.XMODEM:send: block 156
    DEBUG:xmodem.XMODEM:send: block 157
    DEBUG:xmodem.XMODEM:send: block 158
    DEBUG:xmodem.XMODEM:send: block 159
    DEBUG:xmodem.XMODEM:send: block 160
    DEBUG:xmodem.XMODEM:send: block 161
    DEBUG:xmodem.XMODEM:send: block 162
    DEBUG:xmodem.XMODEM:send: block 163
    DEBUG:xmodem.XMODEM:send: block 164
    DEBUG:xmodem.XMODEM:send: block 165
    DEBUG:xmodem.XMODEM:send: block 166
    DEBUG:xmodem.XMODEM:send: block 167
    DEBUG:xmodem.XMODEM:send: block 168
    DEBUG:xmodem.XMODEM:send: block 169
    DEBUG:xmodem.XMODEM:send: block 170
    DEBUG:xmodem.XMODEM:send: block 171
    DEBUG:xmodem.XMODEM:send: block 172
    DEBUG:xmodem.XMODEM:send: block 173
    DEBUG:xmodem.XMODEM:send: block 174
    DEBUG:xmodem.XMODEM:send: block 175
    DEBUG:xmodem.XMODEM:send: block 176
    DEBUG:xmodem.XMODEM:send: block 177
    DEBUG:xmodem.XMODEM:send: block 178
    DEBUG:xmodem.XMODEM:send: block 179
    DEBUG:xmodem.XMODEM:send: block 180
    DEBUG:xmodem.XMODEM:send: block 181
    DEBUG:xmodem.XMODEM:send: block 182
    DEBUG:xmodem.XMODEM:send: block 183
    DEBUG:xmodem.XMODEM:send: block 184
    DEBUG:xmodem.XMODEM:send: block 185
    DEBUG:xmodem.XMODEM:send: block 186
    DEBUG:xmodem.XMODEM:send: block 187
    DEBUG:xmodem.XMODEM:send: block 188
    DEBUG:xmodem.XMODEM:send: block 189
    DEBUG:xmodem.XMODEM:send: block 190
    DEBUG:xmodem.XMODEM:send: block 191
    DEBUG:xmodem.XMODEM:send: block 192
    DEBUG:xmodem.XMODEM:send: block 193
    DEBUG:xmodem.XMODEM:send: block 194
    DEBUG:xmodem.XMODEM:send: block 195
    DEBUG:xmodem.XMODEM:send: block 196
    DEBUG:xmodem.XMODEM:send: block 197
    DEBUG:xmodem.XMODEM:send: block 198
    DEBUG:xmodem.XMODEM:send: block 199
    DEBUG:xmodem.XMODEM:send: block 200
    DEBUG:xmodem.XMODEM:send: block 201
    DEBUG:xmodem.XMODEM:send: block 202
    DEBUG:xmodem.XMODEM:send: block 203
    DEBUG:xmodem.XMODEM:send: block 204
    DEBUG:xmodem.XMODEM:send: block 205
    DEBUG:xmodem.XMODEM:send: block 206
    DEBUG:xmodem.XMODEM:send: block 207
    DEBUG:xmodem.XMODEM:send: block 208
    DEBUG:xmodem.XMODEM:send: block 209
    DEBUG:xmodem.XMODEM:send: block 210
    DEBUG:xmodem.XMODEM:send: block 211
    DEBUG:xmodem.XMODEM:send: block 212
    DEBUG:xmodem.XMODEM:send: block 213
    DEBUG:xmodem.XMODEM:send: block 214
    DEBUG:xmodem.XMODEM:send: block 215
    DEBUG:xmodem.XMODEM:send: block 216
    DEBUG:xmodem.XMODEM:send: block 217
    DEBUG:xmodem.XMODEM:send: block 218
    DEBUG:xmodem.XMODEM:send: block 219
    DEBUG:xmodem.XMODEM:send: block 220
    DEBUG:xmodem.XMODEM:send: block 221
    DEBUG:xmodem.XMODEM:send: block 222
    DEBUG:xmodem.XMODEM:send: block 223
    DEBUG:xmodem.XMODEM:send: block 224
    DEBUG:xmodem.XMODEM:send: block 225
    DEBUG:xmodem.XMODEM:send: block 226
    DEBUG:xmodem.XMODEM:send: block 227
    DEBUG:xmodem.XMODEM:send: block 228
    DEBUG:xmodem.XMODEM:send: block 229
    DEBUG:xmodem.XMODEM:send: block 230
    DEBUG:xmodem.XMODEM:send: block 231
    DEBUG:xmodem.XMODEM:send: block 232
    DEBUG:xmodem.XMODEM:send: block 233
    DEBUG:xmodem.XMODEM:send: block 234
    DEBUG:xmodem.XMODEM:send: block 235
    DEBUG:xmodem.XMODEM:send: block 236
    DEBUG:xmodem.XMODEM:send: block 237
    DEBUG:xmodem.XMODEM:send: block 238
    DEBUG:xmodem.XMODEM:send: block 239
    DEBUG:xmodem.XMODEM:send: block 240
    DEBUG:xmodem.XMODEM:send: block 241
    DEBUG:xmodem.XMODEM:send: block 242
    DEBUG:xmodem.XMODEM:send: block 243
    DEBUG:xmodem.XMODEM:send: block 244
    DEBUG:xmodem.XMODEM:send: block 245
    DEBUG:xmodem.XMODEM:send: block 246
    DEBUG:xmodem.XMODEM:send: block 247
    DEBUG:xmodem.XMODEM:send: block 248
    DEBUG:xmodem.XMODEM:send: block 249
    DEBUG:xmodem.XMODEM:send: block 250
    DEBUG:xmodem.XMODEM:send: block 251
    DEBUG:xmodem.XMODEM:send: block 252
    DEBUG:xmodem.XMODEM:send: block 253
    DEBUG:xmodem.XMODEM:send: block 254
    DEBUG:xmodem.XMODEM:send: block 255
    DEBUG:xmodem.XMODEM:send: block 0
    DEBUG:xmodem.XMODEM:send: block 1
    DEBUG:xmodem.XMODEM:send: block 2
    DEBUG:xmodem.XMODEM:send: block 3
    DEBUG:xmodem.XMODEM:send: block 4
    DEBUG:xmodem.XMODEM:send: block 5
    DEBUG:xmodem.XMODEM:send: block 6
    DEBUG:xmodem.XMODEM:send: block 7
    DEBUG:xmodem.XMODEM:send: block 8
    DEBUG:xmodem.XMODEM:send: block 9
    DEBUG:xmodem.XMODEM:send: block 10
    DEBUG:xmodem.XMODEM:send: block 11
    DEBUG:xmodem.XMODEM:send: block 12
    DEBUG:xmodem.XMODEM:send: block 13
    DEBUG:xmodem.XMODEM:send: block 14
    DEBUG:xmodem.XMODEM:send: block 15
    DEBUG:xmodem.XMODEM:send: block 16
    DEBUG:xmodem.XMODEM:send: block 17
    DEBUG:xmodem.XMODEM:send: block 18
    DEBUG:xmodem.XMODEM:send: block 19
    DEBUG:xmodem.XMODEM:send: block 20
    DEBUG:xmodem.XMODEM:send: block 21
    DEBUG:xmodem.XMODEM:send: block 22
    DEBUG:xmodem.XMODEM:send: block 23
    DEBUG:xmodem.XMODEM:send: block 24
    DEBUG:xmodem.XMODEM:send: block 25
    DEBUG:xmodem.XMODEM:send: block 26
    DEBUG:xmodem.XMODEM:send: block 27
    DEBUG:xmodem.XMODEM:send: block 28
    DEBUG:xmodem.XMODEM:send: block 29
    DEBUG:xmodem.XMODEM:send: block 30
    DEBUG:xmodem.XMODEM:send: block 31
    DEBUG:xmodem.XMODEM:send: block 32
    DEBUG:xmodem.XMODEM:send: block 33
    DEBUG:xmodem.XMODEM:send: block 34
    DEBUG:xmodem.XMODEM:send: block 35
    DEBUG:xmodem.XMODEM:send: block 36
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'0' for block 37
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'2' for block 37
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'0' for block 37
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'0' for block 37
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'0' for block 37
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'0' for block 37
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'0' for block 37
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'0' for block 37
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'0' for block 37
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'1' for block 37
    DEBUG:xmodem.XMODEM:send: block 37
    ERROR:xmodem.XMODEM:send error: expected ACK; got b'1' for block 37
    ERROR:xmodem.XMODEM:send error: NAK received 11 times, aborting.
    
    [ERROR] XMODEM send failed, no response OR incorrect response from EVM OR cancelled by user,
    Power cycle EVM and run this script again !!!

  • It looks the script is able to send the blocks but after sometime the board resets. Please note, this behaviour might be because of an Errata i2371 associated with the UART boot. You can find information on Errata i2371 here: https://www.ti.com/lit/er/sprz457h/sprz457h.pdf

    Have you tried the flashing procedure for multiple PORs and observe the same issue?

  • So how am I supposed to use this eval kit at all to run the SDK examples?
    If the first step in running examples is updating this flash and I can't update the flash due to silicon errata.
    This is unacceptable and the eval kit should be refunded.
    Or resend me one that actually works free of charge.

  • After getting schematic and hitting SW4 to warm reset the board, I got one to pass finally.
    It took several tries but one succeeded. Thanks for the POR suggestion.

    DEBUG:xmodem.XMODEM:send: block 245
    DEBUG:xmodem.XMODEM:send: block 246
    DEBUG:xmodem.XMODEM:send: block 247
    DEBUG:xmodem.XMODEM:send: block 248
    DEBUG:xmodem.XMODEM:send: block 249
    DEBUG:xmodem.XMODEM:send: block 250
    DEBUG:xmodem.XMODEM:send: block 251
    DEBUG:xmodem.XMODEM:send: block 252
    DEBUG:xmodem.XMODEM:send: block 253
    DEBUG:xmodem.XMODEM:send: block 254
    DEBUG:xmodem.XMODEM:send: block 255
    DEBUG:xmodem.XMODEM:send: block 0
    DEBUG:xmodem.XMODEM:send: block 1
    DEBUG:xmodem.XMODEM:send: block 2
    DEBUG:xmodem.XMODEM:send: block 3
    DEBUG:xmodem.XMODEM:send: block 4
    DEBUG:xmodem.XMODEM:send: block 5
    DEBUG:xmodem.XMODEM:send: block 6
    DEBUG:xmodem.XMODEM:send: block 7
    DEBUG:xmodem.XMODEM:send: block 8
    DEBUG:xmodem.XMODEM:send: block 9
    DEBUG:xmodem.XMODEM:send: block 10
    DEBUG:xmodem.XMODEM:send: at EOF
    DEBUG:xmodem.XMODEM:sending EOT, awaiting ACK
    INFO:xmodem.XMODEM:Transmission successful (ACK received).
    DEBUG:xmodem.XMODEM:recv: SOH
    DEBUG:xmodem.XMODEM:recv: data block 1
    INFO:xmodem.XMODEM:Transmission complete, 128 bytes
    Sent sbl_prebuilt/am243x-evm/sbl_null.release.hs_fs.tiimage of size 271805 bytes in 28.97s.
    [STATUS] SUCCESS !!!

    All commands from config file are executed !!!

  • After switching to QSPI mode, I see this:

    Starting NULL Bootloader ... 
    
    DMSC Firmware Version 9.0.7--v09.00.07 (Kool Koala)
    DMSC Firmware revision 0x9
    DMSC ABI revision 3.1
    
    INFO: Bootloader_runCpu:155: CPU r5f1-0  is initialized to 800000000 Hz !!!
    INFO: Bootloader_runCpu:155: CPU r5f1-1 is initialized to 800000000 Hz !!!
    INFO: Bootloader_runCpu:155: CPU m4f0-0 is initialized to 400000000 Hz !!!
    INFO: Bootloader_loadSelfCpu:207: CPU r5f0-0 is initialized to 800000000 Hz !!!
    INFO: Bootloader_loadSelfCpu:207: CPU r5f0-1 is initialized to 800000000 Hz !!!
    INFO: Bootloader_runSelfCpu:217: All done, reseting self ...
    


    Is this the correct DSMC to run the examples now?

  • I'm asking if this is right because it doesn't match the version here in the EVM setup guide:
    software-dl.ti.com/.../EVM_SETUP_PAGE.html

  • Hi Daryl,

    Since you are using the SDK v09_00_00_35, that SBL NULL output is correct. That output means the SoC has been initialized successfully and you can now load/run the examples via CCS.

    On another note, since you are using TI EVM, you can also try the DFU & JTAG flashing. I personally recommend DFU since it requires minimal interaction and is faster also.

    https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/TOOLS_FLASH.html#TOOLS_FLASH_DFU_UNIFLASH

    Regards,

    Prashant

  • Thanks for your help resolving issue and clarification on SBL build. Much appreciated.