PREEMPT_RT kernel on UP! Xtreme based on UP! kernel hwe-5.4-upboard. Only tested on UP Xtreme i7C1-8565U
sudo apt install build-essential fakeroot dpkg-dev perl libssl-dev bc gnupg dirmngr libncurses5-dev libelf-dev flex bison
mkdir ~/kernel
cd ~/kernel
git clone https://github.com/AaeonCM/ubuntu-bionic-up.git
cd ubuntu-bionic-up
git checkout hwe-5.4-upboard
make kernelversion
--Gives information on kernel version-- in my case (5.4.65)--
wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patch-5.4.66-rt38.patch.xz
unxz -cd patch-5.4.66-rt38.patch.xz | patch -p1
-
cp /boot/config-5.4.0-1-generic .config
-
make defconfig
-
xdg-open .config
(text based) -
make menuconfig
(GUI based)
HIGH_RES_TIMERS=y
CONFIG_PREEMPT_RT=y
CONFIG_HZ_1000=y
CONFIG_HZ=1000
CONFIG_OF=n
CONFIG_AUFS_FS=n
disable the CPU idle state and to set the default CPU frequency governor to performance
CONFIG_CPU_IDLE=n
CONFIG_INTEL_IDLE=n
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
To check.
make
(NOTE: You can use “make -jX” option if you have thread support. X is number of core + 1. It will compile faster)
sudo make modules_install -j2
sudo make install -j2
cd /boot
ls
You will see new kernel. (UPDATE TEXT HERE)
sudo update-grub
sudo reboot
uname -a
sudo add-apt-repository ppa:ubilinux/up
sudo apt update
sudo apt install upboard-extras
cd ~/temp
wget https://github.com/raess1/UPxtreme-RT-kernel/blob/main/permissiongroups.sh
chmod +x permissiongroups.sh
./permissiongroups.sh
after that you need to add the user that needs to access the HAT functionality to the corresponding groups:
GPIO
sudo usermod -a -G gpio ${USER}
LEDs
sudo usermod -a -G leds ${USER}
SPI
sudo usermod -a -G spi ${USER}
I2C
sudo usermod -a -G i2c ${USER}
UART
sudo usermod -a -G dialout ${USER}
to apply the permission changes after issuing the previous command a reboot is needed
sudo reboot
echo 26 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio26/direction
echo 1 > /sys/class/gpio/gpio26/value
Should make pin37 output 3.3v (measure)
echo 0 > /sys/class/gpio/gpio26/value
Should make pin37 output 0V (measure)
The UP Board includes 3 LEDs (yellow, green, red) on the underside of the board (underneath the 4 USB2.0 Type-A sockets), which are controlled by the pin control CPLD on the board. As root, you can use the following commands to control the LEDs:
echo 1 > /sys/class/leds/upboard\:green\:/brightness
echo 0 > /sys/class/leds/upboard\:green\:/brightness
sudo apt-get install build-essential libnuma-dev
mkdir ~/rt
cd ~/rt
git clone git://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git
cd rt-tests
git checkout stable/v1.0
make all
make install
To run one test thread per CPU or per CPU core, each thread on a separate processor, type
sudo ./cyclictest -a -t -n -p99
On a non-realtime system, you may see something like
T: 0 ( 1946) P:99 I:1000 C: 21097 Min: 1 Act: 3 Avg: 2 Max: 177
T: 1 ( 1947) P:99 I:1500 C: 14064 Min: 1 Act: 3 Avg: 3 Max: 152
T: 2 ( 1948) P:99 I:2000 C: 10548 Min: 1 Act: 1 Avg: 3 Max: 152
T: 3 ( 1949) P:99 I:2500 C: 8439 Min: 1 Act: 3 Avg: 3 Max: 168
T: 4 ( 1950) P:99 I:3000 C: 7032 Min: 1 Act: 3 Avg: 3 Max: 139
T: 5 ( 1951) P:99 I:3500 C: 6027 Min: 1 Act: 3 Avg: 3 Max: 169
T: 6 ( 1952) P:99 I:4000 C: 5274 Min: 1 Act: 3 Avg: 3 Max: 170
T: 7 ( 1953) P:99 I:4500 C: 4688 Min: 1 Act: 2 Avg: 4 Max: 123
RT-PREEMPT
Note: adjust CPU cores on line 2 and 11 in rt-test.sh
sudo apt install rt-tests stress gnuplot
mkdir ~/plot
cd ~/plot
git clone https://github.com/QiayuanLiao/Ubuntu-RT-UP-Board.git
cd ~/Ubuntu-RT-UP-Board
cd ~/test
sudo sh ./rt-test.sh
rt-can-test is to provide an easy way to test the performance of the Linux PREEMPT_RT patches together with CAN.
The following tests has been performed on https://www.peak-system.com/PCAN-M-2.473.0.html?&L=1 (PCAN-M.2 Four Channel) mounted on UP Xtreme i7C1-8565U (https://up-board.org/up-xtreme/) and transmit CAN message to a moteus r4.5 controller (https://mjbots.com/products/moteus-r4-5) with ID:1
cd ~/repos
git clone https://github.com/erstrom/rt-can-test.git
cd ~/rt-can-test
sudo make
sudo make install
Adapter such as the PEAK-CAN-FD use a 80MHz clock. The following timings have been observed to work (from https://github.com/mjbots/moteus/blob/main/docs/reference.md#80-mhz-clock-systems)
sudo ip link set can3 up type can \
tq 12 prop-seg 25 phase-seg1 25 phase-seg2 29 sjw 10 \
dtq 12 dprop-seg 6 dphase-seg1 2 dphase-seg2 7 dsjw 12 \
restart-ms 1000 fd on
sudo rt-can-test --if can3 --tx 00008001##1420120 -i 100000 -r -v
snippet from console output
[ 16719.938193] TX: 100##1410100
[ 16719.939749] RX: 100##1410100
[ 16720.038242] TX: 100##1410100
[ 16720.039670] RX: 100##1410100
[ 16720.138278] TX: 100##1410100
[ 16720.139730] RX: 100##1410100
sudo rt-can-test --if can3 --tx 00008001##1420120 -i 10000 -r -v
snippet from console output
[ 16681.619501] TX: 100##1410100
[ 16681.620853] RX: 100##1410100
[ 16681.629555] TX: 100##1410100
[ 16681.630995] RX: 100##1410100
[ 16681.639611] TX: 100##1410100
[ 16681.641081] RX: 100##1410100
sudo rt-can-test --if can3 --tx 00008001##1420120 -i 1000 -r -v
snippet from console output
[ 16874.632739] TX: 100##1410100
[ 16874.633044] RX: 100##1410100
[ 16874.633064] RX: 100##1410100
[ 16874.633748] TX: 100##1410100
[ 16874.634755] TX: 100##1410100
[ 16874.635035] RX: 100##1410100
Remove custom kernel
locate -b -e 5.4.65-rt38+
remove
locate -b -e 5.4.65-rt38+ | xargs -p sudo rm -r
sudo update-grub
cd /boot/
ls
Audio problem:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash snd_hda_intel.dmic_detect=0"