update makefile and readme file space

pull/195/head
jameszow 8 months ago
parent 05844fefcb
commit 5da21a5fe3

@ -88,9 +88,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
@ -107,24 +107,24 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE)
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -133,16 +133,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -155,37 +155,37 @@ qemu: $(KERNEL_BIN)
@$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
--section .text \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt

@ -88,9 +88,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
@ -107,24 +107,24 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE)
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -133,16 +133,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -155,28 +155,28 @@ qemu: $(KERNEL_BIN)
@$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -184,9 +184,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt

@ -58,8 +58,7 @@ diff -uNr 01_wait_forever/Makefile 02_runtime_init/Makefile
--section .text \
+ --section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
diff -uNr 01_wait_forever/src/_arch/aarch64/cpu/boot.rs 02_runtime_init/src/_arch/aarch64/cpu/boot.rs
--- 01_wait_forever/src/_arch/aarch64/cpu/boot.rs

@ -89,9 +89,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -110,24 +110,24 @@ DOCKER_TEST = $(DOCKER_CMD) $(DOCKER_ARG_DIR_COMMON) $(DOCKER_IMAGE)
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -136,16 +136,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -158,28 +158,28 @@ qemu: $(KERNEL_BIN)
@$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -187,9 +187,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -208,9 +208,9 @@ test_boot test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -79,9 +79,9 @@ diff -uNr 02_runtime_init/Makefile 03_hacky_hello_world/Makefile
+EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
+EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
-DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
-DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
+DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
@ -113,9 +113,9 @@ diff -uNr 02_runtime_init/Makefile 03_hacky_hello_world/Makefile
+
+else # QEMU is supported.
+
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+## Run boot test
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+test_boot: $(KERNEL_BIN)
+ $(call color_header, "Boot test - $(BSP)")
+ @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -89,9 +89,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -110,24 +110,24 @@ DOCKER_TEST = $(DOCKER_CMD) $(DOCKER_ARG_DIR_COMMON) $(DOCKER_IMAGE)
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -136,16 +136,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -158,28 +158,28 @@ qemu: $(KERNEL_BIN)
@$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -187,9 +187,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -208,9 +208,9 @@ test_boot test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -93,9 +93,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINITERM = ruby ../common/serial/miniterm.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -122,24 +122,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -148,16 +148,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##-----------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -171,34 +171,34 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Connect to the target's serial
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
miniterm:
@$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -206,9 +206,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -227,9 +227,9 @@ test_boot test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -202,7 +202,7 @@ diff -uNr 04_safe_globals/Makefile 05_drivers_gpio_uart/Makefile
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
+EXEC_MINITERM = ruby ../common/serial/miniterm.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
@@ -95,18 +99,26 @@
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
@ -239,15 +239,15 @@ diff -uNr 04_safe_globals/Makefile 05_drivers_gpio_uart/Makefile
+
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
+## Connect to the target's serial
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+miniterm:
+ @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL)
+
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
diff -uNr 04_safe_globals/src/_arch/aarch64/cpu.rs 05_drivers_gpio_uart/src/_arch/aarch64/cpu.rs

@ -95,9 +95,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_MINIPUSH = ruby tests/chainboot_test.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -124,24 +124,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -150,16 +150,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu qemuasm:
@ -177,34 +177,34 @@ qemuasm: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -212,9 +212,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -233,9 +233,9 @@ test_boot test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_MINIPUSH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) \

@ -199,7 +199,7 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile
+EXEC_TEST_MINIPUSH = ruby tests/chainboot_test.rb
+EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
@@ -110,7 +112,7 @@
ifeq ($(shell uname -s),Linux)
@ -220,7 +220,7 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile
all: $(KERNEL_BIN)
@@ -160,7 +162,7 @@
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
-qemu:
@ -237,20 +237,19 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile
+ @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -d in_asm
+
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
-## Connect to the target's serial
+## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
-miniterm:
- @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL)
+chainboot: $(KERNEL_BIN)
+ @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
@@ -232,7 +238,8 @@
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
- @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -93,9 +93,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -122,24 +122,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -148,16 +148,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -171,34 +171,34 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -206,9 +206,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -227,9 +227,9 @@ test_boot test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -121,9 +121,9 @@ diff -uNr 06_uart_chainloader/Makefile 07_timestamps/Makefile
+EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
@@ -162,7 +160,7 @@
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
-qemu qemuasm:
@ -141,17 +141,17 @@ diff -uNr 06_uart_chainloader/Makefile 07_timestamps/Makefile
-
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
- @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD)
+ @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
@@ -238,8 +232,7 @@
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
- @$(DOCKER_TEST) $(EXEC_TEST_MINIPUSH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) \

