blob: 31e78084d1ec4a1ae05f2b9ae46e92989f7e00f1 [file] [log] [blame]
David Ng559a4232012-06-08 16:44:36 -07001#!/system/bin/sh
Duy Truong160ec0c2013-02-10 04:10:47 -08002# Copyright (c) 2012, The Linux Foundation. All rights reserved.
David Ng559a4232012-06-08 16:44:36 -07003#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met:
7# * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above
10# copyright notice, this list of conditions and the following
11# disclaimer in the documentation and/or other materials provided
12# with the distribution.
Duy Truong160ec0c2013-02-10 04:10:47 -080013# * Neither the name of The Linux Foundation nor the names of its
David Ng559a4232012-06-08 16:44:36 -070014# contributors may be used to endorse or promote products derived
15# from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29#
30
31# No path is set up at this point so we have to do it here.
32PATH=/sbin:/system/sbin:/system/bin:/system/xbin
33export PATH
34
35# Check for images and set up symlinks
36cd /firmware/image
37
38# Get the list of files in /firmware/image
39# for which sym links have to be created
40
David Ng8c196492012-08-13 22:26:59 -070041fwfiles=`ls modem* adsp* wcnss* mba*`
David Ng559a4232012-06-08 16:44:36 -070042
43# Check if the links with similar names
44# have been created in /system/etc/firmware
45
46cd /system/etc/firmware
47linksNeeded=0
48
49# For everyfile in fwfiles check if
50# the corresponding file exists
51for fwfile in $fwfiles; do
52
53 # if (condition) does not seem to work
54 # with the android shell. Therefore
55 # make do with case statements instead.
56 # if a file named $fwfile is present
57 # no need to create links. If the file
58 # with the name $fwfile is not present
59 # need to create links.
60
61 case `ls $fwfile` in
62 $fwfile)
63 continue;;
64 *)
65 # file with $fwfile does not exist
66 # need to create links
67 linksNeeded=1
68 break;;
69 esac
70
71done
72
73case $linksNeeded in
74 1)
75 cd /firmware/image
76
77 case `ls modem.mdt 2>/dev/null` in
78 modem.mdt)
79 for imgfile in modem*; do
80 ln -s /firmware/image/$imgfile /system/etc/firmware/$imgfile 2>/dev/null
81 done
David Ng3e317382012-09-07 22:21:00 -070082 ;;
David Ng559a4232012-06-08 16:44:36 -070083 *)
84 # trying to log here but nothing will be logged since it is
85 # early in the boot process. Is there a way to log this message?
86 log -p w -t PIL no modem image found;;
87 esac
88
89 case `ls adsp.mdt 2>/dev/null` in
90 adsp.mdt)
91 for imgfile in adsp*; do
92 ln -s /firmware/image/$imgfile /system/etc/firmware/$imgfile 2>/dev/null
93 done
David Ng3e317382012-09-07 22:21:00 -070094 ;;
David Ng559a4232012-06-08 16:44:36 -070095 *)
96 log -p w -t PIL no adsp image found;;
97 esac
98
99 case `ls wcnss.mdt 2>/dev/null` in
100 wcnss.mdt)
101 for imgfile in wcnss*; do
102 ln -s /firmware/image/$imgfile /system/etc/firmware/$imgfile 2>/dev/null
103 done
David Ng3e317382012-09-07 22:21:00 -0700104 ;;
David Ng559a4232012-06-08 16:44:36 -0700105 *)
106 log -p w -t PIL no wcnss image found;;
107 esac
108
109 case `ls mba.mdt 2>/dev/null` in
110 mba.mdt)
111 for imgfile in mba*; do
112 ln -s /firmware/image/$imgfile /system/etc/firmware/$imgfile 2>/dev/null
113 done
David Ng3e317382012-09-07 22:21:00 -0700114 ;;
David Ng559a4232012-06-08 16:44:36 -0700115 *)
116 log -p w -t PIL no mba image found;;
117 esac
118
David Ng3e317382012-09-07 22:21:00 -0700119 ;;
David Ng559a4232012-06-08 16:44:36 -0700120
121 *)
122 # Nothing to do. No links needed
David Ng3e317382012-09-07 22:21:00 -0700123 ;;
David Ng559a4232012-06-08 16:44:36 -0700124esac
125
126cd /