这里率先发表一下自己最近入坑的感想吧:
1.lichee 派的文档和资料组织比较混乱,新手慎入
2.目前主线的uboot尚未增加对spi-flash的支持
3.不知道我买的是否是一家,总感觉硬件不是特别稳定,经常无法启动
进入正题:
开发环境:
ubuntu 16.04 - 18.04,不推荐14.04,因为GCC版本太老(apt-get install 的),如果更新不了的话,自己又要折腾一番。
机器:实体机 (我试过虚拟机,V3S FEL模式进入后不知道为什么转到虚拟机上面时,总是会丢失连接。) 实体机也不贵,300元全套带回家
板子:lichee zero
电源(important):推荐使用淘宝上的降压模块,然后接入12V电源后降到5V,这样供电能力比电脑的USB会强一些
flash:w25q128
至于编译过程,坑网已经有大佬写了,我就不赘述了。注意几点:
1.拉spi分支的uboot
2.kernel 的相关配置需要修改
3.jffs2 擦除块为8K, 而kernel的spi-nor.c中,w25q128默认是开启4K擦除的,需要将其去除
第一点在首页的帖子就有,我不重复了
第二点,kernel中开启spi-flash支持,文件arch\arm\configs\licheepi_zero_defconfig:
CONFIG_MTD=y
CONFIG_MTD_M25P80=y
CONFIG_MTD_SPI_NOR=y
这个默认是打开的
其次要开启jffs2文件系统支持(如果你用的是jffs2文件系统的话):
CONFIG_JFFS2_FS=y
CONFIG_JFFS2_FS_DEBUG=0
CONFIG_JFFS2_FS_WRITEBUFFER=y
CONFIG_JFFS2_ZLIB=y
dts中增加相关节点:
arch\arm\boot\dts\sun8i-v3s-licheepi-zero.dts
&spi0 {
status ="okay";
w25q128:w25q128@0 {
compatible = "jedec,spi-nor";
reg = <0x0>;
spi-max-frequency = <50000000>;
#address-cells = <1>;
#size-cells = <1>;
};
};
以上配置好后,可以执行 make ARCH=arm licheepi_zero_defconfig
会在当前目录下生成.config文件,这个.config文件可以留有以后备用,省得clean过后每次都去配置,也可以合并进入licheepi_zero_defconfig文件中(推荐)
接着就是要修改drivers\mtd\spi-nor\spi-nor.c 中,你对应的flash的信息,将SECT_4K去除:
{ "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, 0) }, //c37r changed SECT_4K =》 0
因为如果开启此flag,会导致jffs2启动不成功。
如上,即可愉快的进行编译啦,至于如何制作系统,请参考:
http://zero.lichee.pro/%E7%B3%BB%E7%BB%9F%E5%BC%80%E5%8F%91/SPI_flash_build.html
按照这个来就可以了
如有错误,欢迎指正。
不求连城璧,但求杀人剑。超越自己,成就他人
离线
USB电流不够呢
离线
楼主试过w25q256吗?
离线
@晕哥
晕哥,请问下以下这个结构体是在哪个文件的呢?因为我现在使用的flash型号不在上面显示,需要修改下这个文件:
static const struct spi_device_id m25p_ids[] = {
/*
* Allow non-DT platform devices to bind to the "spi-nor" modalias, and
* hack around the fact that the SPI core does not provide uevent
* matching for .of_match_table
*/
{"spi-nor"},
/*
* Entries not used in DTs that should be safe to drop after replacing
* them with "spi-nor" in platform data.
*/
{"s25sl064a"}, {"w25x16"}, {"m25p10"}, {"m25px64"},
/*
* Entries that were used in DTs without "jedec,spi-nor" fallback and
* should be kept for backward compatibility.
*/
{"at25df321a"}, {"at25df641"}, {"at26df081a"},
{"mx25l4005a"}, {"mx25l1606e"}, {"mx25l6405d"}, {"mx25l12805d"},
{"mx25l25635e"},{"mx66l51235l"},
{"n25q064"}, {"n25q128a11"}, {"n25q128a13"}, {"n25q512a"},
{"s25fl256s1"}, {"s25fl512s"}, {"s25sl12801"}, {"s25fl008k"},
{"s25fl064k"},
{"sst25vf040b"},{"sst25vf016b"},{"sst25vf032b"},{"sst25wf040"},
{"m25p40"}, {"m25p80"}, {"m25p16"}, {"m25p32"},
{"m25p64"}, {"m25p128"},
{"w25x80"}, {"w25x32"}, {"w25q32"}, {"w25q32dw"},
{"w25q80bl"}, {"w25q128"}, {"w25q256"},
/* Flashes that can't be detected using JEDEC */
{"m25p05-nonjedec"}, {"m25p10-nonjedec"}, {"m25p20-nonjedec"},
{"m25p40-nonjedec"}, {"m25p80-nonjedec"}, {"m25p16-nonjedec"},
{"m25p32-nonjedec"}, {"m25p64-nonjedec"}, {"m25p128-nonjedec"},
/* Everspin MRAMs (non-JEDEC) */
{ "mr25h256" }, /* 256 Kib, 40 MHz */
{ "mr25h10" }, /* 1 Mib, 40 MHz */
{ "mr25h40" }, /* 4 Mib, 40 MHz */
{ },
};
离线
@晕哥
晕哥,我的flash型号是:MX25L25645
离线
其实很简单呀,这个问题。
dts:
&spi0 {
status = "okay";
w25q64jv{
compatible = "jedec,spi-nor";
status = "okay";
reg = <0x0>;
spi-max-frequency = <50000000>;
#address-cells = <1>;
#size-cells = <1>;
};
};
要注意的是对应好spi-nor-ids.c里的型号,也就是w25q64jv。最开始我使用w25q64后,和楼主一样出错,一样是id=-19错误,改个名后就好了:
{
INFO("w25q64jv", 0xef7017, 0, 64 * 1024, 128,
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
},
结果:
U-Boot 2022.10 (Dec 10 2024 - 00:33:45 -0800) Allwinner Technology
CPU: Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM: 64 MiB
Core: 34 devices, 16 uclasses, devicetree: separate
WDT: Not starting watchdog@1c20ca0
MMC: mmc@1c0f000: 0
Loading Environment from SPIFlash... ******sun4i_spi_probe() ok******spi@1c68000************spi_find_chip_select spi_get_ops err*********************
SF: Detected w25q64cv with page size 256 Bytes, erase size 4 KiB, total 8 MiB
*** Warning - bad CRC, using default environment
Loading Environment from FAT... Card did not respond to voltage select! : -110
** Bad device specification mmc 0 **
In: serial@1c28000
Out: serial@1c28000
Err: serial@1c28000
Net: No ethernet found.
Hit any key to stop autoboot: 0
=> sf probe 0
******spi@1c68000************spi_find_chip_select spi_get_ops err*********************
******spi@1c68000************spi_find_chip_select spi_get_ops err*********************
SF: Detected w25q64cv with page size 256 Bytes, erase size 4 KiB, total 8 MiB
=>
离线