├── README.md ├── documents ├── fetures │ ├── 01-modify-android-property.md │ ├── 02-dont-install-default-apps.md │ ├── 03-default-enable-roots.md │ ├── 04-default_wifi_setting.md │ ├── 05-disable-setupwizard.md │ ├── 07-disable-wallpaper-service.md │ ├── 08-remove-android-service.md │ ├── 09-low-ram-use-zram.md │ ├── 10-low-ram-use-lmkd.md │ ├── 11-change-screen-size.md │ ├── adb-auth-not-required-and-enable-root.md │ └── android-mount-nfs.md ├── guideline │ ├── 04-patches-lineageOS.sh │ ├── build-lineageos-code.md │ └── sync-lineageos-code.md ├── images │ ├── 004.png │ ├── BCM2835-Memory-Map-Large.png │ ├── BCM2835-SoC-block-diagram.png │ ├── BCM2835_Block_Diagram.gif │ ├── android_boot_process.png │ ├── introduction-to-rpi-15-638.jpg │ ├── rpi3b-boot-sequence.png │ └── zo803Hq.png ├── knowledge │ ├── android-boot-process.md │ └── linux-boot-process.md └── resource │ └── BCM2835-ARM-Peripherals.pdf ├── lineageos.bash ├── manifests ├── default.xml ├── manifest_brcm_rpi3.xml ├── manifest_brcm_rpi4.xml └── manifest_brcm_rpi4_lineage18.1.xml ├── patches ├── frameworks_base │ └── 0001-rpi3-modify-generic-keyboard-layout.patch └── vendor_lineage │ └── 0001-disable-adb-authentication-by-default.patch └── scripts ├── build-lineageos-code.sh ├── common.sh ├── config.sh └── sync-lineageos-code.sh /README.md: -------------------------------------------------------------------------------- 1 | # Compile Android system with LineageOS 2 | [Cyanogen](https://en.wikipedia.org/wiki/Cyanogen) is a company that customizes Android ROM, its product [CyanogenMod](https://zh.wikipedia.org/wiki/CyanogenMod)( Often referred to as "CM") is an open code system based on the Android mobile device platform. In December 2016, Cyanogen suddenly announced that it would stop development and close the project infrastructure. LineageOS was officially launched on December 24, 2016 to re-enact CyanogenMod, and its source code is stored in [GitHub](https://github.com/LineageOS)。 3 | 4 | ### **Development Environment (Host)** 5 | 1. The operating system uses Ubuntu 18.04 6 | 2. Install the development kit 7 | ```bash 8 | $ sudo apt-get update 9 | $ sudo apt-get install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf lib32ncurses5-dev lib32readline-dev lib32z1-dev libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev python-mako imagemagick openjdk-8-jdk gcc-arm-linux-gnueabihf 10 | ``` 11 | 3. OpenJDK version 1.8.0_232 12 | ```bash 13 | # installation 14 | $ sudo apt-get update 15 | $ sudo apt-get install openjdk-8-jdk 16 | # If your computer has installed many versions of JDK, specify which version of JDK to use here 17 | $ sudo update-alternatives --config java 18 | ``` 19 | 4. It is recommended to use SSD hard disk (download and compile will wait until death) 20 | -Lineage 15.1 code machine plus compile output file about 70G 21 | -Lineage 16.0 code machine plus compile output file about 140G 22 | 23 | ### **Operating environment(Target)** 24 | - **Model:** Raspberry Pi 3 Model B+ 25 | - **SoC:** Broadcom BCM2837 26 | - **CPU:** ARM Cortex-A53 (64Bit) 27 | - **RAM:** 1GB 28 | - **OS:** lineage 15.1 (Android 8.1.0) \ 29 | Raspberry Pi 3 Block Diagram 30 | - **Model:** Raspberry Pi 4 Model B 31 | - **SoC:** Broadcom BCM2711 32 | - **CPU:** ARM Cortex-A72 (64Bit) 33 | - **RAM:** 4GB 34 | - **OS:** lineage 16.1 (Android 9) 35 | 36 | ### **Operating Instructions** 37 | + [How to download LineageOS code](documents/guideline/sync-lineageos-code.md) 38 | - branch: lineage-15.1, Device name: rpi3 39 | - branch: lineage-16.0, Device name: rpi4 40 | ```bash 41 | #Automated download script 42 | $ wget https://raw.githubusercontent.com/02047788a/build-lineageOS-rpi3/master/scripts/sync-lineageos-code.sh -O sync-lineageos-code.sh 43 | # Execute script input prompt 44 | # Please entry lineageOS checkout folder : (Download catalog) 45 | # Please entry checkout lineageOS branch : (Designated branch) 46 | # Please entry build device name(ex:,rpi3,rpi4) : (Compile module) 47 | ``` 48 | > All input variables exist~/.profile inside (**$LINEAGE_SRC, $LINEAGE_BRANCH, $DEVICE_NAME**) 49 | 50 | + [How to compile LineageOS code](documents/guideline/build-lineageos-code.md) 51 | ```bash 52 | # Download the script to the code directory 53 | $ wget https://raw.githubusercontent.com/02047788a/build-lineageOS-rpi3/master/scripts/build-lineageos-code.sh -O build-lineageos-code.sh 54 | $ sudo ./build-lineageos-code.sh #Compile all images kernel ramdisk systemimage vendorimage 55 | ``` 56 | > Installable after compilation image path: \$LINEAGE_SRC/out/target/product/rpi4/*lineage-16.0-20200201-rpi4.img** 57 | + Burn image to SD card 58 | ```bash 59 | $ sudo dd if=lineage-16.0-20200201-rpi4.img of=/dev/sdX status=progress bs=4M 60 | ``` 61 | > /dev/sdX Is the path of your SD card,Pay attention to change!!! 62 | 63 | ### **AndroidCustomized modification** 64 | - [Android system enables root permission in Production version](documents/fetures/adb-auth-not-required-and-enable-root.md) 65 | - [Android mount NFS](documents/fetures/android-mount-nfs.md) 66 | 67 | ### **Related projects** 68 | - [android_local_manifest](https://github.com/lineage-rpi/android_local_manifest) : lineage-rpi Provided description items 69 | - [android_device_brcm_rpi3](https://github.com/lineage-rpi/android_device_brcm_rpi3) : Android for RPI3 Related hardware firmware settings 70 | - [android_device_brcm_rpi4](https://github.com/02047788a/android_device_brcm_rpi4) : Android for RPI4 Related hardware firmware settings 71 | - [android_kernel_brcm_rpi3](https://github.com/lineage-rpi/android_kernel_brcm_rpi3) : Android for RPI3 Linux core used 72 | - [android_kernel_brcm_rpi4](https://github.com/lineage-rpi/android_kernel_brcm_rpi4) : Android for RPI4 Linux core used 73 | - [proprietary_vendor_brcm](https://github.com/lineage-rpi/proprietary_vendor_brcm) : RPI3/4 of framware 74 | 75 | ### **Reference** 76 | - [ARM Cortex-A series(A53, A57, A73, etc.) processor performance classification and comparison](https://blog.csdn.net/weixin_42229404/article/details/80865138) 77 | 78 | 79 | ### 我想找類似的工作不知道有沒有台北的工作機會??? 80 | - linkedin [連結](https://www.linkedin.com/in/daedalus1/) 81 | - YT教學 嵌入式系統 [連結](https://www.youtube.com/playlist?list=PLwy0WTzBokTPlLXfSy9exZkYoh5GDUv82) 82 | - YT教學 嵌入式驅動 [連結](https://www.youtube.com/playlist?list=PLwy0WTzBokTOB_8kEfzuVhTznK7q-GbVq) 83 | 84 | > 我也懂挖礦上一份工作是用linux整合客製化一套挖礦系統OS,我也親自破解claymopre & phinexminer的 85 | -------------------------------------------------------------------------------- /documents/fetures/01-modify-android-property.md: -------------------------------------------------------------------------------- 1 | ## 修改Android系統設定 2 | 3 | ### build.prop 說明 4 | /system/build.prop 是一个属性文件,在Android系统中.prop文件很重要,记录了系统的设置和改变,类似於/etc中的文件 5 | ### 產生流程 6 | 1. build/core/Makefile 呼叫 build/tools/buildinfo.sh 產出 build.prop 7 | 2. build/core/Makefile 再去追加device/brcm/rip3/system.prop 到 build.prop 8 | 9 | 10 | ```bash 11 | # 修改檔案: device/brcm/rip3/system.prop 12 | # 加入設定國家和時區 13 | persist.sys.language=zh 14 | persist.sys.country=TW 15 | persist.sys.localevar= 16 | persist.sys.timezone=Asia/Taipei 17 | ro.product.locale.language=zh 18 | ro.product.locale.region=TW 19 | 20 | ro.product.brand=JIMMY9478 #机器品牌,随你创造 21 | ro.product.name=JIMMY9478 #机器名,随你创造 22 | ro.product.device=JIMMY9478 #设备名,随你创造 23 | ``` -------------------------------------------------------------------------------- /documents/fetures/02-dont-install-default-apps.md: -------------------------------------------------------------------------------- 1 | ### 移除預設APP 2 | #### 1. 定義編譯模組remove_unused_module 3 | ```bash 4 | # 修改檔案: device/brcm/rpi3/Android.mk 5 | 6 | #加入下面區段 7 | include $(CLEAR_VARS) 8 | LOCAL_MODULE := remove_unused_module 9 | LOCAL_MODULE_TAGS := optional 10 | 11 | LOCAL_MODULE_CLASS := FAKE 12 | LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) 13 | 14 | #要移除的APP 15 | LOCAL_OVERRIDES_PACKAGES += \ 16 | Contacts \ 17 | Email \ 18 | DeskClock \ 19 | Calendar \ 20 | CalendarProvider \ 21 | Contacts \ 22 | Email \ 23 | vr \ 24 | Telecom \ 25 | TeleService \ 26 | PrintSpooler \ 27 | PrintRecommendationService \ 28 | PicoTts \ 29 | MmsService \ 30 | AudioFX \ 31 | ExactCalculator \ 32 | Camera2 \ 33 | Gallery2 \ 34 | Recorder \ 35 | Eleven 36 | 37 | include $(BUILD_SYSTEM)/base_rules.mk 38 | 39 | # 其實式把這些APP編譯輸出fake_packages資料夾,就不會打包到 40 | $(LOCAL_BUILT_MODULE): 41 | $(hide) echo "Fake: $@" 42 | $(hide) mkdir -p $(dir $@) 43 | $(hide) touch $@ 44 | 45 | PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) 46 | ``` 47 | 48 | #### 2. 加入編譯模組remove_unused_module 49 | ```bash 50 | # 修改檔案: device/brcm/rip3/rpi3.mk 51 | # 加入remove_unused_module 52 | PRODUCT_PACKAGES += remove_unused_module 53 | ``` 54 | > Android.mk 裡面的變數 LOCAL_OVERRIDES_PACKAGES 就是要移除的APPS 55 | -------------------------------------------------------------------------------- /documents/fetures/03-default-enable-roots.md: -------------------------------------------------------------------------------- 1 | ### 預設啟用root權限 2 | 3 | #### 1.修改 ro.adb.secure 和 ro.secure 属性 4 | 5 | ```bash 6 | # 修改檔案: build/core/main.mk 7 | 8 | # Target is secure in user builds. 9 | ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0 #改成0 10 | ADDITIONAL_DEFAULT_PROPERTIES += security.perf_harden=1 11 | 12 | ifeq ($(user_variant),user) 13 | ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=0 #改成0 14 | endif 15 | 16 | ifeq ($(user_variant),userdebug) 17 | # Pick up some extra useful tools 18 | tags_to_install += debug 19 | else 20 | # Disable debugging in plain user builds. 21 | #enable_target_debugging := #註解掉 22 | endif 23 | ``` 24 | 25 | #### 2.修改 selinux 26 | 27 | ```cpp 28 | // 修改檔案: system/core/init/init.cpp 29 | 30 | /* 31 | static selinux_enforcing_status selinux_status_from_cmdline() { 32 | ... 33 | */ 34 | static bool selinux_is_enforcing(void) 35 | { 36 | return false; #新增 37 | } 38 | ``` 39 | 40 | #### 3.修改 adb 模块的 android.mk 文件 41 | 42 | ```bash 43 | # 修改檔案: system/core/adb/Android.mk 44 | 45 | #LOCAL_CFLAGS += -DALLOW_ADBD_NO_AUTH=$(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),1,0) 46 | LOCAL_CFLAGS += -DALLOW_ADBD_NO_AUTH=$(if $(filter user userdebug eng,$(TARGET_BUILD_VARIANT)),1,0) 47 | 48 | #ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) 49 | ifneq (,$(filter user userdebug eng,$(TARGET_BUILD_VARIANT))) 50 | ``` -------------------------------------------------------------------------------- /documents/fetures/04-default_wifi_setting.md: -------------------------------------------------------------------------------- 1 | ### 預設wifi連線密碼 2 | 3 | #### 建立連線資訊 4 | ```bash 5 | # AOSP修改檔案: device\brcm\rpi3\prebuilt\vendor\etc\wifi\wpa_supplicant.conf 6 | 7 | #內容如下 8 | disable_scan_offload=1 9 | wowlan_triggers=any 10 | p2p_disabled=1 11 | filter_rssi=-75 12 | no_ctrl_interface= 13 | 14 | network={ 15 | ssid="WIFI名稱" 16 | psk="密碼" 17 | key_mgmt=WPA-PSK 18 | priority=2 19 | } 20 | ``` 21 | #### 生成於Android的檔案系統裡 22 | 檔案路徑: /vendor/etc/wifi/wpa_supplicant.conf 23 | 24 | #### 透過init.rpi3.rc啟動 25 | 26 | ```bash 27 | service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ 28 | -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ 29 | -I/vendor/etc/wifi/wpa_supplicant_overlay.conf \ 30 | -O/data/misc/wifi/sockets \ 31 | -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0 32 | class main 33 | socket wpa_wlan0 dgram 660 wifi wifi 34 | disabled 35 | oneshot 36 | ``` 37 | -------------------------------------------------------------------------------- /documents/fetures/05-disable-setupwizard.md: -------------------------------------------------------------------------------- 1 | ### 開機不要執行設定精靈 2 | 3 | ```java 4 | // AOSP修改檔案:frameworks\base\services\core\java\com\android\server\am\ActivityManagerService.java 5 | 6 | //Settings.Secure.USER_SETUP_COMPLETE = 0啟動設定精靈 7 | public void systemReady(final Runnable goingCallback, TimingsTraceLog traceLog) { 8 | // Start up initial activity. 9 | mBooting = true; 10 | // Enable home activity for system user, so that the system can always boot. We don't 11 | // do this when the system user is not setup since the setup wizard should be the one 12 | // to handle home activity in this case. 13 | /* 14 | if (UserManager.isSplitSystemUser() && 15 | Settings.Secure.getInt(mContext.getContentResolver(), 16 | Settings.Secure.USER_SETUP_COMPLETE, 0) != 0) { 17 | ComponentName cName = new ComponentName(mContext, SystemUserHomeActivity.class); 18 | try { 19 | AppGlobals.getPackageManager().setComponentEnabledSetting(cName, 20 | PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0, 21 | UserHandle.USER_SYSTEM); 22 | } catch (RemoteException e) { 23 | throw e.rethrowAsRuntimeException(); 24 | } 25 | } 26 | */ 27 | Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1); 28 | Settings.Secure.putInt(mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1); 29 | // 重點在這裡,啟動桌面也就是launcher 30 | startHomeActivityLocked(currentUserId, "systemReady"); 31 | ``` 32 | 33 | 34 | https://blog.csdn.net/zhuawalibai/article/details/80221370 -------------------------------------------------------------------------------- /documents/fetures/07-disable-wallpaper-service.md: -------------------------------------------------------------------------------- 1 | ### 不要載入動態桌布 2 | 3 | 4 | ```java 5 | //AOSP修改檔案: frameworks/base/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java 6 | 7 | boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force, 8 | boolean fromUser, WallpaperData wallpaper, IRemoteCallback reply) { 9 | if (DEBUG_LIVE) { 10 | Slog.v(TAG, "bindWallpaperComponentLocked: componentName=" + componentName); 11 | } 12 | 13 | // rpi3 don't use WallpaperComponent" 14 | Slog.v(TAG, "rpi3 don't use WallpaperComponent"); 15 | return false; 16 | } 17 | ``` -------------------------------------------------------------------------------- /documents/fetures/08-remove-android-service.md: -------------------------------------------------------------------------------- 1 | ## 移除不需要的服務 2 | 3 | ### PrintManagerService 4 | ```java 5 | //AOSP修改檔案: frameworks\base\services\java\com\android\server\SystemServer.java 6 | 7 | //註解調不要啟動 8 | /* 9 | if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_PRINTING)) { 10 | traceBeginAndSlog("StartPrintManager"); 11 | mSystemServiceManager.startService(PRINT_MANAGER_SERVICE_CLASS); 12 | traceEnd(); 13 | } 14 | */ 15 | ``` 16 | 17 | 18 | ### 相關檔案 19 | - *註冊服務* frameworks\base\core\java\android\app\SystemServiceRegistry.java 20 | - *啟動服務*frameworks\base\services\java\com\android\server\SystemServer.java 21 | 22 | #### 參考 23 | - [Android系统启动(四)-SystemServer篇](https://www.jianshu.com/p/c6f464457f4c) -------------------------------------------------------------------------------- /documents/fetures/09-low-ram-use-zram.md: -------------------------------------------------------------------------------- 1 | ### low ram 啟用zram 2 | 3 | #### 複寫系統low_ram屬性 4 | ```bash 5 | #AOSP修改檔案:device\brcm\rpi3\rpi3.mk 6 | # raspberry pi3 1G RAM low ram 7 | PRODUCT_PROPERTY_OVERRIDES += ro.config.low_ram=true 8 | ``` 9 | 10 | #### 修改kernel編譯config 11 | ```bash 12 | #AOSP修改檔案:kernel\brcm\rpi3\arch\arm\configs\lineageos_rpi3_defconfig 13 | CONFIG_SWAP=y 14 | CONFIG_CGROUP_MEM_RES_CTLR=y 15 | CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y 16 | CONFIG_ZRAM=y 17 | CONFIG_ZSMALLOC=y 18 | CONFIG_ZSMALLOC_STAT=y 19 | ``` 20 | 21 | #### 新增zram磁區 22 | ```bash 23 | #AOSP修改檔案:device\brcm\rpi3\ramdisk\fstab.rpi3 24 | #加入下面這行 25 | /dev/block/zram0 none swap defaults zramsize=779784192 26 | ``` 27 | 28 | #### 開機掛載啟動zram磁區 29 | ```bash 30 | #AOSP修改檔案:device\brcm\rpi3\ramdisk\init.rpi3.rc 31 | on fs 32 | mount_all /fstab.rpi3 33 | swapon_all /fstab.rpi3 34 | 35 | # Swapping 1 page at a time is ok 36 | write /proc/sys/vm/page-cluster 0 37 | write /proc/sys/vm/swappiness 100 38 | ``` 39 | #### 參考 40 | - [lmkd 和 memcg](https://blog.csdn.net/pillarbuaa/article/details/79207036) -------------------------------------------------------------------------------- /documents/fetures/10-low-ram-use-lmkd.md: -------------------------------------------------------------------------------- 1 | ### low ram lmkd 2 | 3 | #### 複寫系統low_ram屬性 4 | ```bash 5 | #AOSP修改檔案:device\brcm\rpi3\rpi3.mk 6 | # raspberry pi3 1G RAM low ram 7 | PRODUCT_PROPERTY_OVERRIDES += ro.lmk.use_minfree_levels=true 8 | ``` 9 | 10 | #### 修改kernel編譯config 11 | ```bash 12 | #AOSP修改檔案:kernel\brcm\rpi3\arch\arm\configs\lineageos_rpi3_defconfig 13 | CONFIG_ANDROID_LOW_MEMORY_KILLER=n 14 | CONFIG_ANDROID_LOW_MEMORY_KILLER_AUTODETECT_OOM_ADJ_VALUES=n 15 | CONFIG_MEMCG=y 16 | CONFIG_MEMCG_SWAP=y 17 | ``` 18 | 19 | 20 | #### 參考 21 | - [Android P使能用户态LMK说明](http://tjtech.me/how-to-enable-userspace-lmk-under-android-p.html) -------------------------------------------------------------------------------- /documents/fetures/11-change-screen-size.md: -------------------------------------------------------------------------------- 1 | ### 更改螢幕大小 2 | 3 | ```bash 4 | adb shell wm size 720x1280 5 | ``` 6 | 7 | ```java 8 | //AOSP修改檔案: frameworks\base\services\core\java\com\android\server\am\ActivityManagerService.java 9 | 10 | final void finishBooting() { 11 | synchronized (this) { 12 | if (!mBootAnimationComplete) { 13 | mCallFinishBooting = true; 14 | return; 15 | } 16 | mCallFinishBooting = false; 17 | } 18 | 19 | //加入以下這段 20 | try { 21 | Runtime runtime = Runtime.getRuntime(); 22 | runtime.exec("wm size 720x1280"); 23 | Slog.d(TAG, "change screen size to 720x1280."); 24 | } 25 | catch (Exception e1) { 26 | Slog.e(TAG, "change screen size error."); 27 | } 28 | } 29 | ``` -------------------------------------------------------------------------------- /documents/fetures/adb-auth-not-required-and-enable-root.md: -------------------------------------------------------------------------------- 1 | ## Android系統在Production版本啟用root權限 2 | 3 | #### 1. Disable production check 4 | ```cpp 5 | // Path: $LINEAGE_SRC/system/core/adb/services.cpp 6 | void restart_root_service(int fd, void *cookie) { 7 | if (getuid() == 0) { 8 | WriteFdExactly(fd, "adbd is already running as root\n"); 9 | adb_close(fd); 10 | } else { 11 | 12 | //TODO: Stop this checked 13 | /* 14 | if (!__android_log_is_debuggable()) { 15 | WriteFdExactly(fd, "adbd cannot run as root in production builds\n"); 16 | adb_close(fd); 17 | return; 18 | } 19 | */ 20 | 21 | int root_access = android::base::GetIntProperty("persist.sys.root_access", 0); 22 | std::string build_type = android::base::GetProperty("ro.build.type", ""); 23 | 24 | if (build_type != "eng" && (root_access & 2) != 2) { 25 | WriteFdExactly(fd, "root access is disabled by system setting - " 26 | "enable in Settings -> System -> Developer options\n"); 27 | adb_close(fd); 28 | return; 29 | } 30 | 31 | android::base::SetProperty("lineage.service.adb.root", "1"); 32 | WriteFdExactly(fd, "restarting adbd as root\n"); 33 | adb_close(fd); 34 | } 35 | } 36 | ``` 37 | #### 2. don't drop privileges 38 | ```cpp 39 | // Path: $LINEAGE_SRC/system/core/adb/daemon/main.cpp 40 | static bool should_drop_privileges() { 41 | //TODO: add this checked 42 | std::string prop1 = android::base::GetProperty("lineage.service.adb.root", ""); 43 | if(prop1 == "1") 44 | return false; 45 | 46 | /* 47 | * orinage code 48 | */ 49 | } 50 | ``` 51 | #### 3. auth not required 52 | ```cpp 53 | // Path: $LINEAGE_SRC/system/core/adb/daemon/main.cpp 54 | static bool adbd_main() { 55 | /* 56 | * orinage code 57 | */ 58 | 59 | // TODO: stop this check 60 | /* 61 | if (ALLOW_ADBD_NO_AUTH && !android::base::GetBoolProperty("ro.adb.secure", false)) { 62 | auth_required = false; 63 | } 64 | */ 65 | // TODO: always don't auth required 66 | auth_required = false; 67 | 68 | /* 69 | * orinage code 70 | */ 71 | } 72 | ``` 73 | #### 4. stop Selinux enforcing 74 | ##### for Lineage 16.0 75 | ``` 76 | // Path: $LINEAGE_SRC/system/core/init/selinux.cpp 77 | // TODO: remark this function 78 | /* 79 | EnforcingStatus StatusFromCmdline() { 80 | EnforcingStatus status = SELINUX_ENFORCING; 81 | 82 | import_kernel_cmdline(false, 83 | [&](const std::string& key, const std::string& value, bool in_qemu) { 84 | if (key == "androidboot.selinux" && value == "permissive") { 85 | status = SELINUX_PERMISSIVE; 86 | } 87 | }); 88 | 89 | return status; 90 | } 91 | */ 92 | 93 | //TODO: always return false 94 | bool IsEnforcing() { 95 | return false; 96 | } 97 | ``` 98 | 99 | ##### for Lineage 15.1 100 | ```cpp 101 | // Path: system/core/init/init.cpp 102 | /* 103 | static selinux_enforcing_status selinux_status_from_cmdline() { 104 | ... 105 | */ 106 | static bool selinux_is_enforcing(void) 107 | { 108 | return false; #新增 109 | } 110 | ``` 111 | 112 | #### 6. add lineage.service.adb.root property 113 | ```bash 114 | # Path: $LINEAGE_SRC/device/brcm/rpi4/system.prop 115 | # others 116 | lineage.service.adb.root=1 117 | ``` 118 | 119 | ### 參考資料 120 | - [Android系统打开user版本的root权限](https://blog.csdn.net/qq_33487044/article/details/85076001) 121 | -------------------------------------------------------------------------------- /documents/fetures/android-mount-nfs.md: -------------------------------------------------------------------------------- 1 | ## Android掛載NFS磁碟 2 | 3 | ### 1. HOST開啟NFS資料夾 4 | #### 加入要開放的資料夾和權限 5 | ```bash 6 | $ sudo vim /etc/exports 7 | #加入下面這行 8 | /mnt/nfs-rpi *(rw,sync,no_root_squash,no_subtree_check) 9 | ``` 10 | #### 重載NFS 11 | ```bash 12 | $ sudo exportfs -r 13 | ``` 14 | #### 檢查NFS 15 | ```bash 16 | $ showmount -e 17 | ``` 18 | ### 2. kernel打開NFS 19 | 預設android的kernel沒有打開NFS服務,所以要打開NFS功能重新編譯。 20 | #### 修改kernel的compile config 21 | ```bash 22 | #路徑: kernel/brcm/rpi4/arch/arm/configs/lineageos_rpi4_defconfig 23 | CONFIG_NFS_FS=y 24 | CONFIG_NFS_V4=y 25 | CONFIG_NFS_V4_1=y 26 | CONFIG_NFS_V4_2=y 27 | CONFIG_ROOT_NFS=y 28 | ``` 29 | 30 | 31 | ### 3. android掛載NFS 32 | ```bash 33 | # busybox mount -t nfs -o nolock {SERVER_IP}:/mnt/nfs-rpi /data/nfs-rpi //默認選擇vers=3 34 | # busybox mount -t nfs -o nolock,vers=2 {SERVER_IP}:/mnt/nfs-rpi /data/nfs-rpi 35 | or #默認vers=3 36 | # busybox mount -t nfs -o nolock,vers=3 {SERVER_IP}:/mnt/nfs-rpi /data/nfs-rpi 37 | or 38 | # busybox mount -t nfs -o nolock,vers=4 {SERVER_IP}:/mnt/nfs-rpi /data/nfs-rpi 39 | 40 | # busybox umount /data/nfs //卸載 41 | ``` 42 | > 必須用busybox的mount,linux和android的mount還是有區別的 -------------------------------------------------------------------------------- /documents/guideline/04-patches-lineageOS.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source common.sh 3 | source config.sh 4 | 5 | show_banner "patchs lineageOS" 6 | set_environment_variable 7 | show_config 8 | 9 | print_title "Step1. patch lineageOS" 10 | patchesFolder="$PWD" 11 | print_info "01 patch modify generic keyboard layout" 12 | cd $lineageOSFolder/frameworks/base 13 | git am $patchesFolder/patches/frameworks_base/0001-rpi3-modify-generic-keyboard-layout.patch 14 | print_info "02 patch disable adb authentication by default" 15 | cd $lineageOSFolder/vendor/lineage 16 | git am $patchesFolder/patches/vendor_lineage/0001-disable-adb-authentication-by-default.patch 17 | -------------------------------------------------------------------------------- /documents/guideline/build-lineageos-code.md: -------------------------------------------------------------------------------- 1 | ### 編譯 LineageOS 程式碼 2 | 1. **設定compile cache** 3 | ```bash 4 | $ export USE_CCACHE=1 5 | $ export CCACHE_DIR=$HOME/.ccache 6 | $ ccache -M 50G 7 | ``` 8 | 2. **給編譯時期更多記憶體** 9 | ```bash 10 | $ export PATH=~/lineageOS/prebuilts/sdk/tools:$PATH 11 | $ export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g" 12 | $ jack-admin kill-server && jack-admin start-server 13 | ``` 14 | 3. **打上RPI3補丁** 15 | 1. rpi3: modify generic keyboard layout 16 | ```bash 17 | $ cd ~/lineageOS 18 | $ curl --create-dirs -L -o patches/frameworks_base/0001-rpi3-modify-generic-keyboard-layout.patch -O -L https://raw.githubusercontent.com/lineage-rpi/android_local_manifest/lineage-15.1/patches/frameworks_base/0001-rpi3-modify-generic-keyboard-layout.patch 19 | $ cd ~/lineageOS/frameworks/base 20 | $ git am ~/lineageOS/patches/frameworks_base/0001-rpi3-modify-generic-keyboard-layout.patch 21 | ``` 22 | 2. disable adb authentication by default 23 | ```bash 24 | $ cd ~/lineageOS 25 | $ curl --create-dirs -L -o patches/vendor_lineage/0001-disable-adb-authentication-by-default.patch -O -L https://raw.githubusercontent.com/lineage-rpi/android_local_manifest/lineage-15.1/patches/vendor_lineage/0001-disable-adb-authentication-by-default.patch 26 | $ cd ~/lineageOS/vendor/lineage 27 | $ git am ~/lineageOS/patches/vendor_lineage/0001-disable-adb-authentication-by-default.patch 28 | ``` 29 | 30 | 4. **載入編譯環境變數** 31 | ```bash 32 | $ source build/envsetup.sh 33 | $ lunch lineage_rpi3-userdebug 34 | ``` 35 | > 如果無法載入Device發生找不到,需要新增Device參考官方新增說明[連結](https://source.android.com/setup/develop/new-device#build-a-product) 36 | - BUILDTYPE [參考](https://source.android.com/setup/build/building#choose-a-target) 37 | - eng:工程版本 38 | - user:发行版本 39 | - userdebug:部分调试版本 40 | 41 | 5. **編譯全部專案** 42 | ```bash 43 | $ make -j12 kernel ramdisk systemimage vendorimage 44 | ``` 45 | 6. **打包可以燒錄的映像檔** 46 | ```bash 47 | $ cd ~/lineageOS/device/brcm/rpi3/ 48 | $ sudo ./mkimg.sh 49 | ``` 50 | 7. **燒錄映像到SD卡** 51 | ```bash 52 | $ sudo dd if=lineage-15.1-{date}-rpi3.img of=/dev/sdX status=progress bs=4M 53 | ``` 54 | > /dev/sdX 是你SD卡的路徑,注意要改阿!!! 55 | 56 | #### 參考文件 57 | - [編譯版本 Using build variants](https://source.android.com/setup/develop/new-device#build-variants) -------------------------------------------------------------------------------- /documents/guideline/sync-lineageos-code.md: -------------------------------------------------------------------------------- 1 | ### 下載 LineageOS 程式碼 2 | 1. **安裝Repo工具** 3 | ```bash 4 | #建立bin目錄存放Repo 5 | $ mkdir ~/bin 6 | $ export PATH=~/bin:$PATH 7 | #下載Repo工具 8 | $ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo 9 | $ chmod a+x ~/bin/repo 10 | ``` 11 | > Repo 是google用來管理複合式程式碼的工具,一套Android裡面包含很多不同的專案構成 12 | 2. **初始化Repo client端** 13 | ```bash 14 | # 建立程式碼目錄 15 | $ mkdir ~/lineageOS 16 | $ cd ~/lineageOS 17 | ``` 18 | > ~/lineageOS 是我的主要程式碼工作目錄,你們可以自己定義 19 | ```bash 20 | # 設定git名稱和信箱 21 | $ git config --global user.name "Your Name" 22 | $ git config --global user.email "you@example.com" 23 | # 在目前目錄初始化一個client端,指定repository分支lineage-15.1 24 | $ repo init -u git://github.com/LineageOS/android.git -b lineage-15.1 25 | ``` 26 | > LineageOS 的所有分支請參閱 [github branches](https://github.com/LineageOS/android/branches/all) 27 | 28 | 3. **下載raspberry pi需要的額外專案** \ 29 | repo init 會在程式碼工作目錄下建立一個.repo目錄,.repo目錄下manifest.xml這個檔案就是.repo/manifests/[default.xml](../manifests/default.xml)的連結,內容就包含了建構lineageOS必要用到的專案清單。\ 30 | 這裡需要額外定義一個要編譯Raspberry Pi 的額外要下載的manifests.xml。\ 31 | [LineageOS-rpi](https://github.com/lineage-rpi)目前只有提供到RPI3的[manifest_brcm_rpi3.xml](https://github.com/lineage-rpi/android_local_manifest/blob/lineage-15.1/manifest_brcm_rpi3.xml)。\ 32 | 我這提供了調整好了可以編譯RPI4的[manifest_brcm_rpi4.xml](https://github.com/02047788a/build-lineageOS-for-raspberry-pi/blob/master/manifests/manifest_brcm_rpi4.xml) 33 | ```bash 34 | $ mkdir .repo/local_manifests #Repo 1.9.1 has a new feature. 35 | $ wget https://raw.githubusercontent.com/02047788a/build-lineageOS-rpi3/master/manifests/manifest_brcm_rpi3.xml -O .repo/local_manifests/manifest_brcm_rpi3.xml 36 | ``` 37 | > Repo 1.9.1 開始要把新增的manifest_brcm_rpi3.xml放到指定目錄.repo/local_manifests下面。 38 | 4. **下載程式碼** \ 39 | 這裡注意一下 repository 大約 66G,加上編譯產出檔案還有ccache最好準備100G的SSD硬碟空間 40 | ```bash 41 | $ repo sync -j32 #-j32:是指用32條執行緒下載 42 | ``` 43 | > -j32:是指用32條執行緒下載 44 | 45 | #### Repo 常用指令 46 | ```bash 47 | $ repo abandon #刪除分支 48 | $ repo branches #列出分支 49 | $ repo start [] #新增分支 [專案] 50 | $ repo checkout #切換分支 51 | $ repo forall -vc "git reset --hard" #還原變更 52 | ``` 53 | > Repo 命令参考资料 https://source.android.google.cn/setup/using-repo.html 54 | 55 | #### 參考文件 56 | - [LineageOS 維基百科](https://zh.wikipedia.org/wiki/LineageOS) 57 | - [LineageOS 官方網頁](https://www.lineageos.org/) 58 | - [LineageOS 官方維基](https://wiki.lineageos.org/) 59 | - [LineageOS Github](https://github.com/LineageOS/) 60 | - [LineageOS-rpi Github](https://github.com/lineage-rpi) 61 | - [LineageOS branches](https://github.com/LineageOS/android/branches/all) 62 | - [Raspberry Pi 規格 (維基百科)](https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications) 63 | - [Android Local Manifests机制的使用实践](https://duanqz.github.io/2016-04-15-Android-Local-Manifests-Practice) -------------------------------------------------------------------------------- /documents/images/004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimmy947788/build-lineageOS-for-raspberry-pi/fe3bcb9c3cc4a3eeda20a99b0378749020f1300b/documents/images/004.png -------------------------------------------------------------------------------- /documents/images/BCM2835-Memory-Map-Large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimmy947788/build-lineageOS-for-raspberry-pi/fe3bcb9c3cc4a3eeda20a99b0378749020f1300b/documents/images/BCM2835-Memory-Map-Large.png -------------------------------------------------------------------------------- /documents/images/BCM2835-SoC-block-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimmy947788/build-lineageOS-for-raspberry-pi/fe3bcb9c3cc4a3eeda20a99b0378749020f1300b/documents/images/BCM2835-SoC-block-diagram.png -------------------------------------------------------------------------------- /documents/images/BCM2835_Block_Diagram.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimmy947788/build-lineageOS-for-raspberry-pi/fe3bcb9c3cc4a3eeda20a99b0378749020f1300b/documents/images/BCM2835_Block_Diagram.gif -------------------------------------------------------------------------------- /documents/images/android_boot_process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimmy947788/build-lineageOS-for-raspberry-pi/fe3bcb9c3cc4a3eeda20a99b0378749020f1300b/documents/images/android_boot_process.png -------------------------------------------------------------------------------- /documents/images/introduction-to-rpi-15-638.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimmy947788/build-lineageOS-for-raspberry-pi/fe3bcb9c3cc4a3eeda20a99b0378749020f1300b/documents/images/introduction-to-rpi-15-638.jpg -------------------------------------------------------------------------------- /documents/images/rpi3b-boot-sequence.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimmy947788/build-lineageOS-for-raspberry-pi/fe3bcb9c3cc4a3eeda20a99b0378749020f1300b/documents/images/rpi3b-boot-sequence.png -------------------------------------------------------------------------------- /documents/images/zo803Hq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimmy947788/build-lineageOS-for-raspberry-pi/fe3bcb9c3cc4a3eeda20a99b0378749020f1300b/documents/images/zo803Hq.png -------------------------------------------------------------------------------- /documents/knowledge/android-boot-process.md: -------------------------------------------------------------------------------- 1 | ## Android啟動流程 2 | 3 | ### 啟動桌面luancher 4 | ```java 5 | //AOSP修改檔案:frameworks\base\services\core\java\com\android\server\am\ActivityManagerService.java 6 | public void systemReady(final Runnable goingCallback, TimingsTraceLog traceLog) { 7 | /* 8 | something code 9 | */ 10 | startHomeActivityLocked(currentUserId, "systemReady"); 11 | ``` 12 | 13 | #### 參考 14 | - [Android 8.1 开机流程分析(1)](https://blog.csdn.net/qq_19923217/article/details/81240302) 15 | - [Android 8.1 开机流程分析(2)](https://blog.csdn.net/qq_19923217/article/details/82014989) 16 | - [从源码角度看Android系统Launcher在开机时的启动过程](https://blog.csdn.net/salmon_zhang/article/details/93639941) 17 | - [adb获取Android系统属性数据来源](https://blog.csdn.net/haixia_12/article/details/40857721) -------------------------------------------------------------------------------- /documents/knowledge/linux-boot-process.md: -------------------------------------------------------------------------------- 1 | ## 開機啟動流程 2 | 3 | Raspberry Pi 是使用GPU來做bootloader,和其他Embedded板子用CPU來做bootloader不一樣。\ 4 | ![Boot process](/documents/images/zo803Hq.png) 5 | > 官方的firmware專案就包含[bootloader](https://github.com/raspberrypi/firmware/tree/master/boot) 6 | 7 | #### PowerOn 8 | 1. BCM2835 SoC 通電啟動 9 | 2. CPU(ARM core), SDRAM並未啟動 10 | 3. VideoCore GPU 啟動。 11 | 4. VideoCore GPU 上的RISC core來負責bootloader運作。 12 | 5. 進入 bootloader stage 1 。 13 | 14 | #### 開機 stage 1 (GPU負責) 15 | 1. 掛載 SD 記憶卡上的 FAT32的boot磁碟分區。 16 | 2. 載入 bootcode.bin (導加載程序) 到 GPU L2 Cache 。 17 | 3. GPU 從 L2 Cache 執行 bootcode.bin 。 18 | 4. 開始進入bootloader stage 2 流程。 19 | > 樹梅派4之後把bootcode.bin 已經移到 EEPROM 裡面不靠檔案了[參考](https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md) 20 | 21 | #### 開機 stage 2 (bootcode.bin負責) 22 | 1. 啟動SDRAM 23 | 2. 從SD記憶卡上的 FAT32的boot磁碟分區,載入start*.elf 到 VideoCore GPU 開機 [註2](https://github.com/02047788a/build-lineageOS-for-raspberry-pi/blob/master/documents/knowledge/linux-boot-process.md#%E5%82%99%E8%A8%BB) 24 | - start4.elf, start4x.elf, start4cd.elf, and start4db.elf 是樹梅派4的[firmware](https://www.raspberrypi.org/documentation/configuration/boot_folder.md) 25 | 3. 載入fixup*.dat用於配置GPU和CPU之間的SDRAM分區,重新整理GPU和CPU的記憶體因為接下來要準備轉移給CPU去運作系統了。(也配置zImage要使用的空間) 26 | > 此時如果看到彩虹splash 表示開始進入 stage 3 但是還沒進入 linux kernel 27 | 28 | 29 | #### bootloader stage 3 (start*.elf 負責) 30 | 1. 載入config.txt設定檔,把config.txt當作BIOS初始化硬體的參數[參考](https://www.raspberrypi.org/documentation/configuration/config-txt/) 31 | 2. 載入cmdline.txt要把參數傳遞给kernel [參考](https://www.raspberrypi.org/documentation/configuration/cmdline-txt.md) 32 | 3. 載入zImage(linux kernel) 33 | 4. 啟動 ARM core CPU 34 | 5. 進入linux kernel 35 | 36 | #### linux kernel 37 | 1. kernel 透過 cmdline.txt的參數initrd提供的位址去抓取ramdisk.img 38 | 2. kernel 掛載基本檔案系統預備提供給Android使用 39 | 3. kernel 掛載完成檔案系統後就會先執行init這隻程式(kernel\brcm\rpi*\init\main.c) 40 | 41 | #### 備註 42 | 1. bootcode.bin 是引導加載程序( Stage 2 的流程內容程式) 這部份流程都寫在BCM2835無法修改,bootcode.bin 也不開放程式碼。 43 | 2. start.elf 是基礎 firmware,start_x.elf 包含 camera 驅動程式和編/解碼器 firmware,start_db.elf 是硬體debug 用的 firmware,start_cd.elf 是簡化版本不含支援編/解碼器和3D加速功能的硬件模組。 44 | 3. Minimal Raspberry Pi VPU firmware 程式碼 [github](https://github.com/christinaa/rpi-open-firmware) 45 | #### 參考 46 | - [Raspberry Pi Releases BCM2835 Datasheet for ARM Peripherals](https://www.cnx-software.com/2012/02/07/raspberry-pi-releases-bcm2835-datasheet-for-arm-peripherals/) 47 | - [Boot sequence](https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/bootflow.md) 48 | - [git raspberrypi firmware](https://github.com/raspberrypi/firmware) 49 | - [BARE METAL RASPBERRY PI 3B+: NETWORK BOOT](https://metebalci.com/blog/bare-metal-rpi3-network-boot/) 50 | - [The boot folder](https://www.raspberrypi.org/documentation/configuration/boot_folder.md) 51 | - [buildRoot study - 建立自己的作業系統](https://www.cntofu.com/book/46/raspberry_pi/buildroot_study_-_jian_li_zi_ji_de_zuo_ye_xi_tong.md) 52 | - [The Kernel Command Line](https://www.raspberrypi.org/documentation/configuration/cmdline-txt.md) 53 | - [config.txt] (https://www.raspberrypi.org/documentation/configuration/config-txt/) 54 | - [Hardware boot] (https://rxos.readthedocs.io/en/develop/how_it_works/boot.html#hardware-boot) -------------------------------------------------------------------------------- /documents/resource/BCM2835-ARM-Peripherals.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jimmy947788/build-lineageOS-for-raspberry-pi/fe3bcb9c3cc4a3eeda20a99b0378749020f1300b/documents/resource/BCM2835-ARM-Peripherals.pdf -------------------------------------------------------------------------------- /lineageos.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################################################################ 4 | # Help # 5 | ################################################################################ 6 | Help() 7 | { 8 | # Display Help 9 | echo -e "build LineageOS helper." 10 | echo 11 | echo -e "Syntax: scriptTemplate [-g|h|v|V]" 12 | echo -e "options:" 13 | echo -e "[-h|--help] Print this Help." 14 | echo -e "[-i|--init] initialize worker envvierment." 15 | echo -e "[-s|--sync] synchronize repository" 16 | echo -e "[-b|--build] Build source code" 17 | echo -e "[-d|--device] build source code by device" 18 | echo -e "\tcurrent device support rpi3,rpi4" 19 | echo -e "[-m|--moule] build source code by module" 20 | echo -e "\tmodule has (kernel|ramdisk|systemimage|vendorimage)" 21 | echo -e "\tno support this argument was build all modules" 22 | echo 23 | echo "example:" 24 | echo -e "\t./lineageos.bash --init" 25 | echo -e "\t./lineageos.bash --sync" 26 | echo -e "\t./lineageos.bash --build --device=rpi4" 27 | echo -e "\t./lineageos.bash --build --device=rpi4 --module=kernel ramdisk systemimage vendorimage" 28 | } 29 | 30 | 31 | add_path_env(){ 32 | NEW_PATH=$1 33 | if grep -Fxq "export PATH=\$PATH:$NEW_PATH" $PROFILE_PATH 34 | then 35 | echo "$NEW_PATH already in PATH environment variable !" 36 | else 37 | echo "export PATH=\$PATH:$NEW_PATH" >> $PROFILE_PATH 38 | echo "add $NEW_PATH in PATH environment variable !" 39 | fi 40 | source $PROFILE_PATH 41 | } 42 | 43 | write_env(){ 44 | local ENV_KEY=$1 45 | local ENV_VAL=$2 46 | #echo "${ENV_VAL////\\/}" 47 | sed -i "/export $ENV_KEY=/d" $PROFILE_PATH 48 | echo "export $ENV_KEY=$ENV_VAL" >> $PROFILE_PATH 49 | #echo "export $ENV_KEY=$ENV_VAL" 50 | source $PROFILE_PATH 51 | } 52 | 53 | read_var_frm_input(){ 54 | local MESSAGE="$1" 55 | local DEFAULT="$2" 56 | printf "$MESSAGE 【 default: $DEFAULT 】:" 57 | IFS= read -r USER_INPUT 58 | if [ -z "${USER_INPUT}" ] 59 | then 60 | USER_INPUT=$DEFAULT 61 | fi 62 | #echo $USER_INPUT 63 | } 64 | 65 | init_env(){ 66 | # 指定lineageOS程式碼目錄 67 | # =========================================================== 68 | if [[ -z $LINEAGE_WORKER ]] 69 | then 70 | LINEAGE_WORKER="$HOME/lineageOS" 71 | fi 72 | PROMPT_MSG="Please entry lineageOS worker folder" 73 | read_var_frm_input "${PROMPT_MSG}" "${LINEAGE_WORKER}" 74 | LINEAGE_WORKER=$USER_INPUT 75 | write_env "LINEAGE_WORKER" $LINEAGE_WORKER 76 | 77 | # 指定lineageOS 分支版本 78 | # =========================================================== 79 | if [[ -z $LINEAGE_BRANCH ]] 80 | then 81 | LINEAGE_BRANCH="lineage-16.1" 82 | fi 83 | PROMPT_MSG="Please entry checkout lineageOS branch" 84 | read_var_frm_input "${PROMPT_MSG}" "${LINEAGE_BRANCH}" 85 | LINEAGE_BRANCH=$USER_INPUT 86 | write_env "LINEAGE_BRANCH" $LINEAGE_BRANCH 87 | 88 | # 設定 git global user.name 89 | # =========================================================== 90 | GIT_USER_NAME=$(git config --global user.name) 91 | if [[ -z $GIT_USER_NAME ]] 92 | then 93 | PROMPT_MSG="Please entry your git global user.name" 94 | DEFAULT_VAL="Your Name" 95 | read_var_frm_input "${PROMPT_MSG}" "${DEFAULT_VAL}" 96 | GIT_USER_NAME=$USER_INPUT 97 | git config --global user.name "$GIT_USER_NAME" 98 | #else 99 | # echo "git global user.name=$GIT_USER_NAME" 100 | fi 101 | 102 | # 設定 git global user.email 103 | # =========================================================== 104 | GIT_USER_EMAIL=$(git config --global user.email) 105 | if [[ -z $GIT_USER_EMAIL ]] 106 | then 107 | PROMPT_MSG="Please entry your git global user.email" 108 | DEFAULT_VAL="Your email" 109 | read_var_frm_input "${PROMPT_MSG}" "${DEFAULT_VAL}" 110 | GIT_USER_EMAIL=$USER_INPUT 111 | git config --global user.email "$GIT_USER_EMAIL" 112 | #else 113 | # echo "git global user.email=$GIT_USER_EMAIL" 114 | fi 115 | 116 | echo "" 117 | echo "" 118 | echo -e "lineageOS checkout worker is \033[1m$LINEAGE_WORKER\033[0m" 119 | echo -e "lineageOS branch is \033[1m$LINEAGE_BRANCH\033[0m" 120 | 121 | # 建立lineageOS程式碼目錄 122 | # =========================================================== 123 | #[ -d $LINEAGE_WORKER ] && rm -rf $LINEAGE_WORKER 124 | [ ! -d $LINEAGE_WORKER ] && mkdir $LINEAGE_WORKER 125 | 126 | install_build_packges 127 | 128 | turnOn_caching_to_speedup_build 129 | 130 | install_platform_tools 131 | 132 | install_repo_command 133 | } 134 | 135 | #https://wiki.lineageos.org/devices/bacon/build#install-the-platform-tools 136 | install_platform_tools(){ 137 | source $PROFILE_PATH 138 | echo "Install the platform-tools" 139 | 140 | if [[ ! -d $HOME/platform-tools ]] 141 | then 142 | wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip -O platform-tools-latest-linux.zip 143 | unzip platform-tools-latest-linux.zip -d $HOME/platform-tools 144 | fi 145 | 146 | serarch_result=$(grep -rnw "$HOME/.profile" -e "# add Android SDK platform tools to path") 147 | if [[ -z "$serarch_result" ]] 148 | then 149 | echo "" >> $PROFILE_PATH 150 | echo "" >> $PROFILE_PATH 151 | echo "# add Android SDK platform tools to path" >> $PROFILE_PATH 152 | echo "if [ -d \"\$HOME/platform-tools\" ] ; then" >> $PROFILE_PATH 153 | echo " PATH=\"\$HOME/platform-tools:\$PATH\"" >> $PROFILE_PATH 154 | echo "fi" >> $PROFILE_PATH 155 | source $PROFILE_PATH 156 | fi 157 | } 158 | 159 | #https://wiki.lineageos.org/devices/bacon/build#install-the-build-packages 160 | install_build_packges(){ 161 | OS_VERSION=$(lsb_release -a | grep "Release" | awk '{print $2}') 162 | echo $OS_VERSION 163 | sudo apt install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev 164 | if [[ $OS_VERSION < 20.04 ]] 165 | then 166 | sudo apt install libwxgtk3.0-dev 167 | fi 168 | } 169 | 170 | #https://wiki.lineageos.org/devices/bacon/build#turn-on-caching-to-speed-up-build 171 | turnOn_caching_to_speedup_build(){ 172 | source $PROFILE_PATH 173 | write_env "USE_CCACHE" 1 174 | write_env "CCACHE_EXEC" "/usr/bin/ccache" 175 | write_env "CCACHE_DIR" "$HOME/.ccache" 176 | ccache -M 50G 177 | ccache -o compression=true 178 | } 179 | 180 | install_repo_command(){ 181 | source $PROFILE_PATH 182 | # 下載Repo程式碼管理工具 183 | # =========================================================== 184 | if [ ! -d $BIN_DIR ] 185 | then 186 | mkdir $BIN_DIR 187 | add_path_env $BIN_DIR 188 | curl https://storage.googleapis.com/git-repo-downloads/repo > $REPO_PATH 189 | chmod a+x $REPO_PATH 190 | else 191 | echo "folder already exits. $BIN_DIR" 192 | fi 193 | 194 | serarch_result=$(grep -rnw "$HOME/.profile" -e "# set PATH so it includes user's private bin if it exists") 195 | if [[ -z "$serarch_result" ]] 196 | then 197 | echo "" >> $PROFILE_PATH 198 | echo "" >> $PROFILE_PATH 199 | echo "# set PATH so it includes user's private bin if it exists" >> $PROFILE_PATH 200 | echo "if [ -d \"\$HOME/bin\" ] ; then" >> $PROFILE_PATH 201 | echo " PATH=\"\$HOME/bin:\$PATH\"" >> $PROFILE_PATH 202 | echo "fi" >> $PROFILE_PATH 203 | source $PROFILE_PATH 204 | fi 205 | } 206 | 207 | sync_lineage(){ 208 | # 進入lineageOS程式碼目錄 209 | # =========================================================== 210 | cd $LINEAGE_WORKER 211 | echo "entery to lineage source path : $LINEAGE_WORKER" 212 | 213 | # 初始化repository的分支 214 | # =========================================================== 215 | echo "init LineageOS repository for $LINEAGE_BRANCH" 216 | repo init -u git://github.com/LineageOS/android.git -b $LINEAGE_BRANCH 217 | 218 | # 下載lineage manifests額外專案檔案 219 | # =========================================================== 220 | echo "get manifest_brcm.xml for $LINEAGE_BRANCH" 221 | MANIFESTS_CONTENT="https://raw.githubusercontent.com/02047788a/android_local_manifest/$LINEAGE_BRANCH/manifest_brcm.xml" 222 | mkdir -p "$LINEAGE_WORKER/.repo/local_manifests/" 223 | curl --create-dirs -L -o "$LINEAGE_WORKER/.repo/local_manifests/manifest_brcm.xml" -O -L $MANIFESTS_CONTENT 224 | 225 | # 開始下載程式碼 226 | # =========================================================== 227 | repo sync -j$(nproc --all) #使用CPU最大thread數來下載 228 | } 229 | 230 | build_lineage(){ 231 | echo "lineage_$DEVICE-userdebug" 232 | cd $LINEAGE_WORKER 233 | source build/envsetup.sh 234 | lunch lineage_$DEVICE-userdebug 235 | make -j$(nproc --all) $MODULE 236 | } 237 | 238 | 239 | BIN_DIR=$HOME/bin 240 | REPO_PATH=$BIN_DIR/repo 241 | PROFILE_PATH=$HOME/.profile 242 | #echo "PROFILE_PATH=$PROFILE_PATH" 243 | source $PROFILE_PATH 244 | 245 | DEFAULT=NO 246 | for i in "$@" 247 | do 248 | case $1 in 249 | -h|--help) 250 | Help 251 | ;; 252 | -i|--init) 253 | ARG_INIT="y" 254 | ;; 255 | -s|--sync) 256 | ARG_SYNC="y" 257 | ;; 258 | -b|--build) 259 | ARG_BUILD="y" 260 | shift 261 | ;; 262 | -d=*|--device=*) 263 | DEVICE="${i#*=}" 264 | shift 265 | ;; 266 | -m=*|--module=*) 267 | MODULE="${i#*=}" 268 | shift 269 | ;; 270 | --default) 271 | Help 272 | shift 273 | ;; 274 | *) 275 | # Unknown option 276 | ;; 277 | esac 278 | done 279 | 280 | if [[ ! -z $ARG_INIT ]]; 281 | then 282 | init_env 283 | exit 0 284 | fi 285 | 286 | if [[ ! -z $ARG_SYNC ]]; 287 | then 288 | sync_lineage 289 | exit 0 290 | fi 291 | 292 | if [[ ! -z $ARG_BUILD ]]; 293 | then 294 | if [[ -z $DEVICE ]]; 295 | then 296 | echo "must be support device name, example:" 297 | echo -e "\t./lineageos.bash --build --device=rpi4" 298 | exit 22 #Invalid argument 299 | fi 300 | 301 | if [[ -z $MODULE ]]; 302 | then 303 | MODULE="kernel ramdisk systemimage vendorimage" 304 | fi 305 | build_lineage 306 | exit 0 307 | fi 308 | 309 | if [ -z $ARG_INIT ] && [ -z $ARG_BUILD ] && [ -z $ARG_BUILD ] 310 | then 311 | Help 312 | fi -------------------------------------------------------------------------------- /manifests/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 10 | 11 | 15 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | -------------------------------------------------------------------------------- /manifests/manifest_brcm_rpi3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /manifests/manifest_brcm_rpi4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /manifests/manifest_brcm_rpi4_lineage18.1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /patches/frameworks_base/0001-rpi3-modify-generic-keyboard-layout.patch: -------------------------------------------------------------------------------- 1 | From d5c00cff59a120a7b24b2377e7ff715206c3e179 Mon Sep 17 00:00:00 2001 2 | From: Konsta 3 | Date: Sun, 15 Apr 2018 13:43:27 +0300 4 | Subject: [PATCH] rpi3: modify generic keyboard layout 5 | 6 | Change-Id: I838fefac86606f3f881bf83450f81db4cfe689e2 7 | --- 8 | data/keyboards/Generic.kl | 14 +++++++------- 9 | 1 file changed, 7 insertions(+), 7 deletions(-) 10 | 11 | diff --git a/data/keyboards/Generic.kl b/data/keyboards/Generic.kl 12 | index 2a10bdd..b836ee3 100644 13 | --- a/data/keyboards/Generic.kl 14 | +++ b/data/keyboards/Generic.kl 15 | @@ -78,11 +78,11 @@ key 55 NUMPAD_MULTIPLY 16 | key 56 ALT_LEFT 17 | key 57 SPACE 18 | key 58 CAPS_LOCK 19 | -key 59 F1 20 | -key 60 F2 21 | -key 61 F3 22 | -key 62 F4 23 | -key 63 F5 24 | +key 59 HOME 25 | +key 60 BACK 26 | +key 61 APP_SWITCH 27 | +key 62 MENU 28 | +key 63 POWER 29 | key 64 F6 30 | key 65 F7 31 | key 66 F8 32 | @@ -106,8 +106,8 @@ key 83 NUMPAD_DOT 33 | # key 84 (undefined) 34 | key 85 ZENKAKU_HANKAKU 35 | key 86 BACKSLASH 36 | -key 87 F11 37 | -key 88 F12 38 | +key 87 VOLUME_DOWN 39 | +key 88 VOLUME_UP 40 | key 89 RO 41 | # key 90 "KEY_KATAKANA" 42 | # key 91 "KEY_HIRAGANA" 43 | -- 44 | 2.7.4 45 | 46 | -------------------------------------------------------------------------------- /patches/vendor_lineage/0001-disable-adb-authentication-by-default.patch: -------------------------------------------------------------------------------- 1 | From 615897c26131fb343994180617196ebd60d6af06 Mon Sep 17 00:00:00 2001 2 | From: Konsta 3 | Date: Sat, 27 Jul 2013 15:03:04 +0300 4 | Subject: [PATCH] disable adb authentication by default 5 | 6 | This reverts commit 59df363c6097eb4c8b53c1b952d7384a567bafac. 7 | 8 | Change-Id: Ia7317c8a6afac799c047ea6d594d7ccd17e569c0 9 | --- 10 | config/common.mk | 5 ----- 11 | 1 file changed, 5 deletions(-) 12 | 13 | diff --git a/config/common.mk b/config/common.mk 14 | index 70360c9..f65bce1 100644 15 | --- a/config/common.mk 16 | +++ b/config/common.mk 17 | @@ -26,11 +26,6 @@ ifneq ($(TARGET_BUILD_VARIANT),user) 18 | PRODUCT_SYSTEM_DEFAULT_PROPERTIES += persist.sys.dun.override=0 19 | endif 20 | 21 | -ifneq ($(TARGET_BUILD_VARIANT),eng) 22 | -# Enable ADB authentication 23 | -PRODUCT_SYSTEM_DEFAULT_PROPERTIES += ro.adb.secure=1 24 | -endif 25 | - 26 | ifeq ($(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),) 27 | PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \ 28 | ro.device.cache_dir=/data/cache 29 | -- 30 | 2.7.4 31 | 32 | -------------------------------------------------------------------------------- /scripts/build-lineageos-code.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | write_env(){ 4 | local ENV_KEY=$1 5 | local ENV_VAL=$2 6 | #echo "${ENV_VAL////\\/}" 7 | sed -i "/export $ENV_KEY=/d" $PROFILE_PATH 8 | echo "export $ENV_KEY=$ENV_VAL" >> $PROFILE_PATH 9 | } 10 | 11 | #DEVICE_NAME="rpi3" 12 | PROFILE_PATH=$HOME/.profile 13 | 14 | source $PROFILE_PATH 15 | echo "Entry LineageOS source code folder: $LINEAGE_SRC" 16 | cd $LINEAGE_SRC 17 | 18 | if [ -z "$DEVICE_NAME" ] 19 | then 20 | echo "you don't have set DEVICE_NAME, build failed..." 21 | exit 1 22 | fi 23 | 24 | BUILD_IMG=$1 25 | if [ -z "$BUILD_IMG" ] 26 | then 27 | BUILD_IMG="ALL" 28 | fi 29 | 30 | if [[ "$BUILD_IMG" =~ ^(kernel|ramdisk|systemimage|vendorimage|ALL)$ ]] 31 | then 32 | echo "build $BUILD_IMG image." 33 | if [ "$BUILD_IMG" == "ALL" ] 34 | then 35 | BUILD_IMG="kernel ramdisk systemimage vendorimage" 36 | fi 37 | else 38 | echo "unknow image name $BUILD_IMG ." 39 | echo "please check you want build image is (kernel|ramdisk|systemimage|vendorimage|ALL)." 40 | exit 1 41 | fi 42 | 43 | echo "set compiler cache enable." 44 | write_env "USE_CCACHE" 1 45 | write_env "CCACHE_DIR" "$HOME/.ccache" 46 | ccache -M 70G 47 | 48 | echo "set compiler use memory ." 49 | write_env "JACK_ADMIN_PATH" "$LINEAGE_SRC/prebuilts/sdk/tools/jack-admin" 50 | write_env "JACK_SERVER_VM_ARGUMENTS" "\"-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g\"" 51 | $JACK_ADMIN_PATH kill-server && $JACK_ADMIN_PATH start-server 52 | 53 | source build/envsetup.sh 54 | lunch lineage_$DEVICE_NAME-userdebug 55 | make -j12 $BUILD_IMG 56 | 57 | echo "remove old $LINEAGE_BRANCH-$DEVICE_NAME.img...." 58 | rm -f $LINEAGE_SRC/device/brcm/$DEVICE_NAME/$LINEAGE_BRANCH-*-$DEVICE_NAME.img 59 | rm -f $LINEAGE_SRC/out/target/product/$DEVICE_NAME/$LINEAGE_BRANCH-*-$DEVICE_NAME.img 60 | 61 | echo "build new $LINEAGE_BRANCH-$DEVICE_NAME.img..." 62 | cd $LINEAGE_SRC/device/brcm/$DEVICE_NAME/ 63 | sudo sh mkimg.sh 64 | DATE=`date +%Y%m%d` 65 | IMGNAME="$LINEAGE_BRANCH-$DATE-$DEVICE_NAME.img" 66 | mv "$IMGNAME" "$LINEAGE_SRC/out/target/product/$DEVICE_NAME/$IMGNAME" 67 | echo "new image file is here: " 68 | echo " $LINEAGE_SRC/out/target/product/$DEVICE_NAME/$IMGNAME" -------------------------------------------------------------------------------- /scripts/common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | print_title () { 4 | echo "" 5 | printf "\E[1;32;49m$1\E[0m\n" 6 | } 7 | 8 | print_info () { 9 | printf "\E[0;32;49m[INFO]\E[0m $1\n" 10 | } 11 | 12 | print_warn () { 13 | printf "\E[0;33;49m[WARN]\E[0m $1\n" 14 | } 15 | 16 | print_variable() { 17 | padding_formate="%-20s" 18 | printf "\E[0;36;49m$padding_formate = \E[0m" "$1" 19 | printf "\E[0;37;49m$2\E[0m\n" 20 | } 21 | 22 | create_folder() 23 | { 24 | if [ ! -d $1 ] 25 | then 26 | print_info "create foilder $1" 27 | mkdir $1 28 | else 29 | print_info "folder already exits. $1" 30 | fi 31 | } 32 | 33 | print_space(){ 34 | length=$1 35 | printf ' %.0s' $(seq 1 $length) 36 | } 37 | 38 | show_banner(){ 39 | script_name=$1 40 | script_name_len=${#script_name} 41 | banner_width=80 42 | banner_width_char="$(printf '=%.0s' $(seq 1 $banner_width))" 43 | 44 | printf "\E[1;96;49m" 45 | # line 1 46 | printf "%s\n" $banner_width_char 47 | # line 2 48 | line2_space_len=$(expr $banner_width - 2) 49 | printf "=%s=\n" "$(print_space $line2_space_len)" 50 | 51 | # line 3 52 | space_len=$((banner_width-script_name_len-2)) 53 | left_space_len=$((space_len / 2)) 54 | padding_left="$(print_space $left_space_len)" 55 | padding_right="$(print_space $left_space_len)" 56 | script_name_total_len=$((2 + left_space_len + script_name_len + left_space_len + 2)) 57 | if [ $script_name_total_len -gt $banner_width ] 58 | then 59 | padding_left="$(print_space $(expr $left_space_len - 1))" 60 | fi 61 | printf "=%s %s %s=\n" "$padding_left" "$script_name" "$padding_right" 62 | 63 | # line 4 64 | line2_space_len=$(expr $banner_width - 2) 65 | printf "=%s=\n" "$(print_space $line2_space_len)" 66 | 67 | # line 5 68 | printf "%s\n" $banner_width_char 69 | printf "\E[0m\n" 70 | } 71 | 72 | set_environment_variable(){ 73 | print_title "set environment variable" 74 | export "JAVA_HOME=$lineageOSFolder/prebuilts/jdk/jdk8/linux-x86" 75 | export "PATH=$PATH:$JAVA_HOME/bin:$imageMagickBuildFolder/bin:$homeBinFolder" 76 | export "CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" 77 | echo "JAVA_HOME=$JAVA_HOME" 78 | echo "PATH=$PATH" 79 | echo "CLASSPATH=$CLASSPATH" 80 | } 81 | 82 | 83 | show_config(){ 84 | print_variable "workerFolder" $workerFolder 85 | print_variable "imageMagickFolder" $imageMagickFolder 86 | print_variable "imageMagickBuildFolder" $imageMagickBuildFolder 87 | print_variable "homeBinFolder" $homeBinFolder 88 | print_variable "lineageOSFolder" $lineageOSFolder 89 | print_variable "lineageVersion" $lineageVersion 90 | print_variable "useBuildCore" $useBuildCore 91 | print_variable "buildType" $buildType 92 | } -------------------------------------------------------------------------------- /scripts/config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | workerFolder="$HOME/android-lineage-rpi" 3 | imageMagickFolder="$workerFolder/ImageMagick" 4 | imageMagickBuildFolder="$imageMagickFolder/build" 5 | homeBinFolder="$HOME/bin" 6 | lineageOSFolder="$workerFolder/lineageOS" 7 | lineageVersion="lineage-15.1" 8 | useBuildCore=12 9 | buildTarget="lineage_rpi3" 10 | buildType="userdebug" #user,userdebug,eng #https://source.android.com/setup/build/building#choose-a-target -------------------------------------------------------------------------------- /scripts/sync-lineageos-code.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | add_path_env(){ 4 | NEW_PATH=$1 5 | if grep -Fxq "export PATH=\$PATH:$NEW_PATH" $PROFILE_PATH 6 | then 7 | echo "$NEW_PATH already in PATH environment variable !" 8 | else 9 | echo "export PATH=\$PATH:$NEW_PATH" >> $PROFILE_PATH 10 | echo "add $NEW_PATH in PATH environment variable !" 11 | fi 12 | source $PROFILE_PATH 13 | } 14 | 15 | write_env(){ 16 | local ENV_KEY=$1 17 | local ENV_VAL=$2 18 | #echo "${ENV_VAL////\\/}" 19 | sed -i "/export $ENV_KEY=/d" $PROFILE_PATH 20 | echo "export $ENV_KEY=$ENV_VAL" >> $PROFILE_PATH 21 | echo "export $ENV_KEY=$ENV_VAL" 22 | } 23 | 24 | BIN_DIR=$HOME/bin 25 | REPO_PATH=$BIN_DIR/repo 26 | PROFILE_PATH=$HOME/.profile 27 | 28 | read_var_frm_input(){ 29 | local MESSAGE="$1" 30 | local DEFAULT="$2" 31 | printf "$MESSAGE (default: $DEFAULT):" 32 | IFS= read -r USER_INPUT 33 | if [ -z "${USER_INPUT}" ] 34 | then 35 | USER_INPUT=$DEFAULT 36 | fi 37 | #echo $USER_INPUT 38 | } 39 | 40 | source $PROFILE_PATH 41 | MOD=$1 42 | if [[ "$MOD" = "init" ]] 43 | then 44 | # 指定lineageOS程式碼目錄 45 | # =========================================================== 46 | if [[ -z $LINEAGE_SRC ]] 47 | then 48 | LINEAGE_SRC="$HOME/lineageOS" 49 | fi 50 | PROMPT_MSG="Please entry lineageOS checkout folder:" 51 | read_var_frm_input "${PROMPT_MSG}" "${LINEAGE_SRC}" 52 | LINEAGE_SRC=$USER_INPUT 53 | echo "lineageOS checkout forder is $LINEAGE_SRC" 54 | write_env "LINEAGE_SRC" $LINEAGE_SRC 55 | 56 | # 指定lineageOS 分支版本 57 | # =========================================================== 58 | if [[ -z $LINEAGE_BRANCH ]] 59 | then 60 | LINEAGE_BRANCH="lineage-15.1" 61 | fi 62 | PROMPT_MSG="Please entry checkout lineageOS branch:" 63 | read_var_frm_input "${PROMPT_MSG}" "${LINEAGE_BRANCH}" 64 | LINEAGE_BRANCH=$USER_INPUT 65 | echo "lineageOS branch is $LINEAGE_BRANCH" 66 | write_env "LINEAGE_BRANCH" $LINEAGE_BRANCH 67 | 68 | # 指定lineageOS 分支版本 69 | # =========================================================== 70 | if [[ -z $DEVICE_NAME ]] 71 | then 72 | DEVICE_NAME="rpi3" 73 | fi 74 | PROMPT_MSG="Please entry build device name (ex:rpi3,rpi4)" 75 | read_var_frm_input "${PROMPT_MSG}" "${DEVICE_NAME}" 76 | DEVICE_NAME=$USER_INPUT 77 | #echo "build device name is $DEVICE_NAME" 78 | write_env "DEVICE_NAME" $DEVICE_NAME 79 | 80 | # 設定 git global user.name 81 | # =========================================================== 82 | GIT_USER_NAME=$(git config --global user.name) 83 | if [[ -z $GIT_USER_NAME ]] 84 | then 85 | PROMPT_MSG="Please entry your git global user.name" 86 | DEFAULT_VAL="Your Name" 87 | read_var_frm_input "${PROMPT_MSG}" "${DEFAULT_VAL}" 88 | GIT_USER_NAME=$USER_INPUT 89 | git config --global user.name "$GIT_USER_NAME" 90 | else 91 | echo "git global user.name=$GIT_USER_NAME" 92 | fi 93 | 94 | # 設定 git global user.email 95 | # =========================================================== 96 | GIT_USER_EMAIL=$(git config --global user.email) 97 | if [[ -z $GIT_USER_EMAIL ]] 98 | then 99 | PROMPT_MSG="Please entry your git global user.email" 100 | DEFAULT_VAL="Your email" 101 | read_var_frm_input "${PROMPT_MSG}" "${DEFAULT_VAL}" 102 | GIT_USER_EMAIL=$USER_INPUT 103 | git config --global user.email "$GIT_USER_EMAIL" 104 | else 105 | echo "git global user.email=$GIT_USER_EMAIL" 106 | fi 107 | 108 | 109 | # 下載Repo程式碼管理工具 110 | # =========================================================== 111 | if [ ! -d $BIN_DIR ] 112 | then 113 | mkdir $BIN_DIR 114 | add_path_env $BIN_DIR 115 | curl https://storage.googleapis.com/git-repo-downloads/repo > $REPO_PATH 116 | chmod a+x $REPO_PATH 117 | else 118 | echo "folder already exits. $BIN_DIR" 119 | fi 120 | 121 | # 建立lineageOS程式碼目錄 122 | # =========================================================== 123 | [ -d $LINEAGE_SRC ] && rm -rf $LINEAGE_SRC 124 | mkdir $LINEAGE_SRC 125 | 126 | # 進入lineageOS程式碼目錄 127 | # =========================================================== 128 | cd $LINEAGE_SRC 129 | echo "entery to lineage source path : $LINEAGE_SRC" 130 | 131 | # 初始化repository的分支 132 | # =========================================================== 133 | echo "init LineageOS repository for $LINEAGE_BRANCH" 134 | repo init -u git://github.com/LineageOS/android.git -b $LINEAGE_BRANCH 135 | 136 | # 下載lineage manifests額外專案檔案 137 | # =========================================================== 138 | if [ ! -z "$DEVICE_NAME" ] 139 | then 140 | GITHUB_MANIFESTS_CONTENT="https://raw.githubusercontent.com/02047788a/build-lineageOS-for-raspberry-pi/master/manifests/manifest_brcm_rpi4_lineage18.1.xml" 141 | echo "get manifest_brcm_rpi4_lineage18.1.xml manifests" 142 | curl --create-dirs -L -o .repo/local_manifests/manifest_brcm_$DEVICE_NAME.xml -O -L $GITHUB_MANIFESTS_CONTENT 143 | fi 144 | 145 | 146 | # 開始下載程式碼 147 | # =========================================================== 148 | repo sync -j$(nproc --all) #使用CPU最大thread數來下載 149 | else 150 | if [[ "$MOD" = "clean" ]] 151 | then 152 | echo "$MOD" 153 | fi 154 | fi 155 | --------------------------------------------------------------------------------