NAND_S_FUNC_ECC_2K_BCH8_8ERRS_NO_OOB_ERR source "common.sh"; nandecc_tests.sh -r "0:0:0xFF"~"1:1:0xFF"~"2:2:0xFF"~"3:3:0xFF"
 
nandecc_tests.sh -r "0:0:0xFF"~"1:1:0xFF"~"2:2:0xFF"~"3:3:0xFF"
nandecc_tests.sh:
usage()
{
cat <<-EOF >&2
    usage: ./${0##*/} [-n dev_node] [-r rules]
    -n dev_node: optional; if not provided, choose one with the biggest size
    -r rules: the rules used to inject error bits
    -t test_type: optional; by default is positive test. you could pass 'negative'
    -e test empty sectors
    -h Help         print this usage
EOF
exit 0
}
 
########################### TEST LOGIC ###############################
# create a random test file
testfile="testfile.bin"
do_cmd dd if=/dev/urandom of="$testfile" bs=1 count=$pagesize
 
# write to nand
do_cmd flash_erase -q "$dev_node" 0 0
test_print_trc "Write testfile to nand..."
do_cmd nandwrite -p "$dev_node" "$testfile"
 
do_cmd nanddump -p -l "$pagesize" "$dev_node"
orig_nanddump="$TMPDIR/testfile_nanddump.original"
orig_nanddump_w_oob="$TMPDIR/testfile_nanddump_w_oob.original"
do_cmd nanddump -l "$pagesize" -f "${orig_nanddump}" "$dev_node" #-l len -f file
do_cmd nanddump -l "$pagesize" -o -f "$orig_nanddump_w_oob" "$dev_node" #-o --oob Dump OOB data
 
# modify the nanddump file
test_print_trc "Modifying nand dump file to prepare for ecc test"
corrupted_nanddump="$TMPDIR/testfile_nanddump.corrupted"
modify_nanddump_file "$orig_nanddump_w_oob" "$corrupted_nanddump" "$rules" #associate with rules
 
# write the corrupted nand file back
test_print_trc "Write the corrupted nanddump file back..."
do_cmd flash_erase -q "$dev_node" 0 0
do_cmd nandwrite -n -o "$dev_node" "$corrupted_nanddump" #  -o, --oob               Input contains oob data
 
# Display the errors being injected
hexdump_original_w_oob="$TMPDIR/original_w_oob"
hexdump_corrupted_w_oob="$TMPDIR/corrupted_w_oob"
do_cmd "hexdump -C $orig_nanddump_w_oob > "$hexdump_original_w_oob" "
do_cmd "hexdump -C $corrupted_nanddump > "$hexdump_corrupted_w_oob" "
test_print_trc "The below are the errors being injected in the nand page"
test_print_trc "diff "$hexdump_original_w_oob" "$hexdump_corrupted_w_oob" "
diff "$hexdump_original_w_oob" "$hexdump_corrupted_w_oob"

sleep 5

 
# Verify steps
test_print_trc "Dumpping nand..."
corrected_nanddump="$TMPDIR/testfile_nanddump.corrected"
do_cmd "nanddump -l "$pagesize" -f "$corrected_nanddump" "$dev_node" " > $TMPDIR/nanddump_msg 2>&1
cat $TMPDIR/nanddump_msg
cat $TMPDIR/nanddump_msg |grep "uncorrectable bitflip(s)" && result=1 || result=0
echo "result is $result"
 
if [ $? -ne 0 ] || [ $result -eq 1 ]; then
  if [ $type = 'negative' ]; then
    test_print_trc "The bit error(s) are not corrected as expected, checking if dut is ok..."
    #check if dut is still stable
    do_cmd "cat /proc/mtd"
    do_cmd "time dd if=/dev/urandom of=$dev_node bs=1M count=10"  
    do_cmd flash_erase -q "$dev_node" 0 0
    exit 0
  else
    test_print_trc "Nand dump from uncorrected page ..."
    uncorrected_nanddump="$TMPDIR/testfile_nanddump.uncorrected"
    do_cmd "nanddump -n -o -l "$pagesize" -f "$uncorrected_nanddump" "$dev_node" "
    do_cmd "hexdump -C "$uncorrected_nanddump" "
    do_cmd flash_erase -q "$dev_node" 0 0
    die "Nand ECC Test failed. Not all errors are corrected"
  fi
else
  test_print_trc "Nand ECC Test Pass"
  do_cmd flash_erase -q "$dev_node" 0 0
  exit 0
fi
 
modify_nanddump_file()
# Modify the nanddump file to flip bits based on $rules
# Input
#   $1: input file
#   $2: rules like "<sector#>:byte_offset:mask"~"<oob>:byte_offset:mask"
#       sector, byte_offset are decimal. 'mask' could be decimal or hex
#       byte_offset starts from 0
# Output
#   modified file
modify_nanddump_file()
{
  inputfile=$1
  outputfile=$2
  rules=$3

local filesize=`get_filesize $1`
  cp $inputfile $outputfile

ORIG_IFS=$IFS
  IFS="~"
  for rule in $rules
  do
    # rule is like "sector#:byte_offset:mask" or "oob:offset:mask"
    sector=`echo "$rule" | cut -d":" -f1 | tr [:upper:] [:lower:]`
    byte_offset=`echo "$rule" | cut -d":" -f2`
    mask=`echo "$rule" | cut -d":" -f3`
    if [ $sector = 'oob' ]; then
      offset=$(( $pagesize + $byte_offset ))
      if [ $offset -ge $filesize ]; then
        die "Offset to $inputfile should not be bigger than the filesize"
      fi
    else
      offset=$(( $sector * $sector_size + $byte_offset ))
      if [ $offset -ge $pagesize ];then
        die "Offset to $inputfile for non-oob data should not bigger than pagesize"
      fi
    fi

# get the original byte and modify it
    orig_byte=`hexdump_onebyte $inputfile $offset`
    mod_byte_dec=$(( 0x$orig_byte ^ $mask )) #xor mask
    mod_byte=`echo "obase=16; $mod_byte_dec" |bc`

# write the modified byte to replace the original one
    replace_onebyte $outputfile $offset $mod_byte
    
  done
  IFS=$ORIG_IFS

}

 
 
 
 

ltp-ddt nand_ecc_tests的更多相关文章

  1. LTP随笔——本地调用ltp之ltp4j

    关于ltp本地调用的相关参考请见LTP的Git项目:https://github.com/HIT-SCIR 以下以/home/lion/Desktop路径为例下面教程中出现的具体路径以你实际配置的为准 ...

  2. ZH奶酪:自然语言处理工具LTP语言云调用方法

    前言 LTP语言云平台 不支持离线调用: 支持分词.词性标注.命名实体识别.依存句法分析.语义角色标注: 不支持自定义词表,但是你可以先用其他支持自定义分词的工具(例如中科院的NLPIR)把文本进行分 ...

  3. Eclipse DDT

    http://www.eclipse.org/downloads/ https://github.com/DDT-IDE/DDT/blob/latest/documentation/UserGuide ...

  4. ASP.NET中常用的几个李天平开源公共类LTP.Common,Maticsoft.DBUtility,LtpPageControl

    ASP.NET中常用的几个开源公共类: LTP.Common.dll: 通用函数类库     源码下载Maticsoft.DBUtility.dll 数据访问类库组件     源码下载LtpPageC ...

  5. 很好的一篇讲LTP在编解码中的作用的文章

    原文链接 LONG-TERM PREDICTION by: Adit Aviv       Kfir Grichman introduction: The speech signal has been ...

  6. ASP.NET中常用的几个李天平开源公共类LTP.Common,Maticsoft.DBUtility,LtpPageControl (转)

    ASP.NET中常用的几个开源公共类: LTP.Common.dll: 通用函数类库     源码下载Maticsoft.DBUtility.dll 数据访问类库组件     源码下载LtpPageC ...

  7. 编译哈工大语言技术平台云LTP(C++)源码及LTP4J(Java)源码

    转自:编译哈工大语言技术平台云LTP(C++)源码及LTP4J(Java)源码 JDK:java version “1.8.0_31”Java(TM) SE Runtime Environment ( ...

  8. LTP学习

    下载LTP源码和模型文件: https://github.com/linux-test-project/ltp 官方说明文档 http://ltp.readthedocs.org/zh_CN/late ...

  9. LTP 分词算法实践

    参考链接: https://github.com/HIT-SCIR/ltp/blob/master/doc/install.rst http://www.xfyun.cn/index.php/serv ...

  10. ltp工具使用配置

    ltp是一个比较全的自然语言处理工具,可以用它进行分词.词性标注.语法分析等任务. ---- 准备 下载 下载ltp和ltp4j,在cmake官网下载并安装相应版本的cmake,并且下载ant. 构建 ...

随机推荐

  1. Redis之数据类型

    一.概念: Redis:一个开源.支持网络.基于内存.键值对存储数据库. 特点:它可以支持多种数据类型. 二.数据类型 1)Redis String 具体说明: 一般的普通的k到v一个映射是Strin ...

  2. python 3.6连接数据库(pymysql方式)

    pymysql 模块可以通过 pip 安装.但如果你使用的是 pycharm IDE,则可以使用 project python 安装第三方模块. [File] >> [settings] ...

  3. Linux内核设计与实现 总结笔记(第三章)进程

    进程管理 进程:处于执行期的程序. 线程:在进程中活动的对象 虚拟机制 虚拟处理器:多个进程分享一个处理器 虚拟内存:多个线程共享虚拟内存 一.进程描述符和任务结构 进程存放在双向循环链表中(队列), ...

  4. BUUCTF | [CISCN2019 华北赛区 Day1 Web1]Dropbox

    步骤: 1.运行这个: <?php class User { public $db; } class File { public $filename; } class FileList { pr ...

  5. 基于MyBatis实现Dao理论

    基于MyBatis实现Dao理论 推荐使用xml提供sql 实现接口推荐使用Mapper自动实现DAO接口,让我们更关注sql书写本身

  6. codecs模块, decode、encode

    使用codecs模块,在Python中完成字符编码   字符的编码是按照某种规则在单字节字符和多字节字符之间进行转换的某种方法.从单字节到多字节叫做decoding,从多字节到单字节叫做encodin ...

  7. Vue作用域插槽:用作循环结构的模版

    一 项目结构 二 App组件 <template> <div id="app"> <!-- 子组件 --> <todos :list=&q ...

  8. 使用HEXO建站

    使用Hexo模板 按以下指导进行本地预览和上传到你的github. 环境安装 安装node.js node.js官方下载地址https://nodejs.org/en/ 设置npm淘宝镜像站(npm默 ...

  9. AdaGrad Algorithm and RMSProp

    AdaGrad全称是Adaptive Gradient Algorithm,是标准Gradient Descent的又一个派生算法.标准Gradient Descent的更新公式为: 其中Learni ...

  10. mooc-IDEA 调试代码--012

    mooc-IDEA 调试代码 添加断点快捷键:ctrl+F8 单步运行:F9  <=>resum(从一个断点跳转到下一个断点) 一行一行运行:F8 查看所有断点: 禁止所有断点: 条件断点 ...