分享産品試用報告,測試闆卡是基于Xilinx Zynq-7000系列XC7Z010/XC7Z020高性能低功耗處理器設計的異構多核SoC工業級核心闆。
以下為測評内容,歡迎閱讀:
Petalinux制作linux系統1配置
基本配置信息如下:
(1) 配置啟動項
(2) 配置SD卡分區
(3) 首選SD啟動設置
(4) 主機名設定
2文件系統配置
主要包括如下:
(1) gcc編譯支持
(2) python支持
3 設備樹
另一個一個最重要的就是編寫設備樹文件,主要包括LED以及按鍵的設備樹和axi_uart16550設備樹文件的編寫,内容如下:
/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系統啟動成功,輸入密碼和賬戶名即可。
1查看各項驅動
(1) gpio驅動
(2) uart 16550驅動
從上述信息可知成功啟動了相應驅動。
2 MIO LED實驗
該實驗的LED實驗情況如下:
實驗現象如下:
代碼如下:
#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 export\n");
exit(1);
}
write(export, "909", 4);
close(export);
printf("GPIO controller export successfully\n");
//Modify GPIO controller direction
direction = open("/sys/class/gpio/gpio909/direction",O_WRONLY);
if(direction < 0)
{
printf("Cannot open GPIO controller direction\n");
exit(1);
}
write(direction, "out", 4);
close(direction);
printf("GPIO controller direction changed to outputsuccessfully\n");
// Modify GPIO controller value
value = open("/sys/class/gpio/gpio909/value", O_RDWR);
if(value < 0)
{
printf("Cannot open GPIO controller value\n");
exit(1);
}
//Swap GPIO control value each 1 second
while (1)
{
sleep(1);
write(value,"1", 2);
printf("GPIO controller value changed to 1 successfully\n");
sleep(1);
write(value,"0", 2);
printf("GPIO controller value changed to 0 successfully\n");
}
}
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 export\n");
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 successfully\n");
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 successfully\n");
}
}
4 uart16550實驗
根據上述信息可知,串口的驅動字符名為ttyS1和ttyS2,因此實驗現象如下:
,
更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!