Skip to content

Commit 12e417b

Browse files
authored
Merge pull request #94 from Dasharo/add-odroid-slimbootloader
Add Odroid DPP Dasharo (Slim Bootloader+UEFI) Initial deployment and Transition
2 parents a20dd69 + 0f5b449 commit 12e417b

File tree

5 files changed

+196
-35
lines changed

5 files changed

+196
-35
lines changed

include/dts-environment.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ declare DASHARO_REL_VER_DPP
122122
declare DASHARO_REL_VER_DPP_CAP
123123
declare HEADS_REL_VER_DPP
124124
declare DASHARO_REL_VER_DPP_SEABIOS
125+
declare DASHARO_REL_VER_DPP_SLIMUEFI
125126
declare COMPATIBLE_EC_FW_VERSION
126127
# and for capsules:
127128
declare DASHARO_REL_VER_CAP
@@ -133,6 +134,11 @@ declare DASHARO_REL_VER_DPP_CAP
133134
# from which Dasharo firmware supports capsule update for current patform. It is
134135
# set in board_config:
135136
declare DASHARO_SUPPORT_CAP_FROM
137+
# MinIO bucket names:
138+
declare BUCKET_DPP # Means coreboot+UEFI
139+
declare BUCKET_DPP_SEABIOS # Means coreboot+SeaBIOS
140+
declare BUCKET_DPP_HEADS # Means coreboot+Headsd
141+
declare BUCKET_DPP_SLIMUEFI # Means Slim Bootloader+UEFI
136142
# Links to files:
137143
declare BIOS_LINK_COMM
138144
declare BIOS_HASH_LINK_COMM
@@ -143,6 +149,9 @@ declare BIOS_SIGN_LINK_DPP
143149
declare BIOS_LINK_DPP_SEABIOS
144150
declare BIOS_HASH_LINK_DPP_SEABIOS
145151
declare BIOS_SIGN_LINK_DPP_SEABIOS
152+
declare BIOS_LINK_DPP_SLIMUEFI
153+
declare BIOS_HASH_LINK_DPP_SLIMUEFI
154+
declare BIOS_SIGN_LINK_DPP_SLIMUEFI
146155
declare EC_LINK_COMM
147156
declare EC_HASH_LINK_COMM
148157
declare EC_SIGN_LINK_COMM

