Linux2015. 8. 25. 11:34

굳이 차이점이라면...

insmod는 파일을 이용해서 올리고

modprobe는 모듈 이름을 이용해서 올리고 정도?



pi@raspberrypi ~ $ which modprobe

/sbin/modprobe

pi@raspberrypi ~ $ which insmod

/sbin/insmod

pi@raspberrypi ~ $ ls -al /sbin/modprobe

lrwxrwxrwx 1 root root 9  4월 29  2013 /sbin/modprobe -> /bin/kmod

pi@raspberrypi ~ $ ls -al /sbin/insmod

lrwxrwxrwx 1 root root 9  4월 29  2013 /sbin/insmod -> /bin/kmod



insmod

insmod [ filename ] [ module options... ]

insmod is a trivial program to insert a module into the kernel: if the filename is a hyphen, the module is taken from standard input. Most users will want to use modprobe(8) instead, which is more clever.

[링크 : http://linux.die.net/man/8/insmod]


modprobe

modprobe [ -v ] [ -V ] [ -C config-file ] [ -n ] [ -i ] [ -q ] [ -b ] [ -o modulename ] [ modulename ] [ module parameters... ]

modprobe intelligently adds or removes a module from the Linux kernel: note that for convenience, there is no difference between _ and - in module names. modprobe looks in the module directory /lib/modules/'uname -r' for all the modules and other files, except for the optional /etc/modprobe.conf configuration file and /etc/modprobe.d directory (see modprobe.conf(5)). modprobe will also use module options specified on the kernel command line in the form of <module>.<option>.

[링크 : http://linux.die.net/man/8/modprobe]


[링크 : http://www.readysystem.co.kr/ready/bbs/board.php?bo_table=tech_linux&wr_id=36&page=5]

'Linux' 카테고리의 다른 글

리눅스에서 메모리 뱅크 확인하기  (0) 2015.10.30
IIO - Industrial I/O  (2) 2015.09.03
리눅스 device tree  (0) 2015.04.29
커널 컴파일 옵션 neon 과 cpu feature  (0) 2015.04.28
쓰레드 / 프로세스  (0) 2015.04.27
Posted by 구차니
embeded/raspberry pi2015. 8. 24. 15:47

아두이노랑은 이렇게 하라는데

일단.. I2C로 할거니까.. 저렇게 위에 4개 선을 연결하면 어찌어찌 라즈베리에서도 사용가능 할 듯



장치 ID는 0xE5 고정

ADXL345

REGISTER DEFINITIONS

Register 0x00—DEVID (Read Only)

The DEVID register holds a fixed device ID code of 0xE5 (345 octal). 



데이터는 X/Y/Z축 LSB / MSB 순으로 들어 있다.


Register 0x32 to Register 0x37—DATAX0, DATAX1, DATAY0, DATAY1, DATAZ0, DATAZ1 (Read Only)

 These six bytes (Register 0x32 to Register 0x37) are eight bits each and hold the output data for each axis. Register 0x32 and Register 0x33 hold the output data for the x-axis, Register 0x34 and Register 0x35 hold the output data for the y-axis, and Register 0x36 and Register 0x37 hold the output data for the z-axis. The output data is twos complement, with DATAx0 as the least significant byte and DATAx1 as the most significant byte, where x represent X, Y, or Z. The DATA_FORMAT register (Address 0x31) controls the format of the data. It is recommended that a multiple-byte read of all registers be performed to prevent a change in data between reads of sequential registers



I 2 C

 With CS tied high to VDD I/O, the ADXL345 is in I2 C mode, requiring a simple 2-wire connection, as shown in Figure 40. The ADXL345 conforms to the UM10204 I 2 C-Bus Specification and User Manual, Rev. 03—19 June 2007, available from NXP Semiconductors. It supports standard (100 kHz) and fast (400 kHz) data transfer modes if the bus parameters given in Table 11 and Table 12 are met. Single- or multiple-byte reads/writes are supported, as shown in Figure 41. With the ALT ADDRESS pin high, the 7-bit I 2 C address for the device is 0x1D, followed by the R/W bit. This translates to 0x3A for a write and 0x3B for a read. An alternate I2 C address of 0x53 (followed by the R/W bit) can be chosen by grounding the ALT ADDRESS pin (Pin 12). This translates to 0xA6 for a write and 0xA7 for a read. There are no internal pull-up or pull-down resistors for any unused pins; therefore, there is no known state or default state for the CS or ALT ADDRESS pin if left floating or unconnected. It is required that the CS pin be connected to VDD I/O and that the ALT ADDRESS pin be connected to either VDD I/O or GND when using I2 C


[링크 : http://eleparts.co.kr/data/design/product_file/SENSOR/G_SENSOR/data/ADXL345.pdf]


---





---

pi@raspberrypi /boot/overlays $ dmesg | grep i2c

[    3.862054] bcm2708_i2c_init_pinmode(1,2)

[    3.863939] bcm2708_i2c_init_pinmode(1,3)

[    3.866020] bcm2708_i2c 3f804000.i2c: BSC1 Controller at 0x3f804000 (irq 79) (baudrate 100000)


pi@raspberrypi /boot/overlays $ lsmod | grep i2c

i2c_bcm2708             4990  0


pi@raspberrypi /boot/overlays $ insmod i2c-dev

Error: could not load module i2c-dev: No such file or directory


pi@raspberrypi /boot/overlays $ sudo vi /etc/modules

i2c-dev

i2c-bcm2708


pi@raspberrypi ~ $ lsmod | grep i2c

i2c_dev                 6027  0

i2c_bcm2708             4990  0


pi@raspberrypi ~ $ i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- --

pi@raspberrypi ~ $ i2cdetect -y 0

Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory


pi@raspberrypi ~ $ i2cdetect -l

i2c-1   i2c             3f804000.i2c                            I2C adapter


pi@raspberrypi ~ $ i2cdetect -F 1

Functionalities implemented by /dev/i2c-1:

I2C                              yes

SMBus Quick Command              yes

SMBus Send Byte                  yes

SMBus Receive Byte               yes

SMBus Write Byte                 yes

SMBus Read Byte                  yes

SMBus Write Word                 yes

SMBus Read Word                  yes

SMBus Process Call               yes

SMBus Block Write                yes

SMBus Block Read                 no

SMBus Block Process Call         no

SMBus PEC                        yes

I2C Block Write                  yes

I2C Block Read                   yes


pi@raspberrypi ~ $ lsmod | grep -i i2c

i2c_dev                 6027  0

i2c_bcm2708             4990  0



insmod가 아니라 modprobe ...


pi@raspberrypi ~ $ sudo modprobe i2c_dev

pi@raspberrypi ~ $ lsmod | grep i2c

i2c_dev                 6027  0

i2c_bcm2708             4990  0


[링크 : http://raspberrypi.stackexchange.com/.../how-to-make-raspbian-load-the-i2c-dev-module-on-boot-up]



---





#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <iostream>

int main(int argc, char **argv)
{
   printf("**** ADXL435 example program ****\n");
   
   int fd;                                          // File descrition
   char *fileName = "/dev/i2c-1";                        // Name of the port we will be using
   int  address = 0x53;                              // Address of the SRF02 shifted right one bit
   char buf[6];                              // Buffer for data being read/ written on the i2c bus
   short x,y,z;

   if ((fd = open(fileName, O_RDWR)) < 0) {               // Open port for reading and writing
      printf("Failed to open i2c port\n");
      exit(1);
   }
   
   if (ioctl(fd, I2C_SLAVE, address) < 0) {               // Set the port options and set the address of the device we wish to speak to
      printf("Unable to get bus access to talk to slave\n");
      exit(1);
   }

   buf[0] = 0x2d;                                       // Commands for performing a ranging
   buf[1] = 0x18;
   
   if ((write(fd, buf, 2)) != 2) {                        // Write commands to the i2c port
      printf("Error writing to i2c slave\n");
      exit(1);
   }

   buf[0] = 0x31;                                       // Commands for performing a ranging
   buf[1] = 0x09;
   
   if ((write(fd, buf, 2)) != 2) {                        // Write commands to the i2c port
      printf("Error writing to i2c slave\n");
      exit(1);
   }

                                       // This sleep waits for the ping to come back
while(true){   

   buf[0] = 0x32;                                       // This is the register we wish to read from
   if ((write(fd, buf, 1)) != 1) {                        // Send the register to read from
      printf("Error writing to i2c slave\n");
      exit(1);
   }
   

usleep(1000);
  memset(&buf,0,sizeof(buf));

   if (read(fd, buf, 6) != 6) {                        // Read back data into buf[]
      printf("Unable to read from slave\n");
      exit(1);
   }
   else { x=y=z=0;
//               memset(&buf,0,sizeof(buf));

      x = ((short)buf[1]<<8) | (short) buf[0]; 
       y = ((short)buf[3]<<8) | (short) buf[2];
       z = ((short)buf[5]<<8) | (short) buf[4];
       std::cout<<"x:"<<x<<"\ty:"<<y<<"\tz:"<<z<<std::endl;
   }
}
   return 0;

} 



Posted by 구차니
embeded/raspberry pi2015. 8. 24. 15:30


raspi-config 면 기본 설정을 될테고..

나머지는 간단한(?) 테스트용 유틸리티 설치?


$ sudo apt-get install i2c-tools libi2c-dev python-smbus

$ sudo i2cdetect -y 1

[링크 : http://www.rasplay.org/?p=6409]

[링크 : https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c]


예제코드 / 스켈레톤 코드

char *fileName = "/dev/i2c-0";

fd = open(fileName, O_RDWR);

ioctl(fd, I2C_SLAVE, address);

write(fd, buf, 1);

read(fd, buf, 2); 

[링크 : http://www.robot-electronics.co.uk/files/rpi_sd21.c]

    [링크 : http://www.robot-electronics.co.uk/htm/raspberry_pi_examples.htm]


pi@raspberrypi ~ $ i2cdetect

Error: No i2c-bus specified!

Usage: i2cdetect [-y] [-a] [-q|-r] I2CBUS [FIRST LAST]

       i2cdetect -F I2CBUS

       i2cdetect -l

  I2CBUS is an integer or an I2C bus name

  If provided, FIRST and LAST limit the probing range. 


활성화 시키지 않으면 이런 에러가 발생한다.

pi@raspberrypi ~ $ i2cdetect -y 1

Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory 


근데..

전에 처럼 또.. 연결 안하고 안켜면 활성화도 안되는 기분?

pi@raspberrypi ~ $ sudo i2cdetect -y 1

Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory


pi@raspberrypi ~ $ dmesg | grep i2c

[    3.872815] bcm2708_i2c_init_pinmode(1,2)

[    3.874707] bcm2708_i2c_init_pinmode(1,3)

[    3.877782] bcm2708_i2c 3f804000.i2c: BSC1 Controller at 0x3f804000 (irq 79) (baudrate 100000) 



Posted by 구차니
embeded/raspberry pi2015. 8. 23. 22:16

머.. fbtft 였나..

fb를 쓰는거니 당연히 되는 걸로 생각이 되긴 해야 하지만..

사이즈나 속도 면에서 무슨 제약이 걸려서 안되는게 아닐까 싶기도?

아무튼 되는거 보면 왜 놀라운걸까 ㅋㅋ




Posted by 구차니
embeded/raspberry pi2015. 8. 23. 16:01

음.. 다시 봤더니 뭔가 수정된 기분?

아무튼.. 나중에 다시 한번 바닥 부터 만들어 봐야지...

rootfs에 dtb 관련해서 추가되는게 은근 좀 있는 듯...


$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

$ mkdir mnt/fat32

$ mkdir mnt/ext4

$ sudo mount /dev/sdb1 mnt/fat32

$ sudo mount /dev/sdb2 mnt/ext4

$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install

$ sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img

$ sudo scripts/mkknlimg arch/arm/boot/zImage mnt/fat32/$KERNEL.img

$ sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/

$ sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/

$ sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/

$ sudo umount mnt/fat32

$ sudo umount mnt/ext4


[링크 : https://www.raspberrypi.org/documentation/linux/kernel/building.md]


스크립트를 통해서 zImage 파일이 어떻게든 변경되나 보다..

$ sudo ./scripts/mkknlimg arch/arm/boot/zImage ~/KERNEL.img

Version: Linux version 4.1.6-v7+ (minimonk@devmini) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #1 SMP PREEMPT Tue Aug 18 23:54:39 KST 2015

DT: y

283x: n


$ ls -al ~/KERNEL.img

-rw-r--r-- 1 root root 4031680  8월 23 16:19 /home/minimonk/KERNEL.img


$ file ~/KERNEL.img

/home/minimonk/KERNEL.img: Linux kernel ARM boot executable zImage (little-endian)


$ diff arch/arm/boot/zImage ~/KERNEL.img

Binary files arch/arm/boot/zImage and /home/minimonk/KERNEL.img differ  



2015/04/16 - [개소리 왈왈/라즈베리 파이(rpi)] - 라즈베리 파이 2 커널모듈 빌드

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 파이 i2c 사용하기  (0) 2015.08.24
라즈베리 파이 SPI LCD도.. openGL은 되네?  (0) 2015.08.23
라즈베리 카메라 관련  (0) 2015.08.21
motion는 쓸만한게 아니었나..  (0) 2015.08.21
MMAL motion 로그  (0) 2015.08.20
Posted by 구차니

그래서.. 할 시간도 할 수 있는 것도 없다는게 아쉽네..


애 보고 재워서

시간나면 집안일 해야 하고...

집안일 하고 나면 깰 시간이고..

무한반복.. ㄷㄷㄷ


아내도 쉬라고 보내놓고 그러면 주말은 초 죽음 ㅠㅠ

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

돈 나올 구멍은 없고...  (0) 2015.10.02
8월 끝  (0) 2015.08.31
경복궁 / 창덕궁 야간개장 예매 준비!  (0) 2015.08.05
국민은행 + KB 손해보험 -_-  (3) 2015.08.04
8월 할일  (0) 2015.08.02
Posted by 구차니

머..외적 호재가 있는 것도 아니고

내적 호재는 고려도 못할 정도고..

아무튼 반짝(?) 열풍으로 4월 3주차 즈음에 2200 근처 찍고

꾸준히 하락중인데

요 한달가은 정말 정신 못차릴 정도로 급격히 낮아지고 있고

어제 오늘은 40포인트 가까이 연속으로 빠지는 중...


북한과는 전면전 선포할 것 만 같은 분위기로 가고 있으니.. 에효...




Posted by 구차니
embeded/raspberry pi2015. 8. 21. 14:37

나만 잘 안되나..

v4l2나 motion 관련해서 보는데 끄응...

일단 기본 문서들 조사중..



raspistill - Capturing still photographs with the camera module

raspiyuv - Capturing still photographs and generating raw unprocessed image files

raspivid - Capturing video with the camera module

[링크 : https://www.raspberrypi.org/documentation/usage/camera/raspicam/README.md]



$ sudo apt-get install python-picamera 

[링크 : https://www.raspberrypi.org/documentation/usage/camera/python/README.md]

[링크 : http://picamera.readthedocs.org/] pythin picamera API


module has a five megapixel fixed-focus camera that supports 1080p30, 720p60 and VGA90 video modes, as well as stills capture. It attaches via a 15cm ribbon cable to the CSI port on the Raspberry Pi.

[링크 : https://www.raspberrypi.org/products/camera-module/]

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 파이 SPI LCD도.. openGL은 되네?  (0) 2015.08.23
라즈베리 파이 빌드.. 다시?  (0) 2015.08.23
motion는 쓸만한게 아니었나..  (0) 2015.08.21
MMAL motion 로그  (0) 2015.08.20
MMAL motion  (0) 2015.08.19
Posted by 구차니
embeded/raspberry pi2015. 8. 21. 12:46

MMAL motion으로 돌리면

cpu 하나 100% 쳐묵쳐묵 하고 있고

framerate를 30으로 해줘도 1프레임도 안나와서

찾아보니.. 이거뭐..


v4l2 official driver 해도 시궁창이던데...

그냥 MMAL / CSI를 포기해야 하나


아니 그래서 사람들이 이거 관련 글이 별로 없었던 건가?


[링크 : https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=62945]

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 파이 빌드.. 다시?  (0) 2015.08.23
라즈베리 카메라 관련  (0) 2015.08.21
MMAL motion 로그  (0) 2015.08.20
MMAL motion  (0) 2015.08.19
라즈베리 파이 터치 LCD(3.5인치 waveshare) evtest  (0) 2015.08.19
Posted by 구차니
분류가 모호한 글2015. 8. 20. 16:20

문득 생각이 나서..


[링크 : http://www.ese.upenn.edu/seniordesign/1011/posters/group151011poster.pdf]

[링크 : http://research.microsoft.com/en-us/projects/AudioProcessing/]

'분류가 모호한 글' 카테고리의 다른 글

dense 3d reconstruction  (0) 2015.09.22
입식 책상  (0) 2015.09.01
각종 오디오 코덱 가격  (0) 2015.01.26
img 와 iso  (0) 2014.08.29
kdiff3 / winmerge / meld UI 비교  (0) 2014.04.30
Posted by 구차니