Created
September 21, 2023 01:23
-
-
Save sonnny/b904686ff9eb9e5eb0671bda9595664a to your computer and use it in GitHub Desktop.
orangepi cross compile on linux x86 desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// cross compiling on linux | |
// download compiler from https://imola.armbian.com/dl/_toolchain/ | |
// gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz | |
// extract compiler | |
// compile on linux host (assumes x86) | |
// bin/aarch64-none-linux-gnu-gcc gpio.c | |
// this will produce a.out | |
// copy to orangepi | |
// scp a.out [email protected]:/home/orangepi/a.out | |
// orangepi password is orangepi for user orangepi and root | |
// | |
// go to orangepi | |
// ssh [email protected] (password: orangepi) | |
// execute sudo ./a.out (pin 70 should blink) | |
// | |
// assuming root | |
// echo 70 > /sys/class/gpio/export | |
// echo out > /sys/class/gpio/gpio70/direction | |
#include <stdio.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
int main(){ | |
int fs_value=open("/sys/class/gpio/gpio70/value",O_WRONLY); | |
for(int i=0; i<5; i++){ | |
write(fs_value,"1",1); | |
sleep(1); | |
write(fs_value,"0",1); | |
sleep(1);} | |
close(fs_value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment