Xilinx XC7Z020雙核ARM+FPGA開發(fā)板試用合集——創(chuàng)建linux系統(tǒng)
分享產(chǎn)品試用報告,測試板卡是基于Xilinx Zynq-7000系列XC7Z010/XC7Z020高性能低功耗處理器設(shè)計的異構(gòu)多核SoC工業(yè)級核心板。
以下為測評內(nèi)容,歡迎閱讀:
Petalinux制作linux系統(tǒng)1配置
基本配置信息如下:
(1) 配置啟動項
(2) 配置SD卡分區(qū)
(3) 首選SD啟動設(shè)置
(4) 主機名設(shè)定
2文件系統(tǒng)配置
主要包括如下:
(1) gcc編譯支持
(2) python支持
3 設(shè)備樹
另一個一個最重要的就是編寫設(shè)備樹文件,主要包括LED以及按鍵的設(shè)備樹和axi_uart16550設(shè)備樹文件的編寫,內(nèi)容如下:
/include/ "system-conf.dtsi"
/ {
aliases{
ethernet0= &gem0;
serial0= &uart1;
};
gpio-keys{
compatible = "gpio-keys";
#gpio-cells = <2>;
SW0 {
label= "SW0";
#gpio-cells= <2>;
gpios= <&axi_gpio_1 0x0 0x0 0x0>;
linux,code= <108>;
gpio-key,wakeup;
autorepeat;
};
SW1 {
label= "SW1";
#gpio-cells= <2>;
gpios= <&axi_gpio_1 0x1 0x0 0x0>;
linux,code= <108>;
gpio-key,wakeup;
autorepeat;
};
SW2 {
label= "SW2";
#gpio-cells= <2>;
gpios= <&axi_gpio_1 0x2 0x0 0x0>;
linux,code= <108>;
gpio-key,wakeup;
autorepeat;
};
};
gpio-leds{
compatible= "gpio-leds";
#gpio-cells= <2>;
led-ld0{
label= "led-ld0";
#gpio-cells= <2>;
gpios= <&axi_gpio_0 0x0 0 0x0>;
default-state= "on";
linux,default-trigger= "default-on";
};
led-ld1{
label= "led-ld1";
#gpio-cells= <2>;
gpios= <&axi_gpio_0 0x1 0 0x0>;
default-state= "on";
linux,default-trigger= "default-on";
};
led-ld2{
label= "led-ld2";
#gpio-cells= <2>;
gpios= <&axi_gpio_0 0x2 0 0x0>;
default-state= "on";
linux,default-trigger= "default-on";
};
};
};
&axi_uart16550_0 {
status= "okay";
port-number= <1>;
current-speed= <57600>;
xlnx,use-modem-ports= <0x0>;
xlnx,use-user-ports= <0x0>;
};
&axi_uart16550_1 {
status= "okay";
port-number= <1>;
current-speed= <57600>;
xlnx,use-modem-ports= <0x0>;
xlnx,use-user-ports= <0x0>;
};
實驗
啟動界面如下:
Boot
Kernel
登錄
從上述界面可知,linux系統(tǒng)啟動成功,輸入密碼和賬戶名即可。
1查看各項驅(qū)動
(1) gpio驅(qū)動
(2) uart 16550驅(qū)動
從上述信息可知成功啟動了相應(yīng)驅(qū)動。
2 MIO LED實驗
該實驗的LED實驗情況如下:
實驗現(xiàn)象如下:
代碼如下:
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
int value;
int export;
int direction;
//export GPIO controller
export = open("/sys/class/gpio/export", O_WRONLY);
if(export < 0)
{
printf("Cannot open GPIO controller exportn");
exit(1);
}
write(export, "909", 4);
close(export);
printf("GPIO controller export successfullyn");
//Modify GPIO controller direction
direction = open("/sys/class/gpio/gpio909/direction",O_WRONLY);
if(direction < 0)
{
printf("Cannot open GPIO controller directionn");
exit(1);
}
write(direction, "out", 4);
close(direction);
printf("GPIO controller direction changed to outputsuccessfullyn");
// Modify GPIO controller value
value = open("/sys/class/gpio/gpio909/value", O_RDWR);
if(value < 0)
{
printf("Cannot open GPIO controller valuen");
exit(1);
}
//Swap GPIO control value each 1 second
while (1)
{
sleep(1);
write(value,"1", 2);
printf("GPIO controller value changed to 1 successfullyn");
sleep(1);
write(value,"0", 2);
printf("GPIO controller value changed to 0 successfullyn");
}
}
3 axi gpio led實驗
該實驗情況如下:
實驗如下:
代碼如下:
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
int led0;
int led1;
int led2;
//export GPIO controller
led0 = open("/sys/class/leds/led-ld0/brightness", O_WRONLY);
led1 = open("/sys/class/leds/led-ld1/brightness", O_WRONLY);
led2 = open("/sys/class/leds/led-ld2/brightness", O_WRONLY);
if(led0 < 0 | led1 < 0 | led2 < 0)
{
printf("Cannot open GPIO controller exportn");
exit(1);
}
write(led0,"0", 2);
write(led1,"0", 2);
write(led2,"0", 2);
//Swap GPIO control value each 1 second
while (1)
{
sleep(1);
write(led0,"255", 4);
sleep(1);
write(led1,"255", 4);
sleep(1);
write(led2,"255", 4);
printf("GPIO controller value changed to 1 successfullyn");
sleep(1);
write(led0,"0", 2);
sleep(1);
write(led1,"0", 2);
sleep(1);
write(led2,"0", 2);
printf("GPIO controller value changed to 0 successfullyn");
}
}
4 uart16550實驗
根據(jù)上述信息可知,串口的驅(qū)動字符名為ttyS1和ttyS2,因此實驗現(xiàn)象如下: