Last active
February 17, 2025 00:20
-
-
Save j0ju/d1948f89af950dcd8db2e904a9ec02ad to your computer and use it in GitHub Desktop.
Script to force boot a RK1 equipped with Uboot/Ubuntu 24.04 to eMMC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# this is a multicall script: | |
# call it "on" "offf" or "status". | |
switch() { | |
local mode="$1" | |
case "$mode" in | |
on | 1 | ON ) mode=on ;; | |
off | 0 | OFF ) mode=off ;; | |
status | stat | st | "" ) | |
status | |
return $? | |
;; | |
* ) | |
echo "E: unknown mode '$mode', ABORT (on, 1, ON, off, 0, off)." >&2 | |
exit 2 | |
;; | |
esac | |
shift | |
for node; do | |
case "$node" in | |
[1234] ) | |
( set -ex | |
tpi power -n "$node" "$mode" | |
) | |
#if [ "$mode" = off ]; then | |
# ( set -ex | |
# tpi advanced -n "$node" normal | |
# ) | |
#fi | |
;; | |
all ) | |
switch $mode 1 2 3 4 | |
return $? | |
;; | |
* ) | |
echo "E: unknown node specifier '$node', ABORT (1,2,3,4,all)." >&2 | |
exit 2 | |
esac | |
done | |
status | |
} | |
status() { | |
tpi power status | |
} | |
case "$0" in | |
*/on | on ) switch on "$@" ;; | |
*/off | off ) switch off "$@" ;; | |
*/pwr | pwr ) switch "$@" | |
esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
set -x | |
# this needs, coreutils-stty, pppd-chat and minicom installed | |
# minicom needs proper config files in either /etc/{1..4}.minirc | |
# pointing to the correct device | |
case "${1:-}" in | |
[1234] ) NODE="$1" ;; | |
* ) | |
echo "$0 [NODE]" >&2 | |
exit 1 | |
esac | |
DEV="/dev/ttyS$NODE" | |
stty -F $DEV speed 115200 | |
on "$NODE" & | |
chat -V < $DEV > $DEV \ | |
"autoboot:" BREAK \ | |
"=>" 'set boot_targets mmc0' \ | |
"=>" boot \ | |
"Enter choice:" 1 \ | |
# EO chat | |
echo > $DEV | |
exec minicom $NODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment