Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry Pi 5 + LabVIEW Hobbyist Toolkit (Floating Point Exception) #14

Closed
cycleworm opened this issue Oct 30, 2023 · 20 comments
Closed

Comments

@cycleworm
Copy link

Hi, @spathiwa, @sharpk

I just tried to get the Raspberry Pi 5 running with the LabVIEW Hobbyist Toolkit. Setting up the Pi with the integrated Configuration Tool in LabVIEW does not work. So I decided to follow the manual way, which I did successfully in the past with Raspberry Pi 4. (see description here https://forums.ni.com/t5/Hobbyist-Toolkit/Labview-CE-2020-connects-to-raspberry-but-CE-2021-does-not/m-p/4199478#M1077 )

I installed the latest packagee from this link. http://feeds.labviewmakerhub.com/debian/binary/
lvrt23-schroot_23.1.0-1.deb

First problem was that the package complained that the dependency python was missing. But it is installed. Next attempt was to ignore the dependency. So i was i able to install the package. When starting the labview.service I get an Floating Point Exception.

rpi_2023-10-29 17_19_40

I guess some of the used libraries used in the lvrt23 are not compatible with the new Raspbian OS (based on Debian Bookworm) ?
Is it possible that you compile a new lvrt.deb compatible with Raspberry Pi 5 ?

I can help, as I have the hardware already on my desk.

Used Hardware:
Raspberry Pi 5

Used Software:
LabVIEW 2023 Q3 32 Bit
LabVIEW Hobbyist Toolkit 2023 Q1
Raspberry Pi OS (32 and 64 Bit) - Newest release compatible with Raspberry Pi 5 (Debian Bookworm)

@sharpk
Copy link
Collaborator

sharpk commented Nov 8, 2023

I'll have to look into this. Was the error above generated using the 32-bit or 64-bit version of the OS?

I ask because there is a known issue that the deb package doesn't work on the 64-bit OS.

@cycleworm
Copy link
Author

Hi @sharpk. thanks for your reply. That would be great if you could look into this and help.
Yes, same problem on 32 Bit OS. (Raspberry Pi OS (32) Bit, port of Debian Bookworm.

@albsbc
Copy link

albsbc commented Nov 10, 2023

Hi @spathiwa, @sharpk, @cycleworm ,

I have built two new .deb files which allow the LINX lvrt environment to run under the Pi Bookworm OS.
The .deb files are for 32 and 64 bit versions of Pi OS.
I have more testing to do when I get my Pi 5, but GPIO, I2C, SPI and USB serial comms seem to be working ok on a Pi 4. I can also deploy a standalone exe to the Raspberry PI.
The new .deb files correct the Python error. I had to modify NISysServer.py

I'm hoping to have the modified files available next week for uploading to Github 🙂

Cheers,
AndyLB.

@cycleworm
Copy link
Author

Hi @albsbc,

Thanks a lot for trying and testing. :) Is it possible that you share a pre-release of this *.deb file with me?
Then I could test it on my Rpi5. I am working on a post for the community about LabVIEW on Raspberry Pi 5.

Thanks a lot,
Andreas

@sharpk
Copy link
Collaborator

sharpk commented Nov 14, 2023

Hi @albsbc, feel free to post a PR before you get it tested on RPi5 so we can start reviewing.

@sharpk
Copy link
Collaborator

sharpk commented Nov 14, 2023

After some investigation I think I'm seeing what @albsbc found: In the latest Raspebrry Pi OS they have removed the generic 'python' package which the LV package depends on. So the proper thing to do is update the dependency to 'python3'. This also requires that the NISysServer.py script be ported to python 3.

@sharpk sharpk mentioned this issue Nov 16, 2023
@cycleworm
Copy link
Author

i am not able to build a new *.deb file. so i installed the lastet *.deb from here http://feeds.labviewmakerhub.com/debian/binary/ and all dependencies. ignored the python dependency. replaced the NISysServer.py with the new one that you wrote @sharpk. still getting the same floating point exception.

image

I think the error comes from the lvrt file. but i am not sure. any advices how to proceed. did you have any luck so far @albsbc ?

@sharpk
Copy link
Collaborator

sharpk commented Dec 16, 2023

I suspect the issue you're seeing is due to running on a 64-bit version of Raspbian. Have you tried it on a 32-bit version?

@cycleworm
Copy link
Author

Hi. Since you mentioned that there could be problems with 64 bit I tried everything with 32 bit only.

@albsbc
Copy link

albsbc commented Dec 17, 2023

Hi @cycleworm, @sharpk,
The problem seems to be in the start-up of lvrt when the 32 bit Pi Bookworm OS is booted on the Raspberry Pi 5. It works OK when the Micro SD card is booted on a Raspberry Pi 4.
I have been debugging the start-up and will give you an update later today :)
It is possible to patch lvrt to run on the Raspberry Pi 5, but the final version will need a change to the /sys/devices/system/cpu files exported by the Pi OS. Some of the files are not created on the Raspberry Pi 5. It's this which I think is causing the divide by zero floating point exception.
There is also an issue with the GPIO numbering which will require a small change to liblinxdevice_rpi2.so. On the Raspberry Pi 5 the GPIO numbers have an offset of 399. I built a new version of liblinxdevice_rpi2.so with the offset hardcoded and was able to access the GPIO lines from LabVIEW. I2C and SPI seem to work OK!

@albsbc
Copy link

albsbc commented Dec 17, 2023

