Environment: VirtualBox+ubuntu 10.04
Compiler, friendly, comes with arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz
Hardware: tiny6410, core board number 1107
1. Download the source code of linux-2.6.38,
ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.38.tar.bz2
2. Unzip tar xvfj /mnt/ubuntu/linux-2.6.38.tar.bz2 -C .
3. vi Makefile 191 line to change 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 I unzipped the compiler to the /usr/4.5.1 directory
System Type->[*] MINI6410 Select, others can be removed, if you are not sure, you can refer to Friendly Arm
The kernel compiled in this way can be booted by uboot, and then add nand flash support
vi arch/arm/mach-s3c64xx/mach-mini6410.c
line 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 After testing, it was found that the modification here has no effect at all, and even the entire comment does not matter. It is estimated that the partition has been fixed in the s3c_nand_mlc.fo at the back.
The two files drivers/mtd/nand/s3c_nand.c and arch/arm/plat-samsung/include/plat/regs-nand.h can
be copied from the Youshan source code. This is what they wrote themselves. Of course, drivers/mtd/nand/s3c_nand_mlc.fo should also be copied. This is one of the drivers that Youshan has not opened source,
so there is no need to study it. Just copy it.
################################################################
################################################################
Modify the drivers/mtd/nand/nand_base.c file
The modification method is as follows, "-" is the content to be removed, "+" is the content to be added, and the line number is after @@.
If you don't want to bother, just copy drivers/mtd/nand/nand_base.c and overwrite it.
Hey, here are the results of my 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) &&
tristate "NAND Flash support for S3C SoC"
config MTD_NAND_S3C
Add
Then modify drivers/mtd/nand/Kconfig and drivers/mtd/nand/Makefile files
*maf_id == NAND_MFR_HYNIX ||
(*maf_id == NAND_MFR_SAMSUNG ||
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
末尾再增加
S3C_NAND_MLC_SRC = $(shell ls drivers/mtd/nand/s3c_nand_mlc.c 2>/dev/null)
ifeq ($(S3C_NAND_MLC_SRC),)
obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand_mlc.fo
else
obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand_mlc.o
endif
Then make menuconfig
Device Drivers--->
<*> Memory Technology Device (MTD) support --->
[*] MTD partitioning support
[*] Command line partition table parsing
<*> Direct char device access to MTD devices
<*> Caching block device access to MTD devices
<*> NAND Device Support --->
< > NAND Flash support for Samsung S3C SoCs Remove and do not select
<*> NAND Flash support for S3C SoC
[*] S3C NAND Hardware ECC
make zImage
is compiled and the nand flash can be used.
############################################################################
Problems I encountered during the transplant:
############################################################################
Follow the above method. After making zImage, the following prompt will appear:
Among them, Makefile:54 is:
The Makefile was written incorrectly, but I didn't know where it was wrong. After copying the corresponding Makefile content of Friendly Arm, I ran "make zImage" and the compilation was successful.
Previous article:Porting yaffs2 file system
Next article:Linux-2.6.38 to tiny6410 porting manual (serial 4) __USB devices (U disk, camera, wifi)
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- The motherboard of Huawei P30 looks like this
- RS-485 Transceiver
- ST U5 development board evaluation and programming related issues (official sharing)
- Problems with ST Motor Control Workbench
- Capacitor models, selection, capacitance calculation and PCB layout
- 【Me and gui-guider①】Create a new GUI project
- Voltage feedback, common indicators, good or bad judgment...
- TI Simplelink platform next generation wireless product solutions Q&A
- MOS tube
- You can take a look at some of the sentences I saw in the book.