` 本帖最后由 donatello1996 于 2020-12-13 12:34 编辑
收到板子已经一个多月了,而最近在忙别的事情,直到今天才有空发第一帖,还是按照我一贯的老规矩,后面会陆续补上。
板子的配件大致都是那几个常规配件,除了板子本身以外,有一个电源,两根USB线,一根端子电源线,除了没有miniDP转接显示线以外,进行基本的串口终端调试是够用的。值得注意的是,这个端子电源线在我当时收到的时候螺丝没拧紧,通电板子没有反应,我当时吓坏了还以为板子坏了,后面把螺丝重新拧紧之后就可以正常通电了。板子的主控是ZU3EG,功耗还算是比较大的,米尔厂家还配备了风扇散热,所以最好是用12V2A的适配器供电。
板子上,除了基本的USB HOST接口,USB调试串口,JTAG排针,网口,液晶屏接口以外,还针对高性能ZU3EG主控引出了一个标准PCIE接口,只不过是X1的,跟电脑主板的一样,这个接口可厉害了,可以接市面上常规的PCIE转接卡,比如PCIE转光纤口,PCIE加速卡,PCIE固态,PCIE开发板等,但可惜我手上没有这些设备,之后有机会再试一下咯。板子支持三种启动方式,分别是SD卡,EMMC,SPI FLASH,通过拨码选择,默认情况下是用厂家提供的SD卡来启动,EMMC和SPI FLASH需要自行烧录固件进行启动。
板子拿到手之后,上电完成之后的第一件事当然是串口登录和网口登录,串口登录直接用一根microUSB接上板子和电脑即可,就不多叙述了,板子系统默认支持SSH登录,直接SSH登录就可以,在/home/xilinx/build/tmp/work-shared/plnx-zynqmp/kernel-source路径下找到内核源码,可以用于编译外设驱动:
由于最近在开发 STM32和Cortex-A的USBHID 通信,因此准备了一份CustomHID的驱动源码,想要测试下板子的CustomHID通信是否支持,这个源码我之前在好几块板子上跑过,支持和不支持的各占一半,编译任何源码都需要gcc编译器,XILINX板子是自带gcc编译器的,但是不带apt软件安装工具,因为板子的文件系统不是发行版:
使用使用FZ3板子连接STM32板子:
运行效果,显示段错误,即内核不支持Custom HID设备读取,读取出来的信息结构体对象为空,就会发生段错误:
USBHID读取源码:
- /*******************************************************
- Windows HID simplification
- Alan Ott
- Signal 11 Software
- 8/22/2009
- Copyright 2009
- This contents of this file may be used by anyone
- for any reason without any conditions and may be
- used as a starting point for your own applications
- which use HIDAPI.
- ********************************************************/
- #include
- #include
- #include
- #include
- #include "hidapi.h"
- // Headers needed for sleeping.
- #ifdef _WIN32
- #include
- #else
- #include
- #endif
- int main(int argc, char* argv[])
- {
- int res;
- unsigned char buf[256];
- #define MAX_STR 255
- wchar_t wstr[MAX_STR];
- hid_device *handle;
- int i;
- #ifdef WIN32
- UNREFERENCED_PARAMETER(argc);
- UNREFERENCED_PARAMETER(argv);
- #endif
- struct hid_device_info *devs, *cur_dev;
- if (hid_init())
- return -1;
- devs = hid_enumerate(0x0, 0x0);
- if(devs==NULL)
- printf("NULL!
- ");
- printf("Device Found
- type: %04hx %04hx
- path: %s
- serial_number: %ls", devs->vendor_id, devs->product_id, devs->path, devs->serial_number);
- printf("
- ");
- printf(" Manufacturer: %ls
- ", devs->manufacturer_string);
- printf(" Product: %ls
- ", devs->product_string);
- printf(" Release: %hx
- ", devs->release_number);
- printf(" Interface: %d
- ", devs->interface_number);
- printf("
- ");
-
- cur_dev = devs;
- while (cur_dev) {
- printf("Device Found
- type: %04hx %04hx
- path: %s
- serial_number: %ls", cur_dev->vendor_id, cur_dev->product_id, cur_dev->path, cur_dev->serial_number);
- printf("
- ");
- printf(" Manufacturer: %ls
- ", cur_dev->manufacturer_string);
- printf(" Product: %ls
- ", cur_dev->product_string);
- printf(" Release: %hx
- ", cur_dev->release_number);
- printf(" Interface: %d
- ", cur_dev->interface_number);
- printf("
- ");
- cur_dev = cur_dev->next;
- }
- hid_free_enumeration(devs);
- // Set up the command buffer.
- memset(buf,0x00,sizeof(buf));
- buf[0] = 0x01;
- buf[1] = 0x81;
- handle = hid_open(2020, 2020, NULL);
- if (!handle) {
- printf("unable to open device
- ");
- return 1;
- }
- // Read the Manufacturer String
- wstr[0] = 0x0000;
- res = hid_get_manufacturer_string(handle, wstr, MAX_STR);
- if (res < 0)
- printf("Unable to read manufacturer string
- ");
- printf("Manufacturer String: %ls
- ", wstr);
- // Read the Product String
- wstr[0] = 0x0000;
- res = hid_get_product_string(handle, wstr, MAX_STR);
- if (res < 0)
- printf("Unable to read product string
- ");
- printf("Product String: %ls
- ", wstr);
- // Read the Serial Number String
- wstr[0] = 0x0000;
- res = hid_get_serial_number_string(handle, wstr, MAX_STR);
- if (res < 0)
- printf("Unable to read serial number string
- ");
- printf("Serial Number String: (%d) %ls", wstr[0], wstr);
- printf("
- ");
- // Read Indexed String 1
- wstr[0] = 0x0000;
- res = hid_get_indexed_string(handle, 1, wstr, MAX_STR);
- if (res < 0)
- printf("Unable to read indexed string 1
- ");
- printf("Indexed String 1: %ls
- ", wstr);
- // Set the hid_read() function to be non-blocking.
- hid_set_nonblocking(handle, 1);
- // Try to read from the device. There shoud be no
- // data here, but execution should not block.
- res = hid_read(handle, buf, 17);
- // Send a Feature Report to the device
- buf[0] = 0x2;
- buf[1] = 0xa0;
- buf[2] = 0x0a;
- buf[3] = 0x00;
- buf[4] = 0x00;
- res = hid_send_feature_report(handle, buf, 17);
- if (res < 0) {
- printf("Unable to send a feature report.
- ");
- }
- memset(buf,0,sizeof(buf));
- // Read a Feature Report from the device
- buf[0] = 0x2;
- res = hid_get_feature_report(handle, buf, sizeof(buf));
- if (res < 0) {
- printf("Unable to get a feature report.
- ");
- printf("%ls", hid_error(handle));
- }
- else {
- // Print out the returned buffer.
- printf("Feature Report
- ");
- for (i = 0; i < res; i++)
- printf("%02hhx ", buf[i]);
- printf("
- ");
- }
- memset(buf,0,sizeof(buf));
- // Toggle LED (cmd 0x80). The first byte is the report number (0x1).
- buf[0] = 0x1;
- buf[1] = 0x80;
- res = hid_write(handle, buf, 17);
- if (res < 0) {
- printf("Unable to write()
- ");
- printf("Error: %ls
- ", hid_error(handle));
- }
- // Request state (cmd 0x81). The first byte is the report number (0x1).
- buf[0] = 0x1;
- buf[1] = 0x81;
- hid_write(handle, buf, 17);
- if (res < 0)
- printf("Unable to write() (2)
- ");
- // Read requested state. hid_read() has been set to be
- // non-blocking by the call to hid_set_nonblocking() above.
- // This loop demonstrates the non-blocking nature of hid_read().
- res = 0;
- while (res == 0) {
- res = hid_read(handle, buf, sizeof(buf));
- if (res == 0)
- printf("waiting...
- ");
- if (res < 0)
- printf("Unable to read()
- ");
- #ifdef WIN32
- Sleep(500);
- #else
- usleep(500*1000);
- #endif
- }
- printf("Data read:
- ");
- // Print out the returned buffer.
- for (i = 0; i < res; i++)
- printf("%02hhx ", buf[i]);
- printf("
- ");
- hid_close(handle);
- /* Free static HIDAPI objects. */
- hid_exit();
- #ifdef WIN32
- system("pause");
- #endif
- return 0;
- }
复制代码
`
|