From fd0a3ef2c5fafdc6857bdaf38a7fc97c7f994b2d Mon Sep 17 00:00:00 2001 From: Wu Zhangjin Date: Thu, 2 Apr 2020 15:34:18 +0800 Subject: [PATCH 1/8] bsp: use a better method to pull latest update Signed-off-by: Wu Zhangjin --- Makefile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index dc309a4..c59429f 100644 --- a/Makefile +++ b/Makefile @@ -1394,7 +1394,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 +1590,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 +1600,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 -- Gitee From dba15fd886759a35fde1b71a48bcb699731db503 Mon Sep 17 00:00:00 2001 From: Wu Zhangjin Date: Thu, 2 Apr 2020 16:50:02 +0800 Subject: [PATCH 2/8] checkout: check directory before running cd cmd Signed-off-by: Wu Zhangjin --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c59429f..9d6fac4 100644 --- a/Makefile +++ b/Makefile @@ -1371,8 +1371,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; \ -- Gitee From 6a146874ad092c6ed48ac31b32597eb2c6cb0cf9 Mon Sep 17 00:00:00 2001 From: Wu Zhangjin Date: Fri, 3 Apr 2020 01:27:41 +0800 Subject: [PATCH 3/8] Add copyright info Signed-off-by: Wu Zhangjin --- AUTHORS | 7 +++++++ COPYING | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..03d81c9 --- /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 10828e0..814b9f9 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 -- Gitee From f149d11e24b7cd8ea2f62793ea1a0d2983973d4b Mon Sep 17 00:00:00 2001 From: Wu Zhangjin Date: Sat, 4 Apr 2020 15:21:54 +0800 Subject: [PATCH 4/8] README: update rootfs installation Signed-off-by: Wu Zhangjin --- README.md | 3 +-- README_zh.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9e30949..99b9837 100644 --- a/README.md +++ b/README.md @@ -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 655af45..acfc6f4 100644 --- a/README_zh.md +++ b/README_zh.md @@ -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` 文件。 -- Gitee From e89db7b4eb1a1d3a1cde871678b1d04feecfcafb Mon Sep 17 00:00:00 2001 From: Wu Zhangjin Date: Wed, 8 Apr 2020 19:08:29 +0800 Subject: [PATCH 5/8] debug: add .gdbinits and update docs Signed-off-by: Wu Zhangjin --- .kernel_gdbinit => .gdbinits/kernel | 0 .uboot_gdbinit => .gdbinits/uboot | 0 Makefile | 7 ++++--- README.md | 4 ++-- README_zh.md | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) rename .kernel_gdbinit => .gdbinits/kernel (100%) rename .uboot_gdbinit => .gdbinits/uboot (100%) 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/Makefile b/Makefile index 9d6fac4..80b267d 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 @@ -3238,11 +3239,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 @@ -3273,7 +3274,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) & diff --git a/README.md b/README.md index 99b9837..f54541e 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 diff --git a/README_zh.md b/README_zh.md index acfc6f4..29fd4b0 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 或 -- Gitee From 09bff91b0d16dbcdcf026bd26a76c3afe74b201c Mon Sep 17 00:00:00 2001 From: Wu Zhangjin Date: Wed, 8 Apr 2020 21:07:02 +0800 Subject: [PATCH 6/8] uboot: fix up nodtb version support Signed-off-by: Wu Zhangjin --- Makefile | 8 ++++---- tools/uboot/pflash.sh | 1 + tools/uboot/sd.sh | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 80b267d..a63c21a 100644 --- a/Makefile +++ b/Makefile @@ -302,21 +302,21 @@ $(eval $(call _ti,init.private,Makefile)) $(eval $(call _ti,config,Makefile)) $(eval $(call _ti,config.private,Makefile)) +$(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)) + $(eval $(call _bi,labconfig)) include $(BOARD_MAKEFILE) # include $(BOARD_DIR)/Makefile.fini if exist $(eval $(call _bi,fini,Makefile)) $(eval $(call _bi,fini.private,Makefile)) - $(eval $(call _bi,labconfig)) 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)) diff --git a/tools/uboot/pflash.sh b/tools/uboot/pflash.sh index 9f9b245..8930ce3 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 1392a8c..d7dc90f 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 -- Gitee From e883a53c2a777686f527e5666ead55fe8b5daca7 Mon Sep 17 00:00:00 2001 From: Wu Zhangjin Date: Wed, 8 Apr 2020 21:14:42 +0800 Subject: [PATCH 7/8] Makefile: clean up hooks for configuration Signed-off-by: Wu Zhangjin --- Makefile | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index a63c21a..fb8bc24 100644 --- a/Makefile +++ b/Makefile @@ -265,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 @@ -295,26 +284,20 @@ 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_DIR)/.labinit + $(eval $(call _bi,labinit)) $(eval $(call _bi,labconfig)) include $(BOARD_MAKEFILE) - # include $(BOARD_DIR)/Makefile.fini if exist - $(eval $(call _bi,fini,Makefile)) - $(eval $(call _bi,fini.private,Makefile)) + # include $(BOARD_DIR)/.labfini + $(eval $(call _bi,labfini)) endif # Customize kernel git repo and local dir @@ -3346,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 -- Gitee From 9b32ae925cbdb796a9a4025273d3186aa67aa96d Mon Sep 17 00:00:00 2001 From: unicornx Date: Mon, 13 Apr 2020 22:26:21 +0800 Subject: [PATCH 8/8] doc: sum steps to install docker-ce in ubuntu for mainland users --- doc/misc/install-dockerce-in-ubuntu.md | 117 +++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 doc/misc/install-dockerce-in-ubuntu.md diff --git a/doc/misc/install-dockerce-in-ubuntu.md b/doc/misc/install-dockerce-in-ubuntu.md new file mode 100644 index 0000000..15facc4 --- /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 -- Gitee