Skip to content

Commit 16a2ba4

Browse files
committed
init version, add modules and debug shell
1 parent bba57b8 commit 16a2ba4

File tree

11 files changed

+334
-113
lines changed

11 files changed

+334
-113
lines changed

shell/arm_func

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
3+
export ARCH=arm
4+
export CROSS_COMPILE=arm-none-linux-gnueabihf-
5+
export zImage_obj=$SRC_DIR/linux-5.6.11/arch/arm/boot/zImage
6+
export dtb_obj=$SRC_DIR/linux-5.6.11/arch/arm/boot/dts/vexpress-v2p-ca9.dtb
7+
export rootfs_obj=$IMAGE_DIR/rootfs.ext3
8+
9+
function arm_usage(){
10+
echo ""
11+
echo "usage for arm:"
12+
echo " ./smake -arm zImage -- cross-complie linux kernel zImage "
13+
echo " ./smake -arm uImage -- cross-complie linux kernel uImage "
14+
echo " ./smake -arm uboot -- cross-complie uboot"
15+
echo " ./smake -arm busybox -- cross-complie busybox"
16+
echo " ./smake -arm rootfs -- create rootfs ext3 image"
17+
echo " ./smake -arm clean_rootfs -- clean rootfs dir"
18+
echo " ./smake -arm run_uboot -- run uboot in qemu without graphic"
19+
echo " ./smake -arm run_zImage -- run zImage in qemu with graphic"
20+
echo " ./smake -arm debug_uboot -- debug uboot use gdb in qemu without graphic"
21+
echo " ./smake -arm debug_zImage -- debug zImage use gdb in qemu with graphic"
22+
echo " ./smake -arm clean_boot -- clean uboot,reserve config"
23+
echo " ./smake -arm clean_kernel -- clean kernel,reserve config"
24+
echo " ./smake -arm disclean_boot -- deep clean uboot"
25+
echo " ./smake -arm distclean_kernel -- distclean kernel"
26+
echo " ./smake -arm clean_busybox -- clean busybox"
27+
echo " ./smake -arm distclean_busybox -- distclean busybox"
28+
echo " ./smake -arm setup_net -- setup net connection with qemu"
29+
echo " ./smake -arm modules xxx -- make kernel modules in src/modules/xxx,xxx indicates modules directory"
30+
echo " ./smake -arm modules clean xxx -- clean kernel modules in src/modules/xxx,xxx indicates modules directory"
31+
echo ""
32+
}
33+
34+
function make_arm_zImage(){
35+
cd $SRC_DIR/linux-5.6.11
36+
make vexpress_defconfig
37+
make -j12 zImage
38+
make dtbs
39+
make modules
40+
echo "generate zImage dts succeed"
41+
42+
}
43+
44+
function make_arm_uImage(){
45+
export LOADADDR=0x60003000
46+
cd $SRC_DIR/linux-5.6.11
47+
make vexpress_defconfig
48+
make -j12 uImage
49+
make dtbs
50+
make modules
51+
echo "generate uImage succeed"
52+
}
53+
54+
function make_arm_boot(){
55+
cd $SRC_DIR/u-boot-2020.04
56+
make vexpress_ca9x4_defconfig
57+
make -j12
58+
echo "generate uboot succeed"
59+
}
60+
61+
function make_arm_busybox(){
62+
cd $SRC_DIR/busybox-1.31.1
63+
make menuconfig
64+
make -j12
65+
make install
66+
echo "generate busybox succeed"
67+
68+
}
69+
70+
function run_arm_boot(){
71+
cd $SRC_DIR/u-boot-2020.04
72+
qemu-system-arm -M vexpress-a9 \
73+
-m 256M -nographic -kernel u-boot \
74+
-net nic -net tap,ifname=tap0,script=no,downscript=no
75+
#-sd $rootfs_obj
76+
}
77+
78+
function debug_arm_boot(){
79+
cd $SRC_DIR/u-boot-2020.04
80+
qemu-system-arm -S -s -M vexpress-a9 \
81+
-m 256M -nographic -kernel u-boot \
82+
-net nic -net tap,ifname=tap0,script=no,downscript=no
83+
#-sd $rootfs_obj
84+
}
85+
function run_arm_zImage(){
86+
sudo qemu-system-arm -M vexpress-a9 -m 512M -dtb $dtb_obj -kernel $zImage_obj -smp 4\
87+
-append "root=/dev/mmcblk0 rw rootwait earlyprintk console=tty0 init=/linuxrc" -sd $rootfs_obj\
88+
-net nic -net tap,ifname=tap0,script=no,downscript=no
89+
}
90+
91+
function debug_arm_zImage(){
92+
sudo qemu-system-arm -S -s -M vexpress-a9 -m 512M -dtb $dtb_obj -kernel $zImage_obj -smp 4\
93+
-append "root=/dev/mmcblk0 rw rootwait earlyprintk console=tty0 init=/linuxrc" -sd $rootfs_obj\
94+
-net nic -net tap,ifname=tap0,script=no,downscript=no
95+
}

