uboot中如果有支援 spi/qspi flash, 就可以使用 sf 的 erase, read, write 等指令操作 spi flash
sf read: 讀取 flash資料到記憶體
sf write: 寫入記憶體資料到flash
sf erase:刪除指定位置,指定長度的 flash 内容, 刪除後内容全為 1
使用說明
sf probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus and chip select
sf read addr offset len - read 'len' bytes starting at 'offset' to memory at 'addr'
sf write addr offset len - write 'len' bytes from memor at 'addr' to flash at 'offset'
sf erase offset [+]len - erase 'len' bytes from 'offset' + 'len' round up 'len' to block size
sf update addr offset len - erase and write 'len' bytes from memory at 'addr' to flash at 'offset'
使用範例
sf probe
在使用sf read sf write之前,一定要先用sf probe
sf write 0x20000000 0x0 0x10
把記憶體中0x2000 0000的資料, 寫入flash的0x0, 寫入資料長度為0x10, (注意:flash的位置以及寫入長度度最單位位是Byte)
sf read 0x20000000 0x10000 0x10
把flash位置0x10000, 長度为0x10的資料, 寫入到記憶體0x20000000, (注意:flash的位置以及寫入長度度最單位是Byte)
sf erase 0x0 0x10000
刪除flash的0x0, 長度為0x10000的資料, 刪除是以erase block為單位, offset和len參數必須要跟erase block對齊的。
驗證讀寫結果
可以结合uboot md命令, 可以用md查看記憶體中的資料
md.l 0x20000000 0x10
印出記憶體位置0x20000000, 長度為0x10的資料
2018年1月26日 星期五
2017年6月2日 星期五
調整 vim 設定
編輯 ~/.vimrc 這個檔案(若沒有請自行新增)
在檔案中加入所需要的設定
背景 (預設 set bg=light)
set bg=dark
只在 Normal 以及 Visual 模式使用滑鼠,也就是取消 Insert 模式的滑鼠
set mouse=nv
顯示行號
set number
搜尋不分大小寫
set ic
使用空白取代 Tab
set expandtab
自訂縮排 (Tab) 位元數
set tabstop=2
set shiftwidth=2
字數過長時換行
set wrap
不換行
set nowrap
高亮當前行 (水平)
set cursorline
捲動時保留底下 3 行
set scrolloff=3
儲存後退出即可
更多詳細介紹請看:
http://note.drx.tw/2008/01/vimrc-config.html
如要套用別人的 Color Scheme 可以參考
https://blog.longwin.com.tw/2009/03/choose-vim-color-scheme-2009/
在檔案中加入所需要的設定
背景 (預設 set bg=light)
set bg=dark
只在 Normal 以及 Visual 模式使用滑鼠,也就是取消 Insert 模式的滑鼠
set mouse=nv
顯示行號
set number
搜尋不分大小寫
set ic
使用空白取代 Tab
set expandtab
自訂縮排 (Tab) 位元數
set tabstop=2
set shiftwidth=2
字數過長時換行
set wrap
不換行
set nowrap
高亮當前行 (水平)
set cursorline
捲動時保留底下 3 行
set scrolloff=3
儲存後退出即可
更多詳細介紹請看:
http://note.drx.tw/2008/01/vimrc-config.html
如要套用別人的 Color Scheme 可以參考
https://blog.longwin.com.tw/2009/03/choose-vim-color-scheme-2009/
2017年5月12日 星期五
[linux] rm 誤刪檔案
午覺剛睡醒,不小心手殘 rm 砍錯檔!!!! 特別紀錄一下補救方式
首先是安裝 extundelete 程式 ,下載回來之後解壓縮安裝
# tar xvf extundelete-0.2.4.tar.bz2
# cd extundelete-0.2.4
# ./configure
# make install
安裝好後在 src/ 資料夾底下可以看到執行檔
# cd src
查詢被刪除的檔案在哪一個檔案系統
# df -aT
救回特定目錄下的檔案(我所使用的選項)
# ./extundelete /dev/mapper/root --restore-directory /source_code
救回檔案系統下的全部檔案
# ./extundelete /dev/mapper/root --restore-all
救回特定檔案
# ./extundelete /dev/mapper/root --restore-file /source_code/test.txt
註:
/dev/mapper/root <- 檔案所在的檔案系統
/source_code <- 檔案所在的目錄
希望可以幫到大家
首先是安裝 extundelete 程式 ,下載回來之後解壓縮安裝
# tar xvf extundelete-0.2.4.tar.bz2
# cd extundelete-0.2.4
# ./configure
# make install
安裝好後在 src/ 資料夾底下可以看到執行檔
# cd src
查詢被刪除的檔案在哪一個檔案系統
# df -aT
救回特定目錄下的檔案(我所使用的選項)
# ./extundelete /dev/mapper/root --restore-directory /source_code
救回檔案系統下的全部檔案
# ./extundelete /dev/mapper/root --restore-all
救回特定檔案
# ./extundelete /dev/mapper/root --restore-file /source_code/test.txt
註:
/dev/mapper/root <- 檔案所在的檔案系統
/source_code <- 檔案所在的目錄
希望可以幫到大家
2017年2月22日 星期三
tee and grep command
隨手做筆記
時空背景:
在執行程式時,終端機上的訊息太多又跑太快,來不及看。(on CentOS)
Solution:
./exe | tee log
grep -rn Error log
在執行 "exe" 這個程式時透過 "|" pipeline 與 "tee" 這個 tool 將訊息同時顯示在終端機上並寫入 "log" 這個檔案
程式中斷後,透過 "grep" 這個 tool 在 "log" 這個檔案當中搜尋 "Error" 這關鍵字並顯示在終端機上
MAC
ref: https://unix.stackexchange.com/questions/145651/using-exec-and-tee-to-redirect-logs-to-stdout-and-a-log-file-in-the-same-time
./exe &> >(tee -a "$log_file")
時空背景:
在執行程式時,終端機上的訊息太多又跑太快,來不及看。(on CentOS)
Solution:
./exe | tee log
grep -rn Error log
在執行 "exe" 這個程式時透過 "|" pipeline 與 "tee" 這個 tool 將訊息同時顯示在終端機上並寫入 "log" 這個檔案
程式中斷後,透過 "grep" 這個 tool 在 "log" 這個檔案當中搜尋 "Error" 這關鍵字並顯示在終端機上
MAC
ref: https://unix.stackexchange.com/questions/145651/using-exec-and-tee-to-redirect-logs-to-stdout-and-a-log-file-in-the-same-time
./exe &> >(tee -a "$log_file")
訂閱:
文章 (Atom)