@ -97,9 +97,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -133,24 +133,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -217,9 +217,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -231,22 +231,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2
gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
@ -267,9 +267,9 @@ test_boot test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -373,22 +373,22 @@ diff -uNr 07_timestamps/Makefile 08_hw_debug_JTAG/Makefile
+##--------------------------------------------------------------------------------------------------
+.PHONY: jtagboot openocd gdb gdb-opt0
+
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+## Push the JTAG boot image to the real HW target
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+jtagboot:
+ @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
+
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+## Start OpenOCD session
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+openocd:
+ $(call color_header, "Launching OpenOCD")
+ @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
+
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+## Start GDB session
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+gdb: RUSTC_MISC_ARGS += -C debuginfo=2
+gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
+gdb gdb-opt0: $(KERNEL_ELF)

@ -97,9 +97,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -133,24 +133,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -217,9 +217,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -231,22 +231,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2
gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
@ -267,9 +267,9 @@ test_boot test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -97,9 +97,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -133,24 +133,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -217,9 +217,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -231,22 +231,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2
gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
@ -267,9 +267,9 @@ test_boot test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -97,9 +97,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -133,24 +133,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -217,9 +217,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -231,22 +231,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2
gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
@ -267,9 +267,9 @@ test_boot test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -107,9 +107,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -143,24 +143,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -169,16 +169,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -192,36 +192,36 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -229,9 +229,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -243,22 +243,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2
gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
@ -281,16 +281,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Helpers for unit and integration test targets
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER
#!/usr/bin/env bash
@ -313,17 +313,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh
endef
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run unit test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run integration test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare)