shell/common

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
function usage(){
4+
echo""
5+
echo -e "now support architecture as below:"
6+
echo " arm, vexpress-a9 board emulated"
7+
echo "usage:"
8+
echo -e " arm, enter as below for help: \n ./smake -arm"
9+
echo ""
10+
}
11+
12+
function make_modules(){
13+
cd $SRC_DIR/linux-5.6.11
14+
make M=$SRC_DIR/modules/$1 modules SUBDIRS=$SRC_DIR/modules/$2
15+
echo "make modules $2 succeed..."
16+
}
17+
18+
function clean_modules(){
19+
cd $SRC_DIR/modules/$3
20+
make clean
21+
echo "make clean $3 succeed..."
22+
}
23+
24+
function build_rootfs(){
25+
cd $SHELL_DIR
26+
./rootfs_build.sh
27+
echo "generate roots image"
28+
}
29+
30+
function setup_net(){
31+
ifconfig|grep tap0 > /dev/null
32+
if [ $? != 0 ]; then
33+
cd $SHELL_DIR
34+
./setup_net.sh
35+
echo "setup_net succeed..."
36+
else
37+
echo "net haven been setted before...."
38+
fi
39+
}
40+
41+
function clean_rootfs(){
42+
cd $SHELL_DIR
43+
./rootfs_build.sh clean
44+
echo "clean rootfs dir"
45+
}
46+
47+
function clean_kernel(){
48+
cd $SRC_DIR/linux-5.6.11
49+
make clean
50+
echo "Clean kernel ..."
51+
}
52+
53+
function clean_boot(){
54+
cd $SRC_DIR/u-boot-2020.04
55+
make clean
56+
echo "Clean boot ..."
57+
}
58+
59+
function distclean_kernel(){
60+
cd $SRC/linux-5.6.11
61+
make distclean
62+
echo "Distclean kernel over ..."
63+
}
64+
65+
function distclean_boot(){
66+
cd $SRC_DIR/u-boot-2020.04
67+
make distclean
68+
echo "Distclean boot ..."
69+
}
70+
71+
function clean_busybox(){
72+
cd $SRC_DIR/busybox-1.31.1
73+
make clean
74+
echo "clean busybox succeed"
75+
}
76+
77+
function distclean_busybox(){
78+
cd $SRC_DIR/busybox-1.31.1
79+
make distclean
80+
echo "distclean busybox succeed"
81+
}

shell/debug

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
if [ 0 = $# ]; then
4+
echo ""
5+
echo "usage:"
6+
echo " [./debug uboot] for uboot"
7+
echo " [./debug kernel] for kernel"
8+
echo ""
9+
exit
10+
fi
11+
12+
if [ 1 = $# ]; then
13+
if [ $1 = "uboot" ]; then
14+
arm-none-linux-gnueabihf-gdb -tui -x uboot_arm_gdbinit
15+
fi
16+
if [ $1 = "kernel" ]; then
17+
arm-none-linux-gnueabihf-gdb -tui -x kernel_arm_gdbinit
18+
fi
19+
fi

shell/global.mk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
export SHELL_DIR=`pwd`
3+
export TOP_DIR=$(dirname "$PWD")
4+
export SRC_DIR=$TOP_DIR/src
5+
export IMAGE_DIR=$TOP_DIR/images
6+
7+
export CPU_PHYSICAL_NUM=`cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l`
8+
export CPU_LOGICAL_NUM=`cat /proc/cpuinfo| grep "processor"| wc -l`
9+
#export PER_CPU_NUM=`cat /proc/cpuinfo| grep "cpu cores"| uniq`
10+
#echo $TOP_DIR
11+
#echo $SHELL_DIR
12+
#echo $SRC_DIR
13+
#echo $IMAGE_DIRi
14+
#echo $PHYSICAL_NUM
15+
#echo $CPU_LOGICAL_NUM

shell/kernel_arm_gdbinit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
file /home/develop/vexpress-a9/src/linux-5.6.11/vmlinux
2+
target remote 127.0.0.1:1234

shell/kill_qemu.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
ps -A | grep qemu-system-arm | awk '{print $1}' | xargs sudo kill -9

shell/rootfs_build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ sudo mkdir -p rootfs/sbin # /sbin包含系统运行的关键可执行文件以
2222
sudo mkdir -p rootfs/home # /home普通用户的工作目录,没有普通用户都会在这里建立一个文件夹
2323
sudo mkdir -p rootfs/etc # /etc存放系统配置文件以及应用程序的配置文件
2424
sudo mkdir -p rootfs/lib # /lib存放所有应用程序的共享文件以及内核模块
25+
sudo mkdir -p rootfs/lib/modules # /lib存放所有应用程序的共享文件以及内核模块
2526
sudo mkdir -p rootfs/proc/ # /proc目录是内核在内存中映射的实时文件系统,存放内核向用户应用程序提供的信息文件
2627
sudo mkdir -p rootfs/sys/ # /sys是文件系统挂载的地方
2728
sudo mkdir -p rootfs/tmp/ # /tmp存放系统或应用程序产生的临时文件

0 commit comments

Comments
 (0)