Comparison between Raspian 12 Bookworm on Raspberry Pi 4 and Raspberry Pi 5

More
13 Nov 2023 08:44 #285239 by elovalvo
In the last few days there have been a lot of news that have led me to study the performance of LinuxCNC on Raspberry Pi.

In particular, the novelties are:
- purchase of the new model of Raspberry Pi 5
www.raspberrypi.com/documentation/computers/raspberry-pi-5.html

- availability of a new version of the Raspbian operating system based on Linux 6.1 and Debian 12
downloads.raspberrypi.com/raspios_arm64/release_notes.txt

- availability of a new version of the patches to PREEMPT_RT the latest version of Raspbian compatible
github.com/kdoren/linux/releases/tag/rpi_6.1.54-rt15

- the release of the official version of LinuxCNC 2.9.1
forum.linuxcnc.org/29-forum-announcement...2-9-0-release#284586

In the next two posts I will tell you about my experience

Please Log in or Create an account to join the conversation.

More
13 Nov 2023 08:52 - 13 Nov 2023 08:56 #285240 by elovalvo
- Raspian 12 Bookworm version on Raspberry Pi 4 

As reported here
linuxcnc.org/docs/devel/html/getting-sta...lling_on_raspbian_12
I prepared a microSD card with the latest version of Raspbian to use on both Raspberry Pi4 and Pi5 and then evaluate the differences

After up to date with the latest packages, I moved on to install the patch for the PREEMPT_RT.

It must be said that I didn't use the command 
    sudo apt-get install linux-image-rt-arm64
in addition to the fact that the available version is not aligned with the version of the operating system and that in any case (having tried directly) despite the installation being completed without errors, it does not produce any effect.
In my opinion this is due to the fact that the procedure installs the files in /boot rather than in /boot/firmware.
packages.debian.org/bookworm/arm64/linux...13-rt-arm64/filelist

Therefore I followed the Kevin Doren procedure mentioned above.
It should be noted, as reported in the link above, that the installation instructions currently require changes for debian bookworm that expects the files to be copied into directory /boot/firmware/ instead of /boot/

Verify the correct installation with the command
pi@raspberrypi4:~ $ uname -a
Linux raspberrypi4 6.1.54-rt15-v8+ #1 SMP PREEMPT_RT Fri Sep 29 08:29:09 BST 2023 aarch64 GNU/Linux

Then I added "isolcpus=2,3 max.processor.cstate=1"  to /boot/cmdline.txt (for latency issues)


Installing Linuxcnc can be done easily with the LinuxCNC installer script 
www.linuxcnc.org/linuxcnc-install.sh

The result of the latency test (latency-histogram --nobase --sbinsize 1000 --servo 40000)
is the following
 

Then I verified that the hal_pi_gpio and hal_gpio modules load without error.
pi@raspberrypi4:~ $ halrun -I
halcmd: loadrt hal_gpio inputs=GPIO6,GPIO12,GPIO13,GPIO16,GPIO17,GPIO18,GPIO19 \
halcmd+:                                 outputs=GPIO20,GPIO21,GPIO22,GPIO23,GPIO24,GPIO25,GPIO26,GPIO27 \
halcmd+:                                 invert=GPIO20,GPIO27 \
halcmd+:                                 reset=GPIO21,GPIO22
Note: Using POSIX realtime
halcmd: show pin
Component Pins: Owner   Type  Dir      Value  Name      
4  bit   OUT         FALSE  hal_gpio.GPIO12-in      
4  bit   OUT         FALSE  hal_gpio.GPIO12-in-not      
4  bit   OUT         FALSE  hal_gpio.GPIO13-in      
4  bit   OUT         FALSE  hal_gpio.GPIO13-in-not      
4  bit   OUT         FALSE  hal_gpio.GPIO16-in      
4  bit   OUT         FALSE  hal_gpio.GPIO16-in-not      
4  bit   OUT         FALSE  hal_gpio.GPIO17-in      
4  bit   OUT         FALSE  hal_gpio.GPIO17-in-not      
4  bit   OUT         FALSE  hal_gpio.GPIO18-in      
4  bit   OUT         FALSE  hal_gpio.GPIO18-in-not      
4  bit   OUT         FALSE  hal_gpio.GPIO19-in      
4  bit   OUT         FALSE  hal_gpio.GPIO19-in-not      
4  bit   IN          FALSE  hal_gpio.GPIO20-out      
4  bit   IN          FALSE  hal_gpio.GPIO21-out     
4  bit   IN          FALSE  hal_gpio.GPIO22-out      
4  bit   IN          FALSE  hal_gpio.GPIO23-out      
4  bit   IN          FALSE  hal_gpio.GPIO24-out      
4  bit   IN          FALSE  hal_gpio.GPIO25-out      
4  bit   IN          FALSE  hal_gpio.GPIO26-out      
4  bit   IN          FALSE  hal_gpio.GPIO27-out      
4  bit   OUT         FALSE  hal_gpio.GPIO6-in      
4  bit   OUT         FALSE  hal_gpio.GPIO6-in-not      
4  s32   OUT             0  hal_gpio.read.time      
4  s32   OUT             0  hal_gpio.reset.time      
4  s32   OUT             0  hal_gpio.write.time

