diff --git a/.kernel_gdbinit b/.gdbinits/kernel similarity index 100% rename from .kernel_gdbinit rename to .gdbinits/kernel diff --git a/.uboot_gdbinit b/.gdbinits/uboot similarity index 100% rename from .uboot_gdbinit rename to .gdbinits/uboot diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000000000000000000000000000000000000..03d81c9c090e5f9146312be3b99862c550f9d2c0 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,7 @@ +maintainers: +- Wu Zhangijn (@lzufalcon) + +contributors: +- LastRitter (@lastritter) +- Ping Wu (@pingwuu) +- unicornx (@unicornx) diff --git a/COPYING b/COPYING index 10828e06eca80e104cf90bc3fb8f6a4f3c6b2ae8..814b9f9a34655696b2ba7d1817f778dab3c0119f 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,9 @@ +Linux Lab is Copyright (C) 2016-2020 Wu Zhangjin and the +authors in AUTHORS. +The Linux Lab files are licensed under GPL v2 for non-commercial users. + +--- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 diff --git a/Makefile b/Makefile index dc309a4000baca2e9ef314417e830ed1ef17224e..fb8bc247a51faa4576f49ea3fafd72ccefbb30c5 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,7 @@ BOARD_DIR := $(TOP_DIR)/$(BOARDS_DIR)/$(BOARD) FEATURE_DIR := feature/linux TFTPBOOT := tftpboot HOME_DIR := /home/$(USER)/ +GDBINIT_DIR := $(TOP_DIR)/.gdbinits # Search board in basic arch list while board name given without arch specified BASE_ARCHS := arm aarch64 mipsel ppc i386 x86_64 loongson csky @@ -264,22 +265,11 @@ $(call _i,$(1),$(2),$(HOME_DIR)) endef # Include board detailed configuration -# Makefile.config/beforeconfig/afterconfig hooks for more - define board_config -$(call _bi,beforeconfig.private,Makefile) -$(call _bi,beforeconfig,Makefile) - -$(call _bi,config.private,Makefile) -$(call _bi,config,Makefile) - $(call _bi,GCC,Makefile) $(call _bi,ROOT,Makefile) $(call _bi,NET,Makefile) $(call _bvi,LINUX,Makefile) - -$(call _bi,afterconfig,Makefile) -$(call _bi,afterconfig.private,Makefile) endef define fixup_arch @@ -294,28 +284,22 @@ ifneq ($$(IS_ARCH),0) endif endef -# include Makefile.init if exist -# the .private version is for user local customization, should not be added in mainline repository -$(eval $(call _ti,init,Makefile)) -$(eval $(call _ti,init.private,Makefile)) -$(eval $(call _ti,config,Makefile)) -$(eval $(call _ti,config.private,Makefile)) +# include .labinit if exist +$(eval $(call _ti,labinit)) + +$(eval $(call _ti,labconfig)) +$(eval $(call _hi,labconfig)) # Loading board configurations ifneq ($(BOARD),) - # include $(BOARD_DIR)/Makefile.init if exist - $(eval $(call _bi,init.private,Makefile)) - $(eval $(call _bi,init,Makefile)) - include $(BOARD_MAKEFILE) - # include $(BOARD_DIR)/Makefile.fini if exist - $(eval $(call _bi,fini,Makefile)) - $(eval $(call _bi,fini.private,Makefile)) + # include $(BOARD_DIR)/.labinit + $(eval $(call _bi,labinit)) $(eval $(call _bi,labconfig)) + include $(BOARD_MAKEFILE) + # include $(BOARD_DIR)/.labfini + $(eval $(call _bi,labfini)) endif -$(eval $(call _ti,labconfig)) -$(eval $(call _hi,labconfig)) - # Customize kernel git repo and local dir $(eval $(call __vs,KERNEL_SRC,LINUX)) $(eval $(call __vs,KERNEL_GIT,LINUX)) @@ -1371,8 +1355,8 @@ $$(call _stamp_$(1),source): $$(call _stamp_$(1),outdir) @echo "Downloading $(1) source ..." @echo $$(Q)if [ -e $$($(call _uc,$(1))_SRC_FULL)/.git ]; then \ - cd $$($(call _uc,$(1))_SRC_FULL); \ - if [ $$(shell cd $$($(call _uc,$(1))_SRC_FULL) && git show --pretty=oneline -q $$(_$(call _uc,$(2))) >/dev/null 2>&1; echo $$$$?) -ne 0 ]; then \ + [ -d $$($(call _uc,$(1))_SRC_FULL) ] && cd $$($(call _uc,$(1))_SRC_FULL); \ + if [ $$(shell [ -d $$($(call _uc,$(1))_SRC_FULL) ] && cd $$($(call _uc,$(1))_SRC_FULL) && git show --pretty=oneline -q $$(_$(call _uc,$(2))) >/dev/null 2>&1; echo $$$$?) -ne 0 ]; then \ $$($(call _uc,$(1))_GITADD); \ git fetch --tags $$(or $$($(call _uc,$(1))_GITREPO),origin); \ fi; \ @@ -1394,7 +1378,7 @@ $(1)-checkout: $(1)-source $$(call _stamp_$(1),checkout): $$(Q)if [ -d $$($(call _uc,$(1))_SRC) -a -e $$($(call _uc,$(1))_SRC)/.git ]; then \ - cd $$($(call _uc,$(1))_SRC) && git checkout $$(GIT_CHECKOUT_FORCE) $$(_$(2)) && $$(if $$(BSP_CHECKOUT),git pull,echo) && cd $$(TOP_DIR); \ + cd $$($(call _uc,$(1))_SRC) && git checkout $$(GIT_CHECKOUT_FORCE) $$(_$(2)) && cd $$(TOP_DIR); \ fi $$(Q)touch $$@ @@ -1590,7 +1574,8 @@ PHONY += $(1)-env endef #genenvdeps # Build bsp targets -BSP ?= master +# Always checkout the latest commit for bsp +BSP ?= FETCH_HEAD _BSP ?= $(BSP) ifeq ($(_PLUGIN),1) @@ -1599,10 +1584,6 @@ else BSP_SRC := $(subst x$(TOP_DIR)/,,x$(BSP_DIR)) endif -ifeq ($(findstring bsp-checkout, $(MAKECMDGOALS)), bsp-checkout) - BSP_CHECKOUT := 1 -endif - ifeq ($(firstword $(MAKECMDGOALS)),bsp) bsp: force-bsp-checkout PHONY += bsp @@ -3241,11 +3222,11 @@ endif ifeq ($(DEBUG),uboot) GDB_CMD ?= $(GDB) $(BIMAGE) - GDB_INIT ?= $(TOP_DIR)/.uboot_gdbinit + GDB_INIT ?= $(GDBINIT_DIR)/uboot DEBUG_DEPS := uboot-build else GDB_CMD ?= $(GDB) $(VMLINUX) - GDB_INIT ?= $(TOP_DIR)/.kernel_gdbinit + GDB_INIT ?= $(GDBINIT_DIR)/kernel DEBUG_DPES := kernel-build endif @@ -3276,7 +3257,7 @@ endif # FIXME: gdb not continue the commands in .gdbinit while runing with 'CASE=debug tools/testing/run.sh' # just ignore the do_fork breakpoint to workaround it. _debug: - $(Q)ln -sf $(notdir $(GDB_INIT)) .gdbinit + $(Q)ln -sf $(notdir $(GDBINIT_DIR))/$(notdir $(GDB_INIT)) .gdbinit $(Q)sudo -u $(GDB_USER) echo "add-auto-load-safe-path .gdbinit" > $(HOME_GDB_INIT) $(Q)$(DEBUG_CMD) & @@ -3348,9 +3329,8 @@ default-help: PHONY += env env-list env-prepare env-dump env-save lab-help -# include Makefile.fini if exist -$(eval $(call _ti,fini,Makefile)) -$(eval $(call _ti,fini.private,Makefile)) +# include .labfini if exist +$(eval $(call _ti,.labfini)) # # override all of the above targets if the first target is XXX-run, treat left parts as its arguments, simplify input diff --git a/README.md b/README.md index 9e309491c73cec5e8cade68e83f046ad7f2b8a9d..f54541e1035fddd9e9266c36e7c062bb740e792f 100644 --- a/README.md +++ b/README.md @@ -1034,7 +1034,7 @@ And then debug it directly: $ make debug -It will open a new terminal, load the scripts from `.kernel_gdbinit`, run gdb automatically. +It will open a new terminal, load the scripts from `.gdbinits/kernel`, run gdb automatically. It equals to: @@ -1054,7 +1054,7 @@ find out the code line of a kernel panic address: ### 4.6.2 Debugging Uboot -to debug uboot with `.uboot_gdbinit`: +to debug uboot with `.gdbinits/uboot`: $ make debug uboot or @@ -1173,12 +1173,11 @@ default: Simply put the files with a relative path in `system/`, install and rebuild the rootfs: - $ cd system/ $ mkdir system/root/ $ touch system/root/new_file $ make root-install $ make root-rebuild - $ make boot G=1 + $ make boot ### 4.8.2 Share with NFS diff --git a/README_zh.md b/README_zh.md index 655af457c96e201949a8efcc5d28af1c84d92f44..29fd4b0f2929ec76a4ac899972f7ab0cad8f0c48 100644 --- a/README_zh.md +++ b/README_zh.md @@ -1066,7 +1066,7 @@ GCC 的版本可以分别在开发板特定的 Makefile 中针对 Linux, Uboot, $ make debug -将打开一个新的终端窗口,从 `.kernel_gdbinit` 加载脚本,自动运行 gdb。 +将打开一个新的终端窗口,从 `.gdbinits/kernel` 加载脚本,自动运行 gdb。 以上命令等价于运行如下命令: @@ -1086,7 +1086,7 @@ GCC 的版本可以分别在开发板特定的 Makefile 中针对 Linux, Uboot, ### 4.6.2 调试 Uboot -如果想调试 Uboot(采用 `.uboot_gdbinit` 调试脚本): +如果想调试 Uboot(采用 `.gdbinits/uboot` 调试脚本): $ make debug uboot 或 @@ -1208,12 +1208,11 @@ GCC 的版本可以分别在开发板特定的 Makefile 中针对 Linux, Uboot, 将文件放在 `system/` 的相对路径中,安装和重新制作 rootfs: - $ cd system/ $ mkdir system/root/ $ touch system/root/new_file $ make root-install $ make root-rebuild - $ make boot G=1 + $ make boot 上述操作在 root 用户目录下新增 `new_file` 文件。 diff --git a/doc/misc/install-dockerce-in-ubuntu.md b/doc/misc/install-dockerce-in-ubuntu.md new file mode 100644 index 0000000000000000000000000000000000000000..15facc4ef342c476d2717b7cc1df403cb055b440 --- /dev/null +++ b/doc/misc/install-dockerce-in-ubuntu.md @@ -0,0 +1,117 @@ +本文介绍了针对国内大陆用户在 Ubuntu 环境下安装 Docker-CE 的步骤和优化方法。官网指导参考 [Get Docker Engine - Community for Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/)。 + +验证过的版本: +- Ubuntu 16.04 LTS +- Ubuntu 18.04 LTS +- 待补充 + +为加速安装,采用了阿里提供的镜像,参考 [“阿里的 docker-ce 的安装方法”](https://developer.aliyun.com/mirror/docker-ce?spm=a2c6h.13651102.0.0.53322f70PlMeFc),本文在此基础上添加了一些自己的注释。 + +***注:原先参考的是 [清华大学开源软件镜像站点的 Docker Community Edition 镜像使用帮助](https://mirror.tuna.tsinghua.edu.cn/help/docker-ce/),后来因为发现清华的源特别慢,所以还是换了阿里的源。*** + +- **Step 0:卸载旧版本** + + 确保机器上没有安装旧版本的 docker + + ``` + $ sudo apt-get remove docker docker-engine docker.io + ``` + +- **Step 1: 使用 APT 安装** + + - **Step 1.1: 安装依赖** + + ``` + $ sudo apt-get update + $ sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common + ``` + + - **Step 1.2: 添加软件源的 GPG 密钥** + + ``` + curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - + ``` + + - **Step 1.3: 添加 Docker 软件源** + + 这里添加软件源的目的是为了下载 docker-ce 的安装包比较快。 + + ``` + sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" + ``` + +- **Step 2: 安装 Docker CE** + + 安装完成后自动启动 Docker CE 服务。 + + ``` + sudo apt-get -y update + sudo apt-get -y install docker-ce + ``` + +- **Step 3: 把工作用户加入 docker 组,避免使用 root 帐号工作** + + APT 方式安装好 docker-ce 后已经自动帮我们建立了 docker 组,所以我们不需要自己添加 docker 组,只需要把当前工作用户加入 docker 组即可。 + + ``` + $ sudo usermod -aG docker $USER + ``` + + 重启系统生效。 + + +- **Step 4: 配置镜像加速** + + 鉴于国内网络问题,每次使用 `docker pull` 命令 pull 镜像时,docker daemon 都会去 Docker Hub 拉取镜像,拉取 Docker 镜像十分缓慢,强烈建议安装 Docker-CE 之后配置国内镜像加速。 + + 我们可以使用中科大的镜像源来加速(阿里云的docker镜像加速器需要注册账号,每个人都有自己唯一的地址。)。 + + 加速的方法参考 [“USTC Docker 镜像使用帮助”](https://lug.ustc.edu.cn/wiki/mirrors/help/docker), 对于使用 systemd 的系统,譬如 ubuntu 16.04 以上版本,修改 `/etc/docker/daemon.json` 即可(没有该文件的话,请先新建一个)。 + + 在该配置文件中加入如下语句,如果要换用其他的镜像源也可以修改其中的 URL 部分: + ``` + { + "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"] + } + ``` + + 配置完成之后执行如下命令重新启动服务生效。 + + ``` + $ sudo systemctl daemon-reload + $ sudo systemctl restart docker + ``` + +- **Step 5: 测试是否安装正确** + + ``` + $ docker run hello-world + + Unable to find image 'hello-world:latest' locally + latest: Pulling from library/hello-world + 78445dd45222: Pull complete + Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 + Status: Downloaded newer image for hello-world:latest + + Hello from Docker! + This message shows that your installation appears to be working correctly. + + To generate this message, Docker took the following steps: + 1. The Docker client contacted the Docker daemon. + 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. + 3. The Docker daemon created a new container from that image which runs the + executable that produces the output you are currently reading. + 4. The Docker daemon streamed that output to the Docker client, which sent it + to your terminal. + + To try something more ambitious, you can run an Ubuntu container with: + $ docker run -it ubuntu bash + + Share images, automate workflows, and more with a free Docker ID: + https://cloud.docker.com/ + + For more examples and ideas, visit: + https://docs.docker.com/engine/userguide/ + ``` + + 恭喜你,如果看到以上提示,说明 docker-ce 工作正常。 \ No newline at end of file diff --git a/tools/uboot/pflash.sh b/tools/uboot/pflash.sh index 9f9b2454c9ac98137f95f17e2c8f53d2ea33b48a..8930ce3871f9e0f00dfe2d25b2196419150b6343 100755 --- a/tools/uboot/pflash.sh +++ b/tools/uboot/pflash.sh @@ -25,4 +25,5 @@ if [ "${BOOTDEV}" == "pflash" -o "${BOOTDEV}" == "flash" ]; then [ -n "$DTB_IMAGE" -a -f "$DTB_IMAGE" ] && dd if=$DTB_IMAGE of=$PFLASH_IMG status=none conv=notrunc seek=$(((KRN_SIZE+RDK_SIZE) * 1024 / PFLASH_BS)) bs=${PFLASH_BS}K #sync + exit 0 fi diff --git a/tools/uboot/sd.sh b/tools/uboot/sd.sh index 1392a8c4c128ce7fe3705f2443a418721207d005..d7dc90fbaaf7cf6593edc944f511d634f42e9411 100755 --- a/tools/uboot/sd.sh +++ b/tools/uboot/sd.sh @@ -32,4 +32,5 @@ if [ "${BOOTDEV}" == "sdcard" -o "${BOOTDEV}" == "sd" -o "${BOOTDEV}" == "mmc" ] sudo umount $SD_DIR #sync + exit 0 fi