Transplantation of Linux-2.6.32.2 Kernel on mini2440-transplantation of I2C EEPROM driver

Source: Internet
Author: User

Port Environment (Bold font in redIs the modified content,Blue bold ChineseFor special attention)

1. host environment: centos 5.5 and 1 GB memory in vmare.

2. Integrated Development Environment: Elipse ide

3. compiling environment: Arm-Linux-GCC v4.4.3 and arm-None-Linux-gnueabi-GCC v4.5.1.

4. Development Board: mini2440, 2 m nor flash, 128 m nand Flash.

5, U-boot version: u-boot-2009.08

6, Linux: linux-2.6.32.2

7. References:

Complete embedded Linux application development manual, edited by Wei Dongshan.

Mini2440 Linux porting Development Practice Guide

[1] configure the I2C driver in the kernel

The Linux-2.6.32.2 provides a complete driver for the s2c2440 I2C interface, so we only need to configure it in the kernel.
Tip: in fact, the Linux-2.6.32.2 kernel default mini2440_defconfig has been configured with the I2C driver, we just open here to see the specific configuration path.

Run make menuconfig in the kernel source code directory to go to The Kernel configuration main menu, and choose to go to the following sub-menu:

Device Drivers --->
<*> I2C support --->
I2C hardware bus support --->

<*> S3C2410 I2C driver

We can see that "<*> S3C2410 I2C driver" has been selected here, And the S3C2410 here can also be applied to S3C2440, because their I2C ports and register definitions are identical. The driver source code corresponding to the above configuration is: linux-2.6.32.2/Drivers/I2C/busses/i2c-s3c2410.c.

After confirming the above configuration, exit and save.

[2] compile and Test

After re-compilation, copy the uimage to/nfsboot/kernel and restart the Development Board. The following startup information is displayed on the console:

......

SCSI subsystem initialized
Usbcore: registered new interface driver usbfs
Usbcore: registered new interface driver Hub
Usbcore: registered new device driver USB
S3c-i2c s3c2440-i2c: slave address 0x10
S3c-i2c s3c2440-i2c: Bus frequency set to 98 kHz
S3c-i2c s3c2440-i2c: i2c-0: s3c I2C Adapter
Net: Registered protocol family 2

......

To facilitate user testing, mini2440 mounted an EEPROM Chip Based on I2C bus, which is AT24C08. By writing and reading the chip, we can test the I2C bus driver.

Here the friendly official provides a command line test program named "I2C", which was modified based on the open-source eeprog software. The eeprog software is: http://codesink.org/eeprog.html. The I2C test code is located in the CD/Linux sample code/examples/I2C. Copy it to the Linux host/root/Linux-test/codetest directory and run make
Makefile to generate executable code for the test program;

[Root @ localhost I2C] # Make
Arm-Linux-gcc-wall-O2-c-o eeprog. O eeprog. c
Arm-Linux-gcc-wall-O2-c-o 24cxx. O 24cxx. c
Arm-Linux-gcc-wall-O2-O I2C eeprog. O 24cxx. o
[Root @ localhost I2C] #
Then copy the generated I2C to/nfsboot/NFS.

[Root @ localhost I2C] # cp I2C/nfsboot/nfs

Then run the I2C-W command on the serial port terminal to write data (0x00-0xff) to the 24c08 device of the Board ):

