f1c100s spi nand 128MB W25N01G 调试记录
f1c100s 128MB W25N01G spi nand调试记录
镜像使用说明
镜像位置images文件夹
uboot-with-spl-usb.bin FEL模式下使用的uboot镜像
uboot-with-spl-spinand.bin spi nand启动使用的uboot镜像
FEL模式下使用标准sunxi-fel执行如下命令
sunxi-fel uboot uboot-with-spl-usb.bin write 0x80000000 uboot-with-spl-spinand.bin
由于sunxi-fel直接写spi nand代码没有调试过,所以直接将uboot镜像传到内存后写入spi nand
执行完成,等待u-boot倒计时完后会自动将uboot-with-spl-spinand.bin写入spi nand中
FEL模式日志
U-Boot SPL 2018.01-g5a65529-dirty (Dec 17 2019 - 15:19:40)
DRAM: 64 MiB
Trying to boot from FELU-Boot 2018.01-g5a65529-dirty (Dec 17 2019 - 15:19:40 +0800) Allwinner TechnologyCPU: Allwinner F Series (SUNIV)
Model: Lichee Pi Nano
DRAM: 64 MiB
MMC: SUNXI SD/MMC: 0
SPI-NAND: W25N01GV is found size: 128MB.
read status2:0x18
internal ecc is on now turn off
write status2:0x8
read status2:0x8
*** Warning - bad CRC, using default environmentIn: serial@1c25000
Out: serial@1c25000
Err: serial@1c25000
Net: No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot: 0
SPI-NAND: W25N01GV is found size: 128MB.
read status2:0x18
internal ecc is on now turn off
write status2:0x8
read status2:0x8
SPI-NAND: 1310720 bytes @ 0x0 Updated: OK
SPI-NAND: W25N01GV is found size: 128MB.
read status2:0x18
internal ecc is on now turn off
write status2:0x8
read status2:0x8
SPI-NAND: 2490368 bytes @ 0x80000 Read: OK
Unknown command 'sf' - try 'help'
Wrong Image Format for bootm command
ERROR: can't get kernel image!
=>
因为没有内核所以最后会报错,不用管,烧录完成后spi nand启动日志如下
U-Boot SPL 2018.01-g5a65529-dirty (Dec 17 2019 - 15:20:01)
DRAM: 64 MiB
Trying to boot from sunxi SPIU-Boot 2018.01-g5a65529-dirty (Dec 17 2019 - 15:20:01 +0800) Allwinner TechnologyCPU: Allwinner F Series (SUNIV)
Model: Lichee Pi Nano
DRAM: 64 MiB
MMC: SUNXI SD/MMC: 0
SPI-NAND: W25N01GV is found size: 128MB.
read status2:0x18
internal ecc is on now turn off
write status2:0x8
read status2:0x8
*** Warning - bad CRC, using default environmentIn: serial@1c25000
Out: serial@1c25000
Err: serial@1c25000
Net: No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot: 0
=>
源码编译
源码编译需要编译两次,分别生成FEL镜像和SPI NAND镜像
首先修改uboot源码下build.sh中交叉编译器
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- licheepi_nano_spinand_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j8
我的交叉编译工具已经加入到了系统环境变量
生成FEL镜像
修改uboot源码include/configs/sunxi-common.h
打开#define GZYS_USBBURN 1定义
#ifndef _SUNXI_COMMON_CONFIG_H
#define _SUNXI_COMMON_CONFIG_H#include <asm/arch/cpu.h>
#include <linux/stringify.h>
#define GZYS_USBBURN 1
#ifdef CONFIG_OLD_SUNXI_KERNEL_COMPAT
保存后在uboot源码根目录下执行./build.sh进行编译,最后输出信息如下
CC spl/drivers/mtd/spi/sunxi_spi_nand_spl.oCC spl/drivers/serial/serial.oCC spl/drivers/serial/serial_ns16550.oCC spl/drivers/serial/ns16550.oLD spl/disk/built-in.oLD spl/lib/built-in.oLD spl/drivers/serial/built-in.oLD spl/drivers/mmc/built-in.oLD spl/drivers/built-in.oLD spl/u-boot-splOBJCOPY spl/u-boot-spl-nodtb.binCOPY spl/u-boot-spl.binMKSUNXI spl/sunxi-spl.binBINMAN u-boot-sunxi-with-spl.binCFGCHK u-boot.cfg
please delete GZYS_USBBURN in include/configs/sunxi-common.h file and rebuild to create spi nand image
DONE
此时uboot源码根目录下会生成uboot-with-spl-usb.bin文件
生成SPI NAND镜像
修改uboot源码include/configs/sunxi-common.h
注释掉#define GZYS_USBBURN 1定义
#ifndef _SUNXI_COMMON_CONFIG_H
#define _SUNXI_COMMON_CONFIG_H#include <asm/arch/cpu.h>
#include <linux/stringify.h>
#define GZYS_USBBURN 1
#ifdef CONFIG_OLD_SUNXI_KERNEL_COMPAT
保存后在uboot源码根目录下执行./build.sh进行编译,最后输出信息如下
Copying block 23 to 46
1+0 records in
1+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 0.000163137 s, 6.3 MB/s
Copying block 24 to 48
1+0 records in
1+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 0.000174752 s, 5.9 MB/s
Copying block 25 to 50
1+0 records in
1+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 0.000165035 s, 6.2 MB/s
Appending u-boot
984+0 records in
984+0 records out
1007616 bytes (1.0 MB, 984 KiB) copied, 0.00353802 s, 285 MB/s
done
burn uboot-with-spl-spinand.bin to spi nand
cmd is sunxi-fel uboot uboot-with-spl-usb.bin write 0x80000000 uboot-with-spl-spinand.bin
DONE
此时uboot源码根目录下会生成uboot-with-spl-spinand.bin文件
调试中出现的问题及修改
uboot源码增加对w25n01g支持
diff --git a/drivers/mtd/spi-nand/spi-nand-base.c b/drivers/mtd/spi-nand/spi-nand-base.c
index 442a595..bee8a93 100755
--- a/drivers/mtd/spi-nand/spi-nand-base.c
+++ b/drivers/mtd/spi-nand/spi-nand-base.c
@@ -25,6 +25,8 @@ extern int spi_nand_issue_cmd(struct spi_nand_chip *chip, struct spi_nand_cmd *cint spi_nand_erase(struct spi_nand_chip *chip, uint64_t addr, uint64_t len);static struct spi_nand_flash spi_nand_table[] = {+ SPI_NAND_INFO("W25N01GV", 0xEF, 0xAA, 2048, 64, 64, 1024,
+ 1, 1, 0 | SPINAND_NEED_PLANE_SELECT),SPI_NAND_INFO("GD5F1GQ4UAYIG", 0xC8, 0xF1, 2048, 64, 64, 1024,1, 1, 0 | SPINAND_USED_GIGADEVICE),SPI_NAND_INFO("GD5F1GQ4UBYIG", 0xC8, 0xD1, 2048, 64, 64, 1024,
@@ -1844,6 +1846,22 @@ static void spi_nand_set_rd_wr_op(struct spi_nand_chip *chip)chip->write_cache_rdm_op = SPINAND_CMD_PROG_LOAD_RDM_DATA;}}
+//add by leijie for w25n01g turn off internal ecc
+static void w25n01_turn_off_iecc(struct spi_nand_chip *chip)
+{+ u8 buf[1];
+ spi_nand_read_reg(chip,0xb0,buf);
+ printf("read status2:0x%x\n",buf[0]);
+ if(buf[0] & 0x10) {//internal ecc
+ printf("internal ecc is on now turn off\n");
+ buf[0] = buf[0] & ~(1 << 4);
+ printf("write status2:0x%x\n",buf[0]);
+ spi_nand_write_reg(chip,0xb0,buf);
+ }
+ spi_nand_read_reg(chip,0xb0,buf);
+ printf("read status2:0x%x\n",buf[0]);
+ return;
+}/*** spi_nand_init - [Interface] Init SPI-NAND device driver
@@ -1879,8 +1897,9 @@ static int spi_nand_init(struct spi_slave *spi, struct spi_nand_chip **chip_ptr)return -ENODEV;ident_done:
- spi_nand_info("SPI-NAND: %s is found.\n", chip->name);
-
+ spi_nand_info("SPI-NAND: %s is found size: %dMB.\n", chip->name,chip->size/1024/1024);
+ if(id[0] == 0xef)
+ w25n01_turn_off_iecc(chip);// giga-device need re-config rd/wr optionsif( chip->options & SPINAND_USED_GIGADEVICE )spi_nand_set_rd_wr_op(chip);
主要增加了wn25n01内部ecc判断
20191226后面发现spi nand驱动中有对内部ecc进行判断 所以需要把增加的w25n01_turn_off_iecc函数删除,这里源码就不进行更新了
spi nand镜像脚本制作
参照
https://whycan.cn/t_1594.html
中的脚本
gen_sunxi_spinand_onlyboot_img.sh
制作了f1c100_uboot_spinand.sh
#!/bin/bashset -e
[ $# -eq 2 ] || {echo "SYNTAX: $0 <outputfile> <u-boot image>"echo "Given: $@"exit 1
}OUTPUT="$1"
UBOOT="$2"
PAGESIZE=2048
BLOCKSIZE=128TOOLCHECK=$(od --help | grep 'endia')
if [ "$TOOLCHECK" == "" ]; thenecho "od cmd is too old not support endia"exit -1
fi
# SPL-Size is an uint32 at 16 bytes offset contained in the SPL header
#uboot header offset head in include/configs/sunxi-common.h CONFIG_SYS_SPI_U_BOOT_OFFS so spl max size is CONFIG_SYS_SPI_U_BOOT_OFFS
#f1c100s modify CONFIG_SYS_SPI_U_BOOT_OFFS to 0xd000(52K)
SPLSIZE=$(od -An -t u4 -j16 -N4 "$UBOOT" | xargs)
printf "SPLSIZE:%d(0x%x)\n" $SPLSIZE $SPLSIZE
# The u-boot size is an uint32 at (0xd000 + 12) bytes offset uboot start offset 0xd000(52K)
UBOOTSIZE=$(od --endian=big -An -t u4 -j$((53248 + 12)) -N4 "$UBOOT" | xargs)
printf "UBOOTSIZE:%d(0x%x)\n" $UBOOTSIZE $UBOOTSIZE
ALIGNCHECK=$(($PAGESIZE%1024))
if [ "$ALIGNCHECK" -ne "0" ]; thenecho "Page-size is not 1k alignable and thus not supported by EGON"exit -1
fiKPAGESIZE=$(($PAGESIZE/1024))
SPLBLOCKS=25echo "Generating boot0 for boot part of max size 0x8000 SPLBLOCKS:$SPLBLOCKS"
dd if="/dev/zero" of="$OUTPUT" bs=1024 count=$((52 - $SPLBLOCKS))for splcopy in `seq 0 $SPLBLOCKS`;
doto=$(($splcopy*$KPAGESIZE))echo "Copying block $splcopy to $to" dd if="$UBOOT" of="$OUTPUT" bs=1024 count=1 seek=$to skip=$splcopy conv=notrunc
doneecho "Appending u-boot"
dd if="$UBOOT" of="$OUTPUT" bs=1024 seek=52 skip=52 conv=notrunc
sync
echo "done"
其中将页大小和块大小值固定,只传输出文件和输入文件名
由于f1c100s生成的spl镜像sunxi-spl.bin大小为固定值24576个字节,所以简化了脚本
内部brom spi nand启动必需1KB对齐所以将spl镜像放大两倍后小于52KB,暂使用52K这个值
也就是说spl镜像最大为52KB,同时uboot镜像的起始地址为0xd000(52KB)
同时需要修改uboot源码include/configs/sunxi-common.h中的CONFIG_SYS_SPI_U_BOOT_OFFS为0xd000
和CONFIG_SPL_PAD_TO为CONFIG_SYS_SPI_U_BOOT_OFFS
这里有个地方要注意下,如果在FEL模式下运行uboot镜像,需要将CONFIG_SYS_SPI_U_BOOT_OFFS改回0x8000,不然sunxi-fel会报错
启动报错
U-Boot SPL 2018.01-g5a65529-dirty (Dec 17 2019 - 15:20:01)
DRAM: 64 MiB
Trying to boot from sunxi SPI
从spi nand启动卡在上面这个地方,通过加调试信息找到了一个问题
支持spi nand的uboot源码drivers/mtd/spi/sunxi_spi_nand_spl.c
在函数
static u32 sunxi_spi0_read_data中addr默认加了0x8000
需要把这个注释掉
index f70e1ac..0e2a60d 100644
--- a/drivers/mtd/spi/sunxi_spi_nand_spl.c
+++ b/drivers/mtd/spi/sunxi_spi_nand_spl.c
@@ -266,7 +266,7 @@ static u32 sunxi_spi0_read_data(u8 *buf, u32 addr, u32 bufsize,#ifdef CONFIG_SPINAND{u32 ret = bufsize;
- addr += 0x8000;
+ //addr += 0x8000; //modify by leijieint page = addr >> 11;if( pages != page ) { // need read to cachewritel(4, spi_bc_reg); /* Burst counter (total bytes) */
源码及相关说明:
f1c100s spi nand启动调试记录
f1c100s spi nand 128MB W25N01G 调试记录相关推荐
- spi flash擦写调试记录
最近在调试spi flash的擦写,问题是flash擦写uboot时,不成功.原来的uboot丢失. 测试发现是因为擦能成功,但是写时的地址不是secent大小,一个secent大小为64K. 看da ...
- SPI NAND FLASH
前段时间在项目里面使用了spi nand flash,打算记录分享相关知识,所以开了本篇博客,后面会陆续补充相关内容. spi nand flash,从名字上就直接解释了该类型存储设备 ...
- WK2204 - spi转uart调试记录
WK2204 - spi转uart调试记录 硬件 芯片简介 电路设计 驱动 添加设备树 添加驱动 调试 查看启动加载 检查串口通信 数据乱码或丢失 RS485只能收不能发 系统中断响应异常 思考 硬件 ...
- 新唐NUC980使用记录:U-Boot Linux 编译与烧录(基于SPI NAND)
文章目录 目的 U-Boot编译 U-Boot环境变量 Linux编译 默认设置 使用SPI NAND剩余分区 使用SPI NAND YAFFS2作为rootfs 打包镜像 总结 目的 这篇文章中将测 ...
- 海思3559U-Boot移植(二):更换新的SPI Nand Flash
前言: 在开发板上的折腾终归是小打小闹,真正的实践还需要从实际项目和自己参考画的板子选的器件入手,记录更换未经SDK包测试过的国产FLASH调试记录和踩到的坑,重点参考SDK文档包下的Releas ...
- SX1278 FSK 调试记录
SX1278 FSK 调试记录 先挖个sx1278 FSK的坑慢慢填 手中有两个SX1278模组 是安信可的产品 采用主从模式 SPI访问 MCU是STM32F107 数据格式 说明收据接收的第一步就 ...
- 野火MINI_STM32_CubeMX_SPI1_W25Q64 调试记录
野火MINI_STM32_CubeMX_SPI1 调试记录 1.原理图 2. 生成代码 3. main.c 中的关键信息如下所示. 3. W25Q64.C代码如下所示 4.W25Q64.h代码参考 5 ...
- AML8726调试记录
一:源代码下载: 1:Installing Repo # mkdir ~/bin # PATH=~/bin:$PATH # curl https://dl-ssl.google.com/dl/goog ...
- 在ADSP21489下外挂S29AL016J并行FLASH调试记录
我哭,调试了5天 总结下在ADSP21489下挂S29AL016J并行flash调试记录 S29AL016J:2M*8bit 21489EZ-Kite M29W320EB: 4M*8Bit 在修改fl ...
最新文章
- DP【洛谷P2134】 百日旅行
- java字符串的常量池
- php定时发送生日模块消息_RocketMQ消息队列介绍与应用
- 数据结构与算法(一)——排序
- Linux下的MySQL测试,Linux下MySQL命令(1)
- 本地构建和自动化构建_构建自动化面板
- linux的系统移植——【PC-开发板】的环境搭建
- c语言程序降低图像分辨率,减少OpenCV读取高分辨率图像的时间示例
- [转]程序员真实写真:35岁前成功的12条黄金法则
- 新松机器人产业小镇_机器人行业迎来拐点,新松机器人如何“过冬”?丨亿欧读财报...
- 计算机丨浏览器访问出现DNS_PROBE_POSSIBLE解决方法
- nodejs随笔(二)
- java输出空心菱形 用斜杠,java基础知识总结1
- 推荐Arduino更深入学习:《新概念51单片机C语言教程》-郭天祥(文章内含学习资料供下载)
- 马哥教育42期第五周作业
- 使用 Shiro 配合微信小程序或者app登录,做验权
- PhalAPI学习笔记 ——— 第二章接口服务请求
- 【XSY3952】简单的计数题(dp)
- python 中m op n运算_nltk语言模型(ngram)计算上下文中单词的prob
- 乐普生物通过港交所聆讯:在研4种核心产品,平安等为股东