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

Upstream balenaOS patches #2

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

acostach
Copy link

@acostach acostach commented May 27, 2024

We use these patches in balenaOS for building unipi-kernel-modules with kernel 5.15.92

Would be great if we could have them in upstream, since they allow building with newer kernel versions

floion and others added 9 commits May 27, 2024 09:38
We adapt to changes introduced by
https://lore.kernel.org/lkml/20210121090020.3147058-2-gregkh@linuxfoundation.org/

Upstream-Status: Pending
Signed-off-by: Florin Sarbu <florin@balena.io>
In a change to the SPI subsystem [1], a new `delay` struct was added
to replace the `delay_usecs`. This change replaces the current
`delay_usecs` with `delay` for this driver.

[1] commit bebcfd272df6 ("spi: introduce `delay` field for
    `spi_transfer` + spi_transfer_delay_exec()")

Upstream-status: pending
Signed-off-by: Alex Gonzalez <alexg@balena.io>
Use of TTY_LDISC_MAGIC  was removed in
commit 981b22b8777d (tty: remove TTY_LDISC_MAGIC)

Upstream-status: pending
Signed-off-by: Alex Gonzalez <alexg@balena.io>
The tty_register_ldisc() call dropped accepting the ldisc number in
commit fbadf70a805 (tty: set tty_ldisc_ops::num statically)

Upstream-status: pending
Signed-off-by: Alex Gonzalez <alexg@balena.io>
Adapt to commit
0f3dcf3b5d7(tty: make fp of tty_ldisc_ops::receive_buf{,2} const)

Upstream-status: pending
Signed-off-by: Alex Gonzalez <alexg@balena.io>
The spi_set_cs_timing() interface was removed in commit
4ccf359849ce (spi: remove spi_set_cs_timing())

Upstream-status: pending
Signed-off-by: Alex Gonzalez <alexg@balena.io>
Adapt to the removal of the nvram ABI in commit
25ece30561d2 (rtc: nvmem: remove nvram ABI)

Upstream-status: pending
Signed-off-by: Alex Gonzalez <alexg@balena.io>
This change is introduced in commit
3a905c2d9544a (rtc: add devm_ prefix to rtc_nvmem_register())

Upstream-status: pending
Signed-off-by: Alex Gonzalez <alexg@balena.io>
The rename happens in commit
fdcfd854333 (rtc: rework rtc_register_device() resource management)

Upstream-status: pending
Signed-off-by: Alex Gonzalez <alexg@balena.io>
@acostach acostach mentioned this pull request May 27, 2024
@floion
Copy link

floion commented May 28, 2024

@miroslav-ondra @martytriska ^

@martytriska
Copy link
Contributor

Hi @floion ,

thank you for your effort!

However, this repository contains legacy 1st generation of the kernel drivers. Please consider upgrading your project to a new generation of drivers https://github.com/UniPiTechnology/unipi-kernel-modules.

Can you please transform and move this PR to this repo?

Thanks!

@acostach
Copy link
Author

acostach commented Jun 4, 2024

Hi @martytriska and thanks for your reply. Can the drivers in the new repository https://github.com/UniPiTechnology/unipi-kernel-modules be unloaded at runtime?

@martytriska
Copy link
Contributor

Hi @acostach, yes you are right. These modules should be unloadable at runtime (of course, you have to respect the order of particular modules during the unloading process). However, on some variants of Raspberry Pi, they can "block" the reboot without unloading them. As a workaround, our pre-compiled OS Images contain a tiny "daemon" that does the unloading stuff just before rebooting.

@acostach
Copy link
Author

acostach commented Jun 4, 2024

thanks @martytriska ! Do you know what's causing the halt on reboot? And what exact modules need to be unloaded prior to rebooting, I could check that in the daemon if you can point me to the sources

@acostach
Copy link
Author

acostach commented Jun 4, 2024

also @martytriska , I'm seeing this on the UniPi4 with the newer unipi-kernel-modules:

[   12.306049] unipi_iogroup_bus: loading out-of-tree module taints kernel.
[   12.326259] unipi-spi spi0.3: spi channel looks empty
[   12.334598] unipi-spi spi0.2: spi channel looks empty
[   12.347201] unipi-spi spi0.1: spi channel is alive
[   12.347299] unipi-spi spi0.1: Undefined modbus-address. Channel inaccessible via modbus chrdev.
[   12.348512] unipi-spi: Driver registered. Major Version: 2.52:2024:04:26

And there's no /dev/unipi* device drivers. Do I need to install other packages or dependencies in the image?

@miroslav-ondra
Copy link

New devicetree overlays are required. They are generated from templates (os-configurator-data-neuron), but they are not exported to public Github yet.
Download file https://repo.unipi.technology/debian/pool/neuron-main/u/unipi-os-configurator-data/unipi-os-configurator-data_0.68~bookworm-neuron64_arm64.deb and use overlays from it.
Sources will be available in the future.

@martytriska
Copy link
Contributor

@acostach Almost all Linux devices under /dev/ are created during driver initialization based on device tree overlays applied. This process is managed by the unipi-os-configurator tool, which is generic for all Unipi platforms, and unipi-os-configurator-data, which is specific to each PLC family. These tools use data from the device EEPROM, provided by the unipi-id kernel module, to configure all necessary overlays for the particular PLC model.

To dig deeper, I recommend you use our pre-build OS Image as a starting point.

@acostach
Copy link
Author

acostach commented Jun 5, 2024

Thanks @martytriska , @miroslav-ondra , could you please point me to the OS image I should check?

What I've tried:

Updating the package list
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian-security bookworm-security InRelease                             
Hit:3 http://archive.raspberrypi.com/debian bookworm InRelease                                      
Hit:4 http://deb.debian.org/debian bookworm-updates InRelease                                       
Get:5 https://repo.unipi.technology/debian bookworm InRelease [127 kB]        
Fetched 127 kB in 3s (37.9 kB/s)   
Reading package lists... Done
W: https://repo.unipi.technology/debian/dists/bookworm/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package unipi-kernel-modules is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  unipi-kernel-modules-dkms

E: Package 'unipi-kernel-modules' has no installation candidate
E: Unable to locate package unipi-firmware
E: Unable to locate package unipi-common
Cleaning temporary files
Cleaning temporary files

and if I try the replacement package

pi@raspberrypi:~ $ sudo apt-get install unipi-kernel-modules-dkms
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 unipi-kernel-modules-dkms : Depends: unipi-os-configurator-data but it is not installable
E: Unable to correct problems, you have held broken packages.
pi@raspberrypi:~ $ sudo apt-get install unipi-os-configurator-data
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package unipi-os-configurator-data is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'unipi-os-configurator-data' has no installation candidate

@martyy665
Copy link

Hi @acostach,

as a good starting point, you can use the following beta testing image(s):

32bit
https://kb.unipi.technology/files:software:os-images:neuron-base-os-hidden

64bit
https://kb.unipi.technology/files:software:os-images:neuron64-base-os-hidden

@acostach
Copy link
Author

acostach commented Jun 7, 2024

Thanks @martyy665 , @miroslav-ondra I've looked into the 64bit Neuron image and can see the overlays being applied by the boot script according to the detected configuration.

It's not clear to me though if the unipi-tools installed in the beta-image is at the same revision as https://github.com/UniPiTechnology/unipi-tools, because the unipi-tools repository has last been updated 3 years ago. It seems there's also other packages in the beta-image which aren't available in github.

For example I see files like /opt/unipi/firmware/opt/unipi/firmware/00-1.img provided by a package named unipi-firmware6, which are not part of the unipi-os-configurator-data.deb.

Is there an ETA for when the BSP in the beta image will become production ready, also with sources available in github?

Thank you

@acostach
Copy link
Author

@martyy665
Copy link

Hi @acostach,

the unipi-tools repo has been updated to the latest version. Can you check if everything is clear for you now?

Regarding the firmware - please use only 6.xx version as previous legacy versions are no longer supported and do not contain all current HW. All firmware files for version 6.xx are in .img format and follow the naming pattern xx-y.img. All of them are provided by unipi-firmware6 Debian package in its binary form. In the tools repo package, just tools for firmware upgrading are contained.

You can download any of the packages from the repo directly:

https://repo.unipi.technology/

Please let me know if there is anything else you need.

Thank you for your effort :-)!

@tomashora
Copy link

tomashora commented Jun 27, 2024

Hello @acostach / @floion, could you please check the above suggestion and provide us with your feedback/opinion what else coud we do to help?

@acostach
Copy link
Author

Hi @tomashora , sorry, I've been caught up with other projects and didn't get to look at the updated repositories yet. I plan to get back to this in the following weeks and will let you know. Thank you!

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

Successfully merging this pull request may close these issues.

7 participants