include/dts-functions.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,8 @@ board_config() {
654654
esac
655655

656656
BIOS_LINK_DPP="$BUCKET_DPP/$DASHARO_REL_NAME/v$DASHARO_REL_VER_DPP/${DASHARO_REL_NAME}_v$DASHARO_REL_VER_DPP.rom"
657+
# TODO: check if it really will be called "*_slimuefi_*.rom"
658+
BIOS_LINK_DPP_SLIMUEFI="${BUCKET_DPP_SLIMUEFI}/${DASHARO_REL_NAME}/v${DASHARO_REL_VER_DPP_SLIMUEFI}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP_SLIMUEFI}_slim_bootloader_uefi.rom"
657659
;;
658660
"QEMU" | "Emulation")
659661
case "$SYSTEM_MODEL" in
@@ -688,6 +690,8 @@ board_config() {
688690
[ -z "$BIOS_SIGN_LINK_DPP_SEABIOS" ] && BIOS_SIGN_LINK_DPP_SEABIOS="${BIOS_HASH_LINK_DPP_SEABIOS}.sig"
689691
[ -z "$HEADS_HASH_LINK_DPP" ] && HEADS_HASH_LINK_DPP="${HEADS_LINK_DPP}.sha256"
690692
[ -z "$HEADS_SIGN_LINK_DPP" ] && HEADS_SIGN_LINK_DPP="${HEADS_HASH_LINK_DPP}.sig"
693+
[ -z "$BIOS_HASH_LINK_DPP_SLIMUEFI" ] && BIOS_HASH_LINK_DPP_SLIMUEFI="${BIOS_LINK_DPP_SLIMUEFI}.sha256"
694+
[ -z "$BIOS_SIGN_LINK_DPP_SLIMUEFI" ] && BIOS_SIGN_LINK_DPP_SLIMUEFI="${BIOS_HASH_LINK_DPP_SLIMUEFI}.sig"
691695
[ -z "$EC_HASH_LINK_COMM" ] && EC_HASH_LINK_COMM="${EC_LINK_COMM}.sha256"
692696
[ -z "$EC_SIGN_LINK_COMM" ] && EC_SIGN_LINK_COMM="${EC_HASH_LINK_COMM}.sig"
693697
[ -z "$EC_HASH_LINK_DPP" ] && EC_HASH_LINK_DPP="${EC_LINK_DPP}.sha256"
@@ -1410,11 +1414,7 @@ show_main_menu() {
14101414
if [ -f "${DPP_SUBMENU_JSON}" ]; then
14111415
echo -e "${BLUE}**${YELLOW} ${DPP_SUBMENU_OPT})${BLUE} DTS extensions${NORMAL}"
14121416
fi
1413-
# As of now show this option only for PC Engines and only for non-UEFI
1414-
# firmware as we only implement transition to UEFI for PC Engines
1415-
# TODO: migrate all transition logic here e.g. Heads, UEFI->SeaBIOS if
1416-
# possible
1417-
if ! $FSREAD_TOOL test -d "/sys/firmware/efi" && [[ "$SYSTEM_VENDOR" == "PC Engines" ]]; then
1417+
if check_if_dasharo; then
14181418
echo -e "${BLUE}**${YELLOW} ${TRANSITION_OPT})${BLUE} Transition Dasharo Firmware${NORMAL}"
14191419
fi
14201420
}
@@ -1580,6 +1580,9 @@ main_menu_options() {
15801580
return 0
15811581
;;
15821582
"${TRANSITION_OPT}")
1583+
# No transition, if there is no Dasharo firmware installed:
1584+
check_if_dasharo || return 0
1585+
15831586
${CMD_DASHARO_DEPLOY} transition
15841587
result=$?
15851588
if [ "$result" -ne $OK ] && [ "$result" -ne $CANCEL ]; then

include/dts-subscription.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ check_for_dasharo_firmware() {
2121
local _check_dwn_req_resp_uefi_cap="0"
2222
local _check_dwn_req_resp_heads="0"
2323
local _check_dwn_req_resp_seabios="0"
24+
local _check_dwn_req_resp_slimuefi="0"
2425
local _check_logs_req_resp="0"
2526
# Ignore "SC2154 (warning): DPP_CREDENTIAL_FILE is referenced but not assigned"
2627
# for external variable:
@@ -32,7 +33,7 @@ check_for_dasharo_firmware() {
3233
board_config
3334

3435
# If board_config function has not set firmware links - exit with warning:
35-
if [ -z "$BIOS_LINK_DPP" ] && [ -z "$HEADS_LINK_DPP" ] && [ -z "$BIOS_LINK_DPP_SEABIOS" ] && [ -z "$BIOS_LINK_DPP_CAP" ]; then
36+
if [ -z "$BIOS_LINK_DPP" ] && [ -z "$HEADS_LINK_DPP" ] && [ -z "$BIOS_LINK_DPP_SEABIOS" ] && [ -z "$BIOS_LINK_DPP_CAP" ] && [ -z "$BIOS_LINK_DPP_SLIMUEFI" ]; then
3637
print_warning "There is no Dasharo Firmware available for your platform."
3738
return 1
3839
fi
@@ -58,13 +59,19 @@ check_for_dasharo_firmware() {
5859
mc find "${DPP_SERVER_USER_ALIAS}/${BIOS_LINK_DPP_SEABIOS}" >/dev/null 2>>"$ERR_LOG_FILE"
5960
_check_dwn_req_resp_seabios=$?
6061
fi
62+
63+
if [ -n "$BIOS_LINK_DPP_SLIMUEFI" ]; then
64+
mc find "${DPP_SERVER_USER_ALIAS}/${BIOS_LINK_DPP_SLIMUEFI}" >/dev/null 2>>"$ERR_LOG_FILE"
65+
_check_dwn_req_resp_slimuefi=$?
66+
fi
67+
6168
if [ -n "${DPP_EMAIL}" ]; then
6269
mc find "${DPP_SERVER_USER_ALIAS}/${DPP_BUCKET}" >/dev/null 2>>"$ERR_LOG_FILE"
6370
_check_logs_req_resp=$?
6471
fi
6572
fi
6673
# Return 0 if any of Dasharo Firmware binaries is available:
67-
if [ ${_check_dwn_req_resp_uefi} -eq 0 ] || [ ${_check_dwn_req_resp_uefi_cap} -eq 0 ] || [ ${_check_dwn_req_resp_heads} -eq 0 ] || [ ${_check_dwn_req_resp_seabios} -eq 0 ]; then
74+
if [ ${_check_dwn_req_resp_uefi} -eq 0 ] || [ ${_check_dwn_req_resp_uefi_cap} -eq 0 ] || [ ${_check_dwn_req_resp_heads} -eq 0 ] || [ ${_check_dwn_req_resp_seabios} -eq 0 ] || [ ${_check_dwn_req_resp_slimuefi} -eq 0 ]; then
6875
if [ ${_check_logs_req_resp} -eq 0 ]; then
6976
print_ok "A Dasharo Firmware binary has been found for your platform!"
7077
return 0

include/hal/dts-hal.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,75 @@ check_me_op_mode() {
200200

201201
return 0
202202
}
203+
204+
check_if_uefi() {
205+
# Check if current firmware has UEFI payload. Returns 0 on success, otherwise
206+
# returns 1.
207+
grep -q 'UEFI' <(echo "${DASHARO_FLAVOR}") && return 0
208+
# Additional check is useful sometimes:
209+
$FSREAD_TOOL test -d "/sys/firmware/efi" && return 0
210+
211+
return 1
212+
}
213+
214+
check_if_seabios() {
215+
# Check if current firmware has SeaBIOS payload. Returns 0 on success,
216+
# otherwise returns 1.
217+
grep -q 'SeaBIOS' <(echo "${DASHARO_FLAVOR}") && return 0
218+
# Additional check is useful sometimes:
219+
tmp_rom=$(mktemp --dry-run)
220+
config=/tmp/config
221+
# Get current firmware:
222+
$FLASHROM flashrom_read_firm_mock -p "$PROGRAMMER_BIOS" ${FLASH_CHIP_SELECT} -r "$tmp_rom" >>"$FLASH_INFO_FILE" 2>>"$ERR_LOG_FILE"
223+
224+
if [ -f "$tmp_rom" ]; then
225+
# extract config
226+
$CBFSTOOL read_bios_conffile_mock "$tmp_rom" extract -n config -f "$config" >/dev/null 2>>"$ERR_LOG_FILE"
227+
grep -q "CONFIG_PAYLOAD_SEABIOS=y" "$config" 2>>"${ERR_LOG_FILE}" && return 0
228+
fi
229+
230+
return 1
231+
}
232+
233+
check_for_transition() {
234+
# This function checks for possible transition for current hardware and
235+
# firmware configuration flows and returns:
236+
# * In case no transition flows sare available: return code 1 and empty
237+
# stdout.
238+
# * In case at least one transition flow is available: return code 0 and the
239+
# transition flow name on stdout.
240+
#
241+
# Check the end of the function for stdout formatting.
242+
local _is_uefi="false"
243+
local _is_seabios="false"
244+
local _transition_list=()
245+
246+
# The transition is only possible from Dasharo firmware:
247+
check_if_dasharo || return 1
248+
check_if_uefi && _is_uefi="true"
249+
check_if_seabios && _is_seabios="true"
250+
251+
if [[ "$_is_uefi" == "true" ]]; then
252+
# Dasharo (coreboot+UEFI) is installed, check possible transitions:
253+
if [[ "$COREBOOT_UEFI_TO_SLIM_BOOTLOADER_UEFI_TRANSITION" == "true" ]]; then
254+
_transition_list+=("Dasharo (coreboot+UEFI) to Dasharo (Slim Bootloader+UEFI)")
255+
fi
256+
fi
257+
258+
if [[ "$_is_seabios" == "true" ]]; then
259+
# Dasharo (coreboot+SeaBIOS) is installed, check possible transitions:
260+
if [[ "$COREBOOT_SEABIOS_TO_COREBOOT_UEFI_TRANSITION" == "true" ]]; then
261+
_transition_list+=("Dasharo (coreboot+SeaBIOS) to Dasharo (coreboot+UEFI)")
262+
fi
263+
fi
264+
265+
# This loop will make this function return a string that contains a string
266+
# that contains possible transitions separated by a new line, so it can be
267+
# easily reconstructed back to an array with
268+
# readarray -t transitions < <(check_for_transition)
269+
for transition in "${_transition_list[@]}"; do
270+
echo "$transition"
271+
done
272+
273+
[[ -n "${_transition_list[*]}" ]] && return 0 || return 1
274+
}

0 commit comments

Comments
 (0)