mkrescue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. # Qisda, Howard Hsu,2009/12/16
  3. # Move the actual make kernel steps to RescueFS/src/dlfw/mkzImage
  4. # 1) Only do below two steps here:
  5. # 3.Cat kernel with pre-made rescue file system.
  6. # 4.Pad the zeros to 4-byte boundar
  7. # 2) change first command line parameter to "project name"
  8. #
  9. # Qisda,Howard Hsu,2009/11/18
  10. # The script is used to create rescue.bin under ./arch/arm/boot/
  11. # Steps:
  12. # 1. Take rescue config and make its kernel
  13. # 2. Pad the zeros to kernel up to 1586688 bytes
  14. # 3. Cat kernel with pre-made rescue file system.
  15. # 4. Pad the zeros to 4-byte boundary,
  16. # the resulted is rescue.bin under ./arch/arm/boot/
  17. #
  18. # arguments: "skip" : do not remake the kernel, directly do rescue.bin packing
  19. #
  20. # Qisda,Howard Hsu,2009/11/20
  21. # restore the original .config to avoid affect the original kernel build .config
  22. # input
  23. # this file should be executable
  24. # output: rescue.bin
  25. rescueBin=./arch/arm/boot/rescue.bin
  26. # input: two files
  27. # 1-FS
  28. rescueFs=../RescueFS/img/urootfs.img
  29. let projectbuild=0
  30. # 2-Kernel, decide
  31. supportProjs=( qd060b00_movi bq060b00 sh060b00 qd090b00 as090b00 st060b00 )
  32. if [ $# ne 1 ]; then
  33. echo "usage: $0 (600 | 900 | project_name)"
  34. exit 1;
  35. else
  36. currProj=$1
  37. for name in ${supportProjs[@]}
  38. do
  39. echo "check for $name proj"
  40. if [ $currProj == $name ]; then
  41. echo "$currProj is supported"
  42. if [ -f "../RescueFS/img/uzImage_$currProj" ]; then
  43. rescueKernel="../RescueFS/img/uzImage_$currProj"
  44. else
  45. if [[ $currProj =~ 060 ]]; then
  46. rescueKernel=../RescueFS/img/uzImage600
  47. else
  48. rescueKernel=../RescueFS/img/uzImage900
  49. fi
  50. fi
  51. projectbuild=1
  52. break
  53. fi
  54. done
  55. if [ "$currProj" == "skip" ]; then
  56. echo "temp workaround for skip option"
  57. rescueKernel=../RescueFS/img/uzImage600
  58. projectbuild=1
  59. fi
  60. fi
  61. if [ "$projectbuild" -ne "1" ]; then
  62. echo "Invalid proj name: $currProj"
  63. echo "supported projs: ${supportProjs[@]}"
  64. fi
  65. # intermediate
  66. if [ ! -f "$rescueFs" ]; then
  67. echo "$rescueFs does not exist!!!"
  68. exit 1;
  69. fi
  70. if [ ! -f "$rescueKernel" ]; then
  71. echo "$rescueKernel does not exist!!!"
  72. exit 1;
  73. fi
  74. echo "cat kernel($rescueKernel) and Fs into rescue.bin"
  75. cat $rescueKernel $rescueFs > $rescueBin
  76. size=$(stat -c%s "$rescueBin")
  77. let padzero=4-size%4
  78. if [ padzero != 0 ]; then
  79. echo "step4: need $padzero to 4-byte align"
  80. dd if=/dev/zero of=./zero.bin bs=$padzero count=1
  81. cat ./zero.bin >> $rescueBin
  82. rm ./zero.bin
  83. fi