However, this microSD is not compatible with the Raspberry Pi 5, due to the PREEMPT_RT patch which is not compatible.

Therefore I had to prepare a new microSD for the new Raspberry.
Attachments:
Last edit: 13 Nov 2023 08:56 by elovalvo.
The following user(s) said Thank You: dskinne6

Please Log in or Create an account to join the conversation.

More
13 Nov 2023 09:11 - 13 Nov 2023 09:15 #285243 by elovalvo
To prepare a version of Raspbian 12 for Raspberry Pi 5 with PREEMPT_RT I used the script reported here

forums.raspberrypi.com/viewtopic.php?p=2145335

appropriately modified to take account of the patch, taking into account the indications given here
github.com/kdoren/linux/wiki/Building-PR...nel-for-Raspberry-Pi

I used the Linux Kernel is 6.1.61 while the RT patch used is the one for 6.1.59-rt16
 
The procedure produced no errors and therefore I installed the OS on a new microSD containing the new Raspbian 12
pi@raspberrypi5:~ $ uname -a
Linux raspberrypi5 6.1.61-rt16-v8_16k-elvrt+ #3 SMP PREEMPT_RT Tue Nov 7 13:13:29 CET 2023 aarch64 GNU/Linux

Then I added "isolcpus=2,3 max.processor.cstate=1" to /boot/cmdline.txt

Also in this case installing Linuxcnc can be done easily with the LinuxCNC installer script
www.linuxcnc.org/linuxcnc-install.sh

I then ran the command "latency-histogram --nobase --sbinsize 1000 --servo 25000". the value 25000 of the servo parameter is the minimum value allowed by the procedure

The results are definitely surprising

 

I tried the latency test here with smaller servo values.
The lowest value that did not show the "Unexpected realtime delay" message was
latency-test 12000
 

However the hal_pi_gpio module could not be loaded
pi@raspberrypi5:~ $ halrun -I
halcmd: loadrt hal_pi_gpio
Note: Using POSIX realtime Raspberry Pi 5 Model B Rev 1.0 found
The Pi model 23 is not known to work with this driver but will be assumed to be be using the RPi2+ layout 40 pin connector
HAL_PI_GPIO: can't open /dev/gpiomem:  2 - No such file or directory
If the error is 'permission denied' then try adding the user who runs
LinuxCNC to the gpio group: sudo gpasswd -a username gpio
HAL_PI_GPIO: can't open /dev/mem:  13 - Permission denied
hal_pi_gpio: rtapi_app_main: Operation not permitted (-1) 
:1:waitpid failed /usr/bin/rtapi_app hal_pi_gpio
:1:/usr/bin/rtapi_app exited without becoming ready
:1: insmod for hal_pi_gpio failed, returned -1

Instead the hal_gpio module it needs to be changed like this
pi@raspberrypi5:~ $ halrun -I
halcmd: loadrt hal_gpio inputs=PIN31,PIN32,PIN33,PIN36,PIN11,PIN12,PIN35 \
halcmd+:                                 outputs=PIN38,PIN40,PIN15,PIN16,PIN18,PIN22,PIN37,PIN13 \
halcmd+:                                 invert=PIN38,PIN13 \
halcmd+:                                 reset=PIN40,PIN15
Note: Using POSIX realtime
halcmd: show pin Component Pins: Owner   Type  Dir         Value  Name      
4  bit   OUT         FALSE  hal_gpio.PIN11-in      
4  bit   OUT         FALSE  hal_gpio.PIN11-in-not      
4  bit   OUT         FALSE  hal_gpio.PIN12-in      
4  bit   OUT         FALSE  hal_gpio.PIN12-in-not      
4  bit   IN          FALSE  hal_gpio.PIN13-out      
4  bit   IN          FALSE  hal_gpio.PIN15-out      
4  bit   IN          FALSE  hal_gpio.PIN16-out      
4  bit   IN          FALSE  hal_gpio.PIN18-out      
4  bit   IN          FALSE  hal_gpio.PIN22-out      
4  bit   OUT         FALSE  hal_gpio.PIN31-in      
4  bit   OUT         FALSE  hal_gpio.PIN31-in-not      
4  bit   OUT         FALSE  hal_gpio.PIN32-in      
4  bit   OUT         FALSE  hal_gpio.PIN32-in-not      
4  bit   OUT         FALSE  hal_gpio.PIN33-in      
4  bit   OUT         FALSE  hal_gpio.PIN33-in-not      
4  bit   OUT         FALSE  hal_gpio.PIN35-in      
4  bit   OUT         FALSE  hal_gpio.PIN35-in-not      
4  bit   OUT         FALSE  hal_gpio.PIN36-in      
4  bit   OUT         FALSE  hal_gpio.PIN36-in-not      
4  bit   IN          FALSE  hal_gpio.PIN37-out      
4  bit   IN          FALSE  hal_gpio.PIN38-out      
4  bit   IN          FALSE  hal_gpio.PIN40-out      
4  s32   OUT             0  hal_gpio.read.time      
4  s32   OUT             0  hal_gpio.reset.time      
4  s32   OUT             0  hal_gpio.write.time


