background image

Orange Pi 2G-IOT User Manual

Copy right by Shenzhen Xunlong Software Co., Ltd

www.orangepi.org

www.xunlong.tv

65

2) Driver Program (OrangePi_misc.c)

Содержание Orange Pi 2G-IOT

Страница 1: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv I Orange Pi 2G IOT User Manual...

Страница 2: ...your Linux system 12 6 Write Android into Nand 13 7 Android in no screen ADB mode 16 8 Universal software configuration 18 9 Usage of GPIO and WiringPi 21 10 Connect to Network via GSM 25 11 Use GSM t...

Страница 3: ...ideo A speaker Android Scratch Pretty much anything else because Orange Pi 2G IOT is open source 3 Whom is it for Orange Pi 2G IOT is for anyone who wants to create with technology not just consuming...

Страница 4: ...ensor Supports video capture solution up to 1080p 30fps Audio Input MIC 3 5 mm Jack Video Outputs LCD Audio Output 3 5 mm Jack FM SPEAK Optional Power Source USB OTG input can supply power Battery inp...

Страница 5: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 3 Top view Bottom view...

Страница 6: ...User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 4 Interface instructions 5 GPIO Specifications The CSI Camera Connector is a 24 pin FPC connector which can...

Страница 7: ...gePi 2G IOT CSI CON1 P01 NC CON1 P02 GND CON1 P03 TWI2 SDA PE13 CON1 P04 VCC CSI CON1 P05 TWI2 SCK PE12 CON1 P06 CSI RESET PE15 CON1 P07 CSI VSYNC PE3 CON1 P08 CSI STBY EN PE15 CON1 P09 CSI HSYNC PE2...

Страница 8: ...ity power adapter OTG could use as power supply 3 Keyboard and mouse Any keyboard and mouse with USB port is applicable Keyboard and mouse are high power so a USB concentrator is required 4 TTL to USB...

Страница 9: ...ng the TF card i Download tools for formatting TF card such as TF Formatter could be download from https www sdcard org downloads formatter_4 eula_windows ii Unzip the downloaded files and run setup e...

Страница 10: ...rd on Linux a Inserting the TF card into the computer the capacity of the card must be larger than the operating system image usually requires 8GB or bigger capacity b Formatting the TF card i Run fdi...

Страница 11: ...i Run umount dev sdxx command to uninstall all partitions in TF Card iv Run the command of sudo dd bs 4M if path imagename of dev sdx to write image file and wait for it finished You can run sudo pkil...

Страница 12: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 10 Connect LCD and Camera...

Страница 13: ...rate is 921600 Linux Baud rate is 921600 Serial port uses TTL to USB cable to connect It is the power input interface on the right side for connecting a 5V and at least 2A or bigger than 2A power adap...

Страница 14: ...etting audio setting user setting 1 Wifi setting on serial port In the use of serial login system enter the login password the system will prompt you to use the OrangePi_Settings tool to make some bas...

Страница 15: ...wing command to connect to router sudo OrangePi_Settings 6 Write Android into Nand Orange Pi 2G IOT is supported boot from Nand and also supported update Android in Nand 1 Boot Android from NAND Switc...

Страница 16: ...ing tool could only support working on Windows you could download the tool from official website http www orangepi org downloadresources 4 Install USB driver on Windows Unzip the tool file install the...

Страница 17: ...ange Pi 2G IOT Nand version image http www orangepi org downloadresources 6 Use writing tool Use writing tool to write NAND OrangePi_2G IOT_Toolschain OrangePi_2G IOT_NandUpdate_Tools OrangePi_2G I OT...

Страница 18: ...he cable to the Windows PC Meanwhile the screen will indicate that connect successful and downloading It will take around 3min to finished downloaded after that reboot the system and then the system w...

Страница 19: ...d then the system will be Android If the PC haven t set on adb then please refer to the teaching method of Ubuntu and Windows adb in internet Use adb command in the PC terminal to connect the adb adb...

Страница 20: ...ommended to modify the default orangepi account to your own account for secure sake Take changing into Zhangsan as a sample Steps are as follows a Use root account to login Orange Pi b usermod l zhang...

Страница 21: ...cn ubuntu ports xenial proposed main multiverse restricted universe deb http mirrors ustc edu cn ubuntu ports xenial security main multiverse restricted universe deb http mirrors ustc edu cn ubuntu po...

Страница 22: ...needed extending size partition iii Enter d to delete the partition need to change the size my file system is dev sdb2 which is the 2 partition vi Enter n to build a new partition make sure the initia...

Страница 23: ...he number as you desire Besides if it is boot able partition you want to change note that need to keep the boot able mark in case cannot boot The above illustration is using fdisk and resize2fs to mod...

Страница 24: ...mpile and install the WiringPi after get the latest source code cd WiringOP build OrangePi_2G IOT build OrangePi_2G IOT install d Test WiringPi with gpio command You could use gpio command to test GPI...

