8,367
edits
Changes
no edit summary
You could insert SD card into Orange pi, and make the jumper like the following, after booting, it would enter into Linux.
<div style="padding-left:200px;">[[File:Orange-pi-2g-iot-img62.png|200px]]</div>
<br>
== '''Orange Pi Driver development''' ==
<br>
γIn order to help developers become more familiar with OrangePi, this manual describes how to use simple device driver modules and applications on the development board. <br>
<br>
Hardware: Orange Pi development board*1, Card reader*1, TF card*1, power supply*1
<div style="padding-left:200px;">[[File:Orange-pi-zero-img4.png|600px]]</div>
<br>
=== '''Device driver and application programming''' ===
<br>
'''1)Application Program (app.c)'''<br>
<br>
<div>[[File:Orange-pi-i96-img50.png|600px]]</div>
<br>
'''2)Driver Program (OrangePi_misc.c)'''<br>
<br>
<div>[[File:Orange-pi-i96-img51.png|600px]]</div>
<br>
<div>[[File:Orange-pi-i96-img52.png|600px]]</div>
<br>
=== '''Compile device driver''' ===
<br>
Copy the OrangePi_misc.c to the */lichee/linux-3.4/driver/misc directory:<br>
<div>[[File:Orange-pi-pc2-img83.png|800px]]</div>
<br>
Enter to */lichee/linux-3.4/drivers/misc/, and modify makefile<br>
<div>[[File:Orange-pi-pc2-img84.png|800px]]</div>
<br>
Modify Makefile on currently file, shown as following:
<div>[[File:Orange-pi-i96-img53.png|800px]]</div>
<br>
There is Kconfig on the same sibling folders with Makefile. Each Kconfig respectively describes the the source directory file related kernel configuration menu. In the kernel configuration making menuconfig, it read from the Kconfig config menu and the user configuration saved to the config. In the kernel compile, the main Makefile by calling this.Config could know the user's configuration of the kernel.<br>
Kconfig is corresponding to the kernel configuration menu. Add a new driver to the kernel source code, you can modify the Kconfig to increase the configuration menu for your drive, so you can choose whether the menuconfig driver was compiled or not.
<div>[[File:Orange-pi-i96-img54.png|800px]]</div>
<br>
Back to the source code directory:<br>
<div>[[File:Orange-pi-pc2-img85.png|800px]]</div>
<br>
$ ./build.sh<br>
After compiled the kernel, there will be an orangepi_misc.ko file generated on the directory of lichee/linux-3.4/output/lib/modules/3.4.39<br>
<div>[[File:Orange-pi-prime-img16.png|400px]]</div>
<br>
There is a .ko module which generated after compiled of OrangePi_misc.c on */lichee/linux-3.4/output/lib/modules/3.4.39/ <br>
<div>[[File:Orange-pi-pc2-img88.png|800px]]</div>
<br>
Insert U disk (please note the SD card should have been written image) if the SD card system is mounted to the directory / dev/ sdb, SD card will have two sub mount points, respectively are / dev / sdb1 and /dev/sdb2. Two partition of SD card will automatically mount to the PC /media/ directory, the first partition is the boot partition and the second partition is the rootfs partition.
<div>[[File:Orange-pi-i96-img55.png|800px]]</div>
<br>
Copy the OrangePi_misc.ko file to /media/*/lib/modules/3.4.39.<br>
$ cp OrangePi_misc.ko /media/*/lib/modules/3.4.39<br>
<br>
=== '''Cross compiler Application Program''' ===
<br>
Here will take arm-linux-gnueabihf-gcc as an example. Check whether there is the cross compiler, if not, then download and install it.<br>
$ arm-linux-gnueabihf-gcc -v
<div>[[File:Orange-pi-i96-img56.png|800px]]</div>
<br>
While compiling the application, you will fill that you need the cross compiler arm-linux-gnueabihf-gcc, download and install it.
<div>[[File:Orange-pi-i96-img57.png|800px]]</div>
<br>
Unzip the downloaded file and enter the the directory
<div>[[File:Orange-pi-i96-img58.png|800px]]</div>
<br>
Check the information after entering bin directory
<div>[[File:Orange-pi-i96-img59.png|800px]]</div>
<br>
pwd hows the path and export it into the whole project
<div>[[File:Orange-pi-i96-img60.png|800px]]</div>
<br>
$ ll /etc/environment shows that the file can only read, need to modify permissions <br>
$ chmod 755 /etc/environment<br>
Modify permission
<div>[[File:Orange-pi-i96-img61.png|800px]]</div>
<br>
Add the path to the whole environment variable<br>
<div>[[File:Orange-pi-i96-img62.png|800px]]</div>
<br>
Compile the application with cross compiler<br>
<br>
$ arm-linux-gnueabihf-gcc app.c βo aq<br>
There will be an ap application generated in the directory, copy it to the development board file system(on the rootfs directory of /home/orangepi/)<br>
$ cp aq /media/*/home/orangepi/<br>
<br>
=== '''Running driver and application''' ===
<br>
Removed the SD card and inserted it into the development board and power on.<br>
You need to switch to root users and load module driver module to the development board first.<br>
$ insmod /lib/modules/orangepi.ko
<div>[[File:Orange-pi-i96-img63.png|800px]]</div>
<br>
$ lsmod To check whether it is loaded
<div>[[File:Orange-pi-i96-img64.png|800px]]</div>
<br>
$ ll /dev/orangepimisc( Miscellaneous equipment automatically generated device files, the specific look at the driver code)
<div>[[File:Orange-pi-i96-img65.png|800px]]</div>
<br>
Executive application (note the use of the application, check the code for specify)<br>
$ ./aq /dev/orangepimisc
<br>
<br>