Obviously, I remain available to anyone who would like further information
Attachments:
Last edit: 13 Nov 2023 09:15 by elovalvo.
The following user(s) said Thank You: flyingbrick

Please Log in or Create an account to join the conversation.

More
13 Nov 2023 10:13 #285245 by cornholio
What latency are you getting running a servo & base thread ?

Please Log in or Create an account to join the conversation.

More
13 Nov 2023 14:43 #285264 by elovalvo

What latency are you getting running a servo & base thread ?

Result of latency-test

 

Result of latency-histogram

 
 
Attachments:
The following user(s) said Thank You: tommylight, cornholio, flyingbrick

Please Log in or Create an account to join the conversation.

More
14 Nov 2023 10:17 #285358 by rodw
The offical installer needs a bit of work right now as it predates the availability of the install script from linuxcnc you use.
Nobody could give me a repository to use at the time so it downloads the debs from the repo and installs them.
Andy then wrote the installer script you use and I started on updating the AMD64 live installer.
I intend to redo it to follow the linuxcnc script install as this will mean it can be updated with Debian 12
My final updates to the linux AMD64 ISO build were committed today so I should have time to do this shortly.

I think the linuxcnc installer I wrote follows pretty much the same method as your build script from the pi forum. The difference is that we clone the Raspberry Linux  source at the specific commit the RT patch is merged into their mainline rpi-6.1.y branch.
github.com/raspberrypi/linux
This ensures that the kernel exactly matches the RT patch at kernel.org mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/6.1/
The RT patch is placed in this folder github.com/rodw-au/rpi-img-builder-lcnc/...nc-2.9.1/userpatches

We last did this at the 6.1.54 merge on commit fad58933544bb2a7b7db92847c25c79a83171fa6
I did note the 6.1.59 RT patch was released. I can find the commit creating Raspberry's 6.1.59 branch but I cannot see where it (or later branches) was merged into their mainline. So I can't recommend advancing past the current 6.1.54 RT patch.
The commit number is easilly set in userdata.txt  here github.com/rodw-au/rpi-img-builder-lcnc/...ata.txt#L26C9-L26C49
Also, we do set the same kernel commands as you use here github.com/rodw-au/rpi-img-builder-lcnc/...rscripts/uscripts#L6

And finally, we install XFCE and other extras in the same way described in the linuxcnc docs you referred to which I wrote.

But all in all, I doubt its a good idea to do an apt update in case the kernel us upgraded, breaking our RT patch. Maybe its OK as the kernel is pure Raspberry and nothing that Debian knows about.

I do know from my own experience is if the kernel version gets too far ahead of the RT patch (even by a few days I found), the system becomes unstable
The following user(s) said Thank You: flyingbrick

Please Log in or Create an account to join the conversation.

More
16 Nov 2023 08:34 #285587 by cornholio
Man I'm having a hell of a time getting an real time kernel to boot on my RPi5, any chance of sharing your image ?

rpi-image-builder was no good either

Please Log in or Create an account to join the conversation.

More
16 Nov 2023 09:19 #285591 by rodw
Hmm, Cornelius upstream added preliminary support for the 5b in early october.

github.com/pyavitz/rpi-img-builder
the commit is at github.com/pyavitz/rpi-img-builder/commi...a0b81cf61efcf56500ea

Maybe its time to merge upstream into my repo. Then just change the board when building  and it should work

I may have time later tonight to give that a go.

Please Log in or Create an account to join the conversation.

More
16 Nov 2023 10:02 #285594 by cornholio
Preformed a git pull and had no luck :(

got "running /scripts/local/block" loop

Building a non-realtime kernel natively ATM using the script above to see how we go. If that boots I'll try a building a real time kernel.

Is it the branding that prevent us from distributing a image based on the Raspbain-OS ?

Please Log in or Create an account to join the conversation.

More
16 Nov 2023 11:38 #285603 by elovalvo

Man I'm having a hell of a time getting an real time kernel to boot on my RPi5, any chance of sharing your image ?

rpi-image-builder was no good either

Are you addressing me?

Please Log in or Create an account to join the conversation.

Time to create page: 0.167 seconds
Powered by Kunena Forum