charkear | ee5dd4a | 2023-05-17 15:53:43 -0500 | [diff] [blame] | 1 | #!/bin/sh |
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 | |
charkear | ee5dd4a | 2023-05-17 15:53:43 -0500 | [diff] [blame] | 10 | set -- host-prime host-second vrom-prime vrom-second |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 11 | |
charkear | ee5dd4a | 2023-05-17 15:53:43 -0500 | [diff] [blame] | 12 | for f in "$@" |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 13 | do |
Patrick Williams | 8b86a41 | 2023-04-14 14:29:45 -0500 | [diff] [blame] | 14 | image=$(findmtd "${f}") |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 15 | if test -z "$image" |
| 16 | then |
| 17 | echo "Unable to find mtd partition for ${f}" |
| 18 | exit 1 |
| 19 | fi |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 20 | done |
| 21 | |
| 22 | #enable vrom |
| 23 | # host-prime to vrom-prime |
charkear | ee5dd4a | 2023-05-17 15:53:43 -0500 | [diff] [blame] | 24 | dd if="/dev/$(findmtd host-prime)" of="/dev/$(findmtd vrom-prime)" |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 25 | # host-second to vrom-second |
charkear | ee5dd4a | 2023-05-17 15:53:43 -0500 | [diff] [blame] | 26 | dd if="/dev/$(findmtd host-second)" of="/dev/$(findmtd vrom-second)" |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 27 | |
| 28 | echo 0x1800008a > /sys/class/soc/srom/vromoff |
| 29 | |
| 30 | val=$(( ("$(devmem 0xd1000006 8)" && 0xff) | 0x04 )) |
| 31 | devmem 0xd1000006 8 $val |
| 32 | devmem 0xd1000018 8 0xff |
Patrick Williams | 8b86a41 | 2023-04-14 14:29:45 -0500 | [diff] [blame] | 33 | while true |
Mike Garrett | c088ff2 | 2021-08-27 16:59:09 -0500 | [diff] [blame] | 34 | do |
| 35 | devmem 0xd100000f 8 0x14 |
| 36 | sleep 1 |
| 37 | done |
| 38 | |