今天进行machinekit安装时出现了如下报警,查找原因,原来是arm64位的系统,在/usr/include/…/sys
/下面没有io.h,但是可以手动进行创建。但是需要根据自己的板子修改下PCI_IOBASE地址
Compiling machinetalk/support/sizes.c
In file included from rtapi/rtapi.h:1016:0,
from hal/lib/hal.h:126,
from ./emc/motion/motion.h:80,
from machinetalk/support/sizes.c:2:
rtapi/rtapi_io.h:39:43: fatal error: sys/io.h: No such file or directory
compilation terminated.
Makefile:420: recipe for target 'objects/machinetalk/support/sizes.o' failed
io.h的源码如下图,记得修改PCI_IOBASE地址
/*
A largely dummy io.h to statisfy the requirements of Machinekit
on aarch64
The functions still require a valid base address, which appears to be
#define PCI_IOBASE ((void __iomem *)(MODULES_VADDR - SZ_2M))
MODULES_VADDR being the address at which insmod begins loading kernel modules
*/
#ifndef _SYS_IO_H
#define _SYS_IO_H
#include <features.h>
// as per arch/.../memory.txt
#define PCI_IOBASE 0xfee00000UL
// ((void __iomem *)(MODULES_VADDR - SZ_2M))
//((void __iomem *)PCI_IO_START)
__BEGIN_DECLS
/* If TURN_ON is TRUE, request for permission to do direct i/o on the
port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
permission off for that range. This call requires root privileges.
Portability note: not all Linux platforms support this call. Most
platforms based on the PC I/O architecture probably will, however.
E.g., Linux/Alpha for Alpha PCs supports this. */
//extern int ioperm (unsigned long int __from, unsigned long int __num,
// int __turn_on) __THROW;
/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
access any I/O port is granted. This call requires root
privileges. */
// Does not appear this call is supported
// dummy function to return 0 (success and keep pci_write happy
//int iopl(int __level) { return 0; }
#if defined __GNUC__ && __GNUC__ >= 2
// Does not appear this call is supported
// dummy function to return 0 (success and keep pci_write happy
static __inline int iopl(int __level) { return 0; }
static __inline unsigned char
inb (unsigned short int __port)
{
unsigned char val;
unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
asm volatile("ldrb %w0, [%1]" : "=r" (val) : "r" (addr));
return val;
}
static __inline unsigned short int
inw (unsigned short int __port)
{
unsigned short val;
unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
asm volatile("ldrh %w0, [%1]" : "=r" (val) : "r" (addr));
return val;
}
static __inline unsigned int
inl (unsigned short int __port)
{
unsigned int val;
unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
asm volatile("ldrh %w0, [%1]" : "=r" (val) : "r" (addr));
return val;
}
///
static __inline void
outb (unsigned char __value, unsigned short int __port)
{
unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
asm volatile("strb %w0, [%1]" : : "r" (__value), "r" (addr));
}
static __inline void
outw (unsigned short int __value, unsigned short int __port)
{
unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
asm volatile("strh %w0, [%1]" : : "r" (__value), "r" (addr));
}
static __inline void
outl (unsigned int __value, unsigned short int __port)
{
unsigned long addr = ((unsigned long) __port + PCI_IOBASE);
asm volatile("strh %w0, [%1]" : : "r" (__value), "r" (addr));
}
#endif /* GNU C */
__END_DECLS
#endif /* _SYS_IO_H */
参考网址 https://github.com/machinekit/machinekit-hal/issues/96