The GPIO offset could be determined at runtime and so the new liblinxdevice_rpi2.so would work on the other supported versions of Raspberry Pi.

@albsbc
Copy link

albsbc commented Dec 17, 2023

Debug information:
lvrt seems to be raising the divide by zero floating point exception in libniCPULib.so (libniCPULib.so.23.1.0). It also occurs with earlier versions of lvrt-schroot.

The exception is raised after lvrt fails to open the following files

/sys/devices/system/cpu/cpu0/cache/index0/size
/sys/devices/system/cpu/cpu0/cache/index0/number_of_sets
/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size

The files are present when lvrt is run on a Raspberry Pi 4. Raspberry Pi may correct this issue in later updates to the Pi OS.

The exception can also be generated if /sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size is modified to return a value of 0 instead of 64

Is it possible to change the default coherency_line_size value to 64 in libniCPULib.so?

@cycleworm
Copy link
Author

I have no idea how to proceed. I guess we need someone from NI ?
Is it possible to just copy the missing files from a Rpi4 to the Rpi5 ?

@sharpk
Copy link
Collaborator

sharpk commented Dec 22, 2023

@cycleworm So there's really two issues here:

  1. The Raspbian maintainers removed python2 from the most recent Raspbian OS, which broke the NISysServer.py script. I pushed a change linked above which ports the script to python3 and updates the debian package dependencies accordingly. You can workaround this issue using the script I re-wrote and by installing the existing debian package without dependencies and copying in the modified script. Not that this issue is not hardware dependent so it exists on Raspberry Pi 2,3,4 and 5.

  2. There is an issue with libNICPULib.so that is causing a floating point exception when LabVIEW starts, but only on the Raspberry Pi 5. This library is closed source so I (an NI employee with access to the source code) probably need to look into this further when I'm back in the office in January. There are two possible outcomes that I see with this: A) The Raspbian maintainers have the OS slightly misconfigured for the RPi 5 hardware, in which case they may fix it in the future ad the problem may go away just by updating to a newer version of Raspbian. OR B) there could be a logic bug in libNICPULib.so that we (NI) need to resolve.

A further note: the files that @albsbc mentioned above under /sys/devices/system/cpu/* @cycare virtual files that the Linux kernel creates at boot to give you information about the hardware. So those files can't generally be updated via an installer since they're not "real".

@albsbc
Copy link

albsbc commented Dec 30, 2023

Hi @cycleworm, @sharpk,
Thank you for your comments.
I have attached a text file showing the commands that I used to install lvrt23 on a Raspberry Pi 4 running the 32 bit Pi Bookworm OS.
Procedure_to_install_lvrt23-schroot_on_32_bit_Pi_bookworm_OS.txt

@sharpk
Copy link
Collaborator

sharpk commented Jan 5, 2024

Small update: I was finally able to get my hands on a RPi 5 and it looks like the RPi 5 isn't populating the cache information in sysfs correctly (several items like size are missing):

pi@raspberrypi:~ $ ls /sys/devices/system/cpu/cpu0/cache/index0/
level  shared_cpu_list  shared_cpu_map  type  uevent

This leads to the CPUInfo library getting into a bad state and dividing by zero which causes the exception. In theory, the Raspbian maintainers should fix this, but I think I have a fix to prevent CPUInfo from crashing as well. We'll work on packing this and the other fix into a debian package soon.

Thanks for your help @albsbc, the info you provided helped get us to a fix more quickly.

@cycleworm
Copy link
Author

cycleworm commented Jan 25, 2024

Hi @sharpk. Great news, cool that you could get an RPi5. We are planning an free LabVIEW Academic Event for all kind of educators on the 6th of march. We want to motivate them and show them what is possible today with Rpi and LabVIEW. Do you think there is a chance that it will be finished before? We would like to show the setup process there. If not, is it possible to get a prerelease? Thanks a lot.

@sharpk
Copy link
Collaborator

sharpk commented Jan 26, 2024

Hey @cycleworm, No promises, but I think we should have everything ready to go by then. We've got everything working now, it's just a matter of getting it all packaged up in installers. Out of curiosity, who is the "we" that are planning a LabVIEW Academic Event?

If you're interested in what we've been working on you can look at some of the recent PRs in the LINX repo: https://github.com/MakerHub/LINX/pulls?q=is%3Apr+is%3Aclosed

@albsbc
Copy link

albsbc commented Feb 12, 2024

Hi,
I've created a new issue on MakerHub/LINX regarding the Raspberry Pi 5 UART mapping:
LVMakerHub/LINX#127

/dev/serial0 (ttyAMA10) is wired to the UART connector instead of the 40 way connector.

@cycleworm
Copy link
Author

cycleworm commented Feb 22, 2024

oh yeah :) now it works in LabVIEW 2024 Q1 with Hobbyist Toolkit 2024 Q1 and Raspberry Pi 5. 32 bit version of bookworm installed. really happy about that.

image

@sharpk we is Kreiseder IT Services (kreiseder.org) I was working 11 years for NI in Austria and Germany. I started my own business in May 2021. To support the local academic community we are hosting our first free academic day.
https://kreiseder.org/veranstaltung/academic-day

We created a tutorial on our website to get started with Raspberry Pi 5 + LabVIEW.
https://kreiseder.org/2024/02/raspberry-pi-5-and-labview

thanks for your work! @sharpk @albsbc

@sharpk sharpk closed this as completed Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@cycleworm @sharpk @albsbc and others