環境 VirtualBox+ubuntu 10.04
編譯器,友善自帶arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz
硬件,tiny6410,核心板號1107
1、下載linux-2.6.38的源碼,ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.38.tar.bz2
2、解壓 tar xvfj /mnt/ubuntu/linux-2.6.38.tar.bz2 -C .
3、vi Makefile 191行改為 ARCH ?= arm
4、cp arch/arm/configs/s3c6400_defconfig .config
5、make menuconfig
5、General setup->(/usr/4.5.1/bin/arm-linux-) Cross-compiler tool prefix 我將編譯器解壓到了/usr/4.5.1目錄
System Type->[*] MINI6410 選上,其他的可以去掉,不確定的可以參考友善之臂的
這樣編譯出來的內核是可以被uboot引導的,然后是增加nand flash支持
vi arch/arm/mach-s3c64xx/mach-mini6410.c
第117行
struct mtd_partition mini6410_nand_part[] = {
{
.name = 'Bootloader',
.offset = 0,
.size = (4 * 128 *SZ_1K),
.mask_flags = MTD_CAP_NANDFLASH,
},
{
.name = 'Kernel',
.offset = (4 * 128 *SZ_1K),
.size = (5*SZ_1M) ,
.mask_flags = MTD_CAP_NANDFLASH,
},
{
.name = 'File System',
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
}
}; //update at 2011-8-26 經過測試發現,這里改完后根本不起作用,甚至將整個注釋也無妨,估計分區已經固死在后面的s3c_nand_mlc.fo中
drivers/mtd/nand/s3c_nand.c和arch/arm/plat-samsung/include/plat/regs-nand.h兩個文件可以從友善的源碼中
拷貝過來,這是他們自己寫的,當然drivers/mtd/nand/s3c_nand_mlc.fo也要拷貝過來,這是友善沒有開源的一個驅動之一,
所以不用研究了,拷過來就是了。
################################################################
################################################################
修改drivers/mtd/nand/nand_base.c文件
修改方法如下,“-”就是要去掉的內容,“+”就是要增加的內容,@@后面的是行號,
嫌麻煩的的直接將drivers/mtd/nand/nand_base.c拷過來覆蓋掉
嘿嘿,下面是我diff出來的東西。
@@ -342,7 +342,7 @@
*/
static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
{
- int page, chipnr, res = 0;
+ int page, res = 0;
struct nand_chip *chip = mtd->priv;
u16 bad;
@@ -351,6 +351,8 @@
page = (int)(ofs >> chip->page_shift) & chip->pagemask;
+#if 0
+ /* Moved to nand_block_checkbad() for chip specify support */
if (getchip) {
chipnr = (int)(ofs >> chip->chip_shift);
@@ -359,6 +361,7 @@
/* Select the NAND device */
chip->select_chip(mtd, chipnr);
}
+#endif
if (chip->options & NAND_BUSWIDTH_16) {
chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos & 0xFE,
@@ -378,8 +381,10 @@
else
res = hweight8(bad) < chip->badblockbits;
+#if 0
if (getchip)
nand_release_device(mtd);
+#endif
return res;
}
@@ -477,9 +482,26 @@
int allowbbt)
{
struct nand_chip *chip = mtd->priv;
+ int chipnr, res = 0;
+
+ /* Chip specify block_bad() support */
+ if (!chip->bbt) {
+ if (getchip) {
+ chipnr = (int)(ofs >> chip->chip_shift);
- if (!chip->bbt)
- return chip->block_bad(mtd, ofs, getchip);
+ nand_get_device(chip, mtd, FL_READING);
+
+ /* Select the NAND device */
+ chip->select_chip(mtd, chipnr);
+ }
+
+ res = chip->block_bad(mtd, ofs, getchip);
+
+ if (getchip)
+ nand_release_device(mtd);
+
+ return res;
+ }
/* Return info from the table */
return nand_isbad_bbt(mtd, ofs, allowbbt);
@@ -3002,23 +3024,15 @@
id_data[0] == NAND_MFR_SAMSUNG &&
(chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
id_data[5] != 0x00) {
+ int __oobsz[] = { 0, 128, 218, 400 };
/* Calc pagesize */
mtd->writesize = 2048 << (extid & 0x03);
extid >>= 2;
/* Calc oobsize */
- switch (extid & 0x03) {
- case 1:
- mtd->oobsize = 128;
- break;
- case 2:
- mtd->oobsize = 218;
- break;
- case 3:
- mtd->oobsize = 400;
- break;
- default:
+ if (extid & 0x10) {
mtd->oobsize = 436;
- break;
+ } else {
+ mtd->oobsize = __oobsz[(extid & 0x03)];
}
extid >>= 2;
/* Calc blocksize */
@@ -3099,16 +3113,21 @@
/* Calculate the address shift from the page size */
chip->page_shift = ffs(mtd->writesize) - 1;
+
/* Convert chipsize to number of pages per chip -1. */
- chip->pagemask = (chip->chipsize >> chip->page_shift) - 1;
+ if (!chip->pagemask) {
+ chip->pagemask = (chip->chipsize >> chip->page_shift) - 1;
+ }
chip->bbt_erase_shift = chip->phys_erase_shift =
ffs(mtd->erasesize) - 1;
- if (chip->chipsize & 0xffffffff)
- chip->chip_shift = ffs((unsigned)chip->chipsize) - 1;
- else {
- chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32));
- chip->chip_shift += 32 - 1;
+ if (!chip->chip_shift) {
+ if (chip->chipsize & 0xffffffff)
+ chip->chip_shift = ffs((unsigned)chip->chipsize) - 1;
+ else {
+ chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32));
+ chip->chip_shift += 32 - 1;
+ }
}
/* Set the bad block position */
@@ -3126,8 +3145,11 @@
*/
if ((chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
(*maf_id == NAND_MFR_SAMSUNG ||
- *maf_id == NAND_MFR_HYNIX))
- chip->options |= NAND_BBT_SCANLASTPAGE;
+ *maf_id == NAND_MFR_HYNIX)) {
+ if (mtd->writesize < 4096) {
+ chip->options |= NAND_BBT_SCANLASTPAGE;
+ }
+ }
else if ((!(chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
(*maf_id == NAND_MFR_SAMSUNG ||
*maf_id == NAND_MFR_HYNIX ||
然后修改drivers/mtd/nand/Kconfig和drivers/mtd/nand/Makefile文件
在drivers/mtd/nand/Kconfig 238行增加
config MTD_NAND_S3C
tristate 'NAND Flash support for S3C SoC'
depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX) && MTD_NAND
help
This enables the NAND flash controller on the S3C.
No board specfic support is done by this driver, each board
must advertise a platform_device for the driver to attach.
config MTD_NAND_S3C_DEBUG
bool 'S3C NAND driver debug'
depends on MTD_NAND_S3C
help
Enable debugging of the S3C NAND driver
configMTD_NAND_S3C_HWECC
bool 'S3C NAND Hardware ECC'
depends on MTD_NAND_S3C
help
Enable the use of the S3C's internal ECC generator when
using NAND. Early versions of the chip have had problems with
incorrect ECC generation, and if using these, the default of
software ECC is preferable.
If you lay down a device with the hardware ECC, then you will
currently not be able to switch to software, as there is no
implementation for ECC method used by the S3C
drivers/mtd/nand/Makefile中20行增加
obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand.o
上一篇:移植yaffs2 文件系統
下一篇:linux-2.6.38到tiny6410的移植手冊(連載4)__USB設備(U盤,攝像頭,wifi)
推薦閱讀最新更新時間:2025-05-21 18:30

設計資源 培訓 開發板 精華推薦
- LTC2975 的典型應用 - 具有準確輸入電流和能量測量功能的 4 通道 PMBU 電源系統管理器
- STM32 Nucleo-64 開發板,帶 STM32WB15CC,支持 Arduino、ST Morpho 連接
- 使用 Analog Devices 的 LT1302CN8-5 的參考設計
- MC33364臨界導通模式反激轉換器的典型應用電路
- AD9754-EB,用于 AD9754、14 位、125 MSPS 高性能 D/A 轉換器的評估板
- LTC1064-3,優于用于數據通信的貝塞爾線性相位濾波器
- NCS2001SN2T1G 0.9V單電源運放正電容乘法器典型應用電路
- AM6TW-4803DH35Z ±3.3V 6 瓦雙路輸出 DC/DC 轉換器的典型應用
- 使用 Analog Devices 的 LTC1538IG-AUX 的參考設計
- DC1198B-B,使用 LTM4607EV、6 至 36 Vin 至 12V、5A 高效降壓-升壓 DC/DC 模塊穩壓器的演示板