This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/66AK2L06: error in memory mapping GPIO.

Part Number: 66AK2L06

Tool/software: Linux

Hello,

I will try to in and out using GPIO 2, 3.

And i will control gpio using mmap() because sysfs is too slow ( I want output frequency to 5MHz).

I know below.

#define GPIO_BASE		0x0260BF00
#define GPIO_START_ADD	0x0260BF00
#define GPIO_END_ADD	0x0260BFFF

static int dev_fd;

int main(void) {

	dev_fd = open("/dev/mem", O_RDWR | O_SYNC);

	if (dev_fd < 0) {
		printf("oepn(/dev/mem) failed.\n");
		return 0;
	}

	unsigned int *map_base = (unsigned int *)mmap(NULL, 0xFF, PROT_READ | PROT_WRITE, MAP_SHARED, dev_fd, GPIO_BASE);

	if (map_base == MAP_FAILED) {
		perror("Map failed;\n");
		return -1;
	}
	
	return 0;
}

The result is invalid argument.

What is problem?

Thank you!