Open main menu

Wiki-Orange Pi β

Changes

Orange Pi PC 2

9,619 bytes added, 10:53, 23 June 2022
no edit summary
Insert the TF card with written image to OrangePi, turn on the computer then you could enter to Android system.<br>
<br>
 
== '''Orange Pi Driver development''' ==
<br>
 In order to help developers more familiar with Orange Pi, this instruction will make a brief illustration on device driver module and application program. <br>
<br>
Hardware: Orange Pi development board*1, Card reader*1, TF card*1, power supply*1
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img49.png|600px]]</div>
<br>
=== '''Device driver and application programming''' ===
<br>
'''1)Application Program (app.c)'''<br>
<br>
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img50.png|600px]]</div>
<br>
'''2)Driver Program (OrangePi_misc.c)'''<br>
<br>
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img51.png|600px]]</div>
<br>
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img52.png|600px]]</div>
<br>
=== '''Compile device driver''' ===
<br>
Copy the OrangePi_misc.c to the */trunk/kernel/driver/misc:<br>
Enter to */trunk/kernel/driver/misc<br>
Modify Makefile on currently file, shown as following:
<div style="padding-left:200px;">[[文件: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 style="padding-left:200px;">[[文件:Orange-pi-i96-img54.png|800px]]</div>
<br>
Back to the source code directory /OrangePi_i96<br>
$ ./build.sh<br>
Please refer to last section about Linux source code compilation.<br>
Update the new generated module file into Linux system.<br>
It will generated a corresponding .ko file which is generated from the previous compilation of OrangePi_misc.c.<br>
Insert U disk (please note the SD card should have written image) if the SD card is mounted to the directory system of /dev/sdc, then SD card will mount to rootfs, which is /dev/sdc7, and mounted to rootfs partition automatic.
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img55.png|800px]]</div>
<br>
=== '''Compiling method of application''' ===
<br>
Check whether there is the cross compiler, if not, then download and install it.
$ arm-linux-gnueabihf-gcc -v
<div style="padding-left:200px;">[[文件: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>[[文件:Orange-pi-i96-img57.png|800px]]</div>
<br>
Unzip the downloaded file and enter the the directory
<div>[[文件:Orange-pi-i96-img58.png|800px]]</div>
<br>
Check the information after entering bin directory
<div>[[文件:Orange-pi-i96-img59.png|800px]]</div>
<br>
pwd hows the path and export it into the whole project
<div>[[文件: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
<div>[[文件:Orange-pi-i96-img61.png|800px]]</div>
<br>
Add the path to the whole environment variable<br>
<div>[[文件: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>[[文件:Orange-pi-i96-img63.png|800px]]</div>
<br>
$ lsmod To check whether it is loaded
<div>[[文件: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>[[文件: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>
== '''Using Debug tools on OrangePi ''' ==
<br>
Hardware: Orange Pi development board*1, Card reader*1, TF card*1, power supply*1, TTL to USB cable*1
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img66.png|800px]]</div>
<br>
'''TTL to USB cable'''
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img67.png|800px]]</div>
<br>
=== '''Operations on Windows''' ===
<br>
 In order to get more debugging information in the project development process of using OrangePi, OrangePi default support for serial information debugging. For developers, you can simply get the serial port debugging information with the materials mentioned above. The host computer using different serial debugging tools are similar, basically can reference with the following manual for deployment. There are a lot of debugging tools for Windows platform, the most commonly used tool is putty. This section takes putty as an example to explain the deployment.<br>
 Android Baud rate set as 921600<br>
 Linux Baud rate set as 921600<br>
<br>
'''1)Install USB driver on Windows'''<br>
<br>
* Download and unzip the latest version of driver: <br>
 PL2303_Prolific_DriverInstaller_v130.zip
<div>[[文件:Orange-pi-i96-img68.png|800px]]</div>
<br>
* Choose application installation as Administrator
<div>[[文件:Orange-pi-i96-img69.png|800px]]</div>
<br>
* Wait for installation completing
<div>[[文件:Orange-pi-i96-img70.png|800px]]</div>
<br>
'''2)Install putty on Windows'''<br>
<br>
* Download putty installation package
<div>[[文件:Orange-pi-i96-img71.png|800px]]</div>
<br>
* Unzip and install it
<div>[[文件:Orange-pi-i96-img72.png|800px]]</div>
<br>
* Open it after installed, shown as below:
<br>
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img73.png|600px]]</div>
<br>
'''3)Connect method'''<br>
<br>
Use the TTL to the serial port cable, one end connected to OrangePi, the other end connected to PC
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img74.png|600px]]</div>
<br>
'''4)Equipment information acquisition'''
<br>
* Select control panel on Start menu
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img75.png|400px]]</div>
<br>
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img76.png|600px]]</div>
<br>
* Click on the device manager to check the port number
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img77.png|400px]]</div>
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img78.png|400px]]</div>
<br>
'''5)Putty configuration'''
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img79.png|400px]]</div>
<br>
Serial port should set to the corresponding port number (COM5), the speed should set to 921600<br>
<br>
'''6)Start debug'''<br>
Power Orange Pi on and boot it, the serial port will automatic print out debug log.
<div style="padding-left:100px;">[[文件:Orange-pi-i96-img80.png|600px]]</div>
<br>
=== '''Operations on Linux''' ===
<br>
There are Minicom and Kermit serial debugging tools for Linux, this section will take Kermit as an example to have an illustrate.<br>
<br>
'''1)Install Kermit'''
<br>
* Install the Kermit by execute command:
 $ sudo apt-get install ckermit
<div>[[文件:Orange-pi-i96-img81.png|800px]]</div>
<br>
* Configurate Kermit
 $ sudo vi /etc/kermit/kermrc
<div>[[文件:Orange-pi-i96-img82.png|800px]]</div>
<br>
* Add lines:
<div style="padding-left:20px;">
set line /dev/ttyUSB1<br>
set speed 921600<br>
set carrier-watch off<br>
set handshake none<br>
set flow-control none<br>
robust<br>
set file type bin<br>
set file name lit<br>
set rec pack 1000<br>
set send pack 1000<br>
set window 5
</div>
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img83.png|600px]]</div>
<br>
'''2)Connect method for debug'''
<br>
 Use the TTL to the serial port cable, one end connected to OrangePi, the other end connected to PC
<div style="padding-left:200px;">[[文件:Orange-pi-i96-img84.png|600px]]</div>
<br>
'''3)Equipment information acquisition'''<br>
<br>
$ ls /dev/ (Input command in the PC terminal to check the device number of TTL to the serial cable)
<div style="padding-left:100px;">[[文件:Orange-pi-i96-img85.png|800px]]</div>
<br>
* It can be seen from the figure that TTL to the serial port cable is identified as ttyUSB0, configure the /ect/kermit/kermitc file, update the serial port information.<br>
 $ sudo vi /etc/kermit/kermitc
* Set the value of setline into /dev/ttyUSB0
<div style="padding-left:100px;">[[文件:Orange-pi-i96-img86.png|800px]]</div>
<br>
'''4)Start debug'''
<br>
* Input command in the host computer terminal, enter the Kermit mode:
 $ sudo kermit –c
<div style="padding-left:100px;">[[文件:Orange-pi-i96-img87.png|800px]]</div>
<br>
* Power it on and boot Orange Pi, the serial port will automatic print debug log, the account and password ard root/orangepi and orangepi/orangepi
<div style="padding-left:100px;">[[文件:Orange-pi-i96-img88.png|800px]]</div>
<br>
For more information on using the Orange Pi i96, please see the <span style="color:red;">Orange Pi i96 User Manual</span>. (Click to download)