Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux 程式設計 >> Linux 程式設計

mini2440 的 NorFlash 驅動移植步驟

我不確定友善的 linux-2.6.32 核心是否已經內建 mini2440 的 NorFlash 支援,因此還是親自把支援加上去。移植過程分享如下。

一、添加配置項

1、修改 drivers/mtd/maps/Kconfig,在 config_EDB7312 配置項下添加:

config MTD_MINI2440
tristate "CFI Flash device mapped on MINI2440"
depends on ARM && MTD_CFI
help
This enables access to the CFI Flash on the Cogent MINI2440 board.
If you have such a board, say 'Y' here.

2、修改 drivers/mtd/maps/Makefile,在 obj-$(CONFIG_MTD_EDB7312) += edb7312.o 下添加:

obj-$(CONFIG_MTD_MINI2440) += mini2440.o

3、復制驅動文件 mini2440.c 到 drivers/mtd/maps 目錄下。

二、配置並編譯核心

# make menuconfig

以下內容必選:

Memory Technology Devices(MTD) -->
<*> Memory Technology Device (MTD) support
[*] MTD partitioning support
  <*> Direct char device access to MTD devices
  <*> Caching block device access to MTD devices
RAM/ROM/Flash chip drivers -->
  <*> Detect flash chips by Common Flash Interface (CFI) probe
  <*> Support for Inter/Sharp flash chips
  <*> Support for AMD/Fujitsu/Spansion flash chips
  <*> CFI flash device mapped on mini2440

下列內容(只有在 flash 上架 fat16/fat32/ntfs/ext2 等文件系統時才需要選上)不要選,否則加載驅動模塊時會出現 ftl_cs: FTL header not found:

Device Drivers ->
  Memory Technology Devices (MTD) ->
      <> FTL (Flash Translation Layer) support
      <> NFTL (NAND Flash Translation Layer) support
      <> INFTL (Inverse NAND Flash Translation Layer) support

最後執行 make 編譯,把產生的 zImage 燒入即可。這裡的 FTL/NFTL/INFTL 屬於「用來模擬 DiskOnChip 這類智慧 NAND 裝置」的翻譯層,mini2440 板上的 NorFlash 走的是標準 CFI 路徑,根本不需要它們;一旦選上,系統反而會去 probe 不存在的裝置並印出 header not found 的錯誤,讓人誤以為驅動壞了。這也是移植 BSP 時很常見的一類「多選反而出錯」的坑。

Copyright © Linux教程網 All Rights Reserved