[package] fix wprobe build for arm on 3.2
[openwrt.git] / scripts / om2p-fwupgradecfg-gen.sh
1 #/bin/sh
2 #
3 # Copyright (C) 2011 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 usage() {
10 echo "Usage: $0 <out file path> <kernel path> <rootfs path>"
11 rm -f $CFG_OUT
12 exit 1
13 }
14
15 [ "$#" -lt 3 ] && usage
16
17 FLASH_BS=262144
18 CHECK_BS=65536
19 MAX_PART_SIZE=7168
20 CFG_OUT=$1
21
22 KERNEL_PATH=$2
23 KERNEL_FLASH_ADDR=0x1c0000
24 KERNEL_SIZE=$(stat -c%s "$KERNEL_PATH")
25 KERNEL_MD5=$(md5=$(md5sum $KERNEL_PATH); echo ${md5%% *})
26 KERNEL_PART_SIZE=$(size=$(($KERNEL_SIZE / $FLASH_BS)); [ $(($size * $FLASH_BS)) -lt $KERNEL_SIZE ] && size=$(($size + 1)); echo $(($size * $FLASH_BS / 1024)))
27
28 ROOTFS_PATH=$3
29 ROOTFS_FLASH_ADDR=$(addr=$(($KERNEL_FLASH_ADDR + ($KERNEL_PART_SIZE * 1024))); printf "0x%x" $addr)
30 ROOTFS_SIZE=$(stat -c%s "$ROOTFS_PATH")
31 ROOTFS_CHECK_BLOCKS=$((($ROOTFS_SIZE / $CHECK_BS) - 1))
32 ROOTFS_MD5=$(md5=$(dd if=$ROOTFS_PATH bs=$CHECK_BS count=$ROOTFS_CHECK_BLOCKS 2>&- | md5sum); echo ${md5%% *})
33 ROOTFS_CHECK_SIZE=$(printf '0x%x' $(($ROOTFS_CHECK_BLOCKS * $CHECK_BS)))
34 ROOTFS_PART_SIZE=$(($MAX_PART_SIZE - $KERNEL_PART_SIZE))
35
36 cat << EOF > $CFG_OUT
37 [vmlinux]
38 filename=kernel
39 md5sum=$KERNEL_MD5
40 flashaddr=$KERNEL_FLASH_ADDR
41 checksize=0x0
42 cmd_success=setenv bootseq 1,2; setenv kernel_size_1 $KERNEL_PART_SIZE; saveenv
43 cmd_fail=reset
44
45 [rootfs]
46 filename=rootfs
47 md5sum=$ROOTFS_MD5
48 flashaddr=$ROOTFS_FLASH_ADDR
49 checksize=$ROOTFS_CHECK_SIZE
50 cmd_success=setenv bootseq 1,2; setenv kernel_size_1 $KERNEL_PART_SIZE; setenv rootfs_size_1 $ROOTFS_PART_SIZE; saveenv
51 cmd_fail=reset
52 EOF
This page took 0.044299 seconds and 5 git commands to generate.