Bob Mottram 9 年之前
父節點
當前提交
1baba33ec2
沒有帳戶連結到提交者的電子郵件
共有 1 個檔案被更改,包括 133 行新增133 行删除
  1. 133
    133
      src/freedombone-image-hardware-setup

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

32
 export TEXTDOMAINDIR="/usr/share/locale"
32
 export TEXTDOMAINDIR="/usr/share/locale"
33
 
33
 
34
 enable_serial_console() {
34
 enable_serial_console() {
35
-	# By default, spawn a console on the serial port
36
-	device="$1"
37
-	echo $"Adding a getty on the serial port"
38
-	echo "T0:12345:respawn:/sbin/getty -L $device 115200 vt100" >> /etc/inittab
35
+    # By default, spawn a console on the serial port
36
+    device="$1"
37
+    echo $"Adding a getty on the serial port"
38
+    echo "T0:12345:respawn:/sbin/getty -L $device 115200 vt100" >> /etc/inittab
39
 }
39
 }
40
 
40
 
41
 beaglebone_setup_boot() {
41
 beaglebone_setup_boot() {
42
-	# Setup uEnv.txt
43
-	if grep -q btrfs /etc/fstab ; then
44
-		fstype=btrfs
45
-	else
46
-		fstype=ext4
47
-	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
42
+    # Setup uEnv.txt
43
+    if grep -q btrfs /etc/fstab ; then
44
+        fstype=btrfs
45
+    else
46
+        fstype=ext4
47
+    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
56
 mmcroot=/dev/mmcblk0p2 ro
57
 mmcrootfstype=$fstype rootwait fixrtc
57
 mmcrootfstype=$fstype rootwait fixrtc
58
 mmcrootflags=subvol=@
58
 mmcrootflags=subvol=@
79
 uenvcmd=run loadfiles; run mmcargs; bootz \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
79
 uenvcmd=run loadfiles; run mmcargs; bootz \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
80
 EOF
80
 EOF
81
 
81
 
82
-	mkdir -p /boot/dtbs
83
-	cp /usr/lib/linux-image-*-armmp/* /boot/dtbs
82
+    mkdir -p /boot/dtbs
83
+    cp /usr/lib/linux-image-*-armmp/* /boot/dtbs
84
 }
84
 }
85
 
85
 
86
 beaglebone_flash() {
86
 beaglebone_flash() {
87
-	# allow flash-kernel to work without valid /proc contents
88
-	# ** this doesn't *really* work, since there are too many checks
89
-	#    that fail in an emulated environment!  We'll have to do it by
90
-	#    hand below anyway...
91
-	export FK_MACHINE="TI AM335x BeagleBone"
92
-	apt-get install -y flash-kernel
87
+    # allow flash-kernel to work without valid /proc contents
88
+    # ** this doesn't *really* work, since there are too many checks
89
+    #    that fail in an emulated environment!  We'll have to do it by
90
+    #    hand below anyway...
91
+    export FK_MACHINE="TI AM335x BeagleBone"
92
+    apt-get install -y flash-kernel
93
 }
93
 }
94
 
94
 
95
 beaglebone_repack_kernel() {
95
 beaglebone_repack_kernel() {
96
-	# process installed kernel to create uImage, uInitrd, dtb
97
-	# using flash-kernel would be a good approach, except it fails in the
98
-	# cross build environment due to too many environment checks...
99
-	#FK_MACHINE="TI AM335x BeagleBone" flash-kernel
100
-	#  so, let's do it manually...
101
-
102
-	# flash-kernel's hook-functions provided to mkinitramfs have the
103
-	# unfortunate side-effect of creating /conf/param.conf in the initrd
104
-	# when run from our emulated chroot environment, which means our root=
105
-	# on the kernel command line is completely ignored!  repack the initrd
106
-	# to remove this evil...
107
-
108
-	echo "info: repacking beaglebone kernel and initrd"
109
-
110
-	kernelVersion=$(ls /usr/lib/*/am335x-boneblack.dtb | head -1 | cut -d/ -f4)
111
-	version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
112
-	initRd=initrd.img-$version
113
-	vmlinuz=vmlinuz-$version
114
-
115
-	mkdir /tmp/initrd-repack
116
-
117
-	(cd /tmp/initrd-repack ; \
118
-	 zcat /boot/$initRd | cpio -i ; \
119
-	 rm -f conf/param.conf ; \
120
-	 find . | cpio --quiet -o -H newc | \
121
-		 gzip -9 > /boot/$initRd )
122
-
123
-	rm -rf /tmp/initrd-repack
124
-
125
-	(cd /boot ; \
126
-	 cp /usr/lib/$kernelVersion/am335x-boneblack.dtb dtb ; \
127
-	 cat $vmlinuz dtb >> temp-kernel ; \
128
-	 mkimage -A arm -O linux -T kernel -n "Debian kernel ${version}" \
129
-			 -C none -a 0x80200000 -e 0x80200000 -d temp-kernel uImage ; \
130
-	 rm -f temp-kernel ; \
131
-	 mkimage -A arm -O linux -T ramdisk -C gzip -a 0x81000000 -e 0x81000000 \
132
-			 -n "Debian ramdisk ${version}" \
133
-			 -d $initRd uInitrd )
96
+    # process installed kernel to create uImage, uInitrd, dtb
97
+    # using flash-kernel would be a good approach, except it fails in the
98
+    # cross build environment due to too many environment checks...
99
+    #FK_MACHINE="TI AM335x BeagleBone" flash-kernel
100
+    #  so, let's do it manually...
101
+
102
+    # flash-kernel's hook-functions provided to mkinitramfs have the
103
+    # unfortunate side-effect of creating /conf/param.conf in the initrd
104
+    # when run from our emulated chroot environment, which means our root=
105
+    # on the kernel command line is completely ignored!  repack the initrd
106
+    # to remove this evil...
107
+
108
+    echo "info: repacking beaglebone kernel and initrd"
109
+
110
+    kernelVersion=$(ls /usr/lib/*/am335x-boneblack.dtb | head -1 | cut -d/ -f4)
111
+    version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
112
+    initRd=initrd.img-$version
113
+    vmlinuz=vmlinuz-$version
114
+
115
+    mkdir /tmp/initrd-repack
116
+
117
+    (cd /tmp/initrd-repack ; \
118
+     zcat /boot/$initRd | cpio -i ; \
119
+     rm -f conf/param.conf ; \
120
+     find . | cpio --quiet -o -H newc | \
121
+         gzip -9 > /boot/$initRd )
122
+
123
+    rm -rf /tmp/initrd-repack
124
+
125
+    (cd /boot ; \
126
+     cp /usr/lib/$kernelVersion/am335x-boneblack.dtb dtb ; \
127
+     cat $vmlinuz dtb >> temp-kernel ; \
128
+     mkimage -A arm -O linux -T kernel -n "Debian kernel ${version}" \
129
+             -C none -a 0x80200000 -e 0x80200000 -d temp-kernel uImage ; \
130
+     rm -f temp-kernel ; \
131
+     mkimage -A arm -O linux -T ramdisk -C gzip -a 0x81000000 -e 0x81000000 \
132
+             -n "Debian ramdisk ${version}" \
133
+             -d $initRd uInitrd )
134
 }
134
 }
135
 
135
 
136
 odroidc2_setup_boot() {
136
 odroidc2_setup_boot() {
137
-	dtb="$1"
138
-
139
-	# Setup uEnv.txt
140
-	if grep -q btrfs /etc/fstab ; then
141
-		fstype=btrfs
142
-	else
143
-		fstype=ext4
144
-	fi
145
-	kernelVersion=$(ls /usr/lib/*/${dtb}.dtb | head -1 | cut -d/ -f4)
146
-	version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
147
-	initRd=initrd.img-$version
148
-	vmlinuz=vmlinuz-$version
149
-
150
-	# based on http://odroid.com/dokuwiki/doku.php?id=en:c2_building_u-boot
151
-	cat >> /boot/uEnv.txt <<EOF
137
+    dtb="$1"
138
+
139
+    # Setup uEnv.txt
140
+    if grep -q btrfs /etc/fstab ; then
141
+        fstype=btrfs
142
+    else
143
+        fstype=ext4
144
+    fi
145
+    kernelVersion=$(ls /usr/lib/*/${dtb}.dtb | head -1 | cut -d/ -f4)
146
+    version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
147
+    initRd=initrd.img-$version
148
+    vmlinuz=vmlinuz-$version
149
+
150
+    # based on http://odroid.com/dokuwiki/doku.php?id=en:c2_building_u-boot
151
+    cat >> /boot/uEnv.txt <<EOF
152
 mmcroot=/dev/mmcblk0p2 ro
152
 mmcroot=/dev/mmcblk0p2 ro
153
 mmcrootfstype=$fstype rootwait fixrtc
153
 mmcrootfstype=$fstype rootwait fixrtc
154
 mmcrootflags=subvol=@
154
 mmcrootflags=subvol=@
178
 uenvcmd=run loadfiles; run mmcargs; booti \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
178
 uenvcmd=run loadfiles; run mmcargs; booti \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
179
 EOF
179
 EOF
180
 
180
 
181
-	mkdir -p /boot/dtbs
182
-	cp /usr/lib/linux-image-*-armmp/* /boot/dtbs
181
+    mkdir -p /boot/dtbs
182
+    cp /usr/lib/linux-image-*-armmp/* /boot/dtbs
183
 }
183
 }
184
 
184
 
185
 a20_setup_boot() {
185
 a20_setup_boot() {
186
-	dtb="$1"
187
-
188
-	# Setup boot.cmd
189
-	if grep -q btrfs /etc/fstab ; then
190
-		fstype=btrfs
191
-	else
192
-		fstype=ext4
193
-	fi
194
-	kernelVersion=$(ls /usr/lib/*/$dtb | head -1 | cut -d/ -f4)
195
-	version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
196
-	initRd=initrd.img-$version
197
-	vmlinuz=vmlinuz-$version
198
-
199
-	# Create boot.cmd
200
-	cat >> /boot/boot.cmd <<EOF
186
+    dtb="$1"
187
+
188
+    # Setup boot.cmd
189
+    if grep -q btrfs /etc/fstab ; then
190
+        fstype=btrfs
191
+    else
192
+        fstype=ext4
193
+    fi
194
+    kernelVersion=$(ls /usr/lib/*/$dtb | head -1 | cut -d/ -f4)
195
+    version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
196
+    initRd=initrd.img-$version
197
+    vmlinuz=vmlinuz-$version
198
+
199
+    # Create boot.cmd
200
+    cat >> /boot/boot.cmd <<EOF
201
 setenv mmcdev 0
201
 setenv mmcdev 0
202
 setenv mmcpart 1
202
 setenv mmcpart 1
203
 
203
 
228
 run loadfiles; run mmcargs; bootz \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
228
 run loadfiles; run mmcargs; bootz \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
229
 EOF
229
 EOF
230
 
230
 
231
-	# boot.scr for Allwinner A20 based device
232
-	mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
231
+    # boot.scr for Allwinner A20 based device
232
+    mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
233
 
233
 
234
-	# Copy all DTBs
235
-	mkdir -p /boot/dtbs
236
-	cp /usr/lib/$kernelVersion/* /boot/dtbs
234
+    # Copy all DTBs
235
+    mkdir -p /boot/dtbs
236
+    cp /usr/lib/$kernelVersion/* /boot/dtbs
237
 
237
 
238
-	# extra boot modules
239
-	echo "rtc_sunxi" >> /etc/initramfs-tools/modules
238
+    # extra boot modules
239
+    echo "rtc_sunxi" >> /etc/initramfs-tools/modules
240
 }
240
 }
241
 
241
 
242
 case "$MACHINE" in
242
 case "$MACHINE" in
243
-	beaglebone)
244
-		beaglebone_setup_boot
245
-		beaglebone_flash
246
-		beaglebone_repack_kernel
247
-		enable_serial_console ttyO0
248
-		;;
249
-	odroid-c2)
250
-		odroidc2_setup_boot meson64_odroidc2
251
-		enable_serial_console ttyO0
252
-		;;
253
-	cubietruck)
254
-		a20_setup_boot sun7i-a20-cubietruck.dtb
255
-		enable_serial_console ttyS0
256
-		;;
257
-	a20-olinuxino-lime)
258
-		a20_setup_boot sun7i-a20-olinuxino-lime.dtb
259
-		enable_serial_console ttyS0
260
-		;;
261
-	a20-olinuxino-lime2)
262
-		a20_setup_boot sun7i-a20-olinuxino-lime2.dtb
263
-		enable_serial_console ttyS0
264
-		;;
265
-	a20-olinuxino-micro)
266
-		a20_setup_boot sun7i-a20-olinuxino-micro.dtb
267
-		enable_serial_console ttyS0
268
-		;;
269
-	cubieboard2)
270
-		a20_setup_boot sun7i-a20-cubieboard2.dtb
271
-		enable_serial_console ttyS0
272
-		;;
243
+    beaglebone)
244
+        beaglebone_setup_boot
245
+        beaglebone_flash
246
+        beaglebone_repack_kernel
247
+        enable_serial_console ttyO0
248
+        ;;
249
+    odroid-c2)
250
+        odroidc2_setup_boot meson64_odroidc2
251
+        enable_serial_console ttyO0
252
+        ;;
253
+    cubietruck)
254
+        a20_setup_boot sun7i-a20-cubietruck.dtb
255
+        enable_serial_console ttyS0
256
+        ;;
257
+    a20-olinuxino-lime)
258
+        a20_setup_boot sun7i-a20-olinuxino-lime.dtb
259
+        enable_serial_console ttyS0
260
+        ;;
261
+    a20-olinuxino-lime2)
262
+        a20_setup_boot sun7i-a20-olinuxino-lime2.dtb
263
+        enable_serial_console ttyS0
264
+        ;;
265
+    a20-olinuxino-micro)
266
+        a20_setup_boot sun7i-a20-olinuxino-micro.dtb
267
+        enable_serial_console ttyS0
268
+        ;;
269
+    cubieboard2)
270
+        a20_setup_boot sun7i-a20-cubieboard2.dtb
271
+        enable_serial_console ttyS0
272
+        ;;
273
 esac
273
 esac