@ -409,9 +409,9 @@ The file `kernel_test_runner.sh` does not exist by default. We generate it on de
`make test_*` targets is called:
```Makefile
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Helpers for unit and integration test targets
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER
#!/usr/bin/env bash
@ -434,9 +434,9 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh
endef
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run unit test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare)

@ -107,9 +107,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -143,24 +143,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -169,16 +169,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -192,36 +192,36 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -229,9 +229,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -243,22 +243,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2
gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
@ -281,16 +281,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Helpers for unit and integration test targets
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER
#!/usr/bin/env bash
@ -313,17 +313,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh
endef
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run unit test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run integration test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare)

@ -107,9 +107,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -143,24 +143,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -169,16 +169,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -192,36 +192,36 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -229,9 +229,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -243,22 +243,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2
gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
@ -281,16 +281,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Helpers for unit and integration test targets
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER
#!/usr/bin/env bash
@ -313,17 +313,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh
endef
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run unit test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run integration test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare)

@ -77,9 +77,9 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel
# https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files
KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Translation tables
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
@ -118,9 +118,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -154,32 +154,32 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN)
@ -188,16 +188,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -211,36 +211,36 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -248,9 +248,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -262,22 +262,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2
gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
@ -300,16 +300,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Helpers for unit and integration test targets
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER
#!/usr/bin/env bash
@ -333,17 +333,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh
endef
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run unit test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run integration test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare)

@ -579,24 +579,24 @@ KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb
# [...]
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(TARGET) $(BSP) $(KERNEL_ELF_TTABLES)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN)
@ -1859,9 +1859,9 @@ diff -uNr 14_virtual_mem_part2_mmio_remap/Makefile 15_virtual_mem_part3_precompu
-KERNEL_ELF_DEPS = $(filter-out modulo: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
+KERNEL_ELF_RAW_DEPS = $(filter-out modulo: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
+
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+## Translation tables
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+TT_TOOL_PATH = tools/translation_table_tool
+
+KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
@ -1880,25 +1880,25 @@ diff -uNr 14_virtual_mem_part2_mmio_remap/Makefile 15_virtual_mem_part3_precompu
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
@@ -154,16 +165,24 @@
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
-$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
+$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
+## Precompute the kernel translation tables and patch them into the kernel ELF
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
+ $(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
+ @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
+ @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
+
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
-$(KERNEL_BIN): $(KERNEL_ELF)
+$(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_header, "Generating stripped binary")

@ -77,9 +77,9 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel
# https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files
KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Translation tables
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
@ -118,9 +118,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -154,32 +154,32 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN)
@ -188,16 +188,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -211,36 +211,36 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -248,9 +248,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -262,22 +262,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2
gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
@ -300,16 +300,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Helpers for unit and integration test targets
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER
#!/usr/bin/env bash
@ -333,17 +333,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh
endef
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run unit test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run integration test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare)

@ -77,17 +77,17 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel
# https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files
KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Translation tables
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Kernel symbols
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool
KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols
@ -135,9 +135,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -171,39 +171,39 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate kernel symbols and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS)
$(call color_header, "Generating kernel symbols and patching kernel ELF")
@$(MAKE) --no-print-directory -f kernel_symbols.mk
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN)
@ -212,16 +212,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc: clean
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -235,36 +235,36 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -272,9 +272,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -286,22 +286,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2
gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
@ -324,16 +324,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Helpers for unit and integration test targets
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER
#!/usr/bin/env bash
@ -366,17 +366,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh
endef
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run unit test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run integration test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare)

@ -585,9 +585,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/kernel_symbols.mk 17_kernel_sy
+
+EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb
+
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+## Dockerization
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
+
+# DOCKER_IMAGE defined in include file (see top of this file).
@ -702,9 +702,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/Makefile 17_kernel_symbols/Mak
KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*)
-KERNEL_ELF = $(KERNEL_ELF_TTABLES)
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+## Kernel symbols
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool
+
+KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols
@ -726,16 +726,16 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/Makefile 17_kernel_symbols/Mak
@@ -178,11 +195,18 @@
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
+## Generate kernel symbols and patch them into the kernel ELF
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
+$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS)
+ $(call color_header, "Generating kernel symbols and patching kernel ELF")
+ @$(MAKE) --no-print-directory -f kernel_symbols.mk
+
+## ------------------------------------------------------------------------------
+##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
-$(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
+$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_header, "Generating stripped binary")
@ -745,9 +745,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/Makefile 17_kernel_symbols/Mak
@echo $(KERNEL_BIN)
$(call color_progress_prefix, "Size")
@@ -191,7 +215,7 @@
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
-doc:
+doc: clean
$(call color_header, "Generating docs")

@ -66,9 +66,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
# DOCKER_IMAGE defined in include file (see top of this file).

@ -77,17 +77,17 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel
# https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files
KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Translation tables
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Kernel symbols
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool
KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols
@ -137,9 +137,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -173,39 +173,39 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate kernel symbols and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS)
$(call color_header, "Generating kernel symbols and patching kernel ELF")
@$(MAKE) --no-print-directory -f kernel_symbols.mk
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN)
@ -214,16 +214,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc: clean
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -237,36 +237,36 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -274,9 +274,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -288,22 +288,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
$(call color_header, "Launching GDB")
@ -325,16 +325,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Helpers for unit and integration test targets
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER
#!/usr/bin/env bash
@ -367,17 +367,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh
endef
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run unit test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run integration test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare)

@ -1261,9 +1261,9 @@ diff -uNr 17_kernel_symbols/Makefile 18_backtrace/Makefile
--strip-all \
-O binary
@@ -302,8 +304,7 @@
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
-gdb: RUSTC_MISC_ARGS += -C debuginfo=2
-gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0
+gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0

@ -66,9 +66,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
# DOCKER_IMAGE defined in include file (see top of this file).

@ -82,17 +82,17 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel
# https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files
KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Translation tables
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Kernel symbols
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool
KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols
@ -142,9 +142,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -178,39 +178,39 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate kernel symbols and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS)
$(call color_header, "Generating kernel symbols and patching kernel ELF")
@$(MAKE) --no-print-directory -f kernel_symbols.mk
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN)
@ -219,16 +219,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc: clean
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -242,36 +242,36 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -279,9 +279,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -293,22 +293,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
$(call color_header, "Launching GDB")
@ -330,16 +330,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Helpers for unit and integration test targets
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER
#!/usr/bin/env bash
@ -372,17 +372,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh
endef
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run unit test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run integration test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare)

@ -66,9 +66,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
# DOCKER_IMAGE defined in include file (see top of this file).

@ -82,17 +82,17 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel
# https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files
KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Translation tables
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Kernel symbols
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool
KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols
@ -142,9 +142,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -178,39 +178,39 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate kernel symbols and patch them into the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS)
$(call color_header, "Generating kernel symbols and patching kernel ELF")
@$(MAKE) --no-print-directory -f kernel_symbols.mk
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN)
@ -219,16 +219,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc: clean
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -242,36 +242,36 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -279,9 +279,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -293,22 +293,22 @@ nm: $(KERNEL_ELF)
##--------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start OpenOCD session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
openocd:
$(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Start GDB session
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF)
$(call color_header, "Launching GDB")
@ -330,16 +330,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Helpers for unit and integration test targets
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER
#!/usr/bin/env bash
@ -372,17 +372,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh
endef
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run unit test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run integration test(s)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare)

@ -66,9 +66,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
# DOCKER_IMAGE defined in include file (see top of this file).

@ -93,9 +93,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Dockerization
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -122,24 +122,24 @@ endif
all: $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG):
@rm -f target/*.build_config
@mkdir -p target
@touch $(LAST_BUILD_CONFIG)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Compile the kernel ELF
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the stripped kernel binary
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -148,16 +148,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN))
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Generate the documentation
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
doc:
$(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run the kernel in QEMU
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu:
@ -171,34 +171,34 @@ qemu: $(KERNEL_BIN)
endif
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Push the kernel to the real HW target
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run clippy
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Clean
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
clean:
rm -rf target $(KERNEL_BIN)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run readelf
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run objdump
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -206,9 +206,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \
$(KERNEL_ELF) | rustfilt
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run nm
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
nm: $(KERNEL_ELF)
$(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
@ -227,9 +227,9 @@ test_boot test:
else # QEMU is supported.
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
## Run boot test
## ------------------------------------------------------------------------------
##------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

Loading…
Cancel
Save