一区二区三区三上|欧美在线视频五区|国产午夜无码在线观看视频|亚洲国产裸体网站|无码成年人影视|亚洲AV亚洲AV|成人开心激情五月|欧美性爱内射视频|超碰人人干人人上|一区二区无码三区亚洲人区久久精品

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

全志Tina Linux NOR Flash系統(tǒng)開(kāi)發(fā)指南 最詳細(xì)版本 支持所有全志芯片

嵌入式Linux那些事 ? 來(lái)源:嵌入式Linux那些事 ? 作者:嵌入式Linux那些事 ? 2022-12-26 16:47 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

1 簡(jiǎn)介

  • 編寫(xiě)目的

此文檔描述Sunxi NOR 模塊的使用方法,為相關(guān)人員調(diào)試提供指導(dǎo)

  • 適用范圍
    • boot0: 適用于brandy-2.0
    • u-boot: 適用于u-boot-2018
    • kernel: 適用于linux-4.9/linux-5.4 內(nèi)核

BSP 的開(kāi)發(fā)人員、測(cè)試人員

2 模塊介紹

2.1 模塊功能介紹

Linux 中SPINOR 體系結(jié)構(gòu)如下圖所示:

image-20221216110030034

SPI NOR Framework:這層主要是處理不同廠家的NOR 物理特色差異,初始化SPINOR的工作狀態(tài),如工作線寬(1 線、2 線、4 線、8 線)、有效地址位(16M 以上的NOR 需要使用4 地址模式),為上層MTD 提供讀寫(xiě)擦接口

對(duì)應(yīng)代碼目錄:drivers/mtd/spi-nor/spi-nor.c
M25P80(generic SPI NOR controller driver):這層主要對(duì)SPI NOR Framework
層傳下來(lái)的數(shù)據(jù)封裝成msg,傳遞給SPI framework 層。
對(duì)應(yīng)代碼目錄:drivers/mtd/devices/m25p80.c
SPI Framework:這層主要是將msg 加入ctl 的工作隊(duì)列中,啟動(dòng)內(nèi)核線程隊(duì)列,處理隊(duì)列
中的msg。
對(duì)應(yīng)代碼目錄:drivers/spi/spi.c
SPI controller driver:這層初始化SPI 控制器頻率、時(shí)鐘模式、cs 有效電平、大小端等
配置,同時(shí)處理上層傳下來(lái)的msg,通過(guò)CPU/DMA 方式傳輸數(shù)據(jù)到FIFO,再傳輸給外設(shè)
SPINOR。
對(duì)應(yīng)代碼目錄:drivers/spi/spi-sunxi.c

2.2 相關(guān)術(shù)語(yǔ)介紹

術(shù)語(yǔ) 解釋說(shuō)明
Sunxi 指Allwinner 的一系列SOC 硬件平臺(tái)
SPI Serial Peripheral Interface,同步串行外設(shè)接口
NOR Flash NOR Flash 是一種非易失閃存技術(shù),是Intel 在1988 年創(chuàng)建
MTD MTD(memory technology device 內(nèi)存技術(shù)設(shè)備) 是用于訪問(wèn)memory 設(shè)備(ROM、flash)的Linux 的子系統(tǒng)

2.3 模塊配置介紹

2.3.1 longan 的配置和打包

./build.sh config
All available platform:
	0. android
	1. linux
Choice [linux]: 1
... //配置根據(jù)需求選擇
All available flash: //flash類型,只區(qū)分nor和非nor方案,Android方案無(wú)此選項(xiàng),默認(rèn)非nor
	0. default
	1. nor
Choice [default]: 1
  1. 打包普通固件
#./build.sh clean
#./build.sh
#./build.sh pack
  1. 打包卡打印固件
#./build.sh clean
#./build.sh
#./build.sh pack_debug

在配置的過(guò)程中會(huì)把平臺(tái)目錄下的BoardConfig.mk 的信息拷貝到.buildconfig 中。

2.3.2 sys_config 配置

SPINOR 的boot0 啟動(dòng)階段,部分參數(shù)是從boot0 頭部獲取的,而這些參數(shù)是我們?cè)诖虬碳r(shí),通過(guò)工具update_boot0 將sys_config.fex 中[spinor_para],更新到boot0 頭部的,sys_config.fex 的[spinor_para] 配置參數(shù)如下:

