Sunteți pe pagina 1din 20

INDEX

Sl.No. Content Page No.


1. GPIO Settings in Odroid 2
1.1 Default GPIO Configuraion through Script 3
1.2 Default GPIO Configuration through C-Code 4
1.3 ADC Configuration through C code 6
1.4 Get ADC value using command 6
2. Interfacing Odroid-C2 with Secondary Ethernet (cyusb3610) 7
3. Interfacing SIM7600I -USB Modem 10
3.1 AT Commands for SIM7600I 14

4. OTG USB 17

5. Interfacing Odroid-C2 with AMC6821 18


5.1 Reading Temperature using AMC6821 19
5.2 Fan Control using AMC6821 20

1
1. GPIO Settings in Odroid:

Step 1 : Download wiringPi

odroid@odroid64:~$ cd ~/kmani
odroid@odroid64:~/kmani$ git clone https://github.com/hardkernel/WiringPi
odroid@odroid64:~/kmani$ ls
wiringPi.zip

Step 2: Install wiringPi

odroid@odroid64:~/kmani$ mkdir toolchain


odroid@odroid64:~/kmani$ unzip wiringPi -d /home/odroid/kmani/toolchain/
odroid@odroid64:~/kmani$ cd toolchain/
odroid@odroid64:~/kmani/toolchain$ ls
wiringPi

odroid@odroid64:~/kmani/toolchain$ cd wiringPi/
odroid@odroid64:~/kmani/toolchain/wiringPi$ ./build

Step 3: GPIO settings


Set mode( Input/Output) for GPIO pin and write/read the value in GPIO pin
[Refer the GPIO pin number from diagram]

2
Using Command
Set the output mode for gpio pin(Example Pin number:249)
odroid@odroid64:~$ gpio -g mode 249 output

Then read the value in pin number 249


odroid@odroid64:~$ gpio -g read 249
1

In pin No. 249 (Export GPIO) value is High(1) and now write the value (low) in pin No. 249 (Export
GPIO)

odroid@odroid64:~$ gpio -g write 249 0


odroid@odroid64:~$ gpio -g read 249
0
odroid@odroid64:$
Now the value in pin 249 changes from high to low.

1.1 Default GPIO Configuration through Script:

Step 1:Switch to Root User


odroid@odroid64:~$ su

Password: [Default Password: odroid]


root@odroid64:/home/odroid#

Step 2: open /etc/rc.local using nano editior


root@odroid64:/home/odroid#nano /etc/rc.local

Step 3: Configure default GPIO Settings

[Note: Sample GPIO Settings Modify as your need]


[Paste the following content and save it by Ctrl+x and Y and Enter]

gpio -g mode 229 output


gpio -g write 229 1

gpio -g mode 225 output


gpio -g write 225 1

gpio -g mode 249 output


gpio -g write 249 0

#gpio -g mode 228 output


#gpio -g write 228 1

gpio -g mode 214 output


gpio -g write 214 0

3
Step 4: Reboot Now and verify by reading all gpio pins configued as you need

odroid@odroid64:~$ gpio readall

1.2. Default GPIO Configuration through C-Code:

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

int main (void)


{
printf ("GPIO_Default program\n") ;

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) ;

digitalWrite (RELAY_ENA, LOW) ; // Off


digitalWrite (GPIO_UE, HIGH) ; // On
digitalWrite (GPIO_GSM, HIGH) ; // On
digitalWrite (SBC_SLED, HIGH) ; // On
return 0 ;
}

Step 2:
Save the File

Step 3:
Compile using gcc

odroid@odroid64:~/$ gcc gpiosetup.c -o gpiosettings -lpthread -lwiringPi

Step 4:
Now run the Executable

odroid@odroid64:~/$ sudo ./gpiosettings

5
1.3 ADC Configuration through C code:

Using C file:

Step 1:
odroid@odroid64:~/$ nano adc.c
#include <stdio.h>
#include <wiringPi.h>

#define ADCIN0 0 // ADC.AIN0


#define ADCIN1 1 // ADC.AIN1

int main (void)


{
float adcValue1=0,adcValue2=0;
printf ("Read ADC Value from Channel0 and Channel1\n") ;
wiringPiSetup () ;
for (;;)
{
adcValue1=(0.001759531*analogRead(ADCIN0)); // 1.8 / 1023 = 0.001759531
delay (500) ;
adcValue2=(0.001759531*analogRead(ADCIN1));
printf("Value in ADC.AIN0 is %fV\tValue in ADC.AIN1 is %fV\n",adcValue1,adcValue2);
delay (500) ;
}
return 0 ;
}

Step 2:
Save the File

Step 3:
Compile using gcc

odroid@odroid64:~/$ gcc adc.c -o adc_out -lpthread -lwiringPi

Step 4:
Now run the Executable

odroid@odroid64:~/$sudo ./adc_out

1.4 Get ADC value using command:

[ADC0 (pin no. 40) -> Ground]


