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.

TDA4VM: Some problems encountered during debugging SPL startup.

Part Number: TDA4VM

Tool/software:

Hi,

I want to figure out how we load tispl.bin and u-boot.img during SPL startup. For this, I read the following post:

TDA4VM: Where is the R5 SPL source code - Processors forum - Processors - TI E2E support forums

The following is the log of Linux serial port based on SPL startup:

41330.log.txt

I found the functions board_init_r and spl_Lad_Simple_fit. The function boot_from_devices is called in the function board.init_r, where the log is printed:Trying to boot from.....

Firstly, I added a log in the boot_from_devices function:

After the make all and make install commands are compiled and started at the board end, I can't find the logs I added. They are the same as the logs when I started earlier. What is the question?

Regards,

Yang

  • Hi Yang,

    All the compiled binaries are under:

    $SDK/board-support/ti-u-boot-2024.04+git/build/a72/tispl.bin
    $SDK/board-support/ti-u-boot-2024.04+git/build/a72/u-boot.img

    $SDK/board-support/ti-u-boot-2024.04+git/build/r5/tiboot3.bin

    Have you used the images from the above location?

    - Keerthy

  • Hi,

    Thank you for your answer,
    Can you help me investigate how the spi_flash-read() function reads flash data?
    I added some code but did not print out the value in 0x680000:

            uint8_t *buf;
    	buf = malloc(0x40000);
    	if (!buf) {
    		printf("!!!!!!!!!!!!!!!!!!!!!!    F-Data:Unable to allocate buffer\n");
    	}
    
    	spi_flash_read(flash,0x680000,0x40000,buf);
    	printf("!!!!!!!!!  Data read from SPI flash:\n");
    	for (int i = 0; i < 20; i++) {
    		printf("%02X ", buf[i]);
    	}
    

    Is there a problem with the way I use spi_flash-read()?

    Regards,

    Yang

     

  • Yang,

    Are you getting any other prints that you have added?

    The U-Boot SPL also give time stamp of the image that runs, you can double confirm if that's the image that you built. 

    Regards,

    Keerthy 

  • Hi,
    Yes, the version that runs on the board is the same as the one I compiled, because the following log has been successfully printed out:

    printf("!!!!!!!!! Data read from SPI flash:\n");

    But when I printed the buf, there seemed to be no data, and all 20 printed data were 00.
    Of course, I have already written some values in 0x680000.

    Regards,

    Yang

  • Hello Yang,

    Can you share the debug prints that you have added?

    Best Regards,

    Keerthy 

  • Here is my attempt to use the function spi_flash_read() in two different ways.
    Method One:

    static int spl_spi_load_image(struct spl_image_info *spl_image,
    			      struct spl_boot_device *bootdev)
    {
    	int err = 0;
    	unsigned int payload_offs;
    	struct spi_flash *flash;
    	unsigned int sf_bus = spl_spi_boot_bus();
    	unsigned int sf_cs = spl_spi_boot_cs();
    	struct spl_load_info load;
    
    	/*
    	 * Load U-Boot image from SPI flash into RAM
    	 * In DM mode: defaults speed and mode will be
    	 * taken from DT when available
    	 */
    	flash = spi_flash_probe(sf_bus, sf_cs,
    				CONFIG_SF_DEFAULT_SPEED,
    				CONFIG_SF_DEFAULT_MODE);
    	if (!flash) {
    		puts("SPI probe failed.\n");
    		return -ENODEV;
    	}
    
    	load.priv = flash;
    	spl_set_bl_len(&load, 1);
    	load.read = spl_spi_fit_read;
    
    #if CONFIG_IS_ENABLED(OS_BOOT)
    	if (spl_start_uboot()) {
    		unsigned int a = CFG_SYS_SPI_KERNEL_OFFS;
    		printf("spl_spi_load_image satrt,   !!!!!spl_image->load_addr: %lx  a: %u\n",spl_image->load_addr,a);
    		int err = spl_load(spl_image, bootdev, &load, 0,
    				   CFG_SYS_SPI_KERNEL_OFFS);
    
    		if (!err)
    			/* Read device tree. */
    			return spi_flash_read(flash, CFG_SYS_SPI_ARGS_OFFS,
    					      CFG_SYS_SPI_ARGS_SIZE,
    					      (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR);
    	}
    #endif
    
    	payload_offs = spl_spi_get_uboot_offs(flash);
    	if (CONFIG_IS_ENABLED(OF_REAL)) {
    		payload_offs = ofnode_conf_read_int("u-boot,spl-payload-offset",
    						    payload_offs);
    	}
    
    	if(0x280000 == payload_offs)
    	{
    		uint8_t *buf;
    		buf = malloc(0x40000);
    		if (!buf) {
    			printf("!!!!!!!!!!!!!!!!!!!!!!    F-Data:Unable to allocate buffer\n");
    		}
    
    		spi_flash_read(flash,0x680000,0x40000,buf);
    		printf("!!!!!!!!!  Data read from SPI flash:\n");
    		for (int i = 0; i < 20; i++) {
    			printf("%02X ", buf[i]);
    		}
    		printf("*************************************************\n");
    
    		printf("!!!!!!!!!  Data read from SPI flash1111111: ");
    		for (int i = 0; i < 20; i++) {
    			if (buf[i] >= 32 && buf[i] <= 126) 
    			{  
    				printf("%c", buf[i]);
    			} else {
    				printf(".");
    			}
    		}
    		printf("*************************************************\n");
    	}
    
    	printf("spl_spi_load_image satrt,   !!!!!spl_image->load_addr: %lx  payload_offs: %u\n",spl_image->load_addr,payload_offs);
    	err = spl_load(spl_image, bootdev, &load, 0, payload_offs);
    	if (IS_ENABLED(CONFIG_SPI_FLASH_SOFT_RESET))
    		err = spi_nor_remove(flash);
    	return err;
    }
    


    Method Two:

    static inline int _spl_load(struct spl_image_info *spl_image,
    const struct spl_boot_device *bootdev,
    struct spl_load_info *info, size_t size,
    size_t offset)
    {
    struct legacy_img_hdr *header =
    spl_get_load_buffer(-sizeof(*header), sizeof(*header));
    ulong base_offset, image_offset, overhead;
    int read, ret;

    printf(SPL_TPL_PROMPT "_spl_load start,!!!!!!!!!!!!!!!!!!! \n");
    printf("_spl_load satrt, !!!!!spl_image->boot_device: %u offset: %u\n",spl_image->boot_device,offset);
    read = info->read(info, offset, ALIGN(sizeof(*header),
    spl_get_bl_len(info)), header);
    if (read < sizeof(*header))
    return -EIO;

    if(0x280000 == offset)
    {
    uint8_t *buf;
    buf = malloc(0x40);
    if (!buf) {
    printf("_spl_load!!!!!!!!!!!!!!!!!!!!!! F-Data:Unable to allocate buffer\n");
    }

    read = info->read(info, 0x680000, 0x40, buf);

    //spi_flash_read(flash,0x680000,0x40,buf);
    printf("_spl_load!!!!!!!!! Data read from SPI flash:\n");
    for (int i = 0; i < 20; i++) {
    printf("%02X ", buf[i]);
    }
    printf("_spl_load*************************************************\n");

    printf("_spl_load!!!!!!!!! Data read from SPI flash1111111: ");
    for (int i = 0; i < 20; i++) {
    if (buf[i] >= 32 && buf[i] <= 126)
    {
    printf("%c", buf[i]);
    } else {
    printf(".");
    }
    }
    printf("_spl_load*************************************************\n");
    }

    if (image_get_magic(header) == FDT_MAGIC) {
    if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL)) {
    void *buf;

    /*
    * In order to support verifying images in the FIT, we
    * need to load the whole FIT into memory. Try and
    * guess how much we need to load by using the total
    * size. This will fail for FITs with external data,
    * but there's not much we can do about that.
    */
    if (!size)
    size = round_up(fdt_totalsize(header), 4);
    buf = map_sysmem(CONFIG_SYS_LOAD_ADDR, size);
    printf(SPL_TPL_PROMPT "FDT_MAGIC,!!!!!!!!!!!!!!!!!!! \n");
    read = info->read(info, offset,
    ALIGN(size, spl_get_bl_len(info)),
    buf);
    if (read < size)
    return -EIO;

    return spl_parse_image_header(spl_image, bootdev, buf);
    }

    if (IS_ENABLED(CONFIG_SPL_LOAD_FIT))
    {
    printf(" CONFIG_SPL_LOAD_FIT_FULL Load Address: 0x%08X\n", header->ih_load);
    printf(" CONFIG_SPL_LOAD_FIT_FULL Entry Point: 0x%08X\n", header->ih_ep);
    return spl_load_simple_fit(spl_image, info, offset,
    header);
    }
    }

    if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) &&
    valid_container_hdr((void *)header))
    return spl_load_imx_container(spl_image, info, offset);

    if (IS_ENABLED(CONFIG_SPL_LZMA) &&
    image_get_magic(header) == IH_MAGIC &&
    image_get_comp(header) == IH_COMP_LZMA) {
    spl_image->flags |= SPL_COPY_PAYLOAD_ONLY;
    ret = spl_parse_image_header(spl_image, bootdev, header);
    if (ret)
    return ret;

    printf(" CONFIG_SPL_LZMA Load Address: 0x%X\n", header->ih_load);
    printf(" CONFIG_SPL_LZMA Entry Point: 0x%X\n", header->ih_ep);

    return spl_load_legacy_lzma(spl_image, info, offset);
    }

    printf(" 111 Load Address: 0x%X\n", header->ih_load);
    printf(" 111 Entry Point: 0x%X\n", header->ih_ep);
    ret = spl_parse_image_header(spl_image, bootdev, header);
    if (ret)
    return ret;

    base_offset = spl_image->offset;
    /* Only NOR sets this flag. */
    if (IS_ENABLED(CONFIG_SPL_NOR_SUPPORT) &&
    spl_image->flags & SPL_COPY_PAYLOAD_ONLY)
    base_offset += sizeof(*header);
    image_offset = ALIGN_DOWN(base_offset, spl_get_bl_len(info));
    overhead = base_offset - image_offset;
    size = ALIGN(spl_image->size + overhead, spl_get_bl_len(info));

    printf(SPL_TPL_PROMPT "_spl_load,!!!!!!!!!!!!!!!!!!! addr: %lx \n",(spl_image->load_addr - overhead));
    read = info->read(info, offset + image_offset, size,
    map_sysmem(spl_image->load_addr - overhead, size));
    return read < spl_image->size ? -EIO : 0;
    }

    --------------------------------------------------------------

    Could you please help me investigate this? Thank you!

    Regards,

    yang
  • Hello,

    The engineer responsible is currently out of office until next week. Please expect a delay in response.

    Warm regards,

    Christina

  • Hi,
    May I ask when you can reply? Do you have a specific time? Please try to reply as soon as possible. Thank you.

    Regards,

    Yang

  • Hello,

    Keerthy is out of the office but will return on April 21st, so please expect a delayed response.

    Thanks.

  • Hello Yang,

    It is better to follow the U-Boot source file:

    cmd/sf.c

    This is how U-Boot sf commands are implemented.

    Example on my board(A different variant of TDA4 & not the same one as yours):

    sf probe
    SF: Detected s28hs512t with page size 256 Bytes, erase size 256 KiB, total 64 MiB

    Find a non-written block of DDR:

    Ex:

    md 0x81000000
    81000000: 00000000 00000000 00000000 00000000  ................
    81000010: 00000000 00000000 00000000 00000000  ................
    81000020: 00000000 00000000 00000000 00000000  ................
    81000030: 00000000 00000000 00000000 00000000  ................
    81000040: 00000000 00000000 00000000 00000000  ................
    81000050: 00000000 00000000 00000000 00000000  ................
    81000060: 00000000 00000000 00000000 00000000  ................
    81000070: 00000000 00000000 00000000 00000000  ................
    81000080: 00000000 00000000 00000000 00000000  ................
    81000090: 00000000 00000000 00000000 00000000  ................
    810000a0: 00000000 00000000 00000000 00000000  ................
    810000b0: 00000000 00000000 00000000 00000000  ................
    810000c0: 00000000 00000000 00000000 00000000  ................
    810000d0: 00000000 00000000 00000000 00000000  ................
    810000e0: 00000000 00000000 00000000 00000000  ................
    810000f0: 00000000 00000000 00000000 00000000  ................
    

    So 0x81000000 is all 0s and not having any legitimate values written.

    Now I use sf read to read data from flash to 0x81000000

    sf read 0x81000000 0x0 0x10000
    device 0 offset 0x0, size 0x10000
    SF: 65536 bytes @ 0x0 Read: OK

    Now I verify the DDR contents that were written using flash read:

     md 0x81000000                 
    81000000: e3078230 cb058230 010203a0 15140202  0...0...........
    81000010: b10bc732 8d96d810 77e67c06 4880dc3b  2........|.w;..H
    81000020: 300b775f 2a09060d f7864886 0d01010d  _w.0...*.H......
    81000030: 81300005 300b3190 55030609 02130604  ..0..1.0...U....
    81000040: 0b315355 03060930 0c080455 31435302  US1.0...U....SC1
    81000050: 060f3011 07045503 654e080c 6f592077  .0...U....New Yo
    81000060: 21316b72 03061f30 0c0a0455 78655418  rk1!0...U....Tex
    81000070: 49207361 7274736e 6e656d75 2c2e7374  as Instruments.,
    81000080: 636e4920 300c312e 5503060a 030c0b04   Inc.1.0...U....
    81000090: 31505344 060d300f 03045503 6c41060c  DSP1.0...U....Al
    810000a0: 74726562 1d301f31 862a0906 0df78648  bert1.0...*.H...
    810000b0: 16010901 626c4110 40747265 742e7467  .....Albert@gt.t
    810000c0: 6f632e69 171e306d 3134320d 31323131  i.com0...2411121
    810000d0: 32363435 0d175a32 32313432 35313231  54622Z..24121215
    810000e0: 32323634 9081305a 09300b31 04550306  4622Z0..1.0...U.
    810000f0: 55021306 300b3153 55030609 020c0804  ...US1.0...U....
    => 
    

    I see contents of flash.

    So better to refer:

    https://github.com/u-boot/u-boot/blob/master/cmd/sf.c#L276

    Best Regards,
    Keerthy