Advertisement
arrrghhh

hardware_revisions.sh

Sep 29th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.75 KB | None | 0 0
  1. #!/system/bin/sh
  2. #
  3. # Copyright (c) 2012, Motorola Inc. All rights reserved.
  4. #
  5. # The purpose of this script is to compile information about the hardware
  6. # versions of various devices on each unit. This is useful when searching
  7. # through reported issues for correlations with certain hardware revisions.
  8. # The information is collected from various locations in proc and sysfs (some
  9. # of which are product-specific) and compiled into small, single-line text
  10. # files in the userdata partition, one for each type of device. The format of
  11. # these lines are as follows:
  12. #
  13. # <type>:<vendor>:<revision>:<date/lot>:<firmware revision>:<extra info>
  14. #
  15. # The extact format of each field will be device-specific, but should be
  16. # consistent across a particular hardware platform. Most of these files will
  17. # never need to change once they are written.
  18. #
  19. # While the method used to read the information should be consistent on a given
  20. # platform, the specific path to a device's information may vary between
  21. # products. The hardware_revisions.conf file provides a way to adjust those
  22. # paths from the default.
  23. #
  24.  
  25. export PATH=/system/bin:$PATH
  26.  
  27. # Output destination and permissions
  28. OUT_PATH=/data/hardware_revisions
  29. OUT_USR=system
  30. OUT_GRP=system
  31. OUT_PERM=0644
  32. OUT_PATH_PERM=0755
  33.  
  34. # Default paths to hardware information
  35. PATH_RAM=/sys/ram
  36. PATH_NVM=/sys/block/mmcblk0/device
  37. PATH_SDCARD=/sys/block/mmcblk1/device
  38. # Current 8960 touchsceen is only on i2c-3 bus
  39. PATH_TOUCH=`ls -d /sys/bus/i2c/devices/3-*`
  40.  
  41. # Product-specific overrides
  42. [ -e /system/etc/hardware_revisions.conf ] && . /system/etc/hardware_revisions.conf
  43.  
  44.  
  45. #
  46. # Generate a hardware revision file
  47. #
  48. # $1 - name
  49. # $2 - type
  50. # $3 - vendor ID
  51. # $4 - hardware revision
  52. # $5 - date/lot code
  53. # $6 - firmware revision
  54. # $7 - extra information
  55. create_revision_data()
  56. {
  57. FILE="${OUT_PATH}/${1}"
  58.  
  59. # echo "${1}=${2}:${3}:${4}:${5}:${6}:${7}"
  60. echo "${2}:${3}:${4}:${5}:${6}:${7}" > ${FILE}
  61. chown ${OUT_USR} ${OUT_GRP} ${FILE}
  62. chmod ${OUT_PERM} ${FILE}
  63. }
  64.  
  65. mkdir -p ${OUT_PATH}
  66. chown ${OUT_USR} ${OUT_GRP} ${OUT_PATH}
  67. chmod ${OUT_PATH_PERM} ${OUT_PATH}
  68.  
  69.  
  70. #
  71. # Compile ram (static)
  72. #
  73. if [ ! -e "${OUT_PATH}/ram" -a -d "${PATH_RAM}" ] ; then
  74. TYPE=`cat ${PATH_RAM}/type`
  75. VEND=`cat ${PATH_RAM}/info`
  76. VEND="${VEND%%:*:*}"
  77. INFO="$(cat ${PATH_RAM}/mr5),$(cat ${PATH_RAM}/mr6),$(cat ${PATH_RAM}/mr5),\
  78. $(cat ${PATH_RAM}/mr5)"
  79. create_revision_data "ram" "${TYPE}" "${VEND}" "" "" "" "${INFO}"
  80. fi
  81.  
  82.  
  83. #
  84. # Compile nvm (static)
  85. #
  86. if [ ! -e "${OUT_PATH}/nvm" -a -d "${PATH_NVM}" ] ; then
  87. TYPE=`cat ${PATH_NVM}/type`
  88. VEND=`cat ${PATH_NVM}/manfid`
  89. HREV=`cat ${PATH_NVM}/name`
  90. DATE=`cat ${PATH_NVM}/date`
  91. FREV="$(cat ${PATH_NVM}/hwrev),$(cat ${PATH_NVM}/fwrev)"
  92. INFO="$(cat ${PATH_NVM}/cid),$(cat ${PATH_NVM}/csd)"
  93. create_revision_data "nvm" "${TYPE}" "${VEND}" "${HREV}" "${DATE}" "${FREV}" "${INFO}"
  94. fi
  95.  
  96.  
  97. #
  98. # Compile sdcard (always update)
  99. #
  100. if [ -d "${PATH_SDCARD}" ] ; then
  101. TYPE=`cat ${PATH_SDCARD}/type`
  102. VEND=`cat ${PATH_SDCARD}/manfid`
  103. HREV=`cat ${PATH_SDCARD}/name`
  104. DATE=`cat ${PATH_SDCARD}/date`
  105. FREV="$(cat ${PATH_SDCARD}/hwrev),$(cat ${PATH_SDCARD}/fwrev)"
  106. INFO="$(cat ${PATH_SDCARD}/cid),$(cat ${PATH_SDCARD}/csd)"
  107. create_revision_data "sdcard" "${TYPE}" "${VEND}" "${HREV}" "${DATE}" "${FREV}" "${INFO}"
  108. fi
  109.  
  110.  
  111. #
  112. # Compile ap_processor (static)
  113. #
  114. if [ ! -e "${OUT_PATH}/ap_processor" ] ; then
  115. TYPE=
  116. VEND=
  117. HREV=
  118. INFO=
  119. PREVIFS="$IFS"
  120. IFS="
  121. "
  122. for CPU in `cat /proc/cpuinfo` ; do
  123. KEY="${CPU%:*}"
  124. VAL="${CPU#*: }"
  125. case "${KEY}" in
  126. Processor*) TYPE="${VAL}" ;;
  127. *implementer*) VEND="${VAL}" ;;
  128. *variant*) HREV="${VAL}" ;;
  129. *part*) HREV="${HREV},${VAL}" ;;
  130. *revision*) HREV="${HREV},${VAL}" ;;
  131. *Serial*) INFO="${VAL}" ;;
  132. esac
  133. done
  134. IFS="$PREVIFS"
  135. create_revision_data "ap_processor" "${TYPE}" "${VEND}" "${HREV}" "" "" "${INFO}"
  136. fi
  137.  
  138. #
  139. # copy pmic data
  140. #
  141. if [ ! -e "${OUT_PATH}/pmic" ] ; then
  142. cat /sys/hardware_revisions/pmic > ${OUT_PATH}/pmic
  143. chown ${OUT_USR} ${OUT_GRP} ${OUT_PATH}/pmic
  144. chmod ${OUT_PERM} ${OUT_PATH}/pmic
  145. fi
  146.  
  147. #
  148. # copy display data
  149. #
  150. if [ ! -e "${OUT_PATH}/display" ] ; then
  151. cat /sys/hardware_revisions/display > ${OUT_PATH}/display
  152. chown ${OUT_USR} ${OUT_GRP} ${OUT_PATH}/display
  153. chmod ${OUT_PERM} ${OUT_PATH}/display
  154. fi
  155.  
  156. #
  157. # Compile touchscreen (static)
  158. #
  159. if [ ! -e "${OUT_PATH}/touchscreen" -a -e "${PATH_TOUCH}/name" ]; then
  160. VEND=
  161. HREV=
  162. DATE=
  163. FREV=
  164. INFO=
  165. TYPE=`cat ${PATH_TOUCH}/name`
  166. ICVER=`cat -e ${PATH_TOUCH}/ic_ver`
  167. case "${TYPE}" in
  168. melfas*)
  169. VEND="Melfas"
  170. HREV="${ICVER##*'HW Revision:'}"
  171. HREV="${HREV%%\$*}"
  172. FREV="${ICVER##*'Core FW ver:'}"
  173. FREV="${FREV%%\$*}"
  174. ;;
  175. cyttsp*)
  176. VEND="${ICVER##*'Custom ID:'}"
  177. VEND="${VEND%%\$*}"
  178. VEND="Cypress,${VEND}"
  179. HREV="${ICVER##*'TTSP Version:'}"
  180. HREV="${HREV%%\$*}"
  181. FREV="${ICVER##*'Application Version:'}"
  182. FREV="${FREV%%\$*}"
  183. ;;
  184. atmxt*)
  185. VEND="Atmel"
  186. HREV="${ICVER##*'Family ID:'}"
  187. HREV1="${ICVER##*'Variant ID:'}"
  188. HREV="${HREV%%\$*},${HREV1%%\$*}"
  189. FREV="${ICVER##*'Version:'}"
  190. FREV1="${ICVER##*'Build:'}"
  191. FREV="${FREV%%\$*},${FREV1%%\$*}"
  192. ;;
  193. *)
  194. INFO="not supported by current version $0"
  195. ;;
  196. esac
  197. create_revision_data "touchscreen" "${TYPE}" "${VEND}" "${HREV}" "${DATE}" "${FREV}" "${INFO}"
  198. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement