TI Processor SDK Linux am335x evm/bin/commom.sh hacking

Source: Internet
Author: User
Tags dmesg

#!/bin/sh## ti Processor SDK Linux am335x EVM/bin/commom.sh hacking# Description: # This article mainly explains the common.sh script in TI's SDK, in order to understand its working mechanism. ##                                       .-4- -Shenzhen Nanshan Ping Shan Village Zengjianfeng # This distribution contains contributions or derivatives under copyright# asfollows:## Copyright (c) ., Texas Instruments incorporated# All rights reserved.## redistribution and useinchsource and binary forms, with or without# modification, is permitted provided that the following conditions# is met :# -redistributions of source code must retain the above copyright notice,# Thislist of conditions and the following disclaimer.#-Redistributionsinchbinary form must reproduce the above copyright# notice, ThisList of conditions and the following disclaimerinchthe# Documentation and/or other materials provided with the distribution.#-Neither the name of Texas Instruments nor the names of its# contributors may be used to endorse or promote products derived# from  Thissoftware without specific prior written permission.## This software was provided by the COPYRIGHT holders and Contribu tors#" as is"and any EXPRESS OR implied warranties, including, but not limited# to, the implied warranties of merchantability and  FITNESS for A particular# PURPOSE is disclaimed. In NO EVENT shall the COPYRIGHT HOLDER or# CONTRIBUTORS being liable for any DIRECT, INDIRECT, incidental, special,# exemplar Y, or consequential damages (including, but not LIMITED to,# procurement of substitute GOODS OR SERVICES; LOSS of Use, DATA, or# profits; or business interruption) however caused and on any theory of# liability, WHETHER in contract, STRICT liability, OR TORT ( including negligence# OR OTHERWISE) arising in any-out-of-the---the-software, even if# advised of the Possibilit Y of SUCH damage.# Check the previous shell command to know if the execution is correct, if an error occurs, give the message, and then exit. Check_status () {ret=$?if["$ret"-ne"0" ]; Then Echo"Failed Setup, aborting."Exit1fi}# This function wouldreturnThe code name of the Linux host release to the caller# # [email protected]:~/ti-processor-sdk-linux-am335x-evm-01.00.00.00/bin$ Lsb_release-a# LSB Version:core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch# distributor id:ubuntu# Description:ubuntu12.04.1lts# Release:12.04# codename:precise# # eval $__host_ver="' $the _version '"# The above eval is equivalent to assigning a value to the parameter when the function is called, and the meaning of passing pointers in C language. Get_host_type () {Local __host_type=$1Local The_host= ' Lsb_release-a2>/dev/NULL| grep codename: | awk {'Print $'} ' eval $__host_type="' $the _host '"}# This function returns the version of the Linux host to the caller# # [email protected]:~/ti-processor-sdk-linux-am335x-evm-01.00.00.00/bin$ Lsb_release-a# LSB Version:core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch# distributor id:ubuntu# Description:ubuntu12.04.1lts# Release:12.04# codename:precise## Eval $__host_ver="' $the _version '"# The above eval is equivalent to assigning a value to the parameter when the function is called, and the meaning of passing pointers in C language. Get_host_version () {Local __host_ver=$1Local the_version= ' Lsb_release-a2>/dev/NULL| grep Release: | awk {'Print $'} ' eval $__host_ver="' $the _version '"}# This function returns the major version of the Linux host to the caller# If the host isVersion12.04Then Thisfunction wouldreturn  Aget_major_host_version () {Local __host_ver=$1get_host_version major_version eval $__host_ver="' ${major_version%%.*} '"}# This function returns the minor version of the Linux host to the caller# If the host isVersion12.04Then Thisfunction wouldreturn Genevaget_minor_host_version () {Local __host_ver=$1get_host_version minor_version eval $__host_ver="' ${minor_version##*.} '"}# This function would look forAn FTDI connection fromThe development board# and based on the index passedinchIt wouldSetThe. MINIRC.DFL value forthe# Proper FTDI instance.# FTDI is generally mainly USB to UART,FIFO,SPI,I2C tool. Set_ftdi_serial_port () {index=" $"Port=""Ports=""    # [ -N"$var"]: Determine if the $var variable has a valueif[!-N"$index"] then index=1fi while[1==1 ]     Do# This is equivalent to a transplant waiting for the corresponding TTY to appear in the DMESG, waiting time is 10s. Echo"Detecting connection to board ..."Loopcount=0Ports= ' DMESG | grep FTDI | Grep"TTY"| Tail-2| sed s'/.*attached to//g'`         while[-Z"$ports"] && ["$loopCount"-ne"Ten" ]         Do#count toTenand timeoutifNo connection isfound Loopcount=$ ((loopcount+1)) Sleep1Ports= ' DMESG | grep FTDI | Grep"TTY"| Tail-2| sed s'/.*attached to//g'' Done # If we have actually found ports thenGetthe proper index # if a port is foundif[-N"$ports" ]; Then I=1# takes the specified port number in index forPinch$ports Do                if["$i"-eq"$index"] then Port="$p"                     Break# There should not being more thanTenindexes so stop there elif ["$i"-eq"Ten"] Then Breakfi i= ' Expr $i +1' Done # If the port isBlank then we couldn't find the index so ask the# User. # if the specified serial port is not found above, then manually enterif["X$port"=="x"] then echo"The port for the FTDI usb-to-serial device could is"Echo"found. Please enter the port yourself here"Read-P"[/dev/ttyusb#]"Port fi Break; Fi #ifWe didn't find a port and reached the timeout limit then ask# to reconnect # if the corresponding serial port is not found, then ask whether to continueif[-Z"$ports"] && ["$loopCount"="Ten" ]; Then Echo""Echo"unable to detect which port the board was connected to."Echo"Please reconnect your board."Echo"Press ' Y ' to attempt-detect your board again or press ' n ' to continue ..."Read-P"(y/n)"retryboarddetection fi#ifThey choose Retry, ask user to reboot manually and exit# If you choose not to continue, then the reality of the relevant tipsif["$retryBoardDetection"="N" ]; Then Echo""Echo"Please reboot your board manually and connect using minicom."exit; Fi do # take everythinginchThe user'S. minirc.dlf file expect the port setting# This is equivalent to preserving the user's previous settings and adding the currently specified port cat ${home}/.MINIRC.DFL | Grep-v Port > ${home}/. Minirc.dfl.tmp Echo"PU port/dev/$port"> ${home}/. MINIRC.DFL Cat ${home}/.minirc.dfl.tmp >> ${home}/. MINIRC.DFL RM-F ${home}/. minirc.dfl.tmp}

TI Processor SDK Linux am335x evm/bin/commom.sh hacking

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.