Skip to content

Commit 3a21f5f

Browse files
committed
Move cbfstool and other tools to /usr/local/bin under CrOS
Workaround not being able to mount p12 as /tmp/boot under ChromeOS on specific boards (UFS storage?) Signed-off-by: Matt DeVillier <[email protected]>
1 parent cde177b commit 3a21f5f

File tree

2 files changed

+22
-64
lines changed

2 files changed

+22
-64
lines changed

firmware.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ MrChromebox does not provide any support for running Windows."
122122
# update firmware type
123123
firmwareType="Stock ChromeOS w/RW_LEGACY"
124124
#Prevent from trying to boot stock ChromeOS install
125-
rm -rf /tmp/boot/syslinux > /dev/null 2>&1
125+
[[ "$boot_mounted" = true ]] && rm -rf /tmp/boot/syslinux > /dev/null 2>&1
126126
fi
127127

128128
read -rep "Press [Enter] to return to the main menu."
@@ -381,7 +381,7 @@ and you need to recover using an external EEPROM programmer. [Y/n] "
381381
echo_green "Full ROM firmware successfully installed/updated."
382382

383383
#Prevent from trying to boot stock ChromeOS install
384-
if [[ "$isStock" = true && "$isChromeOS" = true ]]; then
384+
if [[ "$isStock" = true && "$isChromeOS" = true && "$boot_mounted" = true ]]; then
385385
rm -rf /tmp/boot/efi > /dev/null 2>&1
386386
rm -rf /tmp/boot/syslinux > /dev/null 2>&1
387387
fi
@@ -444,7 +444,7 @@ the touchpad firmware, otherwise the touchpad will not work."
444444
echo_yellow "Please reboot your Pixelbook now."
445445
else
446446
# try with older eve flashrom
447-
[[ "$isChromeOS" == "true" ]] && tpPath="/tmp/boot/util" || tpPath="/tmp"
447+
[[ "$isChromeOS" == "true" ]] && tpPath="/usr/local/bin" || tpPath="/tmp"
448448
(
449449
cd $tpPath
450450
$CURL -sLO "${util_source}flashrom_eve_tp"

functions.sh

Lines changed: 19 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -196,29 +196,8 @@ function get_cbfstool()
196196
{
197197
if [ ! -f ${cbfstoolcmd} ]; then
198198
working_dir=$(pwd)
199-
if [[ "$isChromeOS" = false && "$isChromiumOS" = false ]]; then
200-
cd /tmp
201-
else
202-
#have to use partition 12 on rootdev due to noexec restrictions
203-
rootdev=$(rootdev -d -s)
204-
[[ "${rootdev}" =~ "mmcblk" || "${rootdev}" =~ "nvme" ]] && part_pfx="p" || part_pfx=""
205-
part_num="${part_pfx}12"
206-
boot_mounted=$(mount | grep "${rootdev}""${part_num}")
207-
if [ "${boot_mounted}" = "" ]; then
208-
#mount boot
209-
mkdir /tmp/boot >/dev/null 2>&1
210-
mount "$(rootdev -d -s)""${part_num}" /tmp/boot
211-
if [ $? -ne 0 ]; then
212-
echo_red "Error mounting boot partition; cannot proceed."
213-
return 1
214-
fi
215-
fi
216-
# clear recovery logs which use valuable space
217-
rm -rf /tmp/boot/recovery* 2>/dev/null
218-
#create util dir
219-
mkdir /tmp/boot/util 2>/dev/null
220-
cd /tmp/boot/util
221-
fi
199+
200+
cd $(dirname ${cbfstoolcmd})
222201

223202
#echo_yellow "Downloading cbfstool utility"
224203
$CURL -sLO "${util_source}cbfstool.tar.gz"
@@ -252,30 +231,7 @@ function get_flashrom()
252231
if [ ! -f "${flashromcmd}" ]; then
253232
working_dir=$(pwd)
254233

255-
if [[ "$isChromeOS" = false && "$isChromiumOS" = false ]]; then
256-
cd /tmp
257-
else
258-
#have to use partition 12 (27 for cloudready) on rootdev due to noexec restrictions
259-
rootdev=$(rootdev -d -s)
260-
[[ "${rootdev}" =~ "mmcblk" || "${rootdev}" =~ "nvme" ]] && part_pfx="p" || part_pfx=""
261-
[[ "$isCloudready" = "true" && -b ${rootdev}${part_pfx}27 ]] \
262-
&& part_num="${part_pfx}27" || part_num="${part_pfx}12"
263-
boot_mounted=$(mount | grep "${rootdev}""${part_num}")
264-
if [ "${boot_mounted}" = "" ]; then
265-
#mount boot
266-
mkdir /tmp/boot >/dev/null 2>&1
267-
mount "$(rootdev -d -s)""${part_num}" /tmp/boot
268-
if [ $? -ne 0 ]; then
269-
echo_red "Error mounting boot partition; cannot proceed."
270-
return 1
271-
fi
272-
fi
273-
# clear recovery logs which use valuable space
274-
rm -rf /tmp/boot/recovery* 2>/dev/null
275-
#create util dir
276-
mkdir /tmp/boot/util 2>/dev/null
277-
cd /tmp/boot/util
278-
fi
234+
cd $(dirname ${flashromcmd})
279235

280236
if [[ "$isChromeOS" = true ]]; then
281237
#needed to avoid dependencies not found on older ChromeOS
@@ -315,7 +271,8 @@ function get_gbb_utility()
315271
{
316272
if [ ! -f ${gbbutilitycmd} ]; then
317273
working_dir=$(pwd)
318-
cd /tmp
274+
275+
cd $(dirname ${gbbutilitycmd})
319276

320277
$CURL -sLO "${util_source}gbb_utility.tar.gz"
321278
if [ $? -ne 0 ]; then
@@ -402,13 +359,25 @@ fi
402359
if [[ "$isChromeOS" = true || "$isChromiumOS" = true ]]; then
403360
#disable power mgmt
404361
initctl stop powerd > /dev/null 2>&1
362+
# try to mount p12 as /tmp/boot
363+
rootdev=$(rootdev -d -s)
364+
[[ "${rootdev}" =~ "mmcblk" || "${rootdev}" =~ "nvme" ]] && part_pfx="p" || part_pfx=""
365+
part_num="${part_pfx}12"
366+
export boot_mounted=$(mount | grep "${rootdev}""${part_num}")
367+
if [ "${boot_mounted}" = "" ]; then
368+
#mount boot
369+
mkdir /tmp/boot >/dev/null 2>&1
370+
mount "$(rootdev -d -s)""${part_num}" /tmp/boot >/dev/null 2>&1 && boot_mounted=true
371+
else
372+
boot_mounted=true
373+
fi
405374
#set cmds
406375
#check if we need to use a newer flashrom which supports output to log file (-o)
407376
flashromcmd=$(which flashrom)
408377
if ! ${flashromcmd} -V -o /dev/null > /dev/null 2>&1 || [[ -d /sys/firmware/efi ]]; then
409-
flashromcmd=/tmp/boot/util/flashrom
378+
flashromcmd=/usr/local/bin/flashrom
410379
fi
411-
cbfstoolcmd=/tmp/boot/util/cbfstool
380+
cbfstoolcmd=/usr/local/bin/cbfstool
412381
gbbutilitycmd=$(which gbb_utility)
413382
else
414383
#set cmds
@@ -991,16 +960,5 @@ return 0
991960
function cleanup()
992961
{
993962
#remove temp files, unmount temp stuff
994-
if [ -d /tmp/boot/util ]; then
995-
rm -rf /tmp/boot/util > /dev/null 2>&1
996-
fi
997963
umount /tmp/boot > /dev/null 2>&1
998-
umount /tmp/Storage > /dev/null 2>&1
999-
umount /tmp/System > /dev/null 2>&1
1000-
umount /tmp/urfs/proc > /dev/null 2>&1
1001-
umount /tmp/urfs/dev/pts > /dev/null 2>&1
1002-
umount /tmp/urfs/dev > /dev/null 2>&1
1003-
umount /tmp/urfs/sys > /dev/null 2>&1
1004-
umount /tmp/urfs > /dev/null 2>&1
1005-
umount /tmp/usb > /dev/null 2>&1
1006964
}

0 commit comments

Comments
 (0)