# ============================================================================== # Filename: autostart-gcu3.rc # Content: Autoboot script executed by uMON after its initialization. # [IdentStart] Dataradio uMON gcu3 $Revision: 1.1 $ [IdentEnd] # ============================================================================== ether off # Always turn off ethernet in case the PSA is not programmed. if $DEBUG_MODE seq 0x1 goto WAKEUP_SEECODE # ============================================================================== # ATTENTION section # This section allows someone to interrupt the booting process # and communicate with the device at the uMON level. # A two step process: # First, open a 200ms window to receive anything. # # Second, if "something" was received in phase 1, open a larger window # to receive a "predetermined" string "dataradio" terminated by # . If this string is received, terminate the start # process and go into command mode (as if the SERVICE jumper was # in place). If the predetermined string is not received, increment # a counter and try receiving the string again. If maximum count # is reached, go to CHECK_SERVICE_JUMPER. # First step: Synchronization read -f # Flush Input buffer sleep -m 200 # Wait 200 ms if -t ngc goto CHECK_SERVICE_JUMPER # Have we got a char from the console ? set ATTENTION Booting # Initialize variables set MAX_ATTEMPTS 10 set COUNT 0 # Second step: Console Input Loop # wait for something <> NULL # READ_BEGIN if $COUNT ge $MAX_ATTEMPTS goto FAIL_MAX_ATTEMPTS set -i COUNT echo \n echo ETH1 $ETHERADD $IPADD echo Enter Code (Terminate with ENTER): \c read -f read -t 2000 ATTENTION if $ATTENTION seq Booting goto CHECK_SERVICE_JUMPER # A timeout occured if $ATTENTION sne dataradio goto READ_BEGIN # Invalid entry, retry # # The string "dataradio" was received to confirm the user wants to interrupt # the booting process. set ATTENTION # Clear variables set MAX_ATTEMPTS set COUNT echo Entering command mode at user request. Loader not launched. goto END_START # FAIL_MAX_ATTEMPTS echo \n echo Maximum number of allowed attempts was reached (Max=$MAX_ATTEMPTS). echo Continuing booting ... set ATTENTION # Clear variables set MAX_ATTEMPTS set COUNT # ============================================================================== # CHECK_SERVICE_JUMPER: # If the SERVICE jumper is in place, do not run the loader application # and go into command mode i.e. terminal shell is available. set ATTENTION # Clear variables set COUNT set MAX_ATTEMPTS if $SERVICE seq \$SERVICE goto RUN_MAIN_APP echo Service Jumper is in place. Loader not launched. goto END_START # ============================================================================== # WAKEUP_SEECODE: echo Going into debug mode ... sc wakeup # SeeCode is running but waiting for uMON to stop in the TRAP. goto END_START # ============================================================================== # RUN_MAIN_APP: # If the file "psa.rc" does not exist # then define the env variable VIRGIN_PSA so that the application # can use it to modify its behavior. tfs size psa.rc SIZE if $SIZE seq \$SIZE goto PSA_NOT_FOUND set SIZE goto RUN_MAIN_APP_1 # PSA_NOT_FOUND: set VIRGIN_PSA 1 set RFADD 00:00:00:01 set ETHERADD 00:0A:99:00:00:01 # RUN_MAIN_APP_1: set COMMAND edba-gcu3.bin # RUN_COMMAND: set ERRORLEVEL 99 item 1 PROGRAM $COMMAND # Program name is the first item in $COMMAND tfs size $PROGRAM SIZE # Verify that the program exist in TFS if $SIZE seq \$SIZE goto RESET_LABEL # Reset system if not found set -e ALL # Create the string of all env variables -$COMMAND # Execute $COMMAND. heap -f $ALL # Free space used by string of all env variables set ALL # Destroy the string of all env variables ether off # Force ethernet to stay OFF # ERRLV_0: # result of a stationReset 0 (Restart Main Program) if $ERRORLEVEL ne 0x0 goto ERRLV_1 goto RUN_MAIN_APP # ERRLV_1: # result of a stationReset 1 (Warm Boot)) if $ERRORLEVEL ne 0x1 goto ERRLV_2 goto RESET_LABEL # ERRLV_2: # result of a stationReset 2 (Stay in uMON for awhile) # if it's a stationReset 2 then prompt for enter, else reset if $ERRORLEVEL ne 0x2 goto ERRLV_3 set ATTENTION Waiting # define something in the variable echo Press ENTER now to go into uMON read -t 5000 ATTENTION # Have about 5 seconds to press key. if $ATTENTION seq Waiting goto RESET_LABEL echo You are now in uMon goto END_START # ERRLV_3: # result of a stationReset 3 (Hard Reset) if $ERRORLEVEL ne 0x3 goto ERRLV_4 # Do a hard reset to ensure complete system restart reset -h # ERRLV_4: # result of a stationReset 4 (Run Program specified in $COMMAND) if $ERRORLEVEL ne 0x4 goto ASSERT_LABEL goto RUN_COMMAND # ASSERT_LABEL: # result of an ASSERT or ABNORMAL Program Termination item 1 ASSERT_MODULE $ASSERTLEVEL # Get the module number that asserted if $ASSERT_MODULE seq \$ASSERT_MODULE goto RESET_LABEL if $ASSERT_MODULE seq \$ASSERTLEVEL goto RESET_LABEL set ATTENTION Waiting # define something in the variable echo Program has asserted. echo Exit Code--\> $ASSERTLEVEL echo Press ENTER now to go into uMON (You have 60 seconds). read -t 60000 ATTENTION if $ATTENTION seq Waiting goto RESET_LABEL echo You are now in uMon goto END_START # ============================================================================== # RESET_LABEL: reset # Force uMON to restart # ============================================================================== # END_START: # If the file "psa.rc" does not exist, # disable the ethernet port and wait in uMON. tfs size psa.rc SIZE if $SIZE seq \$SIZE goto END_START_PSA_NOT_FOUND set SIZE ether on goto END_START_LEAVE_TO_UMON # END_START_PSA_NOT_FOUND: echo "psa.rc" does not exist. echo Ethernet port is OFF. # END_START_LEAVE_TO_UMON: ulvl 0 # End of autostart-gcu3.rc script