summaryrefslogtreecommitdiff
path: root/android-tools/x15/flash.sh
blob: 7f56bdb69f26e740f4764e4bc0feba4a29b80e96 (plain)
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
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
#!/bin/bash
# https://wiki-archive.linaro.org/Boards/BeagleBoard-X15
# https://linaro.atlassian.net/wiki/spaces/CTT/pages/25111140766/BeagleBoard+X15

# echo 0x10 >/sys/module/drm/parameters/debug
#    Bit 0 (0x01)  will enable CORE messages (drm core code)
#    Bit 1 (0x02)  will enable DRIVER messages (drm controller code)
#    Bit 2 (0x04)  will enable KMS messages (modesetting code)
#    Bit 3 (0x08)  will enable PRIME messages (prime code)
#    Bit 4 (0x10)  will enable ATOMIC messages (atomic code)
#    Bit 5 (0x20)  will enable VBL messages (vblank code)
#    Bit 7 (0x80)  will enable LEASE messages (leasing code)
#    Bit 8 (0x100) will enable DP messages (displayport code)
#    module_param_named(debug, drm_debug, int, 0600);
#    drivers/gpu/drm/drm_drv.c
#
# echo 8 > /proc/sys/kernel/printk
# The first value in our output is the current console_loglevel. This is the information we were looking for: the value, 4 in this case, represents the log level currently used. As said before this means that only messages adopting a severity level higher than it, will be displayed on the console.
# The second value in the output represents the default_message_loglevel. This value is automatically used for messages without a specific log level: if a message is not associated with a log level, this one will be used for it.
# The third value in the output reports the minimum_console_loglevel status. It indicates the minimum loglevel which can be used for console_loglevel. The level here used it’s 1, the highest.
# Finally, the last value represents the default_console_loglevel, which is the default loglevel used for console_loglevel at boot time.

img_dir=${1}
if [ -z "${img_dir}" ]; then
    img_dir="out/target/product/am57xevm"
fi
if [ ! -d "${img_dir}" ]; then
    img_dir="out/target/product/beagle_x15"
fi

if ! [ -d ${img_dir} ]; then
    echo "The specified path is not a directory:${img_dir}"
    exit 1
fi

function flash_image(){
    local partition=$1
    local file_img=$2
    if [ -z "${partition}" ] || [ -z "${file_img}" ]; then
        return
    fi

    if [ ! -f "${file_img}" ]; then
        return
    fi
    echo "======= Flash ${partition} partition with file $file_img =============="
    #/SATA3/nougat/out/host/linux-x86/bin/fastboot flash -w ${partition} ${file_img}
    fastboot flash ${partition} ${file_img}
    if [ $? -ne 0 ]; then
        echo "Failed to deploy ${file_img}"
        exit 1
    fi
    # sleep 2 after flash
    sleep 5
}

#fastboot erase environment
#fastboot oem format
#flash_image xloader ${img_dir}/MLO
#flash_image bootloader ${img_dir}/u-boot.img
#flash_image environment ${img_dir}/am57xx-evm-reva3.dtb
#flash_image recovery ${img_dir}/recovery.img
#flash_image boot ${img_dir}/boot.img
flash_image boot_a ${img_dir}/boot.img
flash_image boot_b ${img_dir}/boot.img
## NOTE: falsh of the dtbo_a/b partitions would cause the board failed to boot
## and need to reflash the u-boot to recover
#flash_image dtbo_a ${img_dir}/dtbo.img
#flash_image dtbo_b ${img_dir}/dtbo.img
flash_image vbmeta_a ${img_dir}/vbmeta.img
flash_image vbmeta_b ${img_dir}/vbmeta.img
flash_image recovery ${img_dir}/recovery.img
flash_image super ${img_dir}/super.img
flash_image userdata ${img_dir}/userdata.img
# format would cause error of "FAILED (remote: failed to set partition)"
fastboot erase metadata
fastboot erase misc
fastboot reboot

exit 0

reset or fastboot reboot
=> fastboot 0 # operate on sdcard?
$ fastboot flash xloader MLO # flash MLO to the partition
$ fastboot flash bootloader u-boot.img # flash u-boot.img to the partition
$ fastboot reboot
=> env default -f -a # load the all the defined environments
=> setenv partitions $partitions_android # set partitions environment with the value in partitions_android environment
=> env save # save change on partitions environment
=> fastboot 1 # boot from emmc
$ fastboot oem format # recreate the parititons again
$ fastboot flash boot boot_fit.img # flash other images
$ fastboot flash recovery recovery.img
$ fastboot flash vendor vendor.img
$ fastboot flash system system.img
$ fastboot flash userdata userdata.img
$ fastboot reboot
=> setenv bootargs "androidboot.serialno=${serial#} console=ttyS2,115200 androidboot.console=ttyS2 androidboot.hardware=beagle_x15board"
=> setenv bootargs "androidboot.serialno=${serial#} console=ttyS2,115200 androidboot.console=ttyS2 androidboot.hardware=am57xevmboard"
=> run findfdt
=> run emmc_android_boot
=> part list mmc 1 # list partitions for mmc 1

####
fastboot flash boot_a boot.img
fastboot flash boot_b boot.img
fastboot flash dtbo_a dtbo.img
fastboot flash dtbo_b dtbo.img
fastboot flash vbmeta_a vbmeta.img
fastboot flash vbmeta_b vbmeta.img
fastboot flash recovery recovery.img
fastboot flash super super.img
fastboot flash userdata userdata.img
fastboot erase metadata
fastboot erase misc
fastboot reboot

# "card voltage select 0" usually means loose connection
# erase emmc:
=> mmc dev 1 0
=> mmc rescan
=> mmc erase 0 0x400
=> mmc erase 0 0x4000
=> mmc erase 0 0x40000
=> mmc erase 0 0x400000
# mmc dev 0 is sdcard
# dev 1 is emmc .