m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/sh
  2. app_name=dtu_t536
  3. app_flash=/app/"$app_name"
  4. app_flash_bak=/app/"$app_name".bak
  5. env_file=/tmp/env.dat
  6. if [ $? -eq 1 ]; then
  7. cat /proc/kmsg >> /tmp/kmsg &
  8. fi
  9. stty cols 168
  10. mode=${1:-start}
  11. # lsmod | grep "pps_driver" > /dev/null
  12. # if [ $? != 0 ]
  13. # then
  14. # insmod /app/pps_driver.ko
  15. # fi
  16. # lsmod | grep "sc1161y" > /dev/null
  17. # if [ $? != 0 ]
  18. # then
  19. # insmod /app/sc1161y.ko
  20. # fi
  21. if [ "$mode" = "stop" ]
  22. then
  23. echo stop E907....
  24. echo stop > /sys/class/remoteproc/remoteproc0/state
  25. PIDS=$(pidof "dtu_t536")
  26. if [ -n "$PIDS" ]; then
  27. echo "killing dtu_t536..."
  28. kill $PIDS
  29. fi
  30. fi
  31. if [ "$mode" = "start" ]
  32. then
  33. # show all kernel log messages
  34. echo 8 > /proc/sys/kernel/printk
  35. #
  36. echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore
  37. echo 1 > /proc/sys/net/ipv4/conf/eth1/arp_ignore
  38. echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
  39. #time zone
  40. export TZ="CST-8"
  41. #env file
  42. echo ethact=`printenv ethact` > $env_file
  43. echo ipaddr=`printenv ipaddr` >> $env_file
  44. echo netmask=`printenv netmask` >> $env_file
  45. echo gatewayip=`printenv gatewayip` >> $env_file
  46. echo ver_u_boot=`printenv version` >> $env_file
  47. echo "ver_kernel= Linux $(uname -r) $(cat /proc/version | grep -oE '[A-Z][a-z]{2} [A-Z][a-z]{2} [0-9]{1,2} [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z]{2,4} [0-9]{4}')" >> $env_file
  48. echo ver_root_fs=`cat /etc/rootfs-release` >> $env_file
  49. echo auth=`printenv auth 2>/dev/null` >> $env_file
  50. echo mt_port_on=`printenv mt_port_on 2>/dev/null` >> $env_file
  51. # echo mt_port_on=1 >> $env_file
  52. echo pid=`printenv pid 2>/dev/null` >> $env_file
  53. echo net1mac=`printenv net1mac 2>/dev/null` >> $env_file
  54. echo net2mac=`printenv net2mac 2>/dev/null` >> $env_file
  55. echo net3mac=`printenv net3mac 2>/dev/null` >> $env_file
  56. echo goose_enable=1 >> $env_file
  57. ifconfig eth1 192.168.64.240
  58. echo Load $app_flash from flash...
  59. #check crc
  60. crc_target -c $app_flash
  61. if [ $? = 0 ]
  62. then
  63. echo CRC Check OK!
  64. #未烧录临时用
  65. echo stop > /sys/class/remoteproc/remoteproc0/state
  66. echo start E907...
  67. echo start > /sys/class/remoteproc/remoteproc0/state
  68. cp -rf $app_flash /tmp
  69. chmod +x /tmp/$app_name
  70. # sunxi 20191113 备份ko文件
  71. if [ ! -e $app_flash_bak ]; then
  72. cp $app_flash $app_flash_bak
  73. fi
  74. cd /tmp
  75. export LD_LIBRARY_PATH=/usr/xenomai/lib/:/lib:/usr/lib:$LD_LIBRARY_PATH
  76. /tmp/$app_name >/dev/console 2>&1 &
  77. #./$app_name 2>&1 | tee /tmp/app_start.log &
  78. else
  79. echo CRC Check Error,Stop Load!
  80. # sunxi 20191113 恢复ko文件
  81. if [ -e $app_flash_bak ]; then
  82. crc_target -c $app_flash_bak
  83. if [ $? == 0 ]; then
  84. echo "应用程序恢复中, 请不要断电......"
  85. cp $app_flash_bak $app_flash
  86. echo "恢复成功, 自动重启......"
  87. sleep 1
  88. reboot -f
  89. fi
  90. fi
  91. fi
  92. fi