odroid@odroid64:~$ cat /sys/class/saradc/ch0
5
[ADC1 (pin no. 37) -> 1.8V]
odroid@odroid64:~$ cat /sys/class/saradc/ch1
1022

6
2. Interfacing Odroid-C2 with Secondary Ethernet (cyusb3610)

Step 1: Switch to Root User

odroid@odroid64:~$ su
Password:
root@odroid64:/home/odroid# [Default Password: Odroid]

Step 2: Install Depended Packages ( git,gcc )

root@odroid64:~# apt-get update


root@odroid64:~# apt-get install lzop build-essential libncurses5-dev

Install Git:
root@odroid64:~# apt-get install git

Install alternative gcc-4.9 :


root@odroid64:~# apt-get install gcc-4.9

Step 3: Set Priority for gcc and make high priority for gcc-4.9

root@odroid64:~# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10


root@odroid64:~# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
root@odroid64:~# update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).
Selection Path Priority Status
------------------------------------------------------------
*0 /usr/bin/gcc-4.9 20 auto mode
1 /usr/bin/gcc-4.9 20 manual mode
2 /usr/bin/gcc-5 10 manual mode
Press <enter> to keep the current choice[*], or type selection number: ^C
root@odroid64:~#

Step 4: Check gcc-4.9 is selected by checking gcc version:

root@odroid64:~# gcc -v
Using built-in specs.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
gcc version 4.9.3 (Ubuntu/Linaro 4.9.3-13ubuntu2)

Step 5: Download the kernel source files from git:

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.

Step 6: Change to linux direcory

root@odroid64:/usr/src# cd linux/
root@odroid64:/usr/src/linux#

Step 7: Enabling Driver Support for (AMC6821) through following steps

root@odroid64:/usr/src/linux# make odroidc2_defconfig


#
# configuration written to .config
#

Step 8: Now make and Install the modules

root@odroid64:/usr/src/linux# make -j4


[Note:it may take upto 60 Mins. For the first time]
root@odroid64:/usr/src/linux# make modules_install

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

Step 10: Download the Drivers from the below link

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$ unzip Linux\ Driver\ Source\ Code.zip


Archive: Linux Driver Source Code.zip
extracting: cyusb3610_driver_source.tar.gz

odroid@odroid64:~/Downloads$ ls
cyusb3610_driver_source.tar.gz Linux Driver Source Code.zip

odroid@odroid64:~/Downloads$ tar -xzf cyusb3610_driver_source.tar.gz


odroid@odroid64:~/Downloads$ ls
cyusb3610.c cyusb3610.h Makefile
cyusb3610_driver_source.tar.gz Linux Driver Source Code.zip readme

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$ make install


su -c "cp -v cyusb3610.ko /lib/modules/3.14.79+/kernel/drivers/net/usb && /sbin/depmod -a"
Password:
'cyusb3610.ko' -> '/lib/modules/3.14.79+/kernel/drivers/net/usb/cyusb3610.ko'

Step 14: Reboot and run ifconfig command (usbnet is available)

odroid@odroid64:~/Downloads$ifconfig
[Note: Reboot now, GPIO_UE pin should be Active High]

Check usbnet0 is present using ifconfig command

9
3. Interfacing SIM7600I -USB Modem

➢ Step 1: Switch into root user


odroid@odroid64:~$ su
Password: [Note: Enter password as : odroid]
root@odroid64:/home/odroid# cd
root@odroid64:~#

➢ Step 2: Disable the Mobile Broadband connection and WIFI connection:


root@odroid64:~# nmcli radio wwan off
root@odroid64:~# nmcli radio wifi off

➢ Step 3: Create otdrmodem configuration file in /etc/ppp/peers path


root@odroid64:~# nano /etc/ppp/peers/otdrmodem
[Note:1. Paste the below content and save the file , 2.Change the APN name as per your
provider ( Example: for Airtel -> airtelgprs.com )]
# Example PPPD configuration for OTDR Modem GPRS connection on Odroid C2.

# 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

# Speed of the serial line.


115200

# Assumes that your IP address is allocated dynamically by the ISP.


noipdefault

# Try to get the name server addresses from the ISP.


usepeerdns

# Use this connection as the default route to the internet.


defaultroute

# Makes PPPD "dial again" when the connection is lost.


persist

# Do not ask the remote to authenticate.


noauth

# No hardware flow control on the serial link with OTDR Modem


nocrtscts

# No modem control lines with OTDR Modem.


local

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 5: Start OTDR Modem


root@odroid64:~#pon otdrmodem
[Note: Before pon connect the modem with Odroid C2]

➢ 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

2.root@odroid64:~# cat /var/log/syslog | grep chat


