&axi_gpio_0 {
    compatible = "generic-uio";
};
axi_gpio_0: gpio@41200000 {
            #gpio-cells = <2>;
            compatible = "xlnx,xps-gpio-1.00.a";
            gpio-controller ;
            reg = <0x41200000 0x10000>;
            xlnx,all-inputs = <0x0>;
            xlnx,all-inputs-2 = <0x0>;
            xlnx,all-outputs = <0x0>;
            xlnx,all-outputs-2 = <0x0>;
            xlnx,dout-default = <0x00000000>;
            xlnx,dout-default-2 = <0x00000000>;
            xlnx,gpio-width = <0x18>;
            xlnx,gpio2-width = <0x20>;
            xlnx,interrupt-present = <0x0>;
            xlnx,is-dual = <0x0>;
            xlnx,tri-default = <0xFFFFFFFF>;
            xlnx,tri-default-2 = <0xFFFFFFFF>;
        };
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>

#define GPIO_MAP_SIZE 		0x10000
#define GPIO_DATA_OFFSET	0x00
#define GPIO_TRI_OFFSET		0x04
#define GPIO_DATA2_OFFSET	0x08
#define GPIO_TRI2_OFFSET	0x0C
#define GPIO_GLOBAL_IRQ		0x11C
#define GPIO_IRQ_CONTROL	0x128
#define GPIO_IRQ_STATUS		0x120

volatile int counter;

inline void gpio_write(void *gpio_base, unsigned int offset, unsigned int value)
{
	*((volatile unsigned *)(gpio_base + offset)) = value;
}

inline unsigned int gpio_read(void *gpio_base, unsigned int offset)
{
	return *((volatile unsigned *)(gpio_base + offset));
}

unsigned int get_memory_size(char *sysfs_path_file)
{
	FILE *size_fp;
	unsigned int size;

	// open the file that describes the memory range size that is based on the
	// reg property of the node in the device tree

	size_fp = fopen(sysfs_path_file, "r");

	if (!size_fp) {
		printf("unable to open the uio size file\n");
		exit(-1);
	}

	// get the size which is an ASCII string such as 0xXXXXXXXX and then be stop
	// using the file

	fscanf(size_fp, "0x%08X", &size);
	fclose(size_fp);

	return size;
}

void wait_for_interrupt(int fd, void *gpio_ptr)
{
	int pending = 0;
	int reenable = 1;
	unsigned int reg;


	// block on the file waiting for an interrupt */
	read(fd, (void *)&pending, sizeof(int));

	counter = counter + 1;


	// the interrupt occurred for the 1st GPIO channel so clear it
	reg = gpio_read(gpio_ptr, GPIO_IRQ_STATUS);
	if (reg)
		gpio_write(gpio_ptr, GPIO_IRQ_STATUS, 1); //


	// re-enable the interrupt in the interrupt controller thru the
	// the UIO subsystem now that it's been handled

	write(fd, (void *)&reenable, sizeof(int));
	}

int main()
{
	int uio1_fd;
	void *ptr;
	int gpio_size;


	if ((uio1_fd = open("/dev/uio1", O_RDWR)) < 0)
		{
			perror("open uio1");
		}
		else{printf("uio1 opened \n");}

	gpio_size = get_memory_size("/sys/class/uio/uio1/maps/map0/size");

	ptr = mmap(NULL, gpio_size, PROT_READ|PROT_WRITE, MAP_SHARED, uio1_fd, 0);

	if (ptr == MAP_FAILED) {
			printf("Mmap call failure.\n");
			return -1;
		}
	gpio_write(ptr, GPIO_TRI_OFFSET, 0xFF); // GPIO Channel 1 input

	gpio_write(ptr, GPIO_GLOBAL_IRQ, 0x80000000); // GIER, 31. Bit
	gpio_write(ptr, GPIO_IRQ_CONTROL, 1);  // Channel 1 Interrupt enable

	//wait for interrupt
	while(1)
	{
		wait_for_interrupt(uio1_fd, ptr);
		printf("Interrupt: %d", counter);
		puts("");
	}


	munmap(ptr, gpio_size);

	return 0;
}


'개발 > Xilinx Zynq' 카테고리의 다른 글

DTSI 파일에 모듈 주소 추가  (0) 2016.11.17
Character device drivers automatically create node  (0) 2016.11.17
QSPI Kernel Booting  (0) 2016.11.17
DTSI수정하여 UART0 살리기  (0) 2016.11.16
U-Boot 설정에서 SDHCI 제거  (0) 2016.11.16

