Commit 79edc1b632a9006d68557278ef1206e05a4e2f7b
1 parent
bbe190f190
Exists in
smarc-8mm-p9.0.0_2.0.0_ga
and in
1 other branch
Add flash emmc script and convert console messages to ttymxc0
Showing 2 changed files with 265 additions and 1 deletions Inline Diff
imx8m/smarc_mx8mq/BoardConfig.mk
1 | # | 1 | # |
2 | # SoC-specific compile-time definitions. | 2 | # SoC-specific compile-time definitions. |
3 | # | 3 | # |
4 | 4 | ||
5 | BOARD_SOC_TYPE := IMX8MQ | 5 | BOARD_SOC_TYPE := IMX8MQ |
6 | BOARD_HAVE_VPU := true | 6 | BOARD_HAVE_VPU := true |
7 | BOARD_VPU_TYPE := hantro | 7 | BOARD_VPU_TYPE := hantro |
8 | HAVE_FSL_IMX_GPU2D := false | 8 | HAVE_FSL_IMX_GPU2D := false |
9 | HAVE_FSL_IMX_GPU3D := true | 9 | HAVE_FSL_IMX_GPU3D := true |
10 | HAVE_FSL_IMX_IPU := false | 10 | HAVE_FSL_IMX_IPU := false |
11 | HAVE_FSL_IMX_PXP := false | 11 | HAVE_FSL_IMX_PXP := false |
12 | BOARD_KERNEL_BASE := 0x40400000 | 12 | BOARD_KERNEL_BASE := 0x40400000 |
13 | TARGET_GRALLOC_VERSION := v3 | 13 | TARGET_GRALLOC_VERSION := v3 |
14 | TARGET_HIGH_PERFORMANCE := true | 14 | TARGET_HIGH_PERFORMANCE := true |
15 | TARGET_USES_HWC2 := true | 15 | TARGET_USES_HWC2 := true |
16 | TARGET_HWCOMPOSER_VERSION := v2.0 | 16 | TARGET_HWCOMPOSER_VERSION := v2.0 |
17 | TARGET_HAVE_VIV_HWCOMPOSER = false | 17 | TARGET_HAVE_VIV_HWCOMPOSER = false |
18 | USE_OPENGL_RENDERER := true | 18 | USE_OPENGL_RENDERER := true |
19 | TARGET_CPU_SMP := true | 19 | TARGET_CPU_SMP := true |
20 | TARGET_HAVE_VULKAN := true | 20 | TARGET_HAVE_VULKAN := true |
21 | ENABLE_CFI=false | 21 | ENABLE_CFI=false |
22 | 22 | ||
23 | # enable opencl 2d. | 23 | # enable opencl 2d. |
24 | TARGET_OPENCL_2D := true | 24 | TARGET_OPENCL_2D := true |
25 | 25 | ||
26 | # | 26 | # |
27 | # Product-specific compile-time definitions. | 27 | # Product-specific compile-time definitions. |
28 | # | 28 | # |
29 | 29 | ||
30 | IMX_DEVICE_PATH := device/embedian/imx8m/smarc_mx8mq | 30 | IMX_DEVICE_PATH := device/embedian/imx8m/smarc_mx8mq |
31 | 31 | ||
32 | include $(IMX_DEVICE_PATH)/build_id.mk | 32 | include $(IMX_DEVICE_PATH)/build_id.mk |
33 | include device/fsl/imx8m/BoardConfigCommon.mk | 33 | include device/fsl/imx8m/BoardConfigCommon.mk |
34 | ifeq ($(PREBUILT_FSL_IMX_CODEC),true) | 34 | ifeq ($(PREBUILT_FSL_IMX_CODEC),true) |
35 | -include $(FSL_CODEC_PATH)/fsl-codec/fsl-codec.mk | 35 | -include $(FSL_CODEC_PATH)/fsl-codec/fsl-codec.mk |
36 | endif | 36 | endif |
37 | 37 | ||
38 | BUILD_TARGET_FS ?= ext4 | 38 | BUILD_TARGET_FS ?= ext4 |
39 | TARGET_USERIMAGES_USE_EXT4 := true | 39 | TARGET_USERIMAGES_USE_EXT4 := true |
40 | 40 | ||
41 | TARGET_RECOVERY_FSTAB = $(IMX_DEVICE_PATH)/fstab.freescale | 41 | TARGET_RECOVERY_FSTAB = $(IMX_DEVICE_PATH)/fstab.freescale |
42 | 42 | ||
43 | # Support gpt | 43 | # Support gpt |
44 | BOARD_BPT_INPUT_FILES += device/fsl/common/partition/device-partitions-13GB-ab.bpt | 44 | BOARD_BPT_INPUT_FILES += device/fsl/common/partition/device-partitions-13GB-ab.bpt |
45 | ADDITION_BPT_PARTITION = partition-table-7GB:device/fsl/common/partition/device-partitions-7GB-ab.bpt \ | 45 | ADDITION_BPT_PARTITION = partition-table-7GB:device/fsl/common/partition/device-partitions-7GB-ab.bpt \ |
46 | partition-table-28GB:device/fsl/common/partition/device-partitions-28GB-ab.bpt | 46 | partition-table-28GB:device/fsl/common/partition/device-partitions-28GB-ab.bpt |
47 | 47 | ||
48 | 48 | ||
49 | # Vendor Interface manifest and compatibility | 49 | # Vendor Interface manifest and compatibility |
50 | DEVICE_MANIFEST_FILE := $(IMX_DEVICE_PATH)/manifest.xml | 50 | DEVICE_MANIFEST_FILE := $(IMX_DEVICE_PATH)/manifest.xml |
51 | DEVICE_MATRIX_FILE := $(IMX_DEVICE_PATH)/compatibility_matrix.xml | 51 | DEVICE_MATRIX_FILE := $(IMX_DEVICE_PATH)/compatibility_matrix.xml |
52 | 52 | ||
53 | TARGET_BOOTLOADER_BOARD_NAME := SMARC | 53 | TARGET_BOOTLOADER_BOARD_NAME := SMARC |
54 | 54 | ||
55 | PRODUCT_MODEL := SMARC_MX8MQ | 55 | PRODUCT_MODEL := SMARC_MX8MQ |
56 | 56 | ||
57 | TARGET_BOOTLOADER_POSTFIX := bin | 57 | TARGET_BOOTLOADER_POSTFIX := bin |
58 | 58 | ||
59 | USE_OPENGL_RENDERER := true | 59 | USE_OPENGL_RENDERER := true |
60 | TARGET_CPU_SMP := true | 60 | TARGET_CPU_SMP := true |
61 | 61 | ||
62 | BOARD_WLAN_DEVICE_UNITE := UNITE | 62 | BOARD_WLAN_DEVICE_UNITE := UNITE |
63 | WPA_SUPPLICANT_VERSION := VER_0_8_X | 63 | WPA_SUPPLICANT_VERSION := VER_0_8_X |
64 | BOARD_WPA_SUPPLICANT_DRIVER := NL80211 | 64 | BOARD_WPA_SUPPLICANT_DRIVER := NL80211 |
65 | BOARD_HOSTAPD_DRIVER := NL80211 | 65 | BOARD_HOSTAPD_DRIVER := NL80211 |
66 | 66 | ||
67 | # In UNITE mode,Use default macro for bcmdhd and use unite macro for qcom | 67 | # In UNITE mode,Use default macro for bcmdhd and use unite macro for qcom |
68 | ifeq ($(BOARD_WLAN_DEVICE_UNITE), UNITE) | 68 | ifeq ($(BOARD_WLAN_DEVICE_UNITE), UNITE) |
69 | BOARD_WLAN_DEVICE := bcmdhd | 69 | BOARD_WLAN_DEVICE := bcmdhd |
70 | BOARD_HOSTAPD_PRIVATE_LIB_QCA := lib_driver_cmd_qcwcn | 70 | BOARD_HOSTAPD_PRIVATE_LIB_QCA := lib_driver_cmd_qcwcn |
71 | BOARD_WPA_SUPPLICANT_PRIVATE_LIB_QCA := lib_driver_cmd_qcwcn | 71 | BOARD_WPA_SUPPLICANT_PRIVATE_LIB_QCA := lib_driver_cmd_qcwcn |
72 | BOARD_HOSTAPD_PRIVATE_LIB_BCM := lib_driver_cmd_bcmdhd | 72 | BOARD_HOSTAPD_PRIVATE_LIB_BCM := lib_driver_cmd_bcmdhd |
73 | BOARD_WPA_SUPPLICANT_PRIVATE_LIB_BCM := lib_driver_cmd_bcmdhd | 73 | BOARD_WPA_SUPPLICANT_PRIVATE_LIB_BCM := lib_driver_cmd_bcmdhd |
74 | endif | 74 | endif |
75 | 75 | ||
76 | WIFI_DRIVER_FW_PATH_PARAM := "/sys/module/brcmfmac/parameters/alternative_fw_path" | 76 | WIFI_DRIVER_FW_PATH_PARAM := "/sys/module/brcmfmac/parameters/alternative_fw_path" |
77 | 77 | ||
78 | WIFI_HIDL_FEATURE_DUAL_INTERFACE := true | 78 | WIFI_HIDL_FEATURE_DUAL_INTERFACE := true |
79 | 79 | ||
80 | # QCA qcacld wifi driver module | 80 | # QCA qcacld wifi driver module |
81 | BOARD_VENDOR_KERNEL_MODULES += \ | 81 | BOARD_VENDOR_KERNEL_MODULES += \ |
82 | $(KERNEL_OUT)/drivers/net/wireless/qcacld-2.0/wlan.ko | 82 | $(KERNEL_OUT)/drivers/net/wireless/qcacld-2.0/wlan.ko |
83 | 83 | ||
84 | # BCM fmac wifi driver module | 84 | # BCM fmac wifi driver module |
85 | BOARD_VENDOR_KERNEL_MODULES += \ | 85 | BOARD_VENDOR_KERNEL_MODULES += \ |
86 | $(KERNEL_OUT)/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko \ | 86 | $(KERNEL_OUT)/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko \ |
87 | $(KERNEL_OUT)/drivers/net/wireless/broadcom/brcm80211/brcmutil/brcmutil.ko | 87 | $(KERNEL_OUT)/drivers/net/wireless/broadcom/brcm80211/brcmutil/brcmutil.ko |
88 | 88 | ||
89 | # QCA ath10k wifi driver module | 89 | # QCA ath10k wifi driver module |
90 | BOARD_VENDOR_KERNEL_MODULES += \ | 90 | BOARD_VENDOR_KERNEL_MODULES += \ |
91 | $(KERNEL_OUT)/drivers/net/wireless/ath/ath.ko \ | 91 | $(KERNEL_OUT)/drivers/net/wireless/ath/ath.ko \ |
92 | $(KERNEL_OUT)/drivers/net/wireless/ath/ath10k/ath10k_core.ko \ | 92 | $(KERNEL_OUT)/drivers/net/wireless/ath/ath10k/ath10k_core.ko \ |
93 | $(KERNEL_OUT)/drivers/net/wireless/ath/ath10k/ath10k_pci.ko | 93 | $(KERNEL_OUT)/drivers/net/wireless/ath/ath10k/ath10k_pci.ko |
94 | 94 | ||
95 | BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(IMX_DEVICE_PATH)/bluetooth | 95 | BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(IMX_DEVICE_PATH)/bluetooth |
96 | 96 | ||
97 | # BCM 1CX BT | 97 | # BCM 1CX BT |
98 | BOARD_HAVE_BLUETOOTH_BCM := true | 98 | BOARD_HAVE_BLUETOOTH_BCM := true |
99 | 99 | ||
100 | # Qcom 1CQ(QCA6174) BT | 100 | # Qcom 1CQ(QCA6174) BT |
101 | BOARD_HAVE_BLUETOOTH_QCOM := true | 101 | BOARD_HAVE_BLUETOOTH_QCOM := true |
102 | BOARD_HAS_QCA_BT_ROME := true | 102 | BOARD_HAS_QCA_BT_ROME := true |
103 | BOARD_HAVE_BLUETOOTH_BLUEZ := false | 103 | BOARD_HAVE_BLUETOOTH_BLUEZ := false |
104 | QCOM_BT_USE_SIBS := true | 104 | QCOM_BT_USE_SIBS := true |
105 | ifeq ($(QCOM_BT_USE_SIBS), true) | 105 | ifeq ($(QCOM_BT_USE_SIBS), true) |
106 | WCNSS_FILTER_USES_SIBS := true | 106 | WCNSS_FILTER_USES_SIBS := true |
107 | endif | 107 | endif |
108 | 108 | ||
109 | BOARD_USE_SENSOR_FUSION := true | 109 | BOARD_USE_SENSOR_FUSION := true |
110 | 110 | ||
111 | # for recovery service | 111 | # for recovery service |
112 | TARGET_SELECT_KEY := 28 | 112 | TARGET_SELECT_KEY := 28 |
113 | # we don't support sparse image. | 113 | # we don't support sparse image. |
114 | TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false | 114 | TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false |
115 | 115 | ||
116 | UBOOT_POST_PROCESS := true | 116 | UBOOT_POST_PROCESS := true |
117 | 117 | ||
118 | # camera hal v3 | 118 | # camera hal v3 |
119 | IMX_CAMERA_HAL_V3 := true | 119 | IMX_CAMERA_HAL_V3 := true |
120 | 120 | ||
121 | BOARD_HAVE_USB_CAMERA := true | 121 | BOARD_HAVE_USB_CAMERA := true |
122 | 122 | ||
123 | # whether to accelerate camera service with openCL | 123 | # whether to accelerate camera service with openCL |
124 | # it will make camera service load the opencl lib in vendor | 124 | # it will make camera service load the opencl lib in vendor |
125 | # and break the full treble rule | 125 | # and break the full treble rule |
126 | #OPENCL_2D_IN_CAMERA := true | 126 | #OPENCL_2D_IN_CAMERA := true |
127 | 127 | ||
128 | USE_ION_ALLOCATOR := true | 128 | USE_ION_ALLOCATOR := true |
129 | USE_GPU_ALLOCATOR := false | 129 | USE_GPU_ALLOCATOR := false |
130 | 130 | ||
131 | BOARD_AVB_ENABLE := true | 131 | BOARD_AVB_ENABLE := true |
132 | TARGET_USES_MKE2FS := true | 132 | TARGET_USES_MKE2FS := true |
133 | 133 | ||
134 | # define frame buffer count | 134 | # define frame buffer count |
135 | NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3 | 135 | NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3 |
136 | 136 | ||
137 | ifeq ($(PRODUCT_IMX_DRM),true) | 137 | ifeq ($(PRODUCT_IMX_DRM),true) |
138 | CMASIZE=736M | 138 | CMASIZE=736M |
139 | else | 139 | else |
140 | # if 4GB LPDDR4 | 140 | # if 4GB LPDDR4 |
141 | # CMASIZE=1536M | 141 | # CMASIZE=1536M |
142 | # if 2GB LPDDR4 | 142 | # if 2GB LPDDR4 |
143 | CMASIZE=736M | 143 | CMASIZE=736M |
144 | endif | 144 | endif |
145 | 145 | ||
146 | KERNEL_NAME := Image | 146 | KERNEL_NAME := Image |
147 | BOARD_KERNEL_CMDLINE := init=/init androidboot.gui_resolution=1080p androidboot.console=ttymxc0 androidboot.hardware=freescale androidboot.fbTileSupport=enable cma=$(CMASIZE) androidboot.primary_display=imx-drm firmware_class.path=/vendor/firmware transparent_hugepage=never | 147 | BOARD_KERNEL_CMDLINE := console=ttymxc0,115200 earlycon=imxuart,0x30860000,115200 init=/init androidboot.gui_resolution=1080p androidboot.console=ttymxc0 androidboot.hardware=freescale androidboot.fbTileSupport=enable cma=$(CMASIZE) androidboot.primary_display=imx-drm firmware_class.path=/vendor/firmware transparent_hugepage=never |
148 | 148 | ||
149 | # Default wificountrycode | 149 | # Default wificountrycode |
150 | BOARD_KERNEL_CMDLINE += androidboot.wificountrycode=CN | 150 | BOARD_KERNEL_CMDLINE += androidboot.wificountrycode=CN |
151 | 151 | ||
152 | # Defaultly smarc_mx8mq use BCM 1CX BCM4356 wifi module, if use QCOM qca9377 module, set androidboot.wifivendor=qca | 152 | # Defaultly smarc_mx8mq use BCM 1CX BCM4356 wifi module, if use QCOM qca9377 module, set androidboot.wifivendor=qca |
153 | BOARD_KERNEL_CMDLINE += androidboot.wifivendor=qca | 153 | BOARD_KERNEL_CMDLINE += androidboot.wifivendor=qca |
154 | 154 | ||
155 | ifeq ($(TARGET_USERIMAGES_USE_UBIFS),true) | 155 | ifeq ($(TARGET_USERIMAGES_USE_UBIFS),true) |
156 | ifeq ($(TARGET_USERIMAGES_USE_EXT4),true) | 156 | ifeq ($(TARGET_USERIMAGES_USE_EXT4),true) |
157 | $(error "TARGET_USERIMAGES_USE_UBIFS and TARGET_USERIMAGES_USE_EXT4 config open in same time, please only choose one target file system image") | 157 | $(error "TARGET_USERIMAGES_USE_UBIFS and TARGET_USERIMAGES_USE_EXT4 config open in same time, please only choose one target file system image") |
158 | endif | 158 | endif |
159 | endif | 159 | endif |
160 | 160 | ||
161 | BOARD_PREBUILT_DTBOIMAGE := out/target/product/smarc_mx8mq/dtbo-smarcimx8mq-hdmi.img | 161 | BOARD_PREBUILT_DTBOIMAGE := out/target/product/smarc_mx8mq/dtbo-smarcimx8mq-hdmi.img |
162 | TARGET_BOARD_DTS_CONFIG := \ | 162 | TARGET_BOARD_DTS_CONFIG := \ |
163 | smarcimx8mq-dcss-lvds:fsl-smarcimx8mq-dcss-lvds.dtb \ | 163 | smarcimx8mq-dcss-lvds:fsl-smarcimx8mq-dcss-lvds.dtb \ |
164 | smarcimx8mq-dp:fsl-smarcimx8mq-dp.dtb \ | 164 | smarcimx8mq-dp:fsl-smarcimx8mq-dp.dtb \ |
165 | smarcimx8mq:fsl-smarcimx8mq.dtb \ | 165 | smarcimx8mq:fsl-smarcimx8mq.dtb \ |
166 | smarcimx8mq-dual-display:fsl-smarcimx8mq-dual-display.dtb \ | 166 | smarcimx8mq-dual-display:fsl-smarcimx8mq-dual-display.dtb \ |
167 | smarcimx8mq-edp:fsl-smarcimx8mq-edp.dtb \ | 167 | smarcimx8mq-edp:fsl-smarcimx8mq-edp.dtb \ |
168 | smarcimx8mq-hdmi:fsl-smarcimx8mq-hdmi.dtb \ | 168 | smarcimx8mq-hdmi:fsl-smarcimx8mq-hdmi.dtb \ |
169 | smarcimx8mq-lcdif-lvds:fsl-smarcimx8mq-lcdif-lvds.dtb | 169 | smarcimx8mq-lcdif-lvds:fsl-smarcimx8mq-lcdif-lvds.dtb |
170 | 170 | ||
171 | # u-boot target for smarc_mx8mq | 171 | # u-boot target for smarc_mx8mq |
172 | TARGET_BOOTLOADER_CONFIG := imx8mq-smarcimx8mq_2g:smarcimx8mq_2g_ser3_android_defconfig | 172 | TARGET_BOOTLOADER_CONFIG := imx8mq-smarcimx8mq_2g:smarcimx8mq_2g_ser3_android_defconfig |
173 | 173 | ||
174 | TARGET_KERNEL_DEFCONFIG := smarcimx8m_android_defconfig | 174 | TARGET_KERNEL_DEFCONFIG := smarcimx8m_android_defconfig |
175 | # TARGET_KERNEL_ADDITION_DEFCONF ?= android_addition_defconfig | 175 | # TARGET_KERNEL_ADDITION_DEFCONF ?= android_addition_defconfig |
176 | 176 | ||
177 | # u-boot target used by uuu for smarc_mx8mq | 177 | # u-boot target used by uuu for smarc_mx8mq |
178 | TARGET_BOOTLOADER_CONFIG += imx8mq-smarcimx8mq_2g_uuu:smarcimx8mq_2g_ser3_android_uuu_defconfig | 178 | TARGET_BOOTLOADER_CONFIG += imx8mq-smarcimx8mq_2g_uuu:smarcimx8mq_2g_ser3_android_uuu_defconfig |
179 | 179 | ||
180 | BOARD_SEPOLICY_DIRS := \ | 180 | BOARD_SEPOLICY_DIRS := \ |
181 | device/fsl/imx8m/sepolicy \ | 181 | device/fsl/imx8m/sepolicy \ |
182 | $(IMX_DEVICE_PATH)/sepolicy | 182 | $(IMX_DEVICE_PATH)/sepolicy |
183 | 183 | ||
184 | ifeq ($(PRODUCT_IMX_DRM),true) | 184 | ifeq ($(PRODUCT_IMX_DRM),true) |
185 | BOARD_SEPOLICY_DIRS += \ | 185 | BOARD_SEPOLICY_DIRS += \ |
186 | $(IMX_DEVICE_PATH)/sepolicy_drm | 186 | $(IMX_DEVICE_PATH)/sepolicy_drm |
187 | endif | 187 | endif |
188 | 188 | ||
189 | TARGET_BOARD_KERNEL_HEADERS := device/fsl/common/kernel-headers | 189 | TARGET_BOARD_KERNEL_HEADERS := device/fsl/common/kernel-headers |
190 | 190 |
scripts/sh/smarc-mkemmccard.sh
File was created | 1 | #!/bin/bash -e | |
2 | |||
3 | help() { | ||
4 | |||
5 | bn=`basename $0` | ||
6 | cat << EOF | ||
7 | |||
8 | Version: 1.2 | ||
9 | Last change: Exit on error, and general cleanup | ||
10 | |||
11 | Usage: $bn <option> device_node | ||
12 | |||
13 | options: | ||
14 | -h displays this help message | ||
15 | -s only get partition size | ||
16 | -np not partition. | ||
17 | -f soc_name flash android image file with soc_name | ||
18 | -F soc_name determine the device_node's offset to flash bootloader and flash default android image file | ||
19 | SoC offset(KB) | ||
20 | default 1 | ||
21 | imx8dv 16 | ||
22 | imx8qm/imx8qxp/imx8mq 33 | ||
23 | -a only flash image to slot_a | ||
24 | -b only flash image to slot_b | ||
25 | -c card_size optional setting: 7 / 14 / 28 | ||
26 | If not set, use partition-table.img (default) | ||
27 | If set to 7, use partition-table-7GB.img for 8GB SD card | ||
28 | If set to 14, use partition-table-14GB.img for 16GB SD card | ||
29 | If set to 28, use partition-table-28GB.img for 32GB SD card | ||
30 | Make sure the corresponding file exist for your platform. | ||
31 | -m flash m4 image | ||
32 | -o force_offset force set uboot offset | ||
33 | EOF | ||
34 | |||
35 | } | ||
36 | |||
37 | # parse command line | ||
38 | moreoptions=1 | ||
39 | node="na" | ||
40 | soc_name="" | ||
41 | force_offset="" | ||
42 | cal_only=0 | ||
43 | card_size=0 | ||
44 | bootloader_offset=1 | ||
45 | m4_image_offset=5120 | ||
46 | vaild_gpt_size=17 | ||
47 | not_partition=0 | ||
48 | slot="" | ||
49 | systemimage_file="system.img" | ||
50 | systemimage_raw_file="system_raw.img" | ||
51 | vendor_file="vendor.img" | ||
52 | vendor_raw_file="vendor_raw.img" | ||
53 | partition_file="partition-table.img" | ||
54 | g_sizes=0 | ||
55 | append_soc_name=0 | ||
56 | support_dtbo=0 | ||
57 | flash_m4=0 | ||
58 | RED='\033[0;31m' | ||
59 | STD='\033[0;0m' | ||
60 | |||
61 | while [ "$moreoptions" = 1 -a $# -gt 0 ]; do | ||
62 | case $1 in | ||
63 | -h) help; exit ;; | ||
64 | -s) cal_only=1 ;; | ||
65 | -f) append_soc_name=1 ; soc_name=$2; shift;; | ||
66 | -F) soc_name=$2; shift;; | ||
67 | -c) card_size=$2; shift;; | ||
68 | -np) not_partition=1 ;; | ||
69 | -a) slot="_a" ;; | ||
70 | -b) slot="_b" ;; | ||
71 | -m) flash_m4=1 ;; | ||
72 | -o) force_offset=$2; shift;; | ||
73 | *) moreoptions=0; node=$1 ;; | ||
74 | esac | ||
75 | [ "$moreoptions" = 0 ] && [ $# -gt 1 ] && help && exit | ||
76 | [ "$moreoptions" = 1 ] && shift | ||
77 | done | ||
78 | |||
79 | # check required applications are installed | ||
80 | #command -v simg2img >/dev/null 2>&1 || { echo -e >&2 "${RED}Missing simg2img app. Please run: sudo apt-get install android-tools-fsutils${STD}" ; exit 1 ; } | ||
81 | command -v hdparm >/dev/null 2>&1 || { echo -e >&2 "${RED}Missing hdparm app. Please make sure it is installed. Exiting.${STD}" ; exit 1 ; } | ||
82 | command -v gdisk >/dev/null 2>&1 || { echo -e >&2 "${RED}Missing gdisk app. Please make sure it is installed. Exiting.${STD}" ; exit 1 ; } | ||
83 | |||
84 | if [ ${card_size} -ne 0 ] && [ ${card_size} -ne 7 ] && [ ${card_size} -ne 14 ] && [ ${card_size} -ne 28 ]; then | ||
85 | help; exit 1; | ||
86 | fi | ||
87 | |||
88 | if [ "${soc_name}" = "imx8dv" ]; then | ||
89 | bootloader_offset=16 | ||
90 | fi | ||
91 | |||
92 | if [ "${soc_name}" = "imx8qxp" -o "${soc_name}" = "imx8qm" ]; then | ||
93 | bootloader_offset=32 | ||
94 | fi | ||
95 | |||
96 | if [ "${soc_name}" = "imx8mq" -o "${soc_name}" = "imx8mm" -o "${soc_name}" = "smarcimx8mq" -o "${soc_name}" = "smarcimx8mq-hdmi" -o "${soc_name}" = "smarcimx8mq-dp" -o "${soc_name}" = "smarcimx8mq-lcdif-lvds" -o "${soc_name}" = "smarcimx8mq-dcss-lvds" -o "${soc_name}" = "smarcimx8mq-dual-display" -o "${soc_name}" = "smarcimx8mq-edp" ]; then | ||
97 | bootloader_offset=33 | ||
98 | fi | ||
99 | |||
100 | if [ "${force_offset}" != "" ]; then | ||
101 | bootloader_offset=${force_offset} | ||
102 | fi | ||
103 | |||
104 | if [ ! -e ${node} ]; then | ||
105 | help | ||
106 | exit 1 | ||
107 | fi | ||
108 | |||
109 | echo "${soc_name} bootloader offset is: ${bootloader_offset}" | ||
110 | |||
111 | if [ "${soc_name}" != "" ] && [ "${append_soc_name}" -eq 1 ]; then | ||
112 | soc_name="-${soc_name}" | ||
113 | else | ||
114 | soc_name="" | ||
115 | fi | ||
116 | |||
117 | # dump partitions | ||
118 | if [ "${cal_only}" -eq "1" ]; then | ||
119 | gdisk -l ${node} 2>/dev/null | grep -A 20 "Number " | ||
120 | exit 0 | ||
121 | fi | ||
122 | |||
123 | function get_partition_size | ||
124 | { | ||
125 | start_sector=`gdisk -l ${node} | grep -w $1 | awk '{print $2}'` | ||
126 | end_sector=`gdisk -l ${node} | grep -w $1 | awk '{print $3}'` | ||
127 | # 1 sector = 512 bytes. This will change unit from sector to MBytes. | ||
128 | let "g_sizes=($end_sector - $start_sector + 1) / 2048" | ||
129 | } | ||
130 | |||
131 | function format_partition | ||
132 | { | ||
133 | num=`gdisk -l ${node} | grep -w $1 | awk '{print $1}'` | ||
134 | if [ ${num} -gt 0 ] 2>/dev/null; then | ||
135 | echo "format_partition: $1:${node}p${num} ext4" | ||
136 | mkfs.ext4 -F ${node}p${num} -L$1 | ||
137 | fi | ||
138 | } | ||
139 | |||
140 | function erase_partition | ||
141 | { | ||
142 | num=`gdisk -l ${node} | grep -w $1 | awk '{print $1}'` | ||
143 | if [ ${num} -gt 0 ] 2>/dev/null; then | ||
144 | get_partition_size $1 | ||
145 | echo "erase_partition: $1 : ${node}p${num} ${g_sizes}M" | ||
146 | dd if=/dev/zero of=${node}p${num} bs=1048576 conv=fsync count=$g_sizes | ||
147 | fi | ||
148 | } | ||
149 | |||
150 | function flash_partition | ||
151 | { | ||
152 | for num in `gdisk -l ${node} | grep -E -w "$1|$1_a|$1_b" | awk '{print $1}'` | ||
153 | do | ||
154 | if [ $? -eq 0 ]; then | ||
155 | if [ $(echo ${1} | grep "system") != "" ] 2>/dev/null; then | ||
156 | img_name=${systemimage_raw_file} | ||
157 | elif [ $(echo ${1} | grep "vendor") != "" ] 2>/dev/null; then | ||
158 | img_name=${vendor_raw_file} | ||
159 | elif [ ${support_dtbo} -eq 1 ] && [ $(echo ${1} | grep "boot") != "" ] 2>/dev/null; then | ||
160 | img_name="boot.img" | ||
161 | else | ||
162 | img_name="${1%_*}${soc_name}.img" | ||
163 | fi | ||
164 | echo "flash_partition: ${img_name} ---> ${node}p${num}" | ||
165 | if [ ! -f "${img_name}" ]; then | ||
166 | echo -e >&2 "${RED}File ${img_name} not found. Please check. Exiting${STD}" | ||
167 | return 1 | ||
168 | fi | ||
169 | dd if=${img_name} of=${node}p${num} bs=10M conv=fsync | ||
170 | fi | ||
171 | done | ||
172 | } | ||
173 | |||
174 | function format_android | ||
175 | { | ||
176 | echo "formating android images" | ||
177 | format_partition userdata | ||
178 | format_partition cache | ||
179 | erase_partition presistdata | ||
180 | erase_partition fbmisc | ||
181 | erase_partition misc | ||
182 | } | ||
183 | |||
184 | function make_partition | ||
185 | { | ||
186 | if [ ${card_size} -gt 0 ]; then | ||
187 | partition_file="partition-table-${card_size}GB.img" | ||
188 | fi | ||
189 | if [ ! -f "${partition_file}" ]; then | ||
190 | echo -e >&2 "${RED}File ${partition_file} not found. Please check. Exiting${STD}" | ||
191 | return 1 | ||
192 | fi | ||
193 | echo "make gpt partition for android: ${partition_file}" | ||
194 | dd if=${partition_file} of=${node} bs=1k count=${vaild_gpt_size} conv=fsync | ||
195 | } | ||
196 | |||
197 | function flash_android | ||
198 | { | ||
199 | boot_partition="boot"${slot} | ||
200 | recovery_partition="recovery"${slot} | ||
201 | system_partition="system"${slot} | ||
202 | vendor_partition="vendor"${slot} | ||
203 | vbmeta_partition="vbmeta"${slot} | ||
204 | dtbo_partition="dtbo"${slot} | ||
205 | gdisk -l ${node} 2>/dev/null | grep -q "dtbo" && support_dtbo=1 | ||
206 | |||
207 | bootloader_file="u-boot-imx8mq-smarcimx8mq_2g.imx" | ||
208 | if [ "${support_dtbo}" -eq "1" ] ; then | ||
209 | flash_partition ${dtbo_partition} || exit 1 | ||
210 | fi | ||
211 | flash_partition ${boot_partition} || exit 1 | ||
212 | flash_partition ${recovery_partition} || exit 1 | ||
213 | #simg2img ${systemimage_file} ${systemimage_raw_file} | ||
214 | flash_partition ${system_partition} || exit 1 | ||
215 | #rm ${systemimage_raw_file} | ||
216 | #simg2img ${vendor_file} ${vendor_raw_file} | ||
217 | flash_partition ${vendor_partition} || exit 1 | ||
218 | #rm ${vendor_raw_file} | ||
219 | flash_partition ${vbmeta_partition} || exit 1 | ||
220 | echo "erase_partition: uboot : ${node}" | ||
221 | echo "flash_partition: ${bootloader_file} ---> ${node}" | ||
222 | first_partition_offset=`gdisk -l ${node} | grep ' 1 ' | awk '{print $2}'` | ||
223 | # the unit of first_partition_offset is sector size which is 512 Byte. | ||
224 | count_bootloader=`expr ${first_partition_offset} / 2 - ${bootloader_offset}` | ||
225 | echo "the bootloader partition size: ${count_bootloader}" | ||
226 | dd if=/dev/zero of=${node} bs=1k seek=${bootloader_offset} conv=fsync count=${count_bootloader} | ||
227 | dd if=${bootloader_file} of=${node} bs=1k seek=${bootloader_offset} conv=fsync | ||
228 | if [ "${flash_m4}" -eq "1" ] ; then | ||
229 | m4_image=${soc_name#*-}"_m4_demo.img" | ||
230 | echo "flash_partition: ${m4_image} ---> ${node}" | ||
231 | dd if=${m4_image} of=${node} bs=1k seek=${m4_image_offset} conv=fsync | ||
232 | fi | ||
233 | } | ||
234 | |||
235 | if [ "${not_partition}" -eq "1" ] ; then | ||
236 | flash_android || exit 1 | ||
237 | exit 0 | ||
238 | fi | ||
239 | |||
240 | make_partition || exit 1 | ||
241 | |||
242 | sleep 3 | ||
243 | for i in `cat /proc/mounts | grep "${node}" | awk '{print $2}'`; do umount $i; done | ||
244 | hdparm -z ${node} | ||
245 | |||
246 | # backup the GPT table to last LBA for sd card. | ||
247 | echo -e 'r\ne\nY\nw\nY\nY' | gdisk ${node} | ||
248 | |||
249 | format_android | ||
250 | flash_android || exit 1 | ||
251 | |||
252 | echo | ||
253 | echo ">>>>>>>>>>>>>> Flashing successfully completed <<<<<<<<<<<<<<" | ||
254 | |||
255 | exit 0 | ||
256 | |||
257 | # For MFGTool Notes: | ||
258 | # MFGTool use mksdcard-android.tar store this script | ||
259 | # if you want change it. | ||
260 | # do following: | ||
261 | # tar xf mksdcard-android.sh.tar | ||
262 | # vi mksdcard-android.sh | ||
263 | # [ edit want you want to change ] | ||
264 | # rm mksdcard-android.sh.tar; tar cf mksdcard-android.sh.tar mksdcard-android.sh | ||
265 |