From 169377cc435bbc7fecde2fae1525e8c0cc439e1e Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 12 May 2023 11:25:59 -0700 Subject: [PATCH] Fix i2smic by checking if userspace and kernel space are the same --- i2smic.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/i2smic.py b/i2smic.py index b8a71f8..d40691c 100644 --- a/i2smic.py +++ b/i2smic.py @@ -1,3 +1,5 @@ +import platform + try: from adafruit_shell import Shell except ImportError: @@ -5,6 +7,12 @@ except ImportError: shell = Shell() +def is_kernel_userspace_mismatch(): + """ + Check if the userspace is 64-bit + """ + return platform.machine() == "aarch64" and platform.architecture()[0] == "32bit" + def main(): shell.clear() print("""This script downloads and installs @@ -23,6 +31,13 @@ I2S microphone support. else: shell.bail("Unsupported Pi board detected.") + if shell.is_arm64() and is_kernel_userspace_mismatch(): + print("Unable to compile driver because kernel space is 64-bit, but user space is 32-bit.") + if shell.prompt("Add parameter to /boot/config.txt to use 32-bit kernel?"): + shell.reconfig("/boot/config.txt", "^.*arm_64bit.*$", "arm_64bit=0") + shell.prompt_reboot() + else: + shell.bail("Unable to continue while mismatch is present.") auto_load = ( not shell.argument_exists('noautoload') and shell.prompt("Auto load module at boot?", force_arg="autoload"))