Bob Mottram 8 年之前
父節點
當前提交
bf40e04c80
共有 1 個檔案被更改,包括 48 行新增88 行删除
  1. 48
    88
      src/freedombone-image-hardware-setup

+ 48
- 88
src/freedombone-image-hardware-setup 查看文件

@@ -39,62 +39,34 @@ enable_serial_console() {
39 39
 }
40 40
 
41 41
 beaglebone_setup_boot() {
42
+    bbb_version=$1
43
+
42 44
     # Setup uEnv.txt
43 45
     if grep -q btrfs /etc/fstab ; then
44 46
         fstype=btrfs
45 47
     else
46 48
         fstype=ext4
47 49
     fi
48
-    kernelVersion=$(ls /usr/lib/*/am335x-boneblack.dtb | head -1 | cut -d/ -f4)
49
-    version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
50
-    initRd=initrd.img-$version
51
-    vmlinuz=vmlinuz-$version
52
-
53
-    # uEnv.txt for Beaglebone
54
-    # based on https://github.com/beagleboard/image-builder/blob/master/target/boot/beagleboard.org.txt
55
-    cat >> /boot/uEnv.txt <<EOF
56
-mmcroot=/dev/mmcblk0p2 ro
57
-mmcrootfstype=$fstype rootwait fixrtc
58
-mmcrootflags=subvol=@
59
-
60
-console=ttyO0,115200n8
61
-
62
-kernel_file=$vmlinuz
63
-initrd_file=$initRd
64
-
65
-loadaddr=0x80200000
66
-initrd_addr=0x81000000
67
-fdtaddr=0x80F80000
68
-
69
-initrd_high=0xffffffff
70
-fdt_high=0xffffffff
71
-
72
-loadkernel=load mmc \${mmcdev}:\${mmcpart} \${loadaddr} \${kernel_file}
73
-loadinitrd=load mmc \${mmcdev}:\${mmcpart} \${initrd_addr} \${initrd_file}; setenv initrd_size \${filesize}
74
-loadfdt=load mmc \${mmcdev}:\${mmcpart} \${fdtaddr} /dtbs/\${fdtfile}
75
-
76
-loadfiles=run loadkernel; run loadinitrd; run loadfdt
77
-mmcargs=setenv bootargs console=tty0 console=\${console} root=\${mmcroot} rootfstype=\${mmcrootfstype} rootflags=\${mmcrootflags}
78
-
79
-uenvcmd=run loadfiles; run mmcargs; bootz \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
80
-EOF
81
-
82
-    mkdir -p /boot/dtbs
83
-    cp /usr/lib/linux-image-*-armmp/* /boot/dtbs
84
-}
85
-
86
-beaglebone_wireless_setup_boot() {
87
-    # Setup uEnv.txt
88
-    if grep -q btrfs /etc/fstab ; then
89
-        fstype=btrfs
50
+    if [ ! $bbb_version ]; then
51
+        kernelVersion=$(ls /usr/lib/*/am335x-boneblack.dtb | head -1 | cut -d/ -f4)
90 52
     else
91
-        fstype=ext4
53
+        kernelVersion=$(ls /usr/lib/*/am335x-boneblack-${1}.dtb | head -1 | cut -d/ -f4)
92 54
     fi
93
-    kernelVersion=$(ls /usr/lib/*/am335x-boneblack-wireless.dtb | head -1 | cut -d/ -f4)
94 55
     version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
95 56
     initRd=initrd.img-$version
96 57
     vmlinuz=vmlinuz-$version
97 58
 
59
+    bbb_loadaddr='0x80200000'
60
+    bbb_initrd_addr='0x81000000'
61
+    bbb_fdtaddr='0x80F80000'
62
+    if [[ "$bbb_version" == "wireless" ]]; then
63
+        bbb_loadaddr='0x82000000'
64
+        bbb_initrd_addr='0x88080000'
65
+        bbb_fdtaddr='0x88000000'
66
+    fi
67
+
68
+    # uEnv.txt for Beaglebone
69
+    # based on https://github.com/beagleboard/image-builder/blob/master/target/boot/beagleboard.org.txt
98 70
     cat >> /boot/uEnv.txt <<EOF
99 71
 mmcroot=/dev/mmcblk0p2 ro
100 72
 mmcrootfstype=$fstype rootwait fixrtc
@@ -105,9 +77,9 @@ console=ttyO0,115200n8
105 77
 kernel_file=$vmlinuz
106 78
 initrd_file=$initRd
107 79
 
108
-loadaddr=0x82000000
109
-initrd_addr=0x88080000
110
-fdtaddr=0x88000000
80
+loadaddr=$bbb_loadaddr
81
+initrd_addr=$bbb_initrd_addr
82
+fdtaddr=$bbb_fdtaddr
111 83
 
112 84
 initrd_high=0xffffffff
113 85
 fdt_high=0xffffffff
@@ -136,6 +108,7 @@ beaglebone_flash() {
136 108
 }
137 109
 
138 110
 beaglebone_repack_kernel() {
111
+    bbb_version=$1
139 112
     # process installed kernel to create uImage, uInitrd, dtb
140 113
     # using flash-kernel would be a good approach, except it fails in the
141 114
     # cross build environment due to too many environment checks...
@@ -150,36 +123,11 @@ beaglebone_repack_kernel() {
150 123
 
151 124
     echo "info: repacking beaglebone kernel and initrd"
152 125
 
153
-    kernelVersion=$(ls /usr/lib/*/am335x-boneblack.dtb | head -1 | cut -d/ -f4)
154
-    version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
155
-    initRd=initrd.img-$version
156
-    vmlinuz=vmlinuz-$version
157
-
158
-    mkdir /tmp/initrd-repack
159
-
160
-    (cd /tmp/initrd-repack ; \
161
-     zcat /boot/$initRd | cpio -i ; \
162
-     rm -f conf/param.conf ; \
163
-     find . | cpio --quiet -o -H newc | \
164
-         gzip -9 > /boot/$initRd )
165
-
166
-    rm -rf /tmp/initrd-repack
167
-
168
-    (cd /boot ; \
169
-     cp /usr/lib/$kernelVersion/am335x-boneblack.dtb dtb ; \
170
-     cat $vmlinuz dtb >> temp-kernel ; \
171
-     mkimage -A arm -O linux -T kernel -n "Debian kernel ${version}" \
172
-             -C none -a 0x80200000 -e 0x80200000 -d temp-kernel uImage ; \
173
-     rm -f temp-kernel ; \
174
-     mkimage -A arm -O linux -T ramdisk -C gzip -a 0x81000000 -e 0x81000000 \
175
-             -n "Debian ramdisk ${version}" \
176
-             -d $initRd uInitrd )
177
-}
178
-
179
-beaglebone_wireless_repack_kernel() {
180
-    echo "info: repacking beaglebone wireless kernel and initrd"
181
-
182
-    kernelVersion=$(ls /usr/lib/*/am335x-boneblack-wireless.dtb | head -1 | cut -d/ -f4)
126
+    if [ ! $bbb_version ]; then
127
+        kernelVersion=$(ls /usr/lib/*/am335x-boneblack.dtb | head -1 | cut -d/ -f4)
128
+    else
129
+        kernelVersion=$(ls /usr/lib/*/am335x-boneblack-${1}.dtb | head -1 | cut -d/ -f4)
130
+    fi
183 131
     version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
184 132
     initRd=initrd.img-$version
185 133
     vmlinuz=vmlinuz-$version
@@ -194,15 +142,27 @@ beaglebone_wireless_repack_kernel() {
194 142
 
195 143
     rm -rf /tmp/initrd-repack
196 144
 
197
-    (cd /boot ; \
198
-     cp /usr/lib/$kernelVersion/am335x-boneblack-wireless.dtb dtb ; \
199
-     cat $vmlinuz dtb >> temp-kernel ; \
200
-     mkimage -A arm -O linux -T kernel -n "Debian kernel ${version}" \
201
-             -C none -a 0x82000000 -e 0x82000000 -d temp-kernel uImage ; \
202
-     rm -f temp-kernel ; \
203
-     mkimage -A arm -O linux -T ramdisk -C gzip -a 0x88080000 -e 0x88080000 \
204
-             -n "Debian ramdisk ${version}" \
205
-             -d $initRd uInitrd )
145
+    if [ ! $bbb_version ]; then
146
+        (cd /boot ; \
147
+         cp /usr/lib/$kernelVersion/am335x-boneblack.dtb dtb ; \
148
+         cat $vmlinuz dtb >> temp-kernel ; \
149
+         mkimage -A arm -O linux -T kernel -n "Debian kernel ${version}" \
150
+                 -C none -a 0x80200000 -e 0x80200000 -d temp-kernel uImage ; \
151
+         rm -f temp-kernel ; \
152
+         mkimage -A arm -O linux -T ramdisk -C gzip -a 0x81000000 -e 0x81000000 \
153
+                 -n "Debian ramdisk ${version}" \
154
+                 -d $initRd uInitrd )
155
+    else
156
+        (cd /boot ; \
157
+         cp /usr/lib/$kernelVersion/am335x-boneblack-${bbb_version}.dtb dtb ; \
158
+         cat $vmlinuz dtb >> temp-kernel ; \
159
+         mkimage -A arm -O linux -T kernel -n "Debian kernel ${version}" \
160
+                 -C none -a 0x82000000 -e 0x82000000 -d temp-kernel uImage ; \
161
+         rm -f temp-kernel ; \
162
+         mkimage -A arm -O linux -T ramdisk -C gzip -a 0x88080000 -e 0x88080000 \
163
+                 -n "Debian ramdisk ${version}" \
164
+                 -d $initRd uInitrd )
165
+    fi
206 166
 }
207 167
 
208 168
 a20_setup_boot() {
@@ -270,9 +230,9 @@ case "$MACHINE" in
270 230
         enable_serial_console ttyO0
271 231
         ;;
272 232
     beaglebonewifi)
273
-        beaglebone_wireless_setup_boot
233
+        beaglebone_setup_boot wireless
274 234
         beaglebone_flash
275
-        beaglebone_wireless_repack_kernel
235
+        beaglebone_repack_kernel wireless
276 236
         enable_serial_console ttyO0
277 237
         ;;
278 238
     cubietruck)