Apr 27 15:40:04 odroid64 chat[7284]: abort on (BUSY)
Apr 27 15:40:04 odroid64 chat[7284]: abort on (VOICE)
Apr 27 15:40:04 odroid64 chat[7284]: abort on (NO CARRIER)
Apr 27 15:40:04 odroid64 chat[7284]: abort on (NO DIALTONE)
Apr 27 15:40:04 odroid64 chat[7284]: abort on (NO DIAL TONE)
Apr 27 15:40:04 odroid64 chat[7284]: abort on (NO ANSWER)
Apr 27 15:40:04 odroid64 chat[7284]: abort on (DELAYED)
Apr 27 15:40:04 odroid64 chat[7284]: abort on (ERROR)
Apr 27 15:40:04 odroid64 chat[7284]: abort on (+CGATT: 0)
Apr 27 15:40:04 odroid64 chat[7284]: send (AT^M)
Apr 27 15:40:04 odroid64 chat[7284]: timeout set to 12 seconds
Apr 27 15:40:04 odroid64 chat[7284]: expect (OK)
Apr 27 15:40:04 odroid64 chat[7284]: ^M
Apr 27 15:40:04 odroid64 chat[7284]: OK
Apr 27 15:40:04 odroid64 chat[7284]: -- got it
Apr 27 15:40:04 odroid64 chat[7284]: send (ATH^M)
Apr 27 15:40:05 odroid64 chat[7284]: expect (OK)
Apr 27 15:40:05 odroid64 chat[7284]: ^M
Apr 27 15:40:05 odroid64 chat[7284]: ^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 (ATE1^M)
Apr 27 15:40:05 odroid64 chat[7284]: expect (OK)
Apr 27 15:40:05 odroid64 chat[7284]: ^M
Apr 27 15:40:05 odroid64 chat[7284]: ^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
(ATCGDCONT=1,"IP","airtelgprs.com","",0,0^M)
Apr 27 15:40:05 odroid64 chat[7284]: expect (OK)
Apr 27 15:40:05 odroid64 chat[7284]: ^M

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

➢ Step 9: Stop OTDR Modem [Optional]

root@odroid64:~#poff otdrmodem

3.1 AT Commands for SIM7600I:

Note: select Port /dev/ttyUSB2 in GtkTerm.


For checking device connection:
Command: at
Response: OK

For displaying the product identification information:


Command: ati
Response: Manufacturer: SIMCOM INCORPORATED
Model: SIMCOM_SIM7600I
Revision: SIM7600M22_V1.1
IMEI: 861477031962838
+GCAP: +CGSM
For Dialing:
Command Format: atd<MobileNumber>;
Command: atd8883779486;
Response: OK

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

Step 1:Switch to Root User

odroid@odroid64:~$ su
Password: [Default Password: Odroid]
root@odroid64:/home/odroid#

Step 2: Now install required tools for i2c

root@odroid64:/usr/src/linux#sudo apt-get install device-tree-compiler i2c-tools

Step 3:Now start i2c,amc6821 using modprobe

root@odroid64:/usr/src/linux#modprobe aml_i2c
root@odroid64:/usr/src/linux#modprobe i2c-dev

Step 4: Check i2cdetect to verify i2c library

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 5: To enable AMC6821 on boot

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

Step 1: Check the Devices are detected or not

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

odroid@odroid64:~$ i2cset -y 2 0x18 0x00 0xd5

Step 3: Read Local Temp Data 0x18 device’s from Register 0x0A(Local MSB)

odroid@odroid64:~$ i2cget -y 2 0x18 0x0A


0x21
->Temp=33 [Note: Discarding Lbyte Data (1° C Resolution) ] Refer AMC6821 Data Sheet

Step 4: Read Remote Temp Data 0x18 device’s from Register 0x0B(Remote MSB)

odroid@odroid64:~$ i2cget -y 2 0x18 0x0B


0x21
->Temp=33 [Note: Discarding Lbyte Data (1° C Resolution) ]

Step 5: Read Local & Remote Temp Data 0x18 device

[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

Step 1: Check the Devices are detected or not

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

odroid@odroid64:~$ i2cset -y 2 0x18 0x00 0xb5

Step 3: Change the PWM Bits in 0x18 device’s Fan Characteristics Reg in 0x20
set to 0x3d / 0x1d /0x05 / etc

odroid@odroid64:~$ i2cset -y 2 0x18 0x20 0x3d


odroid@odroid64:~$ i2cset -y 2 0x18 0x20 0x1d
odroid@odroid64:~$ i2cset -y 2 0x18 0x20 0x05

[Note: Should Read in the Following Order Lbyte First then Hbyte]
Step 4: Read Tach Lbyte Data of 0x18 device’s from Register 0x08

odroid@odroid64:~$ i2cget -y 2 0x18 0x08


0x64

Step 5: Read Tach Hbyte Data 0x18 device’s from Register 0x09

odroid@odroid64:~$ i2cget -y 2 0x18 0x09


0x02

[Note: To measure 0x4d device’s fan control repeat step 2-4 with Device Address 0x4d instead of
0x18]

20

S-ar putea să vă placă și