Patrick Williams | 8b86a41 | 2023-04-14 14:29:45 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 2 | |
| 3 | findmtd() { |
| 4 | m=$(grep -xl "$1" /sys/class/mtd/*/name) |
| 5 | m=${m%/name} |
| 6 | m=${m##*/} |
Patrick Williams | 8b86a41 | 2023-04-14 14:29:45 -0500 | [diff] [blame] | 7 | echo "$m" |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 8 | } |
| 9 | |
| 10 | rom_lists=(host-prime host-second vrom-prime vrom-second) |
| 11 | rom_mtd_list=() |
| 12 | |
| 13 | for f in "${rom_lists[@]}" |
| 14 | do |
Patrick Williams | 8b86a41 | 2023-04-14 14:29:45 -0500 | [diff] [blame] | 15 | image=$(findmtd "${f}") |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 16 | if test -z "$image" |
| 17 | then |
| 18 | echo "Unable to find mtd partition for ${f}" |
| 19 | exit 1 |
| 20 | fi |
Patrick Williams | 8b86a41 | 2023-04-14 14:29:45 -0500 | [diff] [blame] | 21 | rom_mtd_list+=("$image") |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 22 | done |
| 23 | |
| 24 | #enable vrom |
| 25 | # host-prime to vrom-prime |
Patrick Williams | 8b86a41 | 2023-04-14 14:29:45 -0500 | [diff] [blame] | 26 | dd if="/dev/${rom_mtd_list[0]}" of="/dev/${rom_mtd_list[2]}" |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 27 | # host-second to vrom-second |
Patrick Williams | 8b86a41 | 2023-04-14 14:29:45 -0500 | [diff] [blame] | 28 | dd if="/dev/${rom_mtd_list[1]}" of="/dev/${rom_mtd_list[3]}" |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 29 | |
| 30 | echo 0x1800008a > /sys/class/soc/srom/vromoff |
| 31 | |
Patrick Williams | 8b86a41 | 2023-04-14 14:29:45 -0500 | [diff] [blame] | 32 | while true |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 33 | do |
| 34 | devmem 0x8000005C 8 0 |
| 35 | devmem 0xd1000306 8 5 |
| 36 | devmem 0xd1000318 8 0x03 |
| 37 | devmem 0xd100030f 8 0x04 |
| 38 | sleep 1 |
| 39 | done |
| 40 | |