---
# System prepended metadata

title: '[rpi readme](https://hackmd.io/@gjm060606/HyFZksdxt)'
tags: [rpi]

---

---
tags: rpi
---
# [rpi readme](https://hackmd.io/@gjm060606/HyFZksdxt)
* [name=Jimmy]

## UART pin
https://pi4j.com/1.3/pins/rpi-cm4.html
![](https://i.imgur.com/Pjjgphy.jpg)

## install toolchain
sudo mkdir -p /opt/rpi
sudo tar xjvf rpi-gcc-8.3.0_linux.tar.bz2 -C /opt/rpi

## install xenomai lib
sudo tar xjvf xenomai_rpi.tar.bz2 -C /usr/

## install qt5
sudo tar xjvf Qt5.14.1_rpi.tar.bz2 -C /usr/local

## export ENV
export PATH=/opt/rpi/rpi-gcc-8.3.0/bin: $PATH
export PATH=/usr/local/Qt5.14.1/bin: $PATH
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-

## Makefile
```
CC=/opt/rpi/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf-gcc
STRIP=/opt/rpi/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf-strip -s
XENO=/usr/xenomai
OPT_XML2=/home/jimmykuo/hda3/rpi/libxml2-2.7.8/opt
OPT_EC=/home/jimmykuo/hda3/rpi/etherlab
MY_CFLAGS := -O2 -pipe -g -feliminate-unused-debug-types -I$(XENO)/include/trank -I$(XENO)/include/mercury 

XENOCONFIG = $(shell PATH=$(XENO):$(XENO)/bin:$(PATH) which xeno-config 2>/dev/null) 
CFLAGS := $(shell $(XENOCONFIG) --skin=alchemy --cflags) $(MY_CFLAGS)
LDFLAGS :=$(shell $(XENOCONFIG) --skin=alchemy --ldflags) $(MY_LDFLAGS) 
ifeq ($(XENOCONFIG),)
all:
        @echo ">>> Invoke make like this: \"make XENO=/path/to/xeno-config\" <<<"
        @echo
endif

LDFLAGS += -Xlinker -rpath -Xlinker $(shell $(XENOCONFIG) --libdir)
#LDFLAGS += -Wl,--gc-sections -static
LDFLAGS += -Wl,--rpath -Wl,$(OPT_EC)/lib

LIBS = -lethercat -lxml2 -lpthread


ifneq ($(OPT_EC),)
INCLUDES +=-I$(OPT_EC)/include 
LIBS     +=-L$(OPT_EC)/lib
endif

ifneq ($(OPT_XML2),)
INCLUDES +=-I$(OPT_XML2)/include/libxml2 
LIBS     +=-L$(OPT_XML2)/lib
endif

ifneq ($(XENO),)
INCLUDES +=-I$(XENO)/include
LIBS     +=-L$(XENO)/lib
endif

INCLUDES +=-I$(XENO)/include/trank

PROGNAME = remoteio-test
SOURCES = main.c
OBJS = main.o

all:$(PROGNAME)
$(PROGNAME):$(OBJS)
        @echo -=--=--=- [$(PROGNAME)] -=--=--=--=--=--=--=--=--=-       
        $(CC) $(CFLAGS) $(LDFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)
#       $(STRIP) $(PROGNAME)
#       $(RM) $(OBJS)
```