출처 : 지식인


http://kin.naver.com/qna/detail.nhn?d1id=11&dirId=1118&docId=210084618&qb=ZmZ0&enc=utf8&section=kin&rank=8&search_sort=0&spq=0


FFT 는 Fast Fourier Transform 즉 고속 푸리에 변환이 되겠읍니다.

무엇에 이용되는 것인가 하면 시간영역에서 계속 변화하는 데이터를 주파수 영역으로 가져다가 어떤 주파수 들이 사용되고 있는지를 알아볼 때 쓰게 됩니다.

 

보통 FFT 는 라이브러리화가 잘 되어 있어서 데이타를 모아서 라이브러리 함수를 call 하면 결과가 리턴되는 데 이것의 해석에

대하여 예를 들어서 이해하기 쉽게 설명해 보겠읍니다.

 

44.1KHz PCM 의 한채널을 가정해 보겠읍니다. (m = 44100)

1초에 44100  개의 데이타가 날라옵니다.

이중에서 100개의 연속된 데이터를 모아서 (n = 100)  FFT 함수를 call 했다고 가정해 봅니다.

for (i = 0; i < n; i++) {
  in[i] = sin(2.0*pi*4410*i/m);  // 4410Hz   
}

위의 경우는 마침 PCM 데이터가 4.41KHz 의 순수한 사인파라고 가정한 것입니다.

이와 같이 n 개의 데이타로 FFT 를 call 하면  k = [(n/2) + 1] 개의 복소수가 리턴되는데요

(복소수라고해 보아야  out[j][0]  out[j][1]   이렇게 두개의 실수이지요)

이것으로 부터 복소수의 크기를 구할 수 있읍니다.

for (j = 0; j < k; j++) {
  mag[j] = sqrt((out[j][0]*out[j][0]) + (out[j][1]*out[j][1]));
}

 

자 이제 해석을 해 볼까요!

n = 100 이었으므로 k = 51 이 됩니다. 즉 mag[0] 에서 mag[50] 까지 이지요.

그런데 1초에 44100 데이타 중에서 n = 100 개만 사용했으므로  m/n = 44100/100 = 441 이라는 값을

인덱스에 곱한 것이 각각의 인덱스가 나타네는 주파수가 됩니다. 즉

mag[0]  의 값은  0 X 441 = 0Hz 즉 DC 성분 이고요

mag[50] 의 값은  50 X 441 = 22050Hz = 22.050KHz 의 성분이 되는 것이지요.

데이타가 위에서 처럼 4.41KHz 였다면

mag[10] 에만 어떤 값이 존재하고  ---> 10 X 441 = 4410Hz = 4.41KHz  즉 4.41KHz 의 주파수 성분만 있고

나머지는 모두 0 이 됩니다.

 

결론은 샘플링 주파수를 알고 있을 때 (m)  n 의 값을 늘리면 k 도 증가하여 좀더 촘촘하게 주파수 간격을

따져 볼수 있게 됩니다. (m/n 은 감소)

즉 n = 44100 으로 하게되면 1 Hz 간격으로 주파수 성분을 알 수 있게 되지만 불행하게도 계산 기간이

엄청 많이 늘어나게 됩니다.

system-top.dtsi 에다가 하기 내용 추가


/{

    axi_radar: axi_radar@41200000 {

        compatible ="xlnx,axi-radar";

        reg = <0x41200000 0x10000>;

    };

};


'개발 > Xilinx Zynq' 카테고리의 다른 글

axi-gpio uio  (0) 2017.06.02
Character device drivers automatically create node  (0) 2016.11.17
QSPI Kernel Booting  (0) 2016.11.17
DTSI수정하여 UART0 살리기  (0) 2016.11.16
U-Boot 설정에서 SDHCI 제거  (0) 2016.11.16

주요 부분


#define DRIVER_NAME "axi-radar"

#define DEVICE_NAME "axi-radar"

#define CLASS_NAME  "axiRadarClass"


/* Simple example of how to receive command line parameters to your module.

   Delete if you don't need them */

unsigned myint = 0xdeadbeef;

char *mystr = "default";


/* class */

static struct class* axiRadarClass = NULL;

static struct device* axiRadarDevice = NULL;


...



static int __init axi_radar_init(void)

{   

    printk("<1>AXI-Radar. 1\n");

    printk("<1>Module parameters were (0x%08x) and \"%s\"\n", myint, mystr);

    

    radar_base_vaddr = 0x00;

    majorNumber = register_chrdev(0, DEVICE_NAME, &fops);

    if (majorNumber< 0) { 

        printk(KERN_ALERT "axi-radar : Registering char device failed with %d\n", majorNumber); 

        return majorNumber;

    } 

    printk(KERN_INFO "axi-radar : major number %d.\n", majorNumber);

    

    axiRadarClass = class_create(THIS_MODULE, CLASS_NAME);

    if (IS_ERR(axiRadarClass)){                // Check for error and clean up if there is

        unregister_chrdev(majorNumber, DEVICE_NAME);

        printk(KERN_ALERT "axi-radar : Failed to register device class\n");

        return PTR_ERR(axiRadarClass);          // Correct way to return an error on a pointer

    }

    printk(KERN_INFO "axi-radar : device class registered correctly\n");

    

    // Register the device driver

    axiRadarDevice = device_create(axiRadarClass, NULL, MKDEV(majorNumber, 0), NULL, DEVICE_NAME);

    if (IS_ERR(axiRadarDevice)){               // Clean up if there is an error

        class_destroy(axiRadarClass);           // Repeated code but the alternative is goto statements

        unregister_chrdev(majorNumber, DEVICE_NAME);

        printk(KERN_ALERT "axi-radar : Failed to create the device\n");

        return PTR_ERR(axiRadarDevice);

    }

    

    return platform_driver_register(&axi_radar_driver);

}



static void __exit axi_radar_exit(void)

{

    device_destroy(axiRadarClass, MKDEV(majorNumber, 0));     // remove the device

    class_unregister(axiRadarClass);                          // unregister the device class

    class_destroy(axiRadarClass);                             // remove the device class

    unregister_chrdev(majorNumber, DEVICE_NAME);             // unregister the major number


    platform_driver_unregister(&axi_radar_driver);

    printk(KERN_ALERT "axi-radar : exit.\n");

}



'개발 > Xilinx Zynq' 카테고리의 다른 글

axi-gpio uio  (0) 2017.06.02
DTSI 파일에 모듈 주소 추가  (0) 2016.11.17
QSPI Kernel Booting  (0) 2016.11.17
DTSI수정하여 UART0 살리기  (0) 2016.11.16
U-Boot 설정에서 SDHCI 제거  (0) 2016.11.16

1. Kernel Update


U-Boot-PetaLinux> setenv ipaddr 192.168.0.125;setenv serverip 192.168.0.43;tftpboot 0x1000000 image.ub

U-Boot-PetaLinux> sf probe 0 0 0

U-Boot-PetaLinux> sf erase 0x1000000 0x1000000

U-Boot-PetaLinux> sf write 0x1000000 0x1000000 0xffffff



2. Kernel Boot Script


U-Boot-PetaLinux> sf probe 0 0 0

U-Boot-PetaLinux> sf read 0x8000000 0x1000000 0x1000000

U-Boot-PetaLinux> bootm 0x8000000


U-Boot-PetaLinux> setenv bootcmd 'sf probe 0 0 0; sf read 0x8000000 0x1000000 0x1000000; bootm 0x8000000'



'개발 > Xilinx Zynq' 카테고리의 다른 글

DTSI 파일에 모듈 주소 추가  (0) 2016.11.17
Character device drivers automatically create node  (0) 2016.11.17
DTSI수정하여 UART0 살리기  (0) 2016.11.16
U-Boot 설정에서 SDHCI 제거  (0) 2016.11.16
petalinux 정리  (1) 2016.11.08

1. Vivado에서 SDHCI 블럭 Disable 하고 UART0블럭 Enable

  UART0 RX MIO 42

  UART0 TX MIO 43



2. Vivado - Synth - Implement - Export Hardware ... 순서대로 진행



3. U-Boot 다시 빌드



4. DTSI 수정


~/Xilinx-ZC706-2016.3/subsystems/linux/configs/device-tree/system-top.dts 파일 하기 부분 추가

&uart0 {

    status = "okay";

};


&sdhci0 {

    status = "disabled";

};


&sdhci1 {

    status = "disabled";

};



5. system-cont.dtsi 파일에서 하기 부분 추가


 aliases {

        serial0 = &uart1;

        serial1 = &uart0;

        ethernet0 = &gem0;

        spi0 = &qspi;

    };



6. 컴파일

petalinux-build -c device-tree 