Страница 25: ...e to explore wiringPi GPIO to the directory of sys class gpio and set the GPIO mode into mode According to the above WiringPi pin mapping hardware pin number 37 is corresponding to WiringPi pin number...

Страница 26: ...Configure pin wiringPi 26 as input mode orangepi gpio mode 26 in vi Use gpio write pin value to write value of output mode pin for example Configure pin wiringPi 25 as output pin orangepi gpio mode 25...

Страница 27: ...e wiringPi before using GPIO with function wiringPiSetup And then you could configure pin mode into INPUT or OUTPUT And please note that the pin number should corresponding to wiringPi Finally you cou...

Страница 28: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 26 ii Install SIM card Please note the direction of when inserting SIM card...

Страница 29: ...With Serial Port You need to install the tool of minicom on Orange Pi 2G IOT before using SMS Please make sure the board has already connect to wifi You could install minicom with the following comman...

Страница 30: ...ong tv 28 After input the command you will enter the configure interface select Serial port setup Push A to modify Serial Device into dev modem0 Use AT command to send message First you need to input...

Страница 31: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 29 Input command of AT cfun 1 to open Modem full function Initialize serial port...

Страница 32: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 30 Send AT command function AT send message...

Страница 33: ...i 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 31 Detail steps you could refer to the following OrangePi_2G_IOT_GSM_Demo c Here is the reflect of r...

Страница 34: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 32...

Страница 35: ...hen Xunlong Software Co Ltd www orangepi org www xunlong tv 33 Finally you will receive the message from OrangePi 2G IOT OrangePi_2G_IOT_GSM_Demo c OrangePi 2G IOT GSM Demo C Copyright 2017 OrangePi i...

Страница 36: ...1500 Hainan 13010501500 Heilongjiang 13010980500 Jilin 13010911500 Tianjin 13010130500 Hebei 13010180500 Inner Mongolia 13010950500 Shanxi 13010701500 Anhui 13010305500 Xinjiang 13010969500 Qinghai 13...

Страница 37: ...f if str1 NULL strcpy buff str1 if str2 NULL strcat buff str2 if str3 NULL strcat buff str3 write fd buff strlen buff display_message 1 buff memset answer 0 sizeof answer sleep 1 read fd answer sizeof...

Страница 38: ...buff buff i 0x1A buff i 1 r buff i 2 0 memset num2 0 sizeof num2 strcpy num2 86 strcat num2 num1 memset num1 0 sizeof num1 strcpy num1 86 strcat num1 City_Number choice number send fd 1 num2 num1 buff...

Страница 39: ...intf tModem version s n VERSION printf n printf Entry your select n printf 1 Send Message n printf 2 Call Phone n printf 3 Exit n choice getchar switch choice case 1 Send_Message fd break case 2 Call_...

Страница 40: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 38 SIM SIM...

Страница 41: ...org www xunlong tv 39 Linux Linux ssh OrangePi 2G IOT 921600 OrangePi 2G IOT Linux C 1 OrangePi 2G IOT minicom OrangePi 2G IOT OrangePi 2G IOT wifi minicom sudo apt get install minicom OrangePi AP Mod...

Страница 42: ...ge Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 40 sudo minicmo s Serial port setup A Serial Device dev modem0 2 AT AT Modem Modem OK Modem AT D...

Страница 43: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 41 AT DT 86135xxxxxxx 2 C C AT Modem AT AT...

Страница 44: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 42 AT OrangePi_2G_IOT_GSM_Demo c...

Страница 45: ...d www orangepi org www xunlong tv 43 C OrangePi_2G_IOT_GSM_Demo c Demo OrangePi 2G IOT Linux GSM OrangePi 2G IOT Linux Ubuntu Debian Raspbian GSM http www orangepi cn downloadresourcescn Linux GSM SIM...

Страница 46: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 44 SIM SIM Linux Linux ssh OrangePi 2G IOT 921600...

Страница 47: ...al wvdial wvdial etc wvdial conf Dialer defaults ISDN 0 Modem Type Analog Modem Phone 99 1 Stupid Mode 1 Dial Command ATDT Modem dev modem0 Baud 460800 Init1 AT COPS 0 Init2 AT CFUN 1 Init3 AT CGATT 1...

Страница 48: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 46 ifconfig ping...

Страница 49: ...y Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 47 The open source project WiringPi is working on OrangePi 2G IOT This section will introduce how to utilize WiringPi on OrangePi 2G...

Страница 50: ...ngePi make OrangePi OrangePi 4 Details GPIO infromation cd WiringPi example OrangePi cat README md Reality Test OrangePi 2G IOT contains GPIOA GPIOB GPIOC and GPIOD Each of group has 32 gpio The type...

Страница 51: ...rol GPIOC it s not good news In other words on version 0 1 GPIOC only support OUTPUT mode The size of GPIOx group is 32 so we can get gpio map GPIOA 0 31 GPIOB 32 63 GPIOC 64 95 GPIOD 96 127 Each gpio...

