• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

How To Guide [SOURCE] ASUS_I005_1-kernel (MacOS / Linux)

Search This thread
WARNING:
This is NOT a custom kernel!

GPL requires that source is released for Android kernels.
It does not, however, require that the source is tracked.


Each release is downloaded, extracted, and added to git in a single repo in order to create a kernel changelog. Some commits may be added to improve building the kernel as a standalone binary. The core functionality and features will remain unchanged.


The IKCONFIG is then pulled from a running device to get the compiler hash


The source provided by ASUS is meant to be built as a complete firmware.
Some commits have been added to fix broken links and restore missing code.
The source, as it is provided, does not build without missing components.
 
Last edited:
There are changes required to use newer versions of LLVM that were already included in the CAF source, but not in the one from Asus.

Code:
commit 210ecf9a8921bccf197372da9a91efb8aa38202f
Author: Sami Tolvanen <[email protected]>
Date:   Wed Nov 25 08:44:09 2020 -0800

    ANDROID: vmlinux.lds.h: merge compound literal sections
  
    After LLVM rG9e33c096476a ("[ELF] Keep orphan section names
    (.rodata.foo .text.foo) unchanged if !hasSectionsCommand"), LLD splits
    compound literals to separate sections with -fdata-sections, which
    it always enables with LTO. Merge these sections to allow LLVM to be
    upgraded.
  
    Bug: 174047799
    Change-Id: I858c5fcc48283d5528c1d3e2b2d7a3c72f9e03d6
    Link: https://github.com/ClangBuiltLinux/linux/issues/958
    Suggested-by: Danny Lin <[email protected]>
    Suggested-by: Fangrui Song <[email protected]>
    Signed-off-by: Sami Tolvanen <[email protected]>
    (cherry picked from commit 559c23e691b8d0b25b055ecdf4c07f19c8407794)
    (cherry picked from commit 6f7ffcefc7b0ad82dbe0975057ea82b045abe160)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index ef257c136f11..b5c86d85f7b3 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -72,10 +72,10 @@
#if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG)
#define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
#define TEXT_CFI_MAIN .text.[0-9a-zA-Z_]*.cfi
-#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX*
+#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral*
#define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
-#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]*
-#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
+#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
+#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
#define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
#else
#define TEXT_MAIN .text

The techpack is only a stub and folder layout, but is also missing parts.
For anyone unfamiliar with Asus source, it may not be immediately obvious that there are four additional components that are required.



The modules do collide, but can be built in hybrid fashion to overcome the issues.

Code:
CONFIG_TOUCHSCREEN_ROG=y
CONFIG_TOUCHSCREEN2_ROG=m

Code:
CONFIG_INPUT_SX932X=y
CONFIG_INPUT_SX932X_2ND=m

The easiest method for building the kernel is to make all modules inline (replace m with y).

Modules will still be unable to load on their own, since the signatures and versions may be off. That is why the verification needs to be disabled.

Code:
commit e009a01e9cf2f0c64a87b84b6986fff01e278b3f
Author: Abandoned Cart <***************@gmail.com>
Date:   Thu Sep 16 12:16:03 2021 -0400

    kernel/module.c: safely bypass sig, vermagic, modversion

diff --git a/kernel/module.c b/kernel/module.c
index ab50f522b662..b9bbde4ad512 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2925,6 +2925,11 @@ static int module_sig_check(struct load_info *info, int flags)
        const char *reason;
        const void *mod = info->hdr;

+#ifdef CONFIG_MODULE_FORCE_PASS
+       info->sig_ok = true;
+       return 0;
+#endif
+
        /*
         * Require flags == 0, as a module with version information
         * removed is no longer the module that was signed
@@ -3274,10 +3279,12 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
                err = try_to_force_load(mod, "bad vermagic");
                if (err)
                        return err;
+#ifndef CONFIG_MODULE_FORCE_PASS
        } else if (!same_magic(modmagic, vermagic, info->index.vers)) {
                pr_err("%s: version magic '%s' should be '%s'\n",
                       info->name, modmagic, vermagic);
                return -ENOEXEC;
+#endif
        }

        if (!get_modinfo(info, "intree")) {
@@ -3988,11 +3995,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
                goto free_copy;
        }

        err = rewrite_section_headers(info, flags);
        if (err)
                goto free_copy;
@@ -4199,9 +4201,11 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)

        pr_debug("finit_module: fd=%d, uargs=%p, flags=%i\n", fd, uargs, flags);

+#ifndef CONFIG_MODULE_FORCE_PASS
        if (flags & ~(MODULE_INIT_IGNORE_MODVERSIONS
                      |MODULE_INIT_IGNORE_VERMAGIC))
                return -EINVAL;
+#endif

        err = kernel_read_file_from_fd(fd, &hdr, &size, INT_MAX,
                                       READING_MODULE);
 
Last edited:
  • Like
Reactions: HunterTik
Restoring Stock / Rooted Boot Image



Compiling on MacOS (Mojave or lower)



Custom Kernel Development on MacOS

 
Last edited:
This process was probably much easier for the last generation. I have never seen a manufacturer hand over a device without any resources for development.

This time around, it seems they haven't even kept the source updated (or at least updated the page to reflect that it hasn't changed). Hopefully that will change once the device releases in the US.
 
Last edited:

That's source. It can't be installed. You build a kernel with it.

Just wanted to fix my wifi bro. The wifi stopped after the update that's why I'm frustrated

Might want to try a factory reset. If that doesn't work, it may be a hardware issue.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    Restoring Stock / Rooted Boot Image



    Compiling on MacOS (Mojave or lower)



    Custom Kernel Development on MacOS

    4
    WARNING:
    This is NOT a custom kernel!

    GPL requires that source is released for Android kernels.
    It does not, however, require that the source is tracked.


    Each release is downloaded, extracted, and added to git in a single repo in order to create a kernel changelog. Some commits may be added to improve building the kernel as a standalone binary. The core functionality and features will remain unchanged.


    The IKCONFIG is then pulled from a running device to get the compiler hash


    The source provided by ASUS is meant to be built as a complete firmware.
    Some commits have been added to fix broken links and restore missing code.
    The source, as it is provided, does not build without missing components.
    1
    There are changes required to use newer versions of LLVM that were already included in the CAF source, but not in the one from Asus.

    Code:
    commit 210ecf9a8921bccf197372da9a91efb8aa38202f
    Author: Sami Tolvanen <[email protected]>
    Date:   Wed Nov 25 08:44:09 2020 -0800
    
        ANDROID: vmlinux.lds.h: merge compound literal sections
      
        After LLVM rG9e33c096476a ("[ELF] Keep orphan section names
        (.rodata.foo .text.foo) unchanged if !hasSectionsCommand"), LLD splits
        compound literals to separate sections with -fdata-sections, which
        it always enables with LTO. Merge these sections to allow LLVM to be
        upgraded.
      
        Bug: 174047799
        Change-Id: I858c5fcc48283d5528c1d3e2b2d7a3c72f9e03d6
        Link: https://github.com/ClangBuiltLinux/linux/issues/958
        Suggested-by: Danny Lin <[email protected]>
        Suggested-by: Fangrui Song <[email protected]>
        Signed-off-by: Sami Tolvanen <[email protected]>
        (cherry picked from commit 559c23e691b8d0b25b055ecdf4c07f19c8407794)
        (cherry picked from commit 6f7ffcefc7b0ad82dbe0975057ea82b045abe160)
    
    diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
    index ef257c136f11..b5c86d85f7b3 100644
    --- a/include/asm-generic/vmlinux.lds.h
    +++ b/include/asm-generic/vmlinux.lds.h
    @@ -72,10 +72,10 @@
    #if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG)
    #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
    #define TEXT_CFI_MAIN .text.[0-9a-zA-Z_]*.cfi
    -#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX*
    +#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral*
    #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
    -#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]*
    -#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
    +#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
    +#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
    #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
    #else
    #define TEXT_MAIN .text

    The techpack is only a stub and folder layout, but is also missing parts.
    For anyone unfamiliar with Asus source, it may not be immediately obvious that there are four additional components that are required.



    The modules do collide, but can be built in hybrid fashion to overcome the issues.

    Code:
    CONFIG_TOUCHSCREEN_ROG=y
    CONFIG_TOUCHSCREEN2_ROG=m

    Code:
    CONFIG_INPUT_SX932X=y
    CONFIG_INPUT_SX932X_2ND=m

    The easiest method for building the kernel is to make all modules inline (replace m with y).

    Modules will still be unable to load on their own, since the signatures and versions may be off. That is why the verification needs to be disabled.

    Code:
    commit e009a01e9cf2f0c64a87b84b6986fff01e278b3f
    Author: Abandoned Cart <***************@gmail.com>
    Date:   Thu Sep 16 12:16:03 2021 -0400
    
        kernel/module.c: safely bypass sig, vermagic, modversion
    
    diff --git a/kernel/module.c b/kernel/module.c
    index ab50f522b662..b9bbde4ad512 100644
    --- a/kernel/module.c
    +++ b/kernel/module.c
    @@ -2925,6 +2925,11 @@ static int module_sig_check(struct load_info *info, int flags)
            const char *reason;
            const void *mod = info->hdr;
    
    +#ifdef CONFIG_MODULE_FORCE_PASS
    +       info->sig_ok = true;
    +       return 0;
    +#endif
    +
            /*
             * Require flags == 0, as a module with version information
             * removed is no longer the module that was signed
    @@ -3274,10 +3279,12 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
                    err = try_to_force_load(mod, "bad vermagic");
                    if (err)
                            return err;
    +#ifndef CONFIG_MODULE_FORCE_PASS
            } else if (!same_magic(modmagic, vermagic, info->index.vers)) {
                    pr_err("%s: version magic '%s' should be '%s'\n",
                           info->name, modmagic, vermagic);
                    return -ENOEXEC;
    +#endif
            }
    
            if (!get_modinfo(info, "intree")) {
    @@ -3988,11 +3995,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
                    goto free_copy;
            }
    
            err = rewrite_section_headers(info, flags);
            if (err)
                    goto free_copy;
    @@ -4199,9 +4201,11 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
    
            pr_debug("finit_module: fd=%d, uargs=%p, flags=%i\n", fd, uargs, flags);
    
    +#ifndef CONFIG_MODULE_FORCE_PASS
            if (flags & ~(MODULE_INIT_IGNORE_MODVERSIONS
                          |MODULE_INIT_IGNORE_VERMAGIC))
                    return -EINVAL;
    +#endif
    
            err = kernel_read_file_from_fd(fd, &hdr, &size, INT_MAX,
                                           READING_MODULE);