petalinux-package --image

cp images/linux/image.ub /tftpboot/



7. 확인 방법

U-boot에서 fdt를 사용한다.

fdt addr 0x868c7dc

fdt print


'개발 > Xilinx Zynq' 카테고리의 다른 글

Character device drivers automatically create node  (0) 2016.11.17
QSPI Kernel Booting  (0) 2016.11.17
U-Boot 설정에서 SDHCI 제거  (0) 2016.11.16
petalinux 정리  (1) 2016.11.08
SDK에서 JTAG으로 리눅스 부팅  (0) 2016.11.08

1. ~/Xilinx-ZC706-2016.3/subsystems/linux/configs/u-boot/config 파일에서 


# CONFIG_CMD_MMC is not set

# CONFIG_ZYNQ_SDHCI is not set



2. platform-auto.h에서


/* sdio - ps7_sd_0 */

#if 0

#define CONFIG_ZYNQ_SDHCI0  0xE0100000

#define CONFIG_MMC

#define CONFIG_GENERIC_MMC

#define CONFIG_SDHCI

#define CONFIG_SUPPORT_VFAT

#define CONFIG_DOS_PARTITION

#define CONFIG_FAT_WRITE

#define CONFIG_ZYNQ_SDHCI_MAX_FREQ  52000000

#endif



3. ReBuild


#!/bin/bash


petalinux-build -c u-boot


petalinux-package --boot --fsbl /home/shlee/shlee_zc706/shlee_zc706.sdk/shlee_zc706_fsbl/Debug/shlee_zc706_fsbl.elf --fpga /home/shlee/shlee_zc706/shlee_zc706.runs/impl_1/designz_main_wrapper.bit --uboot --force -o images/linux/BOOT.BIN


cp images/linux/BOOT.BIN /tftpboot

'개발 > Xilinx Zynq' 카테고리의 다른 글

QSPI Kernel Booting  (0) 2016.11.17
DTSI수정하여 UART0 살리기  (0) 2016.11.16
petalinux 정리  (1) 2016.11.08
SDK에서 JTAG으로 리눅스 부팅  (0) 2016.11.08
petalinux build zc706 & 플래쉬 writing  (0) 2016.11.08
1. petalinux 확인
shlee@xilinxdev:~$ echo $PETALINUX
/opt/petalinux
shlee@xilinxdev:~$ 


2.프로젝트 생성
shlee@xilinxdev:~$ petalinux-create -t project -s /opt/petalinux/Xilinx-ZC706-v2016.3-final.bsp 
INFO: Create project: 
INFO: Projects: 
INFO:   * Xilinx-ZC706-2016.3
INFO: has been successfully installed to /home/shlee/
INFO: New project successfully created in /home/shlee/



3. 전체 빌드
shlee@xilinxdev:~/Xilinx-ZC706-2016.3$ petalinux-build
INFO: Checking component...
INFO: Generating make files and build linux
INFO: Generating make files for the subcomponents of linux
...
...


4. 커널 빌드
shlee@xilinxdev:~/Xilinx-ZC706-2016.3$ petalinux-build -c kernel
INFO: Checking component...
INFO: Generating make files and build linux/kernel
INFO: Generating make files for the subcomponents of linux/kernel
INFO: Building linux/kernel
[INFO ] build linux/kernel
...

shlee@xilinxdev:~/Xilinx-ZC706-2016.3$ petalinux-build -x package
INFO: Checking component...
INFO: Generating make files and build linux
INFO: Generating make files for the subcomponents of linux
INFO: Building linux
[INFO ] package rootfs.cpio to /home/shlee/Xilinx-ZC706-2016.3/images/linux
[INFO ] Update and install vmlinux image
...


5. 모듈 추가
shlee@xilinxdev:~/Xilinx-ZC706-2016.3$ petalinux-create -t modules --name axi-gpio --enable 

~/Xilinx-ZC706-2016.3/components/modules/axi-gpio가 생성되어있음

모듈 컴파일
shlee@xilinxdev:~/Xilinx-ZC706-2016.3$ petalinux-build -c rootfs/axi-gpio -x install


6.  패키지 생성
shlee@xilinxdev:~/Xilinx-ZC706-2016.3$ petalinux-build -x package


7. image.ub 생성
shlee@xilinxdev:~/Xilinx-ZC706-2016.3$ petalinux-package --image


8. scp 파일전송
scp axi-gpio.ko root@192.168.0.52:/home/root 


9. u-boot 빌드

$ petalinux-build -c u-boot



10. u-boot 패키지 (BOOT.BIN 만들기)

$ petalinux-package --boot --fsbl pre-built/linux/images/zynq_fsbl.elf --fpga pre-built/linux/implementation/download.bit --uboot --force -o images/linux/BOOT.BIN



11. u-boot에서 BOOT.BIN QSPI에 Writing 하기

U-Boot-PetaLinux> setenv ipaddr 192.168.0.125;setenv serverip 192.168.0.43; tftpboot 0x1000000 BOOT.BIN;sf probe 0 0 0;sf erase 0x0 0x1000000;sf write 0x1000000 0x0 0xffffff;reset



12. u-boot에서 네트웍으로 리눅스 부팅

U-Boot-PetaLinux> setenv ipaddr 192.168.0.125;setenv serverip 192.168.0.43;tftpboot 0x8000000 image.ub;bootm 0x8000000



13. u-boot에 I2C 추가


~/build/Xilinx-ZC706-2016.3/subsystems/linux/configs/u-boot/platform-auto.h 파일


#define CONFIG_SYS_I2C_ZYNQ


/* I2C */

#if defined(CONFIG_SYS_I2C_ZYNQ)


# define CONFIG_ZYNQ_I2C0

# define CONFIG_SYS_I2C

# define CONFIG_CMD_I2C

# define CONFIG_SYS_I2C_ZYNQ_SPEED              100000

# define CONFIG_SYS_I2C_ZYNQ_SLAVE              0

#endif



14. u-boot 에 새로운 fsbl 적용하기


#!/bin/bash

petalinux-build -c u-boot

petalinux-package --boot --fsbl /home/shlee/shlee_zc706/shlee_zc706.sdk/shlee_zc706_fsbl/Debug/shlee_zc706_fsbl.elf --fpga /home/shlee/shlee_zc706/shlee_zc706.runs/impl_1/designz_main_wrapper.bit --uboot --force -o images/linux/BOOT.BIN





1. petalinux-build 한 images 파일을 sdk에 적절한 폴더에 옮김


2. Xilinx SDK에 [Xilinx Tools]-[Create Zynq Boot Image]를 선택

 


요렇게 넣고


3. 

xsdb% targets

xsdb% source D:\\vivado_work\\zc706_test1\\zc706_test1\\zc706_test1.sdk\\design_1_wrapper_hw_platform_0\\ps7_init.tcl

xsdb% ps7_init

xsdb% ps7_post_config

xsdb% dow D:\\vivado_work\\zc706_test1\\zc706_test1\\zc706_test1.sdk\\linux_image_test\\u-boot.elf

xsdb% dow -data D:\\vivado_work\\zc706_test1\\zc706_test1\\zc706_test1.sdk\\linux_image_test\\BOOT.bin 0x08000000

xsdb% con


4. U-boot가 부팅되면

> sf probe 0 0 0

> sf erase 0x0 0x01000000

> sf write 0x08000000 0 0xffffff


5. 딥스위치 4번 High로 올려도 U-boot 부팅됨....





'개발 > Xilinx Zynq' 카테고리의 다른 글

DTSI수정하여 UART0 살리기  (0) 2016.11.16
U-Boot 설정에서 SDHCI 제거  (0) 2016.11.16
petalinux 정리  (1) 2016.11.08
petalinux build zc706 & 플래쉬 writing  (0) 2016.11.08
ZC706 Doesn't work with VADJ at 1.8v  (0) 2016.11.07

1. petalinux-v2015.4-final-installer-dec.run 다운로드 설치

/opt/pkg에다가


2. Xilinx-ZC706-v2015.4-final.bsp 다운로드 설치

/opt/pkg/petalinux-/ 에 다가


3. sudo dpkg-reconfigure dash <No> 선택


4. petalinux-create -t project -s <BSP>


5. cd <BSP>

   petalinux-build 


 

참조:

http://engineernote.hatenablog.com/entry/2016/01/31/012227



'개발 > Xilinx Zynq' 카테고리의 다른 글

DTSI수정하여 UART0 살리기  (0) 2016.11.16
U-Boot 설정에서 SDHCI 제거  (0) 2016.11.16
petalinux 정리  (1) 2016.11.08
SDK에서 JTAG으로 리눅스 부팅  (0) 2016.11.08
ZC706 Doesn't work with VADJ at 1.8v  (0) 2016.11.07

+ Recent posts