Страница 52: ...pinMode PB5 INPUT pinMode PD2 INPUT Get value from GPIO vol digitalRead PA1 vol digitalRead PB5 vol digitalRead PD2 return 0 2 Set gpio as OUTPUT mode All GPIO support OUTPUT mode The demo code as fol...

Страница 53: ...0 11 Use GSM to Connect Network Orange Pi 2G IOT Linux Dist has debugged to connect network via GSM You could first download Linux Dist from official website Debian Ubuntu and Raspbian could support G...

Страница 54: ...nlong tv 52 Download Linux Dist from official website http www orangepi org downloadresources Download and write image into SD card then insert SD card and SIM card into the board You could login the...

Страница 55: ...ww xunlong tv 53 Execute the following command after power on and login to ppp dial up wvdia Tom This command will run at the backstage for dial up after dial up access you could use ping and ifconfig...

Страница 56: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 54...

Страница 57: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 55...

Страница 58: ...directory of opt Modify the permission of jdk 6u31 linux x64 bin with following command sudo chmod 755 jdk 6u31 linux x64 bin Install jdk1 6 jdk 6u31 linux x64 bin Configuration multi Java version co...

Страница 59: ...thon markdown libxml2 utils xsltproc zlib1g dev i386 sudo ln s usr lib i386 linux gnu mesa libGL so 1 usr lib i386 linux gnu libGL so 3 Download the Source Package and Unzip it Download website http w...

Страница 60: ...urce code Use command to switch to Android source code cd trunk Import development variables source build envsetup sh Select project lunch If boot from TF card select slt userdebug then select NollecA...

Страница 61: ...hub you could download from github Compile Linux would require you work under Linux environment We would recommend you use Ubuntu 16 04 of Linux PC Download Linux source code You could download Linux...

Страница 62: ...ght by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 60 Select Build system with kernel uboot rootfs on main functional interface and use Enter key And then select OrangePi 2G IOT w...

Страница 63: ...his directory contains both Linux source code and scripts Compile Linux Execute the following command after enter into directory of OrangePiRDA build sh The script is is an automatic script you could...

Страница 64: ...2 You will enter into the main interface after entering password select what you are going to do This version is only support the above three options After selecting the corresponding option the syste...

Страница 65: ...here is already marked the location of generated kernel you only need to copy the generated zImage into first partition of SD card and replace zImage inside Till now the kernel has been updated And th...

Страница 66: ...Driver development In order to help developers more familiar with Orange Pi this instruction will make a brief illustration on device driver module and application program Hardware Orange Pi developm...

Страница 67: ...Orange Pi 2G IOT User Manual Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 65 2 Driver Program OrangePi_misc c...

Страница 68: ...know the user s configuration of the kernel 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 configuratio...

Страница 69: ...to rootfs partition automatic Copy the directory file trunk out target product slt NollecA9V2VV8810P_ext4 obj KERNEL out target product slt NollecA9V2VV8810P_ext4 obj KERNEL modules lib modules 3 10...

Страница 70: ...hows that the file can only read need to modify permissions chmod 755 etc environment Add the path to the whole environment variable Compile the application with cross compiler arm linux gnueabihf gcc...

Страница 71: ...nd load module driver module to the development board first insmod lib modules orangepi ko lsmod To check whether it is loaded ll dev orangepimisc Miscellaneous equipment automatically generated devic...

Страница 72: ...mation 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 m...

Страница 73: ...et as 921600 Linux Baud rate set as 921600 1 Install USB driver on Windows Download and unzip the latest version of driver PL2303_Prolific_DriverInstaller_v130 zip Choose application installation as A...

Страница 74: ...y right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 72 Open it after installed shown as below 3 Connect method Use the TTL to the serial port cable one end connected to OrangeP...

Страница 75: ...Copy right by Shenzhen Xunlong Software Co Ltd www orangepi org www xunlong tv 73 4 Equipment information acquisition Select control panel on Start menu Click on the device manager to check the port...

Страница 76: ...to the corresponding port number COM5 the speed should set to 115200 6 Start debug Power Orange Pi on and boot it the serial port will automatic print out debug log 2 Operations on Linux There are Mi...

Страница 77: ...tall the Kermit by execute command sudo apt get install ckermit Configurate Kermit sudo vi etc kermit kermrc Add lines set line dev ttyUSB1 set speed 921600 set carrier watch off set handshake none se...

Страница 78: ...angePi the other end connected to PC 3 Equipment information acquisition ls dev Input command in the PC terminal to check the device number of TTL to the serial cable It can be seen from the figure th...

Страница 79: ...d www orangepi org www xunlong tv 77 4 Start debug Input command in the host computer terminal enter the Kermit mode sudo kermit c Power it on and boot Orange Pi the serial port will automatic print d...

Отзывы: