UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor
178 Views
Registered: ‎05-16-2018

AXI Quad SPI or code cannot send more than 65535 bytes

Jump to solution

I am using the AXI Quad SPI IP to write an ELF file to SPI flash. My bootloader code will boot files just fine using the IP, but I cannot seem to write more than 0xFFFF bytes to the flash. I thought it may have been the FIFO set to 16bits in the FPGA configuration, so I changed that to 256bits, but that did nothing.

spi_settings.PNG

I am using trenz Electronics spi_flash.c code to write to the spi.

I inserted a print statement into spi_flash_write() and printed out every byte that is bein being written out in the XSpi_Transfer() function and I saw every byte enter the function, it's just not getting to the flash.

Here is a screenshot of the hello.elf file (what it should look like on the flash):

hello_elf.png

and here is the contents of the flash that I read back:

spi_readback.png

You can see that the file is cut off at offset 0x800FFFF

Here is how I am doing a write using a simple hello_world.elf file:

int total_byte_count = 112704 //number of bytes the hello.elf file consists of
u8* flash; //pointer to the hello.elf data bytes

...

spi_flash_write(0x00800000, total_byte_count, flash); 

I'll connect an ILA to the SPI IP's AXI port to check if all the bytes are being sent over AXI to eliminate the software as a potential problem spot.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
121 Views
Registered: ‎05-01-2019

Re: AXI Quad SPI or code cannot send more than 65535 bytes

Jump to solution

I don't think the spi_flash_write function at https://github.com/Trenz-Electronic/elf-bootloader/blob/master/spi_flash.c is erasing any sectors but the first one. cur_addr is never being incremented for the sector erase boundary check. 

while(cnt){
	if((cur_addr & 0xFFFF) == 0x0000){
		spi_flash_sector_erase(cur_addr >> 16);
	}
	page_rem = PAGE_SIZE - (cur_addr & 0xFF);
	block_size = (cnt > page_rem) ? page_rem : cnt;
	spi_flash_write_buf((cur_addr+pointer), block_size, (buf+pointer));
	pointer += block_size;
	cnt -= block_size;
}

You'll need to fix that if statement and erase to something like

if((cur_addr+pointer) & 0xFFFF) == 0x0000){ 
	spi_flash_sector_erase((cur_addr+pointer) >> 16); 
}

 

View solution in original post

1 Reply
Highlighted
122 Views
Registered: ‎05-01-2019

Re: AXI Quad SPI or code cannot send more than 65535 bytes

Jump to solution

I don't think the spi_flash_write function at https://github.com/Trenz-Electronic/elf-bootloader/blob/master/spi_flash.c is erasing any sectors but the first one. cur_addr is never being incremented for the sector erase boundary check. 

while(cnt){
	if((cur_addr & 0xFFFF) == 0x0000){
		spi_flash_sector_erase(cur_addr >> 16);
	}
	page_rem = PAGE_SIZE - (cur_addr & 0xFF);
	block_size = (cnt > page_rem) ? page_rem : cnt;
	spi_flash_write_buf((cur_addr+pointer), block_size, (buf+pointer));
	pointer += block_size;
	cnt -= block_size;
}

You'll need to fix that if statement and erase to something like

if((cur_addr+pointer) & 0xFFFF) == 0x0000){ 
	spi_flash_sector_erase((cur_addr+pointer) >> 16); 
}

 

View solution in original post