Index: scripts/_errors_ =================================================================== diff -u -rbcafc1d20046aaf42e7f697f9c33376e0b6b6126 -r5c634095d571c4d74101171c767f7d4a042f9f9a --- scripts/_errors_ (.../_errors_) (revision bcafc1d20046aaf42e7f697f9c33376e0b6b6126) +++ scripts/_errors_ (.../_errors_) (revision 5c634095d571c4d74101171c767f7d4a042f9f9a) @@ -38,6 +38,7 @@ ERR_GENERAL_SCRIPT_PARAM_COUNT=2 ERR_GENERAL_SCRIPT_EMPTY_STRING=3 ERR_GENERAL_SCRIPT_FILE_EXIST=4 +ERR_GENERAL_NO_SD_CARD=5 # 1x: Empty parameters ERR_MTPARAM_WIFI_SSID=10 Index: scripts/_functions_ =================================================================== diff -u -r33ce323edd28935192fdb15010fd51eaa610aa58 -r5c634095d571c4d74101171c767f7d4a042f9f9a --- scripts/_functions_ (.../_functions_) (revision 33ce323edd28935192fdb15010fd51eaa610aa58) +++ scripts/_functions_ (.../_functions_) (revision 5c634095d571c4d74101171c767f7d4a042f9f9a) @@ -28,6 +28,7 @@ # sources . ./_errors_ +. ./_variables_ # functions @@ -174,3 +175,22 @@ "$ERR_CMDFAIL_USB_FOLDER_REMOVE" ) echo "usb mount point '$2' cannot be removed." ;; esac } + +echo_dash_comment() { + echo "$COMMENT_DASH"" $1 " +} + +echo_dash_message() { + echo " $1" +} + +function confirm() { + read -p "$1? [y,n]" -n 1 -r CONTINUE + if [ "$CONTINUE" == "y" ]; then + echo "" + return $TRUE + else + echo "" + return $FALSE + fi +} Index: scripts/_variables_ =================================================================== diff -u -r33ce323edd28935192fdb15010fd51eaa610aa58 -r5c634095d571c4d74101171c767f7d4a042f9f9a --- scripts/_variables_ (.../_variables_) (revision 33ce323edd28935192fdb15010fd51eaa610aa58) +++ scripts/_variables_ (.../_variables_) (revision 5c634095d571c4d74101171c767f7d4a042f9f9a) @@ -28,4 +28,20 @@ # sources # variables +TRUE=1 +FALSE=0 +COMMENT_DASH="--------------------------------------------------------------------------------" + +## Brightness BRIGHTNESS_SYSFS="/sys/class/backlight/lvds_backlight/brightness" + +## SD-Card +SDCARD_DEV=/dev/mmcblk1 +SDCARD_PRT=/dev/mmcblk1p1 +SDCARD_MNT=/media/sd-card +SDCARD_TYP_NAME=ext4 +SDCARD_TYP_NUMB=83 + +CMD_SDCARD_DEV="ls $SDCARD_DEV" +CMD_SDCARD_PRT="ls $SDCARD_PRT" +CMD_LINUX_TYPE="sfdisk --part-type $SDCARD_DEV 1" Index: scripts/run.sh =================================================================== diff -u --- scripts/run.sh (revision 0) +++ scripts/run.sh (revision 5c634095d571c4d74101171c767f7d4a042f9f9a) @@ -0,0 +1,39 @@ +#!/bin/sh + +export P_CANBUS="can0" +export SSID_NAME="DilaityIoT" +export SSID_PASS="E6ACB9855B948EC3" +export TEMP=/tmp +export WORKSPACE=/opt/leahi +export LOGFILE=$TEMP/leahi.manufacturing.log +export DATE="date +%Y%m%d%H%M%S" + +# the application needs this variable to be correctly set to susccessfully launch. +# the egls.json file shall also correctly set and put in the pointing location. +export QT_QPA_EGLFS_KMS_CONFIG=$WORKSPACE/eglfs.json + +# TODO: +# 1 - separate the run.sh and the application service ( and even the cloudsync too ) +# 2 - mv LOGNAME post.log +# + +echo "" > $LOGFILE 2>&1 + +ethtool -s eth0 speed 100 duplex full autoneg on >> $LOGFILE 2>&1 + +timedatectl set-timezone America/Los_Angeles >> $LOGFILE 2>&1 +timedatectl set-ntp 1 >> $LOGFILE 2>&1 +echo "[$($DATE)] Starting" >> $LOGFILE 2>&1 + +echo "[$($DATE)] Configuring the canbus '$P_CANBUS'" >> $LOGFILE 2>&1 +ip link set $P_CANBUS up type can bitrate 250000 >> $LOGFILE 2>&1 +ifconfig $P_CANBUS txqueuelen 4000 >> $LOGFILE 2>&1 +ifconfig $P_CANBUS up >> $LOGFILE 2>&1 + +echo "[$($DATE)] Configuring wifi '$SSID_NAME' connection" >> $LOGFILE 2>&1 +nmcli dev wifi connect "$SSID_NAME" password "$SSID_PASS" >> $LOGFILE 2>&1 + +cd $WORKSPACE +echo "[$($DATE)] Application starting in '$(pwd)'" >> $LOGFILE 2>&1 +$WORKSPACE/leahi --platform eglfs >> $LOGFILE 2>&1 & # -E removed for using -L for testing Leahi FW communication +echo "[$($DATE)] Application launched" >> $LOGFILE 2>&1 Index: scripts/sd-format.sh =================================================================== diff -u --- scripts/sd-format.sh (revision 0) +++ scripts/sd-format.sh (revision 5c634095d571c4d74101171c767f7d4a042f9f9a) @@ -0,0 +1,95 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2020-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file setup.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 16-Dec-2022 +# @author (original) Behrouz NematiPour +# @date (original) 13-Mar-2020 +# +############################################################################ + +# @details +# This script is part of setting up the newly flashed SoM which will run on the device +# after the start.sh script is done copying files on the device. + +# sources +. ./_errors_ +. ./_functions_ +. ./_variables_ + +function check_sdcard() { + while true; do + if [ ! "$($CMD_SDCARD_DEV)" == "$SDCARD_DEV" ];then # if no SD-Card found ask operator to install on and retry after power-cycle. + echo_dash_comment + echo_dash_message "No SD-Card detected" + echo_dash_message "UI Software logging will not work without a SD-Card" + echo_dash_message "Insert a SD-Card and continue when ready" + echo_dash_comment + confirm "Continue" + if [ $? -eq $FALSE ]; then + exit $ERR_GENERAL_NO_SD_CARD + fi + else + break + fi + done + + if [ ! "$($CMD_SDCARD_PRT)" == "$SDCARD_PRT" ]; then return $FALSE; fi # if partition 1 doesn't exist , do the format + if [ ! "$($CMD_LINUX_TYPE)" == "$SDCARD_TYP_NUMB" ]; then return $FALSE; fi # if partition 1 type is not Linux(83) , do the format + return $TRUE # otherwise , do not format +} + +function format_sdcard() { + check_sdcard + if [ $? -eq $TRUE ]; then # if sd-card is OK + echo "Found the SD-Card $SDCARD_DEV" + confirm "Do you want to format the SD-Card" + if [ $? -eq $FALSE ]; then # give user an option to skip the format + return $? + fi + fi + + while true; do + echo "Unmount the SD-Card if is in use" + umount "$SDCARD_PRT" + if [ ! "$( mount | grep $SDCARD_PRT)" == "" ]; then # is still mounted + if [ $? -eq $FALSE ]; then # if SD-Card cannot the unmounted then stop the format. + echo "The SD-Card $SDCARD_DEV cannot be unmounted, therefore cannot be formatted" + confirm "Do you want to retry?" + if [ $? -eq $FALSE ]; then + return $FALSE # do not continue with format + fi + else + break + fi + else + break + fi + done + + echo "Removing current partitions" + sfdisk --delete $SDCARD_DEV 1>/dev/null 2>/dev/null + echo "Create new partition" + echo "label:MBR" | sfdisk $SDCARD_DEV 1>/dev/null 2>/dev/null + echo "type=83" | sfdisk $SDCARD_DEV 1>/dev/null 2>/dev/null + echo "Create a ext4 file system" + mkfs.ext4 $SDCARD_PRT -L "Denali_Log" -F # 1>/dev/null 2>/dev/null + + check_sdcard + if [ $? -eq $TRUE ]; then + echo "SD-Card format PASSED" + else + echo "SD-Card format FAILED !!!" + fi +} + +format_sdcard + +exit 0