-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathbuild.sh
executable file
·2921 lines (2564 loc) · 88 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
set -eE
export LC_ALL=C
export LD_LIBRARY_PATH=
RECORD_IFS="$IFS"
function unset_env_config_rk() {
local tmp_file=$(mktemp)
env | grep -oh "^RK_.*=" >$tmp_file || true
source $tmp_file
rm -f $tmp_file
}
unset_env_config_rk
################################################################################
# Global Variable Configure
################################################################################
_FDS="\\ \n"
cmd=$(realpath $0)
COMMON_DIR=$(dirname $cmd)
PROJECT_TOP_DIR=$(realpath $COMMON_DIR/)
SDK_ROOT_DIR=$(realpath $COMMON_DIR/..)
SDK_SYSDRV_DIR=${SDK_ROOT_DIR}/sysdrv
SDK_MEDIA_DIR=${SDK_ROOT_DIR}/media
SDK_APP_DIR=${PROJECT_TOP_DIR}/app
BOARD_CONFIG=$SDK_ROOT_DIR/.BoardConfig.mk
TARGET_PRODUCT_DIR=${PROJECT_TOP_DIR}/cfg
GLOBAL_ROOT_FILESYSTEM_NAME=rootfs
GLOBAL_OEM_NAME=oem
GLOBAL_FS_TYPE_SUFFIX=_fs_type
GLOBAL_INITRAMFS_BOOT_NAME=""
GLOBAL_PARTITIONS=""
GLOBAL_SDK_VERSION=""
WIFI_NEW_CONF=${SDK_APP_DIR}/wifi_app/wpa_supplicant_new.conf
WIFI_CONF=${SDK_APP_DIR}/wifi_app/wpa_supplicant.conf
BUILDROOT_PATH=${SDK_SYSDRV_DIR}/source/buildroot/buildroot-2023.02.6
BUILDROOT_CONFIG_FILE=${BUILDROOT_PATH}/.config
SDK_CONFIG_DIR=${SDK_ROOT_DIR}/config
DTS_CONFIG=${SDK_CONFIG_DIR}/dts_config
KERNEL_DEFCONFIG=${SDK_CONFIG_DIR}/kernel_defconfig
BUILDROOT_DEFCONFIG=${SDK_CONFIG_DIR}/buildroot_defconfig
UBUNTU_DIR=${SDK_SYSDRV_DIR}/tools/board/ubuntu
KERNEL_PATH=${SDK_SYSDRV_DIR}/source/kernel
UBOOT_PATH=${SDK_SYSDRV_DIR}/source/uboot/u-boot
#for custom rootfs
CUSTOM_ROOT=${SDK_ROOT_DIR}/custom_root
export RK_JOBS=$(($(getconf _NPROCESSORS_ONLN) / 2 + 1))
export RK_BUILD_VERSION_TYPE=RELEASE
export SDK_ROOT_DIR=$SDK_ROOT_DIR
export RK_PROJECT_OUTPUT=$SDK_ROOT_DIR/output/out
export RK_PROJECT_TOP_DIR=$PROJECT_TOP_DIR
export RK_PROJECT_PATH_MEDIA=$SDK_ROOT_DIR/output/out/media_out
export RK_PROJECT_PATH_SYSDRV=$SDK_ROOT_DIR/output/out/sysdrv_out
export RK_PROJECT_PATH_APP=$SDK_ROOT_DIR/output/out/app_out
export RK_PROJECT_PATH_MCU=$SDK_ROOT_DIR/output/out/mcu_out
export RK_PROJECT_PATH_PC_TOOLS=$SDK_ROOT_DIR/output/out/sysdrv_out/pc
export RK_PROJECT_OUTPUT_IMAGE=$SDK_ROOT_DIR/output/image
export RK_PROJECT_PATH_RAMDISK=$SDK_ROOT_DIR/output/out/ramdisk
export RK_PROJECT_PATH_FASTBOOT=$SDK_ROOT_DIR/output/out/fastboot
export RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS=$RK_PROJECT_PATH_RAMDISK/tiny_rootfs
export PATH=$RK_PROJECT_PATH_PC_TOOLS:$PATH
export RK_PROJECT_FILE_ROOTFS_SCRIPT=$RK_PROJECT_OUTPUT/S20linkmount
export RK_PROJECT_FILE_OEM_SCRIPT=$RK_PROJECT_OUTPUT/S21appinit
export RK_PROJECT_FILE_RECOVERY_SCRIPT=$RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS/etc/init.d/S15linkmount_recovery
export RK_PROJECT_FILE_RECOVERY_LUNCH_SCRIPT=$RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS/etc/init.d/S99lunch_recovery
export RK_PROJECT_FILE_SYSDRV_MCU_BIN=$RK_PROJECT_PATH_MCU/rtthread.bin
export RK_PROJECT_TOOLS_MKFS_SQUASHFS=mkfs_squashfs.sh
export RK_PROJECT_TOOLS_MKFS_EXT4=mkfs_ext4.sh
export RK_PROJECT_TOOLS_MKFS_UBIFS=mkfs_ubi.sh
export RK_PROJECT_TOOLS_MKFS_JFFS2=mkfs_jffs2.sh
export RK_PROJECT_TOOLS_MKFS_ROMFS=mkfs_romfs.sh
export RK_PROJECT_TOOLS_MKFS_EROFS=mkfs_erofs.sh
export RK_PROJECT_TOOLS_MKFS_INITRAMFS=mkfs_initramfs.sh
RK_PROJECT_ROOTFS_TYPE=""
OTA_SCRIPT_PATH=$RK_PROJECT_PATH_RAMDISK
ENV_CFG_FILE=$RK_PROJECT_OUTPUT_IMAGE/.env.txt
ENV_SIZE=""
ENV_OFFSET=""
################################################################################
# Public Configure
################################################################################
C_BLACK="\e[30;1m"
C_RED="\e[31;1m"
C_GREEN="\e[32;1m"
C_YELLOW="\e[33;1m"
C_BLUE="\e[34;1m"
C_PURPLE="\e[35;1m"
C_CYAN="\e[36;1m"
C_WHITE="\e[37;1m"
C_NORMAL="\033[0m"
function msg_info() {
echo -e "${C_GREEN}[$(basename $0):info] $1${C_NORMAL}"
}
function msg_warn() {
echo -e "${C_YELLOW}[$(basename $0):warn] $1${C_NORMAL}"
}
function msg_error() {
echo -e "${C_RED}[$(basename $0):error] $1${C_NORMAL}"
}
err_handler() {
ret=$?
[ "$ret" -eq 0 ] && return
msg_error "Running ${FUNCNAME[1]} failed!"
msg_error "exit code $ret from line ${BASH_LINENO[0]}:"
msg_info " $BASH_COMMAND"
exit $ret
}
function finish_build() {
msg_info "Running ${FUNCNAME[1]} succeeded."
cd $PROJECT_TOP_DIR
}
function check_config() {
unset missing
for var in $@; do
eval [ \$$var ] && continue
missing="$missing $var"
done
[ -z "$missing" ] && return 0
msg_info "Skipping ${FUNCNAME[1]} for missing configs: $missing."
return 1
}
function __IS_IN_ARRAY() {
local value="$1"
shift
for item in "$@"; do
if [[ "$item" == "$value" ]]; then
return 0
fi
done
return 1
}
function choose_target_board() {
local LF_HARDWARE=("RV1103_Luckfox_Pico"
"RV1103_Luckfox_Pico_Mini_A"
"RV1103_Luckfox_Pico_Mini_B"
"RV1103_Luckfox_Pico_Plus"
"RV1103_Luckfox_Pico_WebBee"
"RV1106_Luckfox_Pico_Pro"
"RV1106_Luckfox_Pico_Max"
"RV1106_Luckfox_Pico_Ultra"
"RV1106_Luckfox_Pico_Ultra_W")
local LF_BOOT_MEDIA=("SD_CARD" "SPI_NAND" "EMMC")
local LF_SYSTEM=("Buildroot" "Ubuntu" "Custom")
local cnt=0 space8=" "
# Get Hardware Version
local LUNCH_NUM=0
local HW_INDEX
echo "You're building on Linux"
echo -e "${C_GREEN} "${space8}Lunch menu...pick the Luckfox Pico hardware version:"${C_NORMAL}"
echo -e "${C_GREEN} "${space8}选择 Luckfox Pico 硬件版本:"${C_NORMAL}"
echo "${space8}${space8}[${LUNCH_NUM}] RV1103_Luckfox_Pico"
LUNCH_NUM=$((LUNCH_NUM + 1))
echo "${space8}${space8}[${LUNCH_NUM}] RV1103_Luckfox_Pico_Mini_A"
LUNCH_NUM=$((LUNCH_NUM + 1))
echo "${space8}${space8}[${LUNCH_NUM}] RV1103_Luckfox_Pico_Mini_B"
LUNCH_NUM=$((LUNCH_NUM + 1))
echo "${space8}${space8}[${LUNCH_NUM}] RV1103_Luckfox_Pico_Plus"
LUNCH_NUM=$((LUNCH_NUM + 1))
echo "${space8}${space8}[${LUNCH_NUM}] RV1103_Luckfox_Pico_WebBee"
LUNCH_NUM=$((LUNCH_NUM + 1))
echo "${space8}${space8}[${LUNCH_NUM}] RV1106_Luckfox_Pico_Pro"
LUNCH_NUM=$((LUNCH_NUM + 1))
echo "${space8}${space8}[${LUNCH_NUM}] RV1106_Luckfox_Pico_Max"
LUNCH_NUM=$((LUNCH_NUM + 1))
echo "${space8}${space8}[${LUNCH_NUM}] RV1106_Luckfox_Pico_Ultra"
LUNCH_NUM=$((LUNCH_NUM + 1))
echo "${space8}${space8}[${LUNCH_NUM}] RV1106_Luckfox_Pico_Ultra_W"
LUNCH_NUM=$((LUNCH_NUM + 1))
echo "${space8}${space8}[${LUNCH_NUM}] custom"
read -p "Which would you like? [0~${LUNCH_NUM}][default:0]: " HW_INDEX
if [ -z "$HW_INDEX" ]; then
HW_INDEX=0
fi
if ! [[ "$HW_INDEX" =~ ^[0-9]+$ ]]; then
msg_error "Error: HW_INDEX is not a number."
exit 1
else
if (($HW_INDEX < 0 || $HW_INDEX > $LUNCH_NUM)); then
msg_error "Error: HW_INDEX is not in the range 0-$LUNCH_NUM."
exit 1
elif [ $HW_INDEX == $LUNCH_NUM ]; then
for item in ${RK_TARGET_BOARD_ARRAY[@]}; do
local f0 boot_medium ddr sys_ver hardware_version product_name
echo "----------------------------------------------------------------"
echo -e "${C_GREEN}$cnt. $item${C_NORMAL}"
cnt=$((cnt + 1))
f0=${item#BoardConfig*-}
boot_medium=${f0%%-*}
f0=${f0#*-}
sys_ver=${f0%%-*}
f0=${f0#*-}
hardware_version=${f0%%-*}
f0=${f0#*-}
product_name=${f0%%-*}
product_name=${product_name%%.mk}
echo "${space8}${space8} boot medium(启动介质): ${boot_medium}"
echo "${space8}${space8} system version(系统版本): ${sys_ver}"
echo "${space8}${space8} hardware version(硬件版本): ${hardware_version}"
echo "${space8}${space8} application(应用场景): ${product_name}"
echo "----------------------------------------------------------------"
echo ""
done
local INDEX
read -p "Which would you like? [default:0]: " INDEX
INDEX=$((${INDEX:-0}))
if [ $RK_TARGET_BOARD_ARRAY_LEN -lt $INDEX ]; then
msg_error "Input index is error"
finish_build
exit 0
fi
if echo $INDEX | grep -vq [^0-9]; then
RK_BUILD_TARGET_BOARD="${RK_TARGET_BOARD_ARRAY[$INDEX]}"
else
RK_BUILD_TARGET_BOARD="${RK_TARGET_BOARD_ARRAY[0]}"
msg_info "Lunching for Default ${RK_BUILD_TARGET_BOARD} boards..."
return
fi
return
fi
fi
# Get Boot Medium Version
local BM_INDEX MAX_BM_INDEX
echo -e "${C_GREEN} "${space8}Lunch menu...pick the boot medium:"${C_NORMAL}"
echo -e "${C_GREEN} "${space8}选择启动媒介:"${C_NORMAL}"
#if (("$HW_INDEX" >= 0 && "$HW_INDEX" <= 1)); then
# echo "${space8}${space8}[0] SD_CARD"
# read -p "Which would you like? [0][default:0]: " BM_INDEX
# MAX_BM_INDEX=0
#elif (("$HW_INDEX" >= 2 && "$HW_INDEX" <= 5)); then
# echo "${space8}${space8}[0] SD_CARD"
# echo "${space8}${space8}[1] SPI_NAND"
# read -p "Which would you like? [0~1][default:0]: " BM_INDEX
# MAX_BM_INDEX=1
#elif (("$HW_INDEX" >= 6 && "$HW_INDEX" <= 7)); then
# echo "${space8}${space8}[0] EMMC"
# read -p "Which would you like? [0][default:0]: " BM_INDEX
# MAX_BM_INDEX=0
#fi
range_sd_card=(0 1)
range_sd_card_spi_nand=(2 3 4 5 6)
range_emmc=(7 8)
if __IS_IN_ARRAY "$HW_INDEX" "${range_sd_card[@]}"; then
echo "${space8}${space8}[0] SD_CARD"
read -p "Which would you like? [0][default:0]: " BM_INDEX
MAX_BM_INDEX=0
elif __IS_IN_ARRAY "$HW_INDEX" "${range_sd_card_spi_nand[@]}"; then
echo "${space8}${space8}[0] SD_CARD"
echo "${space8}${space8}[1] SPI_NAND"
read -p "Which would you like? [0~1][default:0]: " BM_INDEX
MAX_BM_INDEX=1
elif __IS_IN_ARRAY "$HW_INDEX" "${range_emmc[@]}"; then
echo "${space8}${space8}[0] EMMC"
read -p "Which would you like? [0][default:0]: " BM_INDEX
MAX_BM_INDEX=0
else
echo "Invalid HW_INDEX: $HW_INDEX"
exit 1
fi
# Default is 0
if [ -z "$BM_INDEX" ]; then
BM_INDEX=0
fi
if ! [[ "$BM_INDEX" =~ ^[0-9]+$ ]]; then
msg_error "Error: BM_INDEX is not a number."
exit 1
else
if (($BM_INDEX < 0 || $BM_INDEX > $MAX_BM_INDEX)); then
msg_error "Error: BM_INDEX is not in the range ."
exit 1
fi
fi
# Get System Version
local SYS_INDEX MAX_SYS_INDEX
echo -e "${C_GREEN} "${space8}Lunch menu...pick the system version:"${C_NORMAL}"
echo -e "${C_GREEN} "${space8}选择系统版本:"${C_NORMAL}"
if (("$BM_INDEX" == 1)); then
echo "${space8}${space8}[0] Buildroot(Support Rockchip official features) "
read -p "Which would you like? [0~1][default:0]: " SYS_INDEX
MAX_SYS_INDEX=0
elif (("$BM_INDEX" == 0)); then
echo "${space8}${space8}[0] Buildroot(Support Rockchip official features) "
echo "${space8}${space8}[1] Ubuntu(Support for the apt package management tool)"
read -p "Which would you like? [0~1][default:0]: " SYS_INDEX
MAX_SYS_INDEX=1
fi
if [ -z "$SYS_INDEX" ]; then
SYS_INDEX=0
fi
if ! [[ "$SYS_INDEX" =~ ^[0-9]+$ ]]; then
msg_error "Error: SYS_INDEX is not a number."
exit 1
else
if (($SYS_INDEX < 0 || $SYS_INDEX > $MAX_SYS_INDEX)); then
msg_error "Error: SYS_INDEX is not in the range 0-1."
exit 1
fi
fi
# EMMC
if (("$HW_INDEX" >= range_emmc[0] && "$HW_INDEX" <= range_emmc[${#range_emmc[@]}-1])); then
BM_INDEX=$BM_INDEX+2 #EMMC
fi
RK_BUILD_TARGET_BOARD="BoardConfig_IPC/BoardConfig-${LF_BOOT_MEDIA[$BM_INDEX]}-${LF_SYSTEM[$SYS_INDEX]}-${LF_HARDWARE[$HW_INDEX]}-IPC.mk"
}
function build_select_board() {
RK_TARGET_BOARD_ARRAY=($(
cd ${TARGET_PRODUCT_DIR}/
ls BoardConfig*.mk BoardConfig_*/BoardConfig*.mk | sort
))
RK_TARGET_BOARD_ARRAY_LEN=${#RK_TARGET_BOARD_ARRAY[@]}
if [ $RK_TARGET_BOARD_ARRAY_LEN -eq 0 ]; then
msg_error "No available Board Config"
return
fi
choose_target_board
if [ -f "$TARGET_PRODUCT_DIR/$RK_BUILD_TARGET_BOARD" ]; then
msg_info "Lunching for Default ${RK_BUILD_TARGET_BOARD} boards..."
else
msg_error "${RK_BUILD_TARGET_BOARD} is not currently supported"
exit 0
fi
if [ -n $BOARD_CONFIG ]; then
rm -f $BOARD_CONFIG
fi
ln -rfs $TARGET_PRODUCT_DIR/$RK_BUILD_TARGET_BOARD $BOARD_CONFIG
#cp $TARGET_PRODUCT_DIR/$RK_BUILD_TARGET_BOARD $BOARD_CONFIG
msg_info "switching to board: $(realpath $BOARD_CONFIG)"
if [ "$1" = "LUNCH-FORCE" ]; then
finish_build
exit 0
fi
}
function save_board_config() {
if [ -f $TARGET_PRODUCT_DIR/$ ]; then
cp $$BOARD_CONFIG $TARGET_PRODUCT_DIR/BoardConfig_IPC/$LF_ORIGIN_BOARD_CONFIG
fi
}
function unset_board_config_all() {
local tmp_file=$(mktemp)
grep -oh "^export.*RK_.*=" $(find cfg -name "BoardConfig*.mk") >$tmp_file
source $tmp_file
rm -f $tmp_file
}
function usagemedia() {
check_config RK_KERNEL_DTS RK_KERNEL_DEFCONFIG || return 0
echo -e "make -C ${SDK_MEDIA_DIR}"
finish_build
}
function usagesysdrv() {
check_config RK_KERNEL_DTS RK_KERNEL_DEFCONFIG || return 0
usageuboot
usagekernel
usagerootfs
finish_build
}
function usagekernel() {
check_config RK_KERNEL_DTS RK_KERNEL_DEFCONFIG || return 0
echo -e "make kernel -C ${SDK_SYSDRV_DIR} ${_FDS} \
KERNEL_CFG=${RK_KERNEL_DEFCONFIG} ${_FDS} \
KERNEL_DTS=${RK_KERNEL_DTS} ${_FDS} \
KERNEL_CFG_FRAGMENT=${RK_KERNEL_DEFCONFIG_FRAGMENT}"
finish_build
}
function usageuboot() {
check_config RK_UBOOT_DEFCONFIG || return 0
echo -e "make uboot -C ${SDK_SYSDRV_DIR} ${_FDS} \
UBOOT_CFG=${RK_UBOOT_DEFCONFIG} ${_FDS} \
UBOOT_CFG_FRAGMENT=${RK_UBOOT_DEFCONFIG_FRAGMENT}"
finish_build
}
function usagerootfs() {
# check_config RK_ROOTFS_IMG || return 0
echo -e "make rootfs -C ${SDK_SYSDRV_DIR} "
finish_build
}
function usage() {
echo "Usage: build.sh [OPTIONS]"
echo "Available options:"
echo "lunch -Select Board Configure"
echo "env -build env"
echo "meta -build meta (optional)"
echo "uboot -build uboot"
echo "kernel -build kernel"
echo "rootfs -build rootfs"
echo "driver -build kernel's drivers"
echo "sysdrv -build uboot, kernel, rootfs"
echo "media -build rockchip media libraries"
echo "app -build app"
echo "recovery -build recovery"
echo "tool -build tool"
echo "updateimg -build update image"
echo "unpackimg -unpack update image"
echo "factory -build factory image"
echo "all -build uboot, kernel, rootfs, recovery image"
echo "allsave -build all & firmware & save"
echo ""
echo "clean -clean all"
echo "clean uboot -clean uboot"
echo "clean kernel -clean kernel"
echo "clean driver -clean driver"
echo "clean rootfs -clean rootfs"
echo "clean sysdrv -clean uboot/kernel/rootfs"
echo "clean media -clean rockchip media libraries"
echo "clean app -clean app"
echo "clean recovery -clean recovery"
echo ""
echo "firmware -pack all the image we need to boot up system"
echo "ota -pack update_ota.tar"
echo "save -save images, patches, commands used to debug"
echo "check -check the environment of building"
echo "info -see the current board building information"
echo ""
echo "buildrootconfig -config b # EMMCuildroot and save defconfig"
echo "kernelconfig -config kernel and save defconfig"
echo ""
echo "Default option is 'allsave'."
finish_build
exit 0
}
function build_get_sdk_version() {
version=$(grep -m 1 -o '## V[0-9]\.[0-9]' "${SDK_ROOT_DIR}/UPDATE_LOG.md" | awk '{print $2}')
GLOBAL_SDK_VERSION="Luckfox Pico Sdk ${version}"
}
function build_info() {
if [ ! -L $BOARD_CONFIG ]; then
echo "No found target board config!!!"
fi
build_get_sdk_version
# Support copy RK-RELEASE-NOTES-V*.txt from project/cfg/BoardConfig*/RK-RELEASE-NOTES-V*.txt to SDK_ROOT_DIR
local board_dir board_version_notes
board_dir=$(realpath $BOARD_CONFIG)
board_dir=$(dirname $board_dir)
# if ls $board_dir/RK-RELEASE-NOTES-V*.txt &>/dev/null;then
# board_version_notes=$(ls $board_dir/RK-RELEASE-NOTES-V*.txt |sort -r |head -1)
# rm -f $SDK_ROOT_DIR/RK-RELEASE-NOTES-V*.txt
# test ! -f $board_version_notes || cp -f $board_version_notes $SDK_ROOT_DIR
# fi
echo "Current Building Information:"
echo "Target cfg: $(realpath $BOARD_CONFIG)"
echo "Target Misc config:"
echo "$(env | grep "^RK_" | grep -v "=$" | sort)"
make info -C ${SDK_SYSDRV_DIR}
make info -C ${SDK_MEDIA_DIR}
make info -C ${PROJECT_TOP_DIR}/app
build_check_power_domain
}
function build_check_power_domain() {
local dump_kernel_dtb_file
local tmp_phandle_file
local tmp_io_domain_file
local tmp_regulator_microvolt_file
local tmp_final_target
local tmp_none_item
local kernel_file_dtb_dts
if [ ! -f "${RK_PROJECT_PATH_BOARD_BIN}/${RK_KERNEL_DTS/%.dts/.dtb}" ]; then
echo "Not found ${RK_PROJECT_PATH_BOARD_BIN}/${RK_KERNEL_DTS/%.dts/.dtb}, ignore"
return
fi
kernel_file_dtb_dts="${RK_PROJECT_PATH_BOARD_BIN}/${RK_KERNEL_DTS%.dts}"
dump_kernel_dtb_file=${kernel_file_dtb_dts}.dump.dts
dtc -I dtb -O dts -o ${dump_kernel_dtb_file} ${kernel_file_dtb_dts}.dtb 2>/dev/null
tmp_grep_file=$(mktemp)
if ! grep -Pzo "io-domains\s*{(\n|\w|-|;|=|<|>|\"|_|\s|,)*};" $dump_kernel_dtb_file 1>$tmp_grep_file 2>/dev/null; then
rm -f $dump_kernel_dtb_file
rm -f $tmp_grep_file
return 0
fi
tmp_regulator_microvolt_file=$(mktemp)
tmp_io_domain_file=$(mktemp)
tmp_final_target=$(mktemp)
tmp_phandle_file=$(mktemp)
grep -a supply $tmp_grep_file >$tmp_io_domain_file
rm -f $tmp_grep_file
awk '{print "phandle = " $3}' $tmp_io_domain_file >$tmp_phandle_file
while IFS= read -r item_phandle && IFS= read -u 3 -r item_domain; do
echo "${item_domain% *}" >>$tmp_regulator_microvolt_file
tmp_none_item=${item_domain% *}
cmds="grep -Pzo \"{(\\n|\w|-|;|=|<|>|\\\"|_|\s)*"$item_phandle\"
eval "$cmds $dump_kernel_dtb_file | strings | grep "regulator-m..-microvolt" >> $tmp_regulator_microvolt_file" ||
eval "sed -i \"/${tmp_none_item}/d\" $tmp_regulator_microvolt_file" && continue
echo >>$tmp_regulator_microvolt_file
done <$tmp_phandle_file 3<$tmp_io_domain_file
while read -r regulator_val; do
if echo ${regulator_val} | grep supply &>/dev/null; then
echo -e "\n\n\e[1;33m${regulator_val%*=}\e[0m" >>$tmp_final_target
else
tmp_none_item=${regulator_val##*<}
tmp_none_item=${tmp_none_item%%>*}
echo -e "${regulator_val%%<*} \e[1;31m$(($tmp_none_item / 1000))mV\e[0m" >>$tmp_final_target
fi
done <$tmp_regulator_microvolt_file
echo -e "\e[41;1;30m PLEASE CHECK BOARD GPIO POWER DOMAIN CONFIGURATION !!!!!\e[0m"
echo -e "\e[41;1;30m <<< ESPECIALLY Wi-Fi/Flash/Ethernet IO power domain >>> !!!!!\e[0m"
echo -e "\e[41;1;30m Check Node [pmu_io_domains] in the file: ${kernel_file_dtb_dts}.dts \e[0m"
echo
echo -e "\e[41;1;30m 请再次确认板级的电源域配置!!!!!!\e[0m"
echo -e "\e[41;1;30m <<< 特别是Wi-Fi,FLASH,以太网这几路IO电源的配置 >>> !!!!!\e[0m"
echo -e "\e[41;1;30m 检查内核文件 ${kernel_file_dtb_dts}.dts 的节点 [pmu_io_domains] \e[0m"
cat $tmp_final_target
rm -f $dump_kernel_dtb_file
rm -f $tmp_phandle_file
rm -f $tmp_io_domain_file
rm -f $tmp_regulator_microvolt_file
rm -f $tmp_final_target
}
function build_tool() {
test -d ${SDK_SYSDRV_DIR} && make pctools -C ${SDK_SYSDRV_DIR}
if [ $LF_ENABLE_SPI_NAND_FAST_BOOT = "y" ]; then
cp -fa $PROJECT_TOP_DIR/sfc_scripts/mk-fitimage.sh $RK_PROJECT_PATH_PC_TOOLS
cp -fa $PROJECT_TOP_DIR/sfc_scripts/compress_tool $RK_PROJECT_PATH_PC_TOOLS
cp -fa $PROJECT_TOP_DIR/sfc_scripts/mk-tftp_sd_update.sh $RK_PROJECT_PATH_PC_TOOLS
else
cp -fa $PROJECT_TOP_DIR/scripts/mk-fitimage.sh $RK_PROJECT_PATH_PC_TOOLS
cp -fa $PROJECT_TOP_DIR/scripts/compress_tool $RK_PROJECT_PATH_PC_TOOLS
cp -fa $PROJECT_TOP_DIR/scripts/mk-tftp_sd_update.sh $RK_PROJECT_PATH_PC_TOOLS
fi
finish_build
}
function build_check() {
common_product_build_tools="${PROJECT_TOP_DIR}/scripts/build-depend-tools.txt"
cat $common_product_build_tools 2>/dev/null | while read chk_item; do
chk_item=${chk_item###*}
if [ -z "$chk_item" ]; then
continue
fi
dst=${chk_item%%,*}
src=${chk_item##*,}
echo "**************************************"
if eval $dst &>/dev/null; then
echo "Check [OK]: $dst"
else
echo "Please install ${dst%% *} first"
echo " sudo apt-get install $src"
fi
done
}
function build_app() {
if [ "$RK_ENABLE_WIFI" = "y" ]; then
echo "Set Wifi SSID and PASSWD"
check_config LF_WIFI_PSK LF_WIFI_SSID || return 0
touch $WIFI_NEW_CONF
cat >$WIFI_NEW_CONF <<EOF
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1
network={
ssid="$LF_WIFI_SSID"
psk="$LF_WIFI_PSK"
key_mgmt=WPA-PSK
}
EOF
mv $WIFI_NEW_CONF $WIFI_CONF
fi
check_config RK_APP_TYPE || return 0
echo "============Start building app============"
echo "TARGET_APP_CONFIG=$RK_APP_DEFCONFIG $RK_APP_DEFCONFIG_FRAGMENT $RK_APP_TYPE"
echo "========================================="
build_meta --export --media_dir $RK_PROJECT_PATH_MEDIA # export meta header files
#build_meta --export --media_dir $RK_PROJECT_PATH_MEDIA # for rtl8723bs
test -d ${SDK_APP_DIR} && make -C ${SDK_APP_DIR}
finish_build
}
function __modify_file() {
local flag_opt_match_start flag_opt_match_end todo_file replace_str find_str target_file
todo_file=$1
target_file=$2
find_str=$3
replace_str=$4
if [ -n "$5" ]; then
flag_opt_match_start=$5
fi
if [ -n "$6" ]; then
flag_opt_match_end=$6
fi
rm -f $target_file
if [ ! -d "$RK_PROJECT_PATH_FASTBOOT" ]; then
mkdir -p $RK_PROJECT_PATH_FASTBOOT
fi
while read line; do
if echo "$line" | grep "$flag_opt_match_start$find_str$flag_opt_match_end"; then
echo "$find_str$replace_str" >>$target_file
continue
fi
echo "$line" >>$target_file
done <$todo_file
}
function build_uboot() {
check_config RK_UBOOT_DEFCONFIG || return 0
echo "============Start building uboot============"
echo "TARGET_UBOOT_CONFIG=$RK_UBOOT_DEFCONFIG $RK_UBOOT_DEFCONFIG_FRAGMENT"
echo "========================================="
#Apply patch
if [ ! -f ${SDK_SYSDRV_DIR}/source/.uboot_patch ]; then
echo "============Apply Uboot Patch============"
cd ${SDK_ROOT_DIR}
git apply ${SDK_SYSDRV_DIR}/tools/board/uboot/*.patch
if [ $? -eq 0 ]; then
msg_info "Patch applied successfully."
touch ${SDK_SYSDRV_DIR}/source/.uboot_patch
else
msg_error "Failed to apply the patch."
exit 1
fi
fi
cp ${SDK_SYSDRV_DIR}/tools/board/uboot/*_defconfig ${SDK_SYSDRV_DIR}/source/uboot/u-boot/configs
cp ${SDK_SYSDRV_DIR}/tools/board/uboot/*.dts ${SDK_SYSDRV_DIR}/source/uboot/u-boot/arch/arm/dts
cp ${SDK_SYSDRV_DIR}/tools/board/uboot/*.dtsi ${SDK_SYSDRV_DIR}/source/uboot/u-boot/arch/arm/dts
local uboot_rkbin_ini tempfile target_ini_dir
tempfile="$SDK_SYSDRV_DIR/source/uboot/rkbin/$RK_UBOOT_RKBIN_INI_OVERLAY"
if [ -f "$tempfile" ]; then
uboot_rkbin_ini=$tempfile
fi
target_ini_dir=$SDK_SYSDRV_DIR/source/uboot/rkbin/RKBOOT/
if [ "$RK_ENABLE_FASTBOOT" = "y" -a -n "$RK_UBOOT_RKBIN_MCU_CFG" ]; then
uboot_rkbin_ini=$RK_PROJECT_PATH_FASTBOOT/rk_uboot_rkbin_rkboot_overlay.ini
build_mcu $RK_UBOOT_RKBIN_MCU_CFG "__MCU_CONTINUE__"
case $RK_BOOT_MEDIUM in
emmc)
tempfile=$target_ini_dir/RV1106MINIALL_EMMC_TB.ini
;;
sd_card)
tempfile=$target_ini_dir/RV1106MINIALL_SDMMC_TB.ini
;;
spi_nor)
tempfile=$target_ini_dir/RV1106MINIALL_SPI_NOR_TB.ini
;;
spi_nand | slc_nand)
tempfile=$target_ini_dir/RV1106MINIALL_SPI_NAND_TB.ini
;;
*)
echo "build uboot Not support storage medium type: $RK_BOOT_MEDIUM"
finish_build
exit 1
;;
esac
if [ -f "$RK_PROJECT_FILE_SYSDRV_MCU_BIN" ]; then
__modify_file $tempfile $uboot_rkbin_ini "Hpmcu=" "$RK_PROJECT_FILE_SYSDRV_MCU_BIN" "^"
else
msg_error "build mcu <$RK_UBOOT_RKBIN_MCU_CFG> failed"
exit 1
fi
fi
make uboot -C ${SDK_SYSDRV_DIR} UBOOT_CFG=${RK_UBOOT_DEFCONFIG} UBOOT_CFG_FRAGMENT=${RK_UBOOT_DEFCONFIG_FRAGMENT} SYSDRV_UBOOT_RKBIN_OVERLAY_INI=$uboot_rkbin_ini
finish_build
}
function build_meta() {
msg_info "============Start building meta============"
if [ -n "$RK_META_SIZE" ]; then
if [ -d "${RK_PROJECT_TOP_DIR}/make_meta" ]; then
__meta_param="$RK_META_PARAM $RK_CAMERA_PARAM --meta_part_size=$RK_META_SIZE"
${RK_PROJECT_TOP_DIR}/make_meta/build_meta.sh $@ \
--cam_iqfile ${RK_CAMERA_SENSOR_IQFILES} \
--meta_param $__meta_param \
--output $RK_PROJECT_OUTPUT_IMAGE \
--rootfs_dir $RK_PROJECT_PACKAGE_ROOTFS_DIR \
--media_dir $RK_PROJECT_PATH_MEDIA \
--pc_tools_dir $RK_PROJECT_PATH_PC_TOOLS \
--boot_medium $RK_BOOT_MEDIUM \
--tiny_meta $RK_TINY_META
fi
fi
finish_build
}
function build_env() {
msg_info "============Start building env============"
msg_info "$RK_PARTITION_CMD_IN_ENV"
# Enable building if env partition is no exist
check_config ENV_SIZE || return 0
local env_cfg_img
env_cfg_img=$RK_PROJECT_OUTPUT_IMAGE/env.img
if [ ! -f "$RK_PROJECT_PATH_PC_TOOLS/mkenvimage" ] || [ "$LF_ENABLE_SPI_NAND_FAST_BOOT" = "y" ]; then
build_tool
fi
echo "$SYS_BOOTARGS" >>$ENV_CFG_FILE
echo "sd_parts=mmcblk0:16K@512(env),512K@32K(idblock),4M(uboot)" >>$ENV_CFG_FILE
# build env.img
$RK_PROJECT_PATH_PC_TOOLS/mkenvimage -s $ENV_SIZE -p 0x0 -o $env_cfg_img $ENV_CFG_FILE
chmod +r $env_cfg_img
finish_build
}
function build_media() {
echo "============Start building media============"
make -C ${SDK_MEDIA_DIR}
finish_build
}
function build_driver() {
echo "============Start building kernel's drivers============"
mkdir -p ${RK_PROJECT_OUTPUT_IMAGE}
build_kernel
make -C ${SDK_SYSDRV_DIR} drv
finish_build
}
function build_sysdrv() {
echo "============Start building sysdrv============"
mkdir -p ${RK_PROJECT_OUTPUT_IMAGE}
build_uboot
build_kernel
build_rootfs
build_recovery
rootfs_tarball="$RK_PROJECT_PATH_SYSDRV/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}.tar"
rootfs_out_dir="$RK_PROJECT_OUTPUT/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}"
if ! [ -d $RK_PROJECT_OUTPUT ]; then
mkdir -p $RK_PROJECT_OUTPUT
fi
if [ -f $rootfs_tarball ]; then
if [ -d $rootfs_out_dir ]; then
rm -rf $rootfs_out_dir
fi
tar xf $rootfs_tarball -C $RK_PROJECT_OUTPUT
else
msg_error "Not found rootfs tarball: $rootfs_tarball"
exit 1
fi
msg_info "If you need to add custom files, please upload them to <Luckfox Sdk>/output/out/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}."
finish_build
}
function build_kernel() {
#Apply patch
if [ ! -f ${SDK_SYSDRV_DIR}/source/.kernel_patch ]; then
echo "============Apply Kernel Patch============"
cd ${SDK_ROOT_DIR}
git apply --verbose ${SDK_SYSDRV_DIR}/tools/board/kernel/*.patch
if [ $? -eq 0 ]; then
msg_info "Patch applied successfully."
cp ${SDK_SYSDRV_DIR}/tools/board/kernel/*_defconfig ${KERNEL_PATH}/arch/arm/configs/
cp ${SDK_SYSDRV_DIR}/tools/board/kernel/*.config ${KERNEL_PATH}/arch/arm/configs/
cp ${SDK_SYSDRV_DIR}/tools/board/kernel/kernel-drivers-video-logo_linux_clut224.ppm ${KERNEL_PATH}/drivers/video/logo/logo_linux_clut224.ppm
cp ${SDK_SYSDRV_DIR}/tools/board/kernel/*.dts ${KERNEL_PATH}/arch/arm/boot/dts
cp ${SDK_SYSDRV_DIR}/tools/board/kernel/*.dtsi ${KERNEL_PATH}/arch/arm/boot/dts
touch ${SDK_SYSDRV_DIR}/source/.kernel_patch
else
msg_error "Failed to apply the patch."
fi
fi
check_config RK_KERNEL_DTS RK_KERNEL_DEFCONFIG || return 0
echo "============Start building kernel============"
echo "TARGET_ARCH =$RK_ARCH"
echo "TARGET_KERNEL_CONFIG =$RK_KERNEL_DEFCONFIG"
echo "TARGET_KERNEL_DTS =$RK_KERNEL_DTS"
echo "TARGET_KERNEL_CONFIG_FRAGMENT =$RK_KERNEL_DEFCONFIG_FRAGMENT"
echo "=========================================="
local kernel_build_options
if [ "$RK_ENABLE_FASTBOOT" = "y" ]; then
kernel_build_options="OUTPUT_SYSDRV_RAMDISK_DIR=$RK_PROJECT_PATH_FASTBOOT"
mkdir -p $RK_PROJECT_PATH_FASTBOOT
fi
make kernel -C ${SDK_SYSDRV_DIR} \
$kernel_build_options \
KERNEL_DTS=${RK_KERNEL_DTS} \
KERNEL_CFG=${RK_KERNEL_DEFCONFIG} \
KERNEL_CFG_FRAGMENT=${RK_KERNEL_DEFCONFIG_FRAGMENT}
finish_build
}
function build_rootfs() {
check_config RK_BOOT_MEDIUM || return 0
make rootfs -C ${SDK_SYSDRV_DIR}
__LINK_DEFCONFIG_FROM_BOARD_CFG
local rootfs_tarball rootfs_out_dir
rootfs_tarball="$RK_PROJECT_PATH_SYSDRV/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}.tar"
rootfs_out_dir="$RK_PROJECT_OUTPUT/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}"
if ! [ -d $RK_PROJECT_OUTPUT ]; then
mkdir -p $RK_PROJECT_OUTPUT
fi
if [ -f $rootfs_tarball ]; then
if [ -d $rootfs_out_dir ]; then
rm -rf $rootfs_out_dir
fi
tar xf $rootfs_tarball -C $RK_PROJECT_OUTPUT
else
msg_error "Not found rootfs tarball: $rootfs_tarball"
exit 1
fi
msg_info "If you need to add custom files, please upload them to <Luckfox Sdk>/output/out/rootfs_${RK_LIBC_TPYE}_${RK_CHIP}."
finish_build
}
function build_mcu() {
if [ ! -d "$SDK_SYSDRV_DIR/source/mcu" ]; then
msg_info "Not found mcu [$SDK_SYSDRV_DIR/source/mcu], ignore"
exit 1
fi
# sync gcc
if [ ! -d "$SDK_SYSDRV_DIR/source/mcu/prebuilts/gcc" ]; then
mkdir -p $SDK_SYSDRV_DIR/source/mcu/prebuilts/gcc/linux-x86/riscv64
wget -P $SDK_SYSDRV_DIR/source/mcu/prebuilts/gcc/linux-x86/riscv64 \
https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.2.0-1.2/xpack-riscv-none-embed-gcc-10.2.0-1.2-linux-x64.tar.gz
if [ ! -f $SDK_SYSDRV_DIR/source/mcu/prebuilts/gcc/linux-x86/riscv64/xpack-riscv-none-embed-gcc-10.2.0-1.2-linux-x64.tar.gz ]; then
msg_error "Download prebuilts fail!Try downloading manually from https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.2.0-1.2/xpack-riscv-none-embed-gcc-10.2.0-1.2-linux-x64.tar.gz"
exit 1
fi
tar -xvf $SDK_SYSDRV_DIR/source/mcu/prebuilts/gcc/linux-x86/riscv64/xpack-riscv-none-embed-gcc-10.2.0-1.2-linux-x64.tar.gz \
-C $SDK_SYSDRV_DIR/source/mcu/prebuilts/gcc/linux-x86/riscv64
fi
local build_opt
build_opt=""
if [ "$1" = "info" ]; then
$SDK_SYSDRV_DIR/source/mcu/build.sh info
finish_build
exit 0
elif [ -n "$1" ]; then
if find $SDK_SYSDRV_DIR/source/mcu -type d -name "$1"; then
build_opt="$1"
fi
fi
$SDK_SYSDRV_DIR/source/mcu/build.sh lunch $build_opt
$SDK_SYSDRV_DIR/source/mcu/build.sh clean
mkdir -p $RK_PROJECT_PATH_MCU
$SDK_SYSDRV_DIR/source/mcu/build.sh all $RK_PROJECT_PATH_MCU
if [ "$2" = "__MCU_CONTINUE__" ]; then
return
else
exit 0
fi
}
function build_recovery() {
check_config RK_ENABLE_RECOVERY || return 0
local kernel_image
local kernel_dtb_file="$RK_PROJECT_PATH_RAMDISK/${RK_KERNEL_DTS/%.dts/.dtb}"
local ota_script="$OTA_SCRIPT_PATH/RK_OTA_update.sh"
local erase_misc_script="$RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS/usr/bin/RK_OTA_erase_misc.sh"
local ramdisk_file="rootfs.cpio"
# make busybox and kernel
mkdir -p $RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS $RK_PROJECT_PATH_RAMDISK
if [ -z "$RK_RECOVERY_KERNEL_DEFCONFIG_FRAGMENT" ]; then
msg_error "Please define RK_RECOVERY_KERNEL_DEFCONFIG_FRAGMENT on BoardConfig"
exit 1
fi
RK_KERNEL_DEFCONFIG_FRAGMENT="${RK_RECOVERY_KERNEL_DEFCONFIG_FRAGMENT}"
make kernel -C ${SDK_SYSDRV_DIR} \
OUTPUT_SYSDRV_RAMDISK_DIR=$RK_PROJECT_PATH_RAMDISK \
SYSDRV_BUILD_RECOVERY=y \
KERNEL_DTS=${RK_KERNEL_DTS} \
KERNEL_CFG=${RK_KERNEL_DEFCONFIG} \
KERNEL_CFG_FRAGMENT=${RK_KERNEL_DEFCONFIG_FRAGMENT}
make -C ${SDK_SYSDRV_DIR} \
OUTPUT_SYSDRV_RAMDISK_TINY_ROOTFS_DIR=$RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS \
SYSDRV_BUILD_RECOVERY=y \
busybox
# copy tools
mkdir -p $RK_PROJECT_PATH_PC_TOOLS
if [ ! -f $RK_PROJECT_PATH_PC_TOOLS/mk-fitimage.sh \
-o ! -f $RK_PROJECT_PATH_PC_TOOLS/mkimage ]; then
build_tool
fi
cp -fa $PROJECT_TOP_DIR/scripts/RkLunch-recovery.sh $RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS/usr/bin/RkLunch.sh
cp -fa $PROJECT_TOP_DIR/scripts/boot4recovery.its $RK_PROJECT_PATH_RAMDISK
mkdir -p $(dirname $RK_PROJECT_FILE_RECOVERY_LUNCH_SCRIPT)
cat >$RK_PROJECT_FILE_RECOVERY_LUNCH_SCRIPT <<EOF
#!/bin/sh
case \$1 in