From 62a35ee2a81f717d69f988c64bfb041ce8794d81 Mon Sep 17 00:00:00 2001 From: hPrnicessPi3 Date: Fri, 9 May 2025 13:09:03 -0600 Subject: [PATCH] bug fixes and symantic improvements --- add-to-export-sh.txt | 2 +- custom_bin/changeesp.sh | 8 +- custom_bin/chipinfo | 24 +++- custom_bin/espinfo | 34 ++---- custom_bin/{exit_idf.sh => exit-idf.sh} | 1 - custom_bin/{help_esp_tools => help-esp-tools} | 0 ...{install_esp_branch => install-esp-branch} | 0 esp-idf-tools-cmd.sh | 51 +++++--- help.txt | 110 ++++++++---------- version.txt | 2 +- 10 files changed, 128 insertions(+), 104 deletions(-) rename custom_bin/{exit_idf.sh => exit-idf.sh} (91%) rename custom_bin/{help_esp_tools => help-esp-tools} (100%) rename custom_bin/{install_esp_branch => install-esp-branch} (100%) diff --git a/add-to-export-sh.txt b/add-to-export-sh.txt index fbc953e..c08376b 100644 --- a/add-to-export-sh.txt +++ b/add-to-export-sh.txt @@ -64,7 +64,7 @@ echo -e "\nSetting alias" alias changeport="source $binDir/changeport.sh" alias changebaud="source $binDir/changebaud.sh" alias changeesp="source $binDir/changeesp.sh" -alias exit_esp_tools="source $binDir/exit_idf.sh" +alias exit-esp-tools="source $binDir/exit-idf.sh" alias monitor="idf.py monitor" alias flashmonitor="idf.py flash monitor" alias menuconfig="idf.py menuconfig" diff --git a/custom_bin/changeesp.sh b/custom_bin/changeesp.sh index bdee88c..875026b 100644 --- a/custom_bin/changeesp.sh +++ b/custom_bin/changeesp.sh @@ -6,8 +6,12 @@ subprocess() { return 0 } -ret='' -subprocess ret +if [ ! -z "$1" ]; then + ret="$1" +else + ret='' + subprocess ret +fi export ESPTARGET="${ret}" diff --git a/custom_bin/chipinfo b/custom_bin/chipinfo index 2d6118e..206e409 100644 --- a/custom_bin/chipinfo +++ b/custom_bin/chipinfo @@ -1,8 +1,22 @@ #!/bin/bash -echo -e "\nflash_id\n" -esptool.py flash_id +echo -e "Getting ESP Chip Info...\n" +# echo -e "Base MAC Address:" +# esptool.py --port $ESPPORT --baud $ESPBAUD --chip auto read_mac +echo -e "\nChip ID:" +esptool.py --port $ESPPORT --baud $ESPBAUD --chip auto chip_id -echo -e "\nchip_id\n" -esptool.py chip_id +echo -e "\nFlash ID:" +esptool.py --port $ESPPORT --baud $ESPBAUD --chip auto flash_id -echo -e "\nAll done :3\n" \ No newline at end of file +echo -e "\nFlash Status:" +esptool.py --port $ESPPORT --baud $ESPBAUD --chip auto read_flash_status + +echo -e "\nSecurity Info:" +esptool.py --port $ESPPORT --baud $ESPBAUD --chip auto get_security_info + +if [ -f "./CMakeLists.txt" ]; then + echo -e "\nEfuse Table:" + idf.py --port $ESPPORT --baud $ESPBAUD efuse-dump +fi + +echo -e "\nAll donsies~ :3\n" diff --git a/custom_bin/espinfo b/custom_bin/espinfo index 206e409..18743bf 100644 --- a/custom_bin/espinfo +++ b/custom_bin/espinfo @@ -1,22 +1,12 @@ -#!/bin/bash -echo -e "Getting ESP Chip Info...\n" -# echo -e "Base MAC Address:" -# esptool.py --port $ESPPORT --baud $ESPBAUD --chip auto read_mac -echo -e "\nChip ID:" -esptool.py --port $ESPPORT --baud $ESPBAUD --chip auto chip_id - -echo -e "\nFlash ID:" -esptool.py --port $ESPPORT --baud $ESPBAUD --chip auto flash_id - -echo -e "\nFlash Status:" -esptool.py --port $ESPPORT --baud $ESPBAUD --chip auto read_flash_status - -echo -e "\nSecurity Info:" -esptool.py --port $ESPPORT --baud $ESPBAUD --chip auto get_security_info - -if [ -f "./CMakeLists.txt" ]; then - echo -e "\nEfuse Table:" - idf.py --port $ESPPORT --baud $ESPBAUD efuse-dump -fi - -echo -e "\nAll donsies~ :3\n" +echo "esp-idf install dir: $ESPIDF_INSTALLDIR" +echo "esp-idf path: $IDF_PATH" +echo "esp-idf version: $ESP_IDF_VERSION" +echo "esp-idf python path: $IDF_PYTHON_ENV_PATH +echo "openocd scripts: $OPENOCD_SCRIPTS" +echo "esp-idf rom elf dir: $ESP_ROM_ELF_DIR" +echo "esp-idf-deactivate file path $IDF_DEACTIVATE_FILE_PATH" +echo "esp-idf tools install cmd: $IDF_TOOLS_INSTALL_CMD" +echo "esp-idf-tools export cmd: $IDF_TOOLS_EXPORT_CMD" +echo "port: $ESPPORT" +echo "baud: $ESPBAUD" +echo "target device $SPTARGET" \ No newline at end of file diff --git a/custom_bin/exit_idf.sh b/custom_bin/exit-idf.sh similarity index 91% rename from custom_bin/exit_idf.sh rename to custom_bin/exit-idf.sh index 922ab2e..04092ef 100644 --- a/custom_bin/exit_idf.sh +++ b/custom_bin/exit-idf.sh @@ -7,7 +7,6 @@ unset ESP_ROM_ELF_DIR unset IDF_DEACTIVATE_FILE_PATH unset IDF_TOOLS_INSTALL_CMD unset IDF_TOOLS_EXPORT_CMD -unset IDF_TOOLS_EXPORT_CMD unset ESPPORT unset ESPBAUD unset ESPTARGET diff --git a/custom_bin/help_esp_tools b/custom_bin/help-esp-tools similarity index 100% rename from custom_bin/help_esp_tools rename to custom_bin/help-esp-tools diff --git a/custom_bin/install_esp_branch b/custom_bin/install-esp-branch similarity index 100% rename from custom_bin/install_esp_branch rename to custom_bin/install-esp-branch diff --git a/esp-idf-tools-cmd.sh b/esp-idf-tools-cmd.sh index ccf18db..351c8f0 100644 --- a/esp-idf-tools-cmd.sh +++ b/esp-idf-tools-cmd.sh @@ -263,10 +263,10 @@ function testAppendAlias() { } function handleAliasEnviron() { - testAppendAlias "get_esp_tools" "alias get_esp_tools='. $exportScript'" - testAppendAlias "run_esp_cmd" "alias run_esp_cmd='git -C $runningDir pull;echo -e \"\nOld Version:\";tail -1 $versionData;echo -e \"\n\";bash $runningDir/esp-idf-tools-cmd.sh'" - testAppendAlias "esp_install_monitor" "alias esp_install_monitor='tail -n 75 -f $log'" - testAppendAlias "esp_install_logs" "alias esp_install_logs='less $versionData;less $log'" + testAppendAlias "get-esp-tools" "alias get-esp-tools='. $exportScript'" + testAppendAlias "run-esp-cmd" "alias run-esp-cmd='git -C $runningDir pull;echo -e \"\nOld Version:\";tail -1 $versionData;echo -e \"\n\";bash $runningDir/esp-idf-tools-cmd.sh'" + testAppendAlias "esp-install-monitor" "alias esp-install-monitor='tail -n 75 -f $log'" + testAppendAlias "esp-install-logs" "alias esp-install-logs='less $versionData;less $log'" if [ -z $ESPIDF_INSTALLDIR ]; then writeToLog "ESPIDF_INSTALLDIR environment variable not found, appending to $rcFile" @@ -338,7 +338,14 @@ function handleDownloadInstall() { returnStatus gitHashChk=$? - gitDataLog="$(date '+%d/%m/%Y %H:%M:%S %Z (%s)') commit $commitHash branch $gitBranch version $scriptVers action $action" + # if gitDataLog file doesnt exist, initialize with header + if [[ ! -f "$gitDataLog" ]]; then + writeToLog "$gitDataLog not found, initializing with header" + echo "date | esp-idf branch | esp-idf-tools version | action" > "$gitDataLog"; + fi + + # date | esp-idf branch | esp-idf-tools version | action + gitDataLog="$(date '+%d/%m/%Y %H:%M:%S %Z (%s)') | $commitHash | $gitBranch | $scriptVers | $action" writeToLog "$gitDataLog" echo "$gitDataLog" >> $versionData returnStatus @@ -347,7 +354,7 @@ function handleDownloadInstall() { handleReboot() { # writeToLog "Handling reboot: (function ran)\n" - eval "sudo shutdown -r +$rebootMins" + sudo shutdown -r +$rebootMins } # warning not work how i make it work fuckin ell @@ -481,7 +488,6 @@ function handleClearInstallLog() { fi } - function handleEnd() { handleChk @@ -591,7 +597,7 @@ elif [[ "$arg" == "interactive" || "$arg" == "i" ]]; then elif [[ "$arg" == "cron" || "$arg" == "c" ]]; then # full install with warn, sleep, and reboot action="REINSTALL (CRON)" - # sleepMins=3 + sleepMins=1 idfGet="update" sleepMins=0 @@ -610,9 +616,8 @@ elif [[ "$arg" == "cron" || "$arg" == "c" ]]; then # full install with warn, sle elif [[ "$arg" == "update" || "$arg" == "u" ]]; then # update without logouts or reboot action="UPDATE" - # sleepMins=3 idfGet="update" - sleepMins=0 + sleepMins=1 handleStart handleClearInstallLog @@ -624,12 +629,12 @@ elif [[ "$arg" == "update" || "$arg" == "u" ]]; then # update without logouts or exit -elif [[ "$arg" == "clearlogs" || "$arg" == "cl" || "$arg" == "clear" || "$arg" == "clean" ]]; then # clear logs +elif [[ "$arg" == "clearlogs" || "$arg" == "cl" || "$arg" == "clear"]]; then handleEmptyLogs exit -elif [[ "$arg" == "nuke" || "$arg" == "n" ]]; then # clear logs +elif [[ "$arg" == "nuke" || "$arg" == "n" ]]; then action="REINSTALL (NUKE)" idfGet="download" @@ -644,14 +649,34 @@ elif [[ "$arg" == "nuke" || "$arg" == "n" ]]; then # clear logs exit -elif [ "$arg" == "uninstall" ]; then # clear logs +elif [[ "$arg" == "nukereboot" || "$arg" == "nr" ]]; then + action="REINSTALL (NUKEREBOOT)" + sleepMins=1 + idfGet="download" + + handleStart + handleClearInstallLog + handleSetupEnvironment + handleCustomBins + handleDownloadInstall + handleExport + handleAliasEnviron + handleEnd + handleReboot + + exit + +elif [ "$arg" == "uninstall" ]; then handleUninstall + echo -e "\nAll done :3\n" exit elif [ ! -z $arg ]; then writeToLog "FAIL: bad argument. Terminating" + exit + else # full noninteractive (re)install without logout, reboot, or sleeps action="REINSTALL (DEFAULT)" diff --git a/help.txt b/help.txt index 5aa0cd8..199afce 100644 --- a/help.txt +++ b/help.txt @@ -1,76 +1,91 @@ Modes: + Some take optional [branch] paramater + [branch] is the esp-idf branch you desire, defaults to master if not specified. + + default: reinstalls non-interactively with no delays, logouts, or reboots - `run_esp_cmd` + `run-esp-cmd` test: tests the script. very fast. minimal actions taken. no reinstall is done - `run_esp_cmd test` - `run_esp_cmd t` + `run-esp-cmd test [branch]` + `run-esp-cmd t [branch]` retool: reinstalls bins and export.sh, nothing else - `run_esp_cmd retool` - `run_esp_cmd rt` + `run-esp-cmd retool` + `run-esp-cmd rt` cron: runs noninteractively with forced user logout and automatic reboot, plus delays - `run_esp_cmd cron` - `run_esp_cmd c` + `run-esp-cmd cron [branch]` + `run-esp-cmd c [branch]` update: updates and installs latest without reboot or user logout - `run_esp_cmd update` - `run_esp_cmd u` + `run-esp-cmd update [branch]` + `run-esp-cmd u [branch]` interactive: interactively installs/reinstalls esp-idf - `run_esp_cmd interactive` - `run_esp_cmd i` + `run-esp-cmd interactive` + `run-esp-cmd i` nuke: full delete and re-download and install - `run_esp_cmd nuke` - `run_esp_cmd n` + `run-esp-cmd nuke [branch]` + `run-esp-cmd n [branch]` + + nukereboot + full delete and re-download and install, then reboot + `run-esp-cmd nukereboot [branch]` + `run-esp-cmd nr [branch]` clearlogs: clear logs - `run_esp_cmd clearlogs` - `run_esp_cmd clear` - `run_esp_cmd clean` - `run_esp_cmd cl` + `run-esp-cmd clearlogs` + `run-esp-cmd clear` + `run-esp-cmd cl` help: display this help text - `run_esp_cmd help` - `run_esp_cmd h` - `run_esp_cmd -h` - `run_esp_cmd --help` + `run-esp-cmd help` + `run-esp-cmd h` + `run-esp-cmd -h` + `run-esp-cmd --help` + `help-esp-tools` uninstall: uninstall esp-idf - `run_esp_cmd uninstall` + `run-esp-cmd uninstall` Usage: Once installed for the first time, restart your shell. to activate esp-idf with the custom additions, run: - `get_esp_tools` + `get-esp-tools` exit with - `exit_esp_tools` + `exit-esp-tools` for help - `help_esp_tools` + `help-esp-tools` Features: - `help-esp` show this help - `get_idf` enter esp-idf - `exit_idf` exit esp-idf and reset terminal + `get-idf-tools` enter esp-idf + `help-esp-tools` show this help + `exit-esp-tools` exit esp-idf and reset terminal `build` idf.py build `changebaud` prompts to enter a new baud - `changeesp` prompts to type in esp32s3, esp32c6, etc - `changeport` opens a menu to select a serial port - `clean` idf.py clean + `changeesp` change esp device + `changeesp` alone prompts to enter + `changeesp ` manually changes to + ex. `changeesp esp32p4` + `changeport` change serial port + `changeport` alone prompts to select + `changeport ` manually specifies path + ex. `changeport /dev/ttyUSB0` changes to /dev/ttyUSB0 + `clean` idf.py clean `fullclean` fully resets a project, 'idf.py fullclean' plus remove the build dir and delete some temp and backup files `rebuildfull` does a `fullclean` but also an `erase-flash` and also `setup` `setup` same as running `idf.py set-target $ESPTARGET; idf.py menuconfig; idf.py build` @@ -83,32 +98,15 @@ Features: `chipinfo` get information from the esp chip `espinfo` get detailed information from the esp chip `menuconfig` run `idf.py menuconfig` + `create-project ` same as idf.py create-project + ex. `create-project hello-world` + `esp-install-monitor` monitors install.log. alias for `tail -n 75 -f $ESPIDF_INSTALLDIR/install.log` + `esp-install-logs` displays full text of install.log and version-data.txt Aliases: - run_esp_cmd - Updates the esp-install-custom code via git, displays the script version, then executes esp-idf-tools-cmd.sh with optional arument. - Takes identical arguments to running esp-idf-tools-cmd.sh manually - run_esp_cmd - run_esp_cmd clean - run_esp_cmd nuke [branch] - run_esp_cmd retool [branch] - run_esp_cmd cron [branch] - run_esp_cmd update [branch] - run_esp_cmd interactive - run_esp_cmd test - run_esp_cmd uninstall - Second optional argument specifies branch (requires two arguments!): - `run_esp_cmd nuke v5.4.1` - esp_install_monitor - monitors install.log - alias for tail -n 75 -f $ESPIDF_INSTALLDIR/install.log - no arguments - - esp_install_logs - displays full text of install.log and version-data.txt - no arguments + Helpful Stuff: cron: @@ -116,9 +114,3 @@ Helpful Stuff: `crontab -e` add below to bottom of file: 0 4 * * * bash $HOME/esp/esp-install-custom/esp-idf-tools-cmd.sh cron - - monitor log file during install: - `tail -n 75 $ESPIDF_INSTALLDIR/install.log;` - - view both logs from beginning: - `less $ESPIDF_INSTALLDIR/install.log; less $ESPIDF_INSTALLDIR/version-data.txt` diff --git a/version.txt b/version.txt index db9c88e..07e4439 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -8-rc-5 \ No newline at end of file +9-rc-2