从qspi启动linux时间,Zynq-Linux移植学习笔记(二十三)——QSPI速度配置
默認情況下QSPI拷貝文件到DDR中需要時間很長,15M左右大小的bin文件約30s左右。在某些產品中無法滿足需求。
經排查發現u-boot代碼中有對速度進行配置的地方,位于zynq-common.h中。
默認值為30000000,也就是30M,而QSPI主頻最多可達到100M,所以應該可以通過修改該值提升QSPI讀寫速度。
但是從30M提升到50M后發現速度依然不變,懷疑代碼中根本沒有配置該值,于是對u-boot代碼進行了檢查。
排查發現在u-boot在/common/cmd_sf.c中用到了速度配置,函數如下:
static int do_spi_flash_probe(int argc,char * const argv[])
{
unsignedint bus = CONFIG_SF_DEFAULT_BUS;
unsignedint cs = CONFIG_SF_DEFAULT_CS;
unsigned int speed =CONFIG_SF_DEFAULT_SPEED;
unsigned int mode =CONFIG_SF_DEFAULT_MODE;
char*endp;
structspi_flash *new;
if (argc >= 2) {
cs = simple_strtoul(argv[1], &endp, 0);
if (*argv[1] == 0 || (*endp != 0 && *endp!= ':'))
return -1;
if (*endp == ':') {
if (endp[1] == 0)
return -1;
bus = cs;
cs = simple_strtoul(endp + 1, &endp,0);
if (*endp != 0)
return -1;
}
}
if (argc >= 3) {
speed = simple_strtoul(argv[2], &endp, 0);
if (*argv[2] == 0 || *endp != 0)
return -1;
}
if (argc >= 4) {
mode = simple_strtoul(argv[3], &endp, 16);
if (*argv[3] == 0 || *endp != 0)
return -1;
}
new = spi_flash_probe(bus, cs,speed, mode);
if(!new) {
printf("Failedto initialize SPI flash at %u:%u\n", bus, cs);
return1;
}
if(flash)
spi_flash_free(flash);
flash= new;
return0;
}
函數中的speed和mode決定了QSPI的訪問速度和模式。打樁發現speed和mode一開始是被正確賦值的,但卻在函數中被修改為了0,導致提升CONFIG_SF_DEFAULT_SPEED時speed值并沒有改變。錯誤原因在于傳入參數argv[]均為0
而argv[]參數應該在U_BOOT_CMD中進行配置,通常情況下用戶不會主動去修改:
U_BOOT_CMD(
sf, 5, 1, do_spi_flash,
"SPIflash sub-system",
"probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus\n"
" and chip select\n"
"sfread addr offset len - read `len' bytesstarting at\n"
" `offset' to memory at `addr'\n"
"sfwrite addr offset len - write `len' bytesfrom memory\n"
" at `addr'to flash at `offset'\n"
"sferase offset [+]len - erase`len' bytes from `offset'\n"
" `+len' round up `len' to block size\n"
"sfupdate addr offset len - erase andwrite `len' bytes from memory\n"
" at `addr' to flash at `offset'"
SF_TEST_HELP
);
最簡單的解決方法是將下面一段代碼進行注釋
static int do_spi_flash_probe(int argc,char * const argv[])
{
unsignedint bus = CONFIG_SF_DEFAULT_BUS;
unsignedint cs = CONFIG_SF_DEFAULT_CS;
unsignedint speed = CONFIG_SF_DEFAULT_SPEED;
unsignedint mode = CONFIG_SF_DEFAULT_MODE;
char*endp;
structspi_flash *new;
/*
if (argc >= 2) {
cs = simple_strtoul(argv[1], &endp, 0);
if (*argv[1] == 0 || (*endp != 0 && *endp!= ':'))
return -1;
if (*endp == ':') {
if (endp[1] == 0)
return -1;
bus = cs;
cs = simple_strtoul(endp + 1, &endp,0);
if (*endp != 0)
return -1;
}
}
if (argc >= 3) {
speed = simple_strtoul(argv[2], &endp, 0);
if (*argv[2] == 0 || *endp != 0)
return -1;
}
if (argc >= 4) {
mode = simple_strtoul(argv[3], &endp, 16);
if (*argv[3] == 0 || *endp != 0)
return -1;
}
*/
new= spi_flash_probe(bus, cs, speed, mode);
if(!new) {
printf("Failedto initialize SPI flash at %u:%u\n", bus, cs);
return1;
}
if(flash)
spi_flash_free(flash);
flash= new;
return0;
}
修改完成后QSPI到DDR內存的拷貝時間可以忽略不計。
需要注意的是如果拷貝速度太快可能會出錯,所以設置speed在30M-50M之間就能滿足要求了,不需要配置到100M。
文章來源:Felven的博客
注:本文為授權轉載文章,如需轉載請聯系作者授權
總結
以上是生活随笔為你收集整理的从qspi启动linux时间,Zynq-Linux移植学习笔记(二十三)——QSPI速度配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux停止mysql后又自己启动,L
- 下一篇: linux 管道非阻塞,在Linux中管