0

我想在 Aria V hps 和我的 nios 处理器之间使用 Altera MM Mailbox IP 组件进行通信。

Qsys中的项目

我设法为 Nios 处理器(FPGA 端)写下 C 代码以使用邮箱 IP,然后通过 EDS 使用 sopc-create-header-files 为 HPS 制作头文件。

生成的头文件的链接

这是 sopc-create-header-files 为我所做的:

#define MAILBOX_SIMPLE_0_COMPONENT_TYPE altera_avalon_mailbox_simple
#define MAILBOX_SIMPLE_0_COMPONENT_NAME mailbox_simple_0
#define MAILBOX_SIMPLE_0_BASE 0x60
#define MAILBOX_SIMPLE_0_SPAN 16
#define MAILBOX_SIMPLE_0_END 0x6f

但我不知道如何使用它。在 NIOS IDE 中我包含了库 altera_avalon_mailbox_simple.h,而在 DS-5 中我没有。我应该在我的 DS-5 项目中包含任何其他邮箱库吗?也许我应该使用相同的方法将邮箱映射为外围设备?

void mmap_fpga_peripherals()
{
    h2f_lw_axi_master = mmap(NULL, h2f_lw_axi_master_span, PROT_READ | PROT_WRITE, MAP_SHARED, fd_dev_mem, h2f_lw_axi_master_ofst);

    if(h2f_lw_axi_master == MAP_FAILED)
    {
        printf("ERROR: h2f_lw_axi_master mmap() failed.\n");
        printf("    errno = %s\n", strerror(errno));
        close(fd_dev_mem);
        exit(EXIT_FAILURE);
    }

    fpga_buttons = h2f_lw_axi_master + BUTTONS_0_BASE;
    fpga_hex_displays[0] = h2f_lw_axi_master + HEX_0_BASE;
    fpga_hex_displays[1] = h2f_lw_axi_master + HEX_1_BASE;
    fpga_hex_displays[2] = h2f_lw_axi_master + HEX_2_BASE;
    fpga_hex_displays[3] = h2f_lw_axi_master + HEX_3_BASE;
    fpga_hex_displays[4] = h2f_lw_axi_master + HEX_4_BASE;
    fpga_hex_displays[5] = h2f_lw_axi_master + HEX_5_BASE;
}

但我认为我不应该使用mmap_fpga_peripherals()来映射邮箱。我不确定。

4

1 回答 1

0

您还应该通过 sopc2dts 生成设备树二进制文件,该二进制文件通常位于路径 intelFPGA/xxx/embedded/host_tools/altera/device_tree 下。然后在邮箱设备的基础上编写Linux驱动程序。有关详细信息,请参阅 Linux 项目中的规范。

Documentation/devicetree/bindings/mailbox/altera-mailbox.txt
Documentation/mailbox.txt
drivers/mailbox/mailbox.c
drivers/mailbox/mailbox-altera.c
drivers/mailbox/mailbox-test.c
include/linux/mailbox_client.h
include/linux/mailbox_controller.h
于 2021-10-13T08:02:59.480 回答