주요 부분


#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

+ Recent posts