Documente Academic
Documente Profesional
Documente Cultură
4. OTG USB 17
1
1. GPIO Settings in Odroid:
odroid@odroid64:~$ cd ~/kmani
odroid@odroid64:~/kmani$ git clone https://github.com/hardkernel/WiringPi
odroid@odroid64:~/kmani$ ls
wiringPi.zip
odroid@odroid64:~/kmani/toolchain$ cd wiringPi/
odroid@odroid64:~/kmani/toolchain/wiringPi$ ./build
2
Using Command
Set the output mode for gpio pin(Example Pin number:249)
odroid@odroid64:~$ gpio -g mode 249 output
In pin No. 249 (Export GPIO) value is High(1) and now write the value (low) in pin No. 249 (Export
GPIO)
3
Step 4: Reboot Now and verify by reading all gpio pins configued as you need
Step 1:
odroid@odroid64:~/$sudo nano gpiosetup.c
#include <stdio.h>
#include <wiringPi.h>
#define RELAY_ENA 7
#define PSU1_STATUS 0
#define PSU2_STATUS 1
#define SMBALERT_1 2
#define OVR_1 3
#define THERM_1 4
#define FAN_FAULT_1 5
#define SMBALERT_2 12
#define OVR_2 13
#define THERM_2 6
#define FAN_FAULT_2 14
#define GPIO_UE 10
#define GPIO_GSM 11
#define SBC_SLED 21
wiringPiSetup () ;
pinMode (RELAY_ENA, OUTPUT) ;
pinMode (PSU1_STATUS, INPUT) ;
4
pinMode (PSU2_STATUS, INPUT) ;
pinMode (SMBALERT_1, INPUT) ;
pinMode (OVR_1, INPUT) ;
pinMode (THERM_1, INPUT) ;
pinMode (FAN_FAULT_1, INPUT) ;
pinMode (SMBALERT_2, INPUT) ;
pinMode (OVR_2, INPUT) ;
pinMode (THERM_2, INPUT) ;
pinMode (FAN_FAULT_2, INPUT) ;
pinMode (GPIO_UE, OUTPUT) ;
pinMode (GPIO_GSM, OUTPUT) ;
pinMode (SBC_SLED, OUTPUT) ;
Step 2:
Save the File
Step 3:
Compile using gcc
Step 4:
Now run the Executable
5
1.3 ADC Configuration through C code:
Using C file:
Step 1:
odroid@odroid64:~/$ nano adc.c
#include <stdio.h>
#include <wiringPi.h>
Step 2:
Save the File
Step 3:
Compile using gcc
Step 4:
Now run the Executable
odroid@odroid64:~/$sudo ./adc_out
6
2. Interfacing Odroid-C2 with Secondary Ethernet (cyusb3610)
odroid@odroid64:~$ su
Password:
root@odroid64:/home/odroid# [Default Password: Odroid]
Install Git:
root@odroid64:~# apt-get install git
Step 3: Set Priority for gcc and make high priority for gcc-4.9
root@odroid64:~# gcc -v
Using built-in specs.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
gcc version 4.9.3 (Ubuntu/Linaro 4.9.3-13ubuntu2)
root@odroid64:~# cd /usr/src
root@odroid64:/usr/src# git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y
Cloning into 'linux'...
remote: Counting objects: 51208, done.
remote: Compressing objects: 100% (47984/47984), done.
remote: Total 51208 (delta 3707), reused 20881 (delta 2572), pack-reused 0
Receiving objects: 100% (51208/51208), 139.38 MiB | 2.96 MiB/s, done.
7
Resolving deltas: 100% (3707/3707), done.
Checking connectivity... done.
Checking out files: 100% (48395/48395), done.
root@odroid64:/usr/src# cd linux/
root@odroid64:/usr/src/linux#
Step 9: Copy the compiled files to the boot drive and reboot
root@odroid64:/usr/src/linux#cp -f arch/arm64/boot/Image
arch/arm64/boot/dts/meson64_odroidc2.dtb /media/boot/
root@odroid64:/usr/src/linux#sync
root@odroid64:/usr/src/linux#reboot
http://www.cypress.com/documentation/software-and-drivers/ez-usb-gx3-software-and-drivers
[Note: Signin Required]
Step 11: Extract the driver in Downloads Folder
odroid@odroid64:~/Downloads$ ls
Linux Driver Source Code.zip
odroid@odroid64:~/Downloads$ ls
cyusb3610_driver_source.tar.gz Linux Driver Source Code.zip
8
Step 12: Now run make command in the following Directory
odroid@odroid64:~/Downloads$ make
make -C /lib/modules/3.14.79+/build SUBDIRS=/home/odroid/Downloads modules
make[1]: Entering directory '/usr/src/linux'
CC [M] /home/odroid/Downloads/cyusb3610.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/odroid/Downloads/cyusb3610.mod.o
LD [M] /home/odroid/Downloads/cyusb3610.ko
make[1]: Leaving directory '/usr/src/linux'
Step 13: Now run make install command in the following Directory
odroid@odroid64:~/Downloads$ifconfig
[Note: Reboot now, GPIO_UE pin should be Active High]
9
3. Interfacing SIM7600I -USB Modem
# MUST CHANGE: Change the -T parameter value **** to your network's APN value.
# For example if your APN is 'internet' (without quotes), the line would look like:
# connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T internet"
connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T airtelgprs.com"
# MUST CHANGE: Uncomment the appropriate serial device for your platform below.
# For Ubuntu use /dev/ttyUSB3 by uncommenting the line below:
/dev/ttyUSB3
10
➢ Step 4: Create DNS configuration file in /etc/resolv.conf.head path
root@odroid64:~# nano /etc/resolv.conf.head
[Note:Paste the below content and save the file ]
#OpenDns Servers
nameserver 208.67.222.222
nameserver 208.67.220.220
➢ Step 6: Make Confirmation [Note :It’s not a issues if this command show binary
executable error just go through for next step ]
1.root@odroid64:~# cat /var/log/syslog | grep pppd
Apr 27 15:38:32 odroid64 pppd[7120]: pppd 2.4.7 started by root, uid 0
Apr 27 15:38:45 odroid64 pppd[7120]: Connect script failed
Apr 27 15:39:04 odroid64 pppd[7138]: pppd 2.4.7 started by root, uid 0
Apr 27 15:39:04 odroid64 pppd[7138]: Device ttyUSB3 is locked by pid 7120
Apr 27 15:39:34 odroid64 pppd[7138]: Device ttyUSB3 is locked by pid 7120
Apr 27 15:39:38 odroid64 pppd[7120]: tcsetattr: Interrupted system call (line 1058)
Apr 27 15:39:38 odroid64 pppd[7120]: Hangup (SIGHUP)
Apr 27 15:39:38 odroid64 pppd[7120]: Failed to open /dev/ttyUSB3: No such device
Apr 27 15:40:05 odroid64 pppd[7138]: Serial connection established.
Apr 27 15:40:05 odroid64 pppd[7138]: Using interface ppp0
Apr 27 15:40:05 odroid64 pppd[7138]: Connect: ppp0 <--> /dev/ttyUSB3
Apr 27 15:40:06 odroid64 pppd[7138]: PAP authentication succeeded
Apr 27 15:40:06 odroid64 pppd[7138]: Could not determine remote IP address:
defaulting to 10.64.64.64
Apr 27 15:40:06 odroid64 pppd[7138]: not replacing default route to wlp2s0
[192.168.1.6]
Apr 27 15:40:06 odroid64 pppd[7138]: local IP address 100.81.207.67
Apr 27 15:40:06 odroid64 pppd[7138]: remote IP address 10.64.64.64
Apr 27 15:40:06 odroid64 pppd[7138]: primary DNS address 203.145.160.5
Apr 27 15:40:06 odroid64 pppd[7138]: secondary DNS address 59.144.144.46
Apr 27 15:40:07 odroid64 pppd[7348]: pppd 2.4.7 started by root, uid 0
11
Apr 27 15:40:07 odroid64 pppd[7348]: Device ttyUSB3 is locked by pid 7138
Apr 27 15:40:08 odroid64 pppd[7120]: Device ttyUSB3 is locked by pid 7138
Apr 27 15:40:24 odroid64 pppd[7381]: no device specified and stdin is not a tty
12
Apr 27 15:40:05 odroid64 chat[7284]:
AT+CGDCONT=1,"IP","airtelgprs.com","",0,0^M^M
Apr 27 15:40:05 odroid64 chat[7284]: OK
Apr 27 15:40:05 odroid64 chat[7284]: -- got it
Apr 27 15:40:05 odroid64 chat[7284]: send (ATD*99#^M)
Apr 27 15:40:05 odroid64 chat[7284]: timeout set to 22 seconds
Apr 27 15:40:05 odroid64 chat[7284]: expect (CONNECT)
Apr 27 15:40:05 odroid64 chat[7284]: ^M
Apr 27 15:40:05 odroid64 chat[7284]: ATD*99#^M^M
Apr 27 15:40:05 odroid64 chat[7284]: CONNECT
Apr 27 15:40:05 odroid64 chat[7284]: -- got it
Apr 27 15:40:05 odroid64 chat[7284]: send (^M)
3.root@odroid64:~# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:17294 errors:0 dropped:0 overruns:0 frame:0
TX packets:17294 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1480554 (1.4 MB) TX bytes:1480554 (1.4 MB)
ppp0 Link encap:Point-to-Point Protocol
inet addr:100.81.207.67 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:236 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:3847 (3.8 KB) TX bytes:15805 (15.8 KB)
➢ Step 7: ping with Google public DNS 8.8.8.8
root@odroid64:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=47 time=111 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=47 time=93.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=47 time=97.0 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=47 time=101 ms
13
➢ Step 8: Get your Public IP [Optional]
www.whatismyip.com
root@odroid64:~#poff otdrmodem
14
For Terminate the Call:
1. Command:at+cvhu=0
Response: OK
2. Command:ath
Response: VOICE CALL: END: 000212
OK
For Reading Message:
1. First check the Preferred Message Storage:
Command: at+cpms?
Response: +CPMS: "SM",0,20,"SM",0,20,"SM",0,20
OK
2. Change the Preferred Message Storage:
Command: at+cpms="ME","SM","SM"
Response: +CPMS:4,23,0,20,0,20
OK
Note: 13 - indicates the four messges(0-3) are there.
23 -indicates the total message storage.
3.Set Select SMS message format:
Command: at+cmgf=1
Response: OK
4. Read all the messages:
Command: at+cmgl="all"
Response: +CMGL: 0,"REC
READ","+919677479066","","18/04/20,11:07:25+22"
You have 1 missed call(s) from +919677479066 .Last call: 20-04-
2018 11:05
+CMGL: 1,"REC
READ","+919677479066","","18/04/20,13:20:00+22"
You have 1 missed call(s) from +919677479066 .Last call: 20-04-
2018 13:17
+CMGL: 2,"REC
READ","+919677479066","","18/04/23,11:35:52+22"
Test msg
15
5.Read the message in particular memory location:
Command: at+cmgr=3;
Response: +CMGR: "REC
READ","+919677479066","","18/04/23,11:36:09+22"
Hello
OK
For sending the message:
1. Set Select SMS message format:
Command: at+cmgf=1
Response: OK
2.Sending Message:
Command Format: at+cmgs=”<Mobile Number>”
Command: at+cmgs="8883779486"
Note: Press Enter and type the message content then press esc or ctrl+z for exit and
send.e.g:
> test message from sim7600i
+CMGS: 153
Response: OK
16
4. OTG USB :
➢ Step 1:
Check whether g_mass_storage.ko file available or not.
Location:/lib/modules/`uname -r`/kernel/drivers/usb/gadget/
➢ Step 2:
Run the command In Odroid C2
Command 1:
Check the /dev/mmcblk0p1 is mounted or not by using mount command.
odroid@odroid64:~$mount
And it shows /dev/mmcblk0p1 on /media/boot type vfat
(rw,nosuid,nodev,flush,umask=000)
Command 2:
Unmount /dev/mmcblk0p1 by using umount command.
odroid@odroid64:~$sudo umount /dev/mmcblk0p1
Command 3:
Add /dev/mmcblk0p1 into g_mass_storage by using modprobe command.
odroid@odroid64:~$sudo modprobe g_mass_storage file=/dev/mmcblk0p1
➢ Step 3:
Connect the USB Cable with Host PC and boot partition memory will automatically detected.
17
5.Interfacing Odroid-C2 with AMC6821
odroid@odroid64:~$ su
Password: [Default Password: Odroid]
root@odroid64:/home/odroid#
root@odroid64:/usr/src/linux#modprobe aml_i2c
root@odroid64:/usr/src/linux#modprobe i2c-dev
root@odroidc2:/usr/src/linux# i2cdetect -y 2
[Note:2-i2c Device Channel Number]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- 4d -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@odroidc2:/usr/src/linux#nano /etc/modules
[Paste the following content and save it by Ctrl+x and Y and Enter]
aml_i2c
i2c-dev
18
5.1 Reading Temperature using AMC6821
root@odroidc2:/usr/src/linux# i2cdetect -y 2
[Note:2-i2c Device Channel Number]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- 4d -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Step 2: Enable START bit of 0x18 device’s Configuration Register 0x00 set to 0xd5
Step 3: Read Local Temp Data 0x18 device’s from Register 0x0A(Local MSB)
Step 4: Read Remote Temp Data 0x18 device’s from Register 0x0B(Remote MSB)
[Note: Should Read in the Following Order Only to get 0.125°C Resolution ]
odroid@odroid64:~$ i2cget -y 2 0x18 0x06
0x21
-> [00100001= 001 for LocalTemp and 001 for RemoteTemp] (Local and Remote LSB)
odroid@odroid64:~$ i2cget -y 2 0x18 0x0A
0x21
->Temp=33.125 (Local MSB)
odroid@odroid64:~$ i2cget -y 2 0x18 0x0B
0x21
-> Temp=33.125 (Remote MSB)
[Note: To measure 0x4d device’s temperature repeat step 2- 5 with Device Address 0x4d instead
of 0x18] and also Refer AMC6821 Data Sheet
19
5.2 Fan Control using AMC6821
root@odroidc2:/usr/src/linux# i2cdetect -y 2
[Note:2-i2c Device Channel Number]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- 4d -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Step 2: Enable Software RPM Mode in 0x18 device’s Configuration Reg 0x00 set
to 0xb5
Step 3: Change the PWM Bits in 0x18 device’s Fan Characteristics Reg in 0x20
set to 0x3d / 0x1d /0x05 / etc
[Note: Should Read in the Following Order Lbyte First then Hbyte]
Step 4: Read Tach Lbyte Data of 0x18 device’s from Register 0x08
Step 5: Read Tach Hbyte Data 0x18 device’s from Register 0x09
[Note: To measure 0x4d device’s fan control repeat step 2-4 with Device Address 0x4d instead of
0x18]
20