[spinor_para]
;readcmd =0x6b
;read_mode =4
;write_mode =4
;flash_size =16
;delay_cycle =1
;frequency =100000000
;erase_size =64
;lock_flag =0
;sample_delay =0
;sample_mode =2
spi_sclk = port:PC00<4><0><2><default>
spi_cs = port:PC01<4><1><2><default>
spi0_mosi = port:PC02<4><0><2><default>
spi0_miso = port:PC03<4><0><2><default>
spi0_wp = port:PC04<4><0><2><default>
spi0_hold = port:PC05<4><0><2><default>

其中:

readcmd:boot0 用于讀取數(shù)據(jù)的命令,不填默認(rèn)用uboot 傳遞過(guò)來(lái)的readcmd
read_mode、write_mode:boot0 的工作線寬(1、2、4),不填默認(rèn)更加readcmd 決
定線寬
flash_size:flash 的大小
delay_cycle:boot0 的采樣延時(shí)配置,大于60MHZ 配置為1,小于24MHZ 配置為2,
大于24MHZ 小于60HZ 配置為3
frequency:boot0 的SPI 工作頻率,不填使用默認(rèn)值50M
erase_size:boot0 的擦除單位
lock_flag:鎖功能是否打開(kāi)
sample_delay:boot0 的細(xì)調(diào)采樣的采樣延時(shí),uboot、kernel 也會(huì)用到,默認(rèn)不填等于
0xaaaaffff
sample_mode:boot0 的細(xì)調(diào)采樣的采樣模式,uboot、kernel 也會(huì)用到,默認(rèn)不填等于
0xaaaaffff
spi_sclk、spi_cs、spi0_mosi、spi0_miso、spi0_wp 和spi0_hold 用于配置相應(yīng)的GPIO。

2.3.3 UBOOT 配置

2.3.3.1 編譯和配置
#make clean
#make sun8iw19p1_nor_config ----啟動(dòng)的uboot (#make sun8iw19p1_config----燒寫(xiě)uboot)
#make -j32
2.3.3.2 Menuconfig 配置
#cd brandy/brandy-2.0/u-boot-2018
#make menuconfig

進(jìn)入Device Drivers

Device Drivers ---->
[*]SPI Suppport ---->
[*]Sunxi flash support ---->

image-20221216110954138

進(jìn)入SPI Support

Device Drivers ---->
[*]SPI Suppport ---->
[*]Sunxi SPI driver

image-20221216111017858

進(jìn)入sunxi_flash_support

Device Drivers ---->
[*]Sunxi flash support ---->
[*]Support sunxi spinor devices

image-20221216111039312

2.3.4 KERNEL 配置

2.3.4.1 SPINOR-驅(qū)動(dòng)配置
#cd kernel/liunx-4.9
#make ARCH=arm menuconfig

進(jìn)入Device Drivers

Device Drivers ---->
<*>Memory Technology Device (MTD) support ---->
[*]SPI support ---->

image-20221216111201111

進(jìn)入Menory Technology Device(MTD) support

Device Drivers ---->
<*>Memory Technology Device (MTD) support ---->
<*>SUNXI partitioning support
<*>Direct char device access to MTD devices
<*>Caching block device access to MTD devices
Self-contained MTD device drivers ---->
SPI-NOR device support ---->

image-20221216111231797

進(jìn)入Self-contained MTD device drivers(5.4 內(nèi)核不需要選擇此項(xiàng))

Device Drivers ---->
<*>Memory Technology Device (MTD) support ---->
Self-contained MTD device drivers ---->
<*>Support most SPI Flash chips (AT16DF, M25P.....)

image-20221216111301751

2.3.4.2 cmdline 方式選擇
Boot opttions ---->

image-20221216111354759

進(jìn)入Boot options

Boot opttions ---->
Kernel command line type ---->

image-20221216111427021

進(jìn)入kernel command line type

Boot opttions ---->
Kernel command line type ---->
(X)Use bootloade kernel arguments if available

image-20221216111454068

2.3.4.3 文件系統(tǒng)配置

進(jìn)入File systems

File system ---->
[*]Miscellaneous filesystems ---->

image-20221216111527624

? 進(jìn)入Miscellaneous filesystems

? Incluede support for ZLIB compressed file systems (NEW)

? Incluede support for LZ4 compressed file systems (NEW)

? Incluede support for LZO compressed file systems (NEW)

? Incluede support for XZ compressed file systems (NEW)

File system ---->
[*]Miscellaneous filesystems ---->
[*]Incluede support for XZ compressed file systems (NEW)(壓縮方式選擇如下)

image-20221216111604498

以上的壓縮方式(ZLIB/LZ4/LZO/XZ)具體選擇哪一種需要根據(jù)longan/build/mkcmd.sh 中如下代碼使用的壓縮方式而定,如下代碼使用的是gzip 壓縮方式,則內(nèi)核File systems 中配置需選擇LZO 壓縮方式,若使用的是xz, 則需選擇XZ 壓縮方式。

${ROOTFS} ${LICHEE_PLAT_OUT}/rootfs.squashfs -root-owned -no-progress -comp gzip -noappend

2.4 源碼目錄介紹

2.4.1 UBOOT 源碼目錄

\\u-boot-2018drivers
├──sunxi_flash ---sunxi_flash的初始化/退出/讀/寫(xiě)/擦除等f(wàn)lash接口
├─mmc ---mmc接口代碼
├─nand ---nand接口代碼
├─spinor ---spi nor接口代碼
├─sunxi_flash.c ---sunxi_flash操作接口
└──其他
├── spi --sunxi_spi的接口代碼
├─sunxi_spi.c ---具體代碼的實(shí)現(xiàn)
├──mtd
├─spi
├─sf_probe.c ---nand接口代碼
├─spinor ---spi nor接口代碼
├─sunxi_flash.c ---sunxi_flash

2.4.2 KERNEL 源碼目錄

longankernellinux-4.9drivers├── mtd
├─spi-nor
├─spi-nor.c ---spi nor驅(qū)動(dòng)代碼
└──其他
├── spi --spi的接口代碼
└── makefile ---編譯文件

3 接口描述

3.1 驅(qū)動(dòng)物理層接口

3.1.1 spi_nor_erase

static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)

description:mtd erase interface

@mtd: MTD device structure

@instr: erase operation descrition structure

return:success return 0,fail return fail code**

3.1.2 spi_nor_read

static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)

description:mtd read interface

@mtd:MTD device structure

@from: offset to read from MTD device

@len: data len

@retlen: had read data len

@buf: data buffer

return:success return max_bitflips,fail return fail code**

3.1.3 spi_nor_write

static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)

description:mtd write data interface

@to: offset to MTD device

@len: want write data len

@retlen:return the writen len

@buf: data buffer

return: success return 0, fail return code fail

3.1.4 spi_nor_lock

static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
description:check block is badblock or not

@mtd:MTD device structure

@ofs: offset the mtd device start (align to simu block size)

@len:The length of the operating

return: success return 0, fail return code fail

3.1.5 spi_nor_unlock

static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
description:check block is badblock or not

@mtd:MTD device structure

@ofs: offset the mtd device start (align to simu block size)

@len:The length of the operating

return: success return 0, fail return code fail

3.1.6 spi_nor_is_locked

static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
description:check block is badblock or not

@mtd:MTD device structure

@ofs: offset the mtd device start (align to simu block size)

@len:The length of the operating

return: Is lock return 1, else return 0

3.1.7 spi_nor_has_lock_erase

static int spi_nor_has_lock_erase(struct mtd_info *mtd, struct erase_info *instr)

description:mtd has lock erase interface,F(xiàn)irst unlock to operate space, after the

completion of the flash lock up

@mtd: MTD device structure

@instr: erase operation descrition structure

return:success return 0,fail return fail code

3.1.8 spi_nor_has_lock_write

static int spi_nor_has_lock_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)

description:mtd has lock write data interface,F(xiàn)irst unlock to operate space, after

the completion of the flash lock up

@to: offset to MTD device

@len: want write data len

@retlen:return the writen len

@buf: data buffer

return: success return 0, fail return code fail

3.2 Uboot 應(yīng)用接口

3.2.1 sunxi_flash_spinor_probe

static int sunxi_flash_spinor_probe(void)

description:SPINOR initialization,Set the storage type。

return:zero on success, else a negative error code.

3.2.2 sunxi_flash_spinor_init

static int sunxi_flash_spinor_init(int boot_mode, int res)

description:SPINOR initialization。

@boot_mode:Working mode

@res:The default is 0

return:zero on success, else a negative error code.

3.2.3 sunxi_flash_spinor_exit

int sunxi_flash_spinor_exit(void)

description:Release registration is a resource for applications.

return:zero on success, else a negative error code.

3.2.4 sunxi_flash_spinor_write

static int sunxi_flash_spinor_write(uint start_block, uint nblock, void *buffer)

description:mtd write data interface.

@start_block:want write start sector

@nblock:want write sectorcount

@buffer:data buffer

return:zero on success, else a negative error code.

3.2.5 sunxi_flash_spinor_write

static int sunxi_flash_spinor_write(uint start_block, uint nblock, void *buffer)

description:mtd readdata interface.

@start_block:want read start sector

@nblock:want read sector count

@buffer:data buffer

return:zero on success, else a negative error code.

3.2.6 sunxi_flash_spinor_erase

static int sunxi_flash_spinor_erase(int erase, void *mbr_buffer)

description:erase boot || partition data.

@erase:erase flag

@buffer:The default is NULL

return:zero on success, else a negative error code.

3.2.7 sunxi_flash_spinor_force_erase

int sunxi_flash_spinor_force_erase(void)

description:erase boot & partition data.

return:zero on success, else a negative error code.

3.2.8 sunxi_flash_spinor_flush

int sunxi_flash_spinor_flush(void)

description:Flush physical cache data to flash.

return:zero on success, else a negative error code.

3.2.9 sunxi_flash_spinor_download_spl

static int sunxi_flash_spinor_download_spl(unsigned char *buf, int len, unsigned int ext)

description:write boot0.

@buf:boot0 data buffer

@len:boot0 data len

@ext:storage type

return:zero on success, else a negative error code.

3.2.10 sunxi_flash_spinor_download_toc

static int sunxi_flash_spinor_download_toc(unsigned char *buf, int len, unsigned int ext)

description:write uboot.

@buf:uboot data buffer

@len:uboot data len

@ext:storage type

return:zero on success, else a negative error code.

4 使用例子

4.1 uboot shell 使用

4.1.1 sunxi_flash

mem_addr:內(nèi)存地址,0x40000000 之后可以隨便選取如:0x45000000,0x46000000

part_name:分區(qū)文件名,boot-resource、env、boot、rootfs

size:可以省略,默認(rèn)讀取整個(gè)分區(qū)文件

  1. sunxi_flash read [size] 讀取flash 中的分區(qū)文件到內(nèi)存中
    例:使用sunxi_flash read 命令將boot 分區(qū)讀入到0x49000000 中,然后使用md 命令讀取
    0x49000000 中的內(nèi)容。

image-20221216112650227

驗(yàn)證方法:

  1. 0x49000000 讀入前與讀入后數(shù)據(jù)有沒(méi)有發(fā)生變化
  2. 在out/pack_out 目錄下找到對(duì)應(yīng)的分區(qū)文件,使用hexdump -Cv boot.fex -n 500 命
    令輸出分區(qū)文件的數(shù)據(jù),對(duì)比一致即讀入成功。

image-20221216112713299

  1. sunxi_flash write [size] 將內(nèi)存中的數(shù)據(jù),寫(xiě)入到分區(qū)中
    例:
    1)使用mm 命令修改內(nèi)存內(nèi)容

image-20221216112743939

2)使用sunxi_flash write 0x44000000 env 將內(nèi)存中的數(shù)據(jù)寫(xiě)入env 分區(qū)

image-20221216112759532

3)重新將env 分區(qū)讀入內(nèi)存中,對(duì)比一致表示寫(xiě)入成功

image-20221216112809980  

審核編輯:湯梓紅

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • Linux
    +關(guān)注

    關(guān)注

    87

    文章

    11508

    瀏覽量

    213570
  • MPU
    MPU
    +關(guān)注

    關(guān)注

    0

    文章

    414

    瀏覽量

    49872
  • Tina
    +關(guān)注

    關(guān)注

    2

    文章

    45

    瀏覽量

    17322
  • 全志芯片
    +關(guān)注

    關(guān)注

    3

    文章

    7

    瀏覽量

    2951
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    2月芯片開(kāi)源項(xiàng)目分享合集

    屏游戲掌機(jī)! 最最重要的是,本項(xiàng)目支持提供的Tina Linux SDK,文檔齊全,在經(jīng)過(guò)一段時(shí)間的調(diào)整后,項(xiàng)目已經(jīng)完全可以量產(chǎn)。 2
    發(fā)表于 03-02 14:39

    8月芯片開(kāi)源項(xiàng)目分享合集

    Linux內(nèi)核驅(qū)動(dòng)的源碼。 linux-card 作者:syske 作者本人的第一塊F1C200S的實(shí)驗(yàn)板,踩了很多坑,更新了六個(gè)版本
    發(fā)表于 09-02 10:25

    &OpenHarmony】三款支持OpenHarmony開(kāi)發(fā)板在開(kāi)放原子開(kāi)源基金會(huì)OpenHarmony見(jiàn)面會(huì)實(shí)況分享

    成果,見(jiàn)面會(huì)在B站等多個(gè)平臺(tái)進(jìn)行了全程直播,累計(jì)觀看人數(shù)超2W人。其中志在會(huì)上分享了3款支持OpenHarmony的芯片/開(kāi)發(fā)板,分別是XR806、T507和D1。第一款是
    發(fā)表于 11-15 16:16

    &OpenHarmony】三款支持OpenHarmony開(kāi)發(fā)板在開(kāi)放原子開(kāi)源基金會(huì)OpenHarmony見(jiàn)面會(huì)實(shí)況分享

    分享了3款支持OpenHarmony的芯片/開(kāi)發(fā)板,分別是XR806、T507和D1。第一款是的D1
    發(fā)表于 11-15 16:48

    輕量系統(tǒng)開(kāi)發(fā)套件介紹: XR806 開(kāi)發(fā)套件

    XR806 開(kāi)發(fā)套件是科技旗下子公司廣州芯之聯(lián)研發(fā)設(shè)計(jì)的一款支持WiFi和BLE的高集
    發(fā)表于 04-21 13:51

    全新Tina Linux v5.0釋放!帶來(lái)全新AIoT產(chǎn)品開(kāi)發(fā)體驗(yàn)

    Tina Linux基于linux內(nèi)核深度定制開(kāi)發(fā)的AIoT
    發(fā)表于 07-12 18:25

    【免費(fèi)試用04期】V853開(kāi)發(fā)板試用活動(dòng)

    】編譯 Tina Linux部分之openWrt 編譯【V853開(kāi)發(fā)板試用】編譯 Tina
    發(fā)表于 07-21 10:27

    V853開(kāi)發(fā)板試用】開(kāi)箱及初識(shí)之美

    , 同時(shí)支持供電和數(shù)據(jù)傳輸PMU:AXP2101板身大?。洪L(zhǎng) 118mm寬 75mmPCB板層:4層板系統(tǒng)配置官方支持
    發(fā)表于 08-21 23:47

    Ubuntu官方發(fā)布適配D1-H哪吒開(kāi)發(fā)板的鏡像

    ,融入OS”為核心,建立起了豐富的Linux開(kāi)發(fā)生態(tài),目前開(kāi)發(fā)板已經(jīng)成功適配了自研Tina
    發(fā)表于 08-23 09:24

    V853開(kāi)發(fā)板試用】V853開(kāi)發(fā)板試用測(cè)評(píng)報(bào)告

    ,很好滿足不同任務(wù)的場(chǎng)景。3.軟件資源V853系統(tǒng)配置Tina Linux 5.0系統(tǒng),基于
    發(fā)表于 08-29 02:09

    【開(kāi)源硬件】芯片系列優(yōu)秀開(kāi)源工程分享

    。 YuzukiRuler Pro采用 D1-H為主控,最大支持2GB內(nèi)存,256GB儲(chǔ)存的全面屏Linux小尺子,RISCV64 指令集,板載UART和OTG,還將屏幕升級(jí)為一個(gè)
    發(fā)表于 09-14 09:49

    Tina_Linux_系統(tǒng)軟件開(kāi)發(fā)指南

    Tina_Linux_系統(tǒng)軟件開(kāi)發(fā)指南
    的頭像 發(fā)表于 03-02 15:25 ?3034次閱讀
    <b class='flag-5'>Tina_Linux</b>_<b class='flag-5'>系統(tǒng)軟件開(kāi)發(fā)指南</b>

    Tina Linux配置開(kāi)發(fā)指南

    Tina Linux配置開(kāi)發(fā)指南
    的頭像 發(fā)表于 03-02 15:28 ?1.8w次閱讀
    <b class='flag-5'>Tina</b> <b class='flag-5'>Linux</b>配置<b class='flag-5'>開(kāi)發(fā)指南</b>

    Linux NOR開(kāi)發(fā)指南

    Linux NOR開(kāi)發(fā)指南
    的頭像 發(fā)表于 03-06 09:55 ?1370次閱讀
    <b class='flag-5'>Linux</b> <b class='flag-5'>NOR</b><b class='flag-5'>開(kāi)發(fā)指南</b>

    AW_R329_Tina_Linux_開(kāi)發(fā)入門(mén)_v0.5

    AW_R329_Tina_Linux_開(kāi)發(fā)入門(mén)_v0.5
    發(fā)表于 10-19 15:11 ?4次下載