[Root @ mini2440 sdcard] # CD ../nfs
[Root @ mini2440 NFS] # ls
Adc_test backlight_test I2C tstest
[Root @ mini2440 NFS] #./I2C-W
Open/dev/I2C/0 with 8bit Mode
Error eeprom_open: no such file or directory
Error at line 90: Unable to open EEPROM device file (check that the file exists
And that it's readable)
Sysmsg: no such file or directory

The file I2C/0 is not displayed.

[Root @ mini2440 NFS] # ls/dev
ADC ptyv1 tType
Apm_bios ptyv2 ttypf
Backlight ptyv3 ttyq0
Console ptyv4 ttyq1
Cpu_dma_latency ptyv5 ttyq2
Device ptyv6 ttyq3
Event0 ptyv7 ttyq4
Fb0 ptyv8 ttyq5
Full ptyv9 ttyq6
I2c-0Ptyva ttyq7
Kmem ptyvb ttyq8
Kmsg ptyvc ttyq9
Mem

You can see the i2c-0 of this device file.

To modify the code in I2C source code, add writable attributes to the code before modification.

[Root @ localhost I2C] # chmod A + W eeprog. c

Open eeprog. c In the I2C source file, locate the 87 line, and modify it as follows:

Fprintf (stderr, "Open/dev/I2c-0With 8bit mode \ n ");
Die_if (eeprom_open ("/dev/I2c-0", 0x50, eeprom_type_8bit_addr, & E) <0,
"Unable to open EEPROM device file"
"(Check that the file exists and that it's readable )");
Switch (OP)

Then re-compile.

[Root @ localhost I2C] # Make
Arm-Linux-gcc-wall-O2-c-o eeprog. O eeprog. c
Arm-Linux-gcc-wall-O2-O I2C eeprog. O 24cxx. o
[Root @ localhost I2C] # cp I2C/nfsboot/nfs
CP: overwrite "/nfsboot/nfs/I2C "? Y
[Root @ localhost I2C] #
Execute the I2C-W command again

[Root @ mini2440 NFS] #./I2C-W
Open/dev/i2c-0 with 8bit Mode
Writing 0x00-0xff into 24c08

0000 | 00 01 02 03 04 05 06 07 08 09 0a 0b 0C 0d 0e 0f
0010 | 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1f
0020 | 20 21 22 23 24 25 26 28 29 2a 2B 2C 2D 2E 2f
0030 | 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3f
0040 | 40 41 42 43 44 46 47 48 4A 4B 4C 4D 4E 4f
0050 | 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5d 5E 5f
0060 | 60 61 62 63 64 65 66 67 68 69 6a 6B 6C 6D 6e 6f
0070 | 70 71 72 73 74 75 76 77 78 79 7A 7b 7C 7d 7E 7f
0080 | 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8d 8e 8f
0090 | 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9d 9e 9f
00a0 | A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 aa AB ac ad AE af
00b0 | B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 Ba bb bc bd be BF
00c0 | C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 ca cb cc cd ce cf
00d0 | D0 D1 D2 D3 D4 D5 D7 D8 D9 da dB DC dd de DF
00e0 | E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 ea eb ec ed EE ef
00f0 | F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 fa fb fc fd Fe FF

[Root @ mini2440 NFS] #

Enter I2C-R in the command line to read the output from the 24c08 device of the Board.

[Root @ mini2440 NFS] #./I2C-R
Open/dev/i2c-0 with 8bit Mode
Reading 256 bytes from 0x0

0000 | 00 01 02 03 04 05 06 07 08 09 0a 0b 0C 0d 0e 0f
0010 | 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1f
0020 | 20 21 22 23 24 25 26 28 29 2a 2B 2C 2D 2E 2f
0030 | 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3f
0040 | 40 41 42 43 44 46 47 48 4A 4B 4C 4D 4E 4f
0050 | 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5d 5E 5f
0060 | 60 61 62 63 64 65 66 67 68 69 6a 6B 6C 6D 6e 6f
0070 | 70 71 72 73 74 75 76 77 78 79 7A 7b 7C 7d 7E 7f
0080 | 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8d 8e 8f
0090 | 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9d 9e 9f
00a0 | A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 aa AB ac ad AE af
00b0 | B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 Ba bb bc bd be BF
00c0 | C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 ca cb cc cd ce cf
00d0 | D0 D1 D2 D3 D4 D5 D7 D8 D9 da dB DC dd de DF
00e0 | E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 ea eb ec ed EE ef
00f0 | F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 fa fb fc fd Fe FF

[Root @ mini2440 NFS] #

Next, port the uda1341 audio driver.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.