diff --git a/.gdb/uboot.default b/.gdb/uboot.default index 412ce5934e4785af0625cf2ec9cd333f0caa9a6e..6d1e76b788026d3aa78d3744c947e5bf6adfbb0e 100644 --- a/.gdb/uboot.default +++ b/.gdb/uboot.default @@ -1,6 +1,6 @@ shell echo "Waiting for 1 secs..." shell sleep 1 -shell echo"Executing gdb commands in local .gdbinit ..." +shell echo "Executing gdb commands in local .gdbinit ..." shell echo "(gdb) target remote :1234" target remote :1234 diff --git a/Makefile b/Makefile index 4d89af15f35aaa1fa15953605d2230d13ae00ae1..a4879859a92a5caee85848d6349bb141c9169634 100644 --- a/Makefile +++ b/Makefile @@ -426,6 +426,7 @@ ifeq ($(findstring -run,$(first_target)),-run) x := $(APP_ARGS) endif +# common commands ifneq ($(filter $(first_target),$(APP_TARGETS)),) # use the rest as arguments for "run" APP_ARGS := $(filter-out $(first_target),$(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))) @@ -445,7 +446,7 @@ ifneq ($$($(2)),) override app += $(1) endif -endef +endef #default_detectapp ifneq ($(APP_ARGS),) APP := $(firstword $(APP_ARGS)) @@ -3052,8 +3053,14 @@ endif EMULATOR_OPTS ?= -M $(MACH) -m $(call _v,MEM,LINUX) $(NET) -smp $(call _v,SMP,LINUX) $(KERNEL_OPT) $(EXIT_ACTION) EMULATOR_OPTS += $(SHARE_OPT) +# Debug listen on a unqiue port, should run exclusively +ifneq ($(DEBUG),0) + DEBUG_LOCK := $(GDBINIT_DIR)/.lock + KEEP_UNIQUE := flock -n -x $(DEBUG_LOCK) +endif + # Launch Qemu, prefer our own instead of the prebuilt one -BOOT_CMD := sudo $(EMULATOR) $(EMULATOR_OPTS) +BOOT_CMD := $(KEEP_UNIQUE) sudo $(EMULATOR) $(EMULATOR_OPTS) ifeq ($(U),1) ifeq ($(SD_BOOT),1) @@ -3407,7 +3414,11 @@ endif ifeq ($(XTERM_STATUS), 0) DEBUG_CMD := $(XTERM_CMD) else - DEBUG_CMD := $(Q)echo "\nLOG: Please run this in another terminal:\n\n " $(GDB_CMD) "\n" + DEBUG_CMD := $(Q)sleep 0.1 && echo "\nLOG: debug server started, please connect it with these commands:\n\n" \ + " (host) $$ cd /path/to/cloud-lab\n" \ + " (host) $$ tools/docker/bash linux-lab\n" \ + " ubuntu@linux-lab:/labs/linux-lab$$ make $(MAKECMDGOALS)\n" + #DEBUG_CMD := $(Q)echo "\nLOG: Please run this in another terminal:\n\n " $(GDB_CMD) "\n" endif # FIXME: gdb not continue the commands in .gdbinit while runing with 'CASE=debug tools/testing/run.sh' @@ -3428,7 +3439,10 @@ ifneq ($(TEST_TIMEOUT),0) else DEBUG_INIT := _debug_init_1 endif -DEBUG_CLIENT := $(DEBUG_DEPS) $(DEBUG_INIT) _debug + +ifeq ($(shell pgrep flock >/dev/null; echo $$?), 1) + DEBUG_CLIENT := $(DEBUG_DEPS) $(DEBUG_INIT) _debug +endif PHONY += _debug _debug_init_1 _debug_init_2 @@ -3445,8 +3459,14 @@ _BOOT_DEPS += $(UBOOT_IMGS) _BOOT_DEPS += $(DEBUG_CLIENT) _BOOT_DEPS += $(BOOT_DTB) +ifneq ($(DEBUG),0) + RUN_BOOT_CMD := $(BOOT_CMD) || $(GDB_CMD) +else + RUN_BOOT_CMD := $(BOOT_CMD) +endif + _boot: $(_BOOT_DEPS) - $(BOOT_CMD) + $(RUN_BOOT_CMD) PHONY += boot-test _boot diff --git a/README.md b/README.md index ffe95636dc68ce2abdb02f349cf89a8db594fdca..8b05290b1169dc2047791acaf24e997f058efdc7 100644 --- a/README.md +++ b/README.md @@ -254,14 +254,14 @@ Docker is required by Linux Lab, please install it at first: Install Ubuntu via Virtualbox or Vmware Virtual Machine -Before running Linux Lab, please make sure the following command works without sudo and without any issue: +Before running Linux Lab, please refer to section 6.1.4 and make sure the following command works without sudo and without any issue: $ docker run hello-world In China, to use docker service normally, please **must** configure one of chinese docker mirror sites, for example: - * [Aliyun Docker Mirror Documentation](https://help.aliyun.com/document_detail/60750.html) - * [USTC Docker Mirror Documentation](https://lug.ustc.edu.cn/wiki/mirrors/help/docker) + * [Aliyun Docker Mirror Documentation](https://help.aliyun.com/document_detail/60750.html)(For non Univerisity) + * [USTC Docker Mirror Documentation](https://lug.ustc.edu.cn/wiki/mirrors/help/docker)(For Univerisity) More docker related issues, such as download slowly, download timeout and download errors, are cleary documented in the 6.1 section of FAQs. diff --git a/README_zh.md b/README_zh.md index 436a5892e008f313beb71b75a5b1d6f475d09153..2f9c2beb43ebf4ae926a8046c8278331f913c210 100644 --- a/README_zh.md +++ b/README_zh.md @@ -319,14 +319,14 @@ Linux Lab 是一套完备的嵌入式 Linux 开发环境,需要预留足够的 通过 Virtualbox 或 Vmware 安装 Ubuntu 后使用 -在运行 Linux Lab 之前,请确保无需 `sudo` 权限也可以正常运行以下命令: +在运行 Linux Lab 之前,请参考 6.1.4 节确保无需 `sudo` 权限也可以正常运行以下命令: $ docker run hello-world 另外,在国内要正常使用 Docker,请**务必**配置好国内的 Docker 镜像加速服务: - * [阿里云 Docker 镜像使用文档](https://help.aliyun.com/document_detail/60750.html) - * [USTC Docker 镜像使用文档](https://lug.ustc.edu.cn/wiki/mirrors/help/docker) + * [阿里云 Docker 镜像使用文档](https://help.aliyun.com/document_detail/60750.html)(适合企业和家庭网络) + * [USTC Docker 镜像使用文档](https://lug.ustc.edu.cn/wiki/mirrors/help/docker)(适合高校网络) 使用 Linux Lab 过程中的常见 Docker 相关问题,请参考常见问题中的 6.1 节,镜像下载慢、下载超时、下载出错等问题都有详细解决方案。 diff --git a/doc/install/arch-docker.md b/doc/install/arch-docker.md index fac424b0f83f43ed7cbdde5c997bfb589e7062ab..3dd659736a1990e623f54299235f0a1d813e0198 100644 --- a/doc/install/arch-docker.md +++ b/doc/install/arch-docker.md @@ -90,6 +90,11 @@ "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"] } + 使用 `systemd` 用户可以通过执行 `sudo systemctl edit docker.service` 来修改设置, 覆盖默认的启动参数: + + [Service] + ExecStart= + ExecStart=/usr/bin/docker -d -H fd:// --registry-mirror=https://docker.mirrors.ustc.edu.cn 配置完成之后执行如下命令重新启动服务生效。 diff --git a/doc/install/manjaro-docker.md b/doc/install/manjaro-docker.md index a70ea2071f0ddbbfedf2203e7382fa6228381cc9..f023ec19291b27154fb6bbc02bc4316d221271f0 100644 --- a/doc/install/manjaro-docker.md +++ b/doc/install/manjaro-docker.md @@ -95,6 +95,11 @@ Manjaro Linux 设置国内镜像站: "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"] } + 使用 `systemd` 用户可以通过执行 `sudo systemctl edit docker.service` 来修改设置, 覆盖默认的启动参数: + + [Service] + ExecStart= + ExecStart=/usr/bin/docker -d -H fd:// --registry-mirror=https://docker.mirrors.ustc.edu.cn 配置完成之后执行如下命令重新启动服务生效。