From c18cbff97fac49716a35ec2d3b73e0d9b1dc60ac Mon Sep 17 00:00:00 2001 From: m-1-k-3 Date: Mon, 29 Apr 2024 12:56:59 +0200 Subject: [PATCH 1/2] s115 qemu command output --- modules/S115_usermode_emulator.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/S115_usermode_emulator.sh b/modules/S115_usermode_emulator.sh index 2c7612a9c..5c8429d75 100755 --- a/modules/S115_usermode_emulator.sh +++ b/modules/S115_usermode_emulator.sh @@ -675,6 +675,30 @@ emulate_binary() { # This is very ugly and should only be used in docker environment! pkill -9 -O "${QRUNTIME}" -f .*qemu-.*-sta.* >/dev/null || true write_log "\\n-----------------------------------------------------------------\\n" "${LOG_FILE_BIN}" + write_log "\\n\\nFor reproducing the EMBA user-mode emulation mechanism, the following commands could be used as starting point:" "${LOG_FILE_BIN}" + write_log "\\n - Start EMBA docker container with the firmware directory as log directory:" "${LOG_FILE_BIN}" + local lFW_PATH=$(sort -u "${TMP_DIR}"/fw_name.log | head -1) + write_log " # ${ORANGE}EMBA=\".\" FIRMWARE=\"${lFW_PATH:-"/absolute/path/to/firmware"}\" LOG=\"/absolute/path/to/EMBA/log/directory\" docker-compose run emba${NC}" "${LOG_FILE_BIN}" + write_log "\\n - Change your working directory to the root directory of your firmware:" "${LOG_FILE_BIN}" + write_log " # ${ORANGE}cd ${R_PATH}${NC}" "${LOG_FILE_BIN}" + write_log "\\n - Copy the static compiled user-mode emulator to your current working directory" "${LOG_FILE_BIN}" + write_log " # ${ORANGE}cp \$(which ${EMULATOR}) .${NC}" "${LOG_FILE_BIN}" + if [[ -z "${CPU_CONFIG_}" ]] || [[ "${CPU_CONFIG_}" == "NONE" ]]; then + write_log "\\n - Start the emulation with the following command: " "${LOG_FILE_BIN}" + if [[ "${CHROOT}" == "jchroot" ]] || grep -q "jchroot" "${TMP_DIR}"/chroot_mode.tmp; then + write_log " # ${ORANGE}${CHROOT} ${OPTS[@]} . -- ./${EMULATOR} ${BIN_} ${NC}" "${LOG_FILE_BIN}" + else + write_log " # ${ORANGE}${CHROOT} ${OPTS[@]} . ./${EMULATOR} ${BIN_} ${NC}" "${LOG_FILE_BIN}" + fi + else + write_log "\\n - Start the emulation with the following command: " "${LOG_FILE_BIN}" + if [[ "${CHROOT}" == "jchroot" ]] || grep -q "jchroot" "${TMP_DIR}"/chroot_mode.tmp; then + write_log " # ${ORANGE}${CHROOT} ${OPTS[@]} . -- ./${EMULATOR} -cpu ${CPU_CONFIG_} ${BIN_} ${NC}" "${LOG_FILE_BIN}" + else + write_log " # ${ORANGE}${CHROOT} ${OPTS[@]} . ./${EMULATOR} -cpu ${CPU_CONFIG_} ${BIN_} ${NC}" "${LOG_FILE_BIN}" + fi + fi + write_log "\\n${ORANGE}WARNING: EMBA is doing some more magic in the background. Probably it is not that easy, but give it a try.${NC}" "${LOG_FILE_BIN}" } check_disk_space_emu() { From 881a3753a5a737cde7a9701a7f3e643ef634e00e Mon Sep 17 00:00:00 2001 From: m-1-k-3 Date: Mon, 29 Apr 2024 13:45:37 +0200 Subject: [PATCH 2/2] shellcheck --- modules/S115_usermode_emulator.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/S115_usermode_emulator.sh b/modules/S115_usermode_emulator.sh index 5c8429d75..45efa8688 100755 --- a/modules/S115_usermode_emulator.sh +++ b/modules/S115_usermode_emulator.sh @@ -677,7 +677,8 @@ emulate_binary() { write_log "\\n-----------------------------------------------------------------\\n" "${LOG_FILE_BIN}" write_log "\\n\\nFor reproducing the EMBA user-mode emulation mechanism, the following commands could be used as starting point:" "${LOG_FILE_BIN}" write_log "\\n - Start EMBA docker container with the firmware directory as log directory:" "${LOG_FILE_BIN}" - local lFW_PATH=$(sort -u "${TMP_DIR}"/fw_name.log | head -1) + local lFW_PATH="" + lFW_PATH=$(sort -u "${TMP_DIR}"/fw_name.log | head -1) write_log " # ${ORANGE}EMBA=\".\" FIRMWARE=\"${lFW_PATH:-"/absolute/path/to/firmware"}\" LOG=\"/absolute/path/to/EMBA/log/directory\" docker-compose run emba${NC}" "${LOG_FILE_BIN}" write_log "\\n - Change your working directory to the root directory of your firmware:" "${LOG_FILE_BIN}" write_log " # ${ORANGE}cd ${R_PATH}${NC}" "${LOG_FILE_BIN}" @@ -686,16 +687,16 @@ emulate_binary() { if [[ -z "${CPU_CONFIG_}" ]] || [[ "${CPU_CONFIG_}" == "NONE" ]]; then write_log "\\n - Start the emulation with the following command: " "${LOG_FILE_BIN}" if [[ "${CHROOT}" == "jchroot" ]] || grep -q "jchroot" "${TMP_DIR}"/chroot_mode.tmp; then - write_log " # ${ORANGE}${CHROOT} ${OPTS[@]} . -- ./${EMULATOR} ${BIN_} ${NC}" "${LOG_FILE_BIN}" + write_log " # ${ORANGE}${CHROOT} ${OPTS[*]} . -- ./${EMULATOR} ${BIN_} ${NC}" "${LOG_FILE_BIN}" else - write_log " # ${ORANGE}${CHROOT} ${OPTS[@]} . ./${EMULATOR} ${BIN_} ${NC}" "${LOG_FILE_BIN}" + write_log " # ${ORANGE}${CHROOT} ${OPTS[*]} . ./${EMULATOR} ${BIN_} ${NC}" "${LOG_FILE_BIN}" fi else write_log "\\n - Start the emulation with the following command: " "${LOG_FILE_BIN}" if [[ "${CHROOT}" == "jchroot" ]] || grep -q "jchroot" "${TMP_DIR}"/chroot_mode.tmp; then - write_log " # ${ORANGE}${CHROOT} ${OPTS[@]} . -- ./${EMULATOR} -cpu ${CPU_CONFIG_} ${BIN_} ${NC}" "${LOG_FILE_BIN}" + write_log " # ${ORANGE}${CHROOT} ${OPTS[*]} . -- ./${EMULATOR} -cpu ${CPU_CONFIG_} ${BIN_} ${NC}" "${LOG_FILE_BIN}" else - write_log " # ${ORANGE}${CHROOT} ${OPTS[@]} . ./${EMULATOR} -cpu ${CPU_CONFIG_} ${BIN_} ${NC}" "${LOG_FILE_BIN}" + write_log " # ${ORANGE}${CHROOT} ${OPTS[*]} . ./${EMULATOR} -cpu ${CPU_CONFIG_} ${BIN_} ${NC}" "${LOG_FILE_BIN}" fi fi write_log "\\n${ORANGE}WARNING: EMBA is doing some more magic in the background. Probably it is not that easy, but give it a try.${NC}" "${LOG_FILE_BIN}"