Migration environment
1. Host environment: CentOS 5.5 under VMare, 1G memory.
2. Integrated development environment: Eclipse IDE
3. Compilation environment: arm-linux-gcc v4.4.3, arm-none-linux-gnueabi-gcc v4.5.1.
4. Development board: mini2440, 2M nor flash, 128M nand flash.
5.u-boot version: u-boot-2009.08
6. Linux version: linux-2.6.32.2
7. References:
Complete Handbook of Embedded Linux Application Development, edited by Wei Dongshan.
Mini2440 Linux Porting Development Practical Guide
【1】Configure I2C driver in the kernel
Linux-2.6.32.2 provides a complete driver for the I2C interface of S2C2440, so we only need to configure it in the kernel to use it.
Tip: In fact, the default mini2440_defconfig of the Linux-2.6.32.2 kernel has already configured the I2C driver, we just open it here to see the specific configuration path.
Execute make menuconfig in the kernel source code directory to enter the kernel configuration main menu, and select the following submenus in turn:
Device Drivers --->
<*> I2C support --->
I2C Hardware Bus support --->
<*> S3C2410 I2C Driver
We can see that "<*> S3C2410 I2C Driver" has been selected. The S3C2410 here can also be applied to S3C2440 because their I2C port and register definitions are exactly the same. 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】Compilation test
After recompiling, copy uImage to /nfsboot/kernel, then restart the development board. You can see the following startup information in the console terminal:
... ...
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 has an EEPROM chip, AT24C08, mounted on the I2C bus. 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 is modified based on the open source eeprog software. The download address of eeprog software is: http://codesink.org/eeprog.html . The I2c test code is located in the CD/linux example code/examples/i2c. Copy it to the linux host/root/linux-test/codetest directory, then enter the directory and execute make Makefile to generate the test program executable code;
[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 execute the command i2c –w in the serial 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
An error occurred and there is no file called I2C/0.
[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-0 ptyva ttyq 7
kmem ptyvb ttyq8
kmsg ptyvc ttyq9
mem
You can see the device file i2c-0.
To modify the code in the i2c source code, you need to add the writable attribute to it before modifying it
[root@localhost i2c]# chmod a+w eeprog.c
Then open the i2c source file and get eeprog.c, locate around line 87, and modify it as follows:
fprintf(stderr, "Open /dev/i2c-0 with 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 recompile.
[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: Do you want to 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 27 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 45 46 47 48 49 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 d6 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]#
Type in the command line: i2c –r to read the output from the 24C08 device on 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 27 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 45 46 47 48 49 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 d6 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.
Previous article:Linux-2.6.32.2 kernel porting on mini2440 (Thirteen) --- porting UDA1341 audio driver
Next article:Linux-2.6.32.2 kernel transplantation on mini2440 (XI) --- transplantation of SD card driver
Recommended ReadingLatest update time:2024-11-16 12:56
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Free application: Domestic FPGA Gaoyunjia Little Bee Family GW1N Series Development Board
- Taking stock of the college entrance examination experience of Internet tycoons! How many points did you get in the exam?
- Without American EDA software, we can’t make chips?
- 【Share】Flash management tools: FAL (Flash Abstraction Layer) library
- [Awards awarded] Grab the post! Download the TWS headset white paper, write a wonderful review, and win a JD card!
- Constant voltage circuit and constant current circuit composed of operational amplifier and triode
- [RVB2601 Creative Application Development] Record the startup process of the hello world system
- How to initialize the key port of the power button in C language
- About the use and description of idconfig
- [CC1352P Review] The beginning of a little frustration