Zynqでネイティブgcc

やっと、Zynq上でコンパイルができた。

root@zedboard-aquaxis:~# gcc --version

gcc (GCC) 4.8.1

Copyright (C) 2013 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

テストソースは下記のような感じで、axi_gpioでLEDを0xAAで光らせてみた。

横着してごめんなさい。

"/dev/mem"でmmapして、BASE_ADRSでaxi_gpioのアドレスへ明示的にずらしてます。

include <unistd.h>

include <sys/mman.h>

include <stdio.h>

include <fcntl.h>

define SIZE 0x1000

define BASE_ADRS 0x41240000

define REG_DATA 0x00

define REG_TRI  0x01

void main(){

  int fd;

  unsigned int *buf;

  fd = open("/dev/mem", O_RDWR),

  if (fd == -1) {

    printf("open\n"),

    return;

  }

  buf = mmap(NULL, SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, BASE_ADRS),

  if (buf == MAP_FAILED) {

    printf("mmap\n"),

    return;

  }

  buf[REG_TRI]  = 0x00;

  buf[REG_DATA] = 0xAA;

  munmap(buf, SIZE),

  close(fd),

}

#ドライバは週末に作ろう

#DTBとuio_platform_genirqを使うつもりだけど・・・

write: 2013/10/23/ 02:44:14