From 0253e0a89dfaf31a740927ce8f03e83efe4f1318 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 17 Jan 2017 05:36:07 +0000 Subject: [PATCH] firmware: remove false dependency from runtime to ksupport. This significantly speeds up no-change builds. --- artiq/firmware/runtime/kernel.rs | 12 +++++++++--- artiq/runtime/Makefile | 12 ++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/artiq/firmware/runtime/kernel.rs b/artiq/firmware/runtime/kernel.rs index 5096badc1..dc36dfacc 100644 --- a/artiq/firmware/runtime/kernel.rs +++ b/artiq/firmware/runtime/kernel.rs @@ -12,9 +12,15 @@ pub unsafe fn start() { stop(); - let ksupport_image = include_bytes!(concat!(env!("CARGO_TARGET_DIR"), "/../ksupport.elf")); - let ksupport_addr = (KERNELCPU_EXEC_ADDRESS - KSUPPORT_HEADER_SIZE) as *mut u8; - ptr::copy_nonoverlapping(ksupport_image.as_ptr(), ksupport_addr, ksupport_image.len()); + extern { + static _binary_ksupport_elf_start: u8; + static _binary_ksupport_elf_end: u8; + } + let ksupport_start = &_binary_ksupport_elf_start as *const _; + let ksupport_end = &_binary_ksupport_elf_end as *const _; + ptr::copy_nonoverlapping(ksupport_start, + (KERNELCPU_EXEC_ADDRESS - KSUPPORT_HEADER_SIZE) as *mut u8, + ksupport_end as usize - ksupport_start as usize); csr::kernel_cpu::reset_write(0); diff --git a/artiq/runtime/Makefile b/artiq/runtime/Makefile index 602774e83..1b6b09833 100644 --- a/artiq/runtime/Makefile +++ b/artiq/runtime/Makefile @@ -3,9 +3,6 @@ include $(MISOC_DIRECTORY)/software/common.mak PYTHON ?= python3.5 -OBJECTS := flash_storage.o main.o -OBJECTS_KSUPPORT := ksupport_glue.o artiq_personality.o - RUSTOUT := cargo/or1k-unknown-none/debug RUSTOUT_KSUPPORT := cargo-ksupport/or1k-unknown-none/debug @@ -31,13 +28,13 @@ LDFLAGS += --gc-sections \ all: runtime.bin runtime.fbi .PHONY: $(RUSTOUT)/libruntime.a -$(RUSTOUT)/libruntime.a: ksupport.elf +$(RUSTOUT)/libruntime.a: RUSTFLAGS="-C target-feature=+mul,+div,+ffl1,+cmov,+addc -C opt-level=s -Cpanic=abort" \ CARGO_TARGET_DIR=$(realpath .)/cargo \ cargo build --target=or1k-unknown-none \ --manifest-path $(realpath $(RUNTIME_DIRECTORY)/../firmware/runtime/Cargo.toml) -runtime.elf: $(OBJECTS) $(RUSTOUT)/libruntime.a +runtime.elf: $(RUSTOUT)/libruntime.a flash_storage.o main.o ksupport_data.o $(LD) $(LDFLAGS) \ -T $(RUNTIME_DIRECTORY)/runtime.ld \ -o $@ \ @@ -52,7 +49,7 @@ $(RUSTOUT_KSUPPORT)/libksupport.a: cargo build --target=or1k-unknown-none \ --manifest-path $(realpath $(RUNTIME_DIRECTORY)/../firmware/libksupport/Cargo.toml) -ksupport.elf: $(OBJECTS_KSUPPORT) $(RUSTOUT_KSUPPORT)/libksupport.a +ksupport.elf: $(RUSTOUT_KSUPPORT)/libksupport.a ksupport_glue.o artiq_personality.o $(LD) $(LDFLAGS) \ --eh-frame-hdr \ -T $(RUNTIME_DIRECTORY)/ksupport.ld \ @@ -68,6 +65,9 @@ ksupport.elf: $(OBJECTS_KSUPPORT) $(RUSTOUT_KSUPPORT)/libksupport.a $(OBJCOPY) -O binary $< $@ @chmod -x $@ +%_data.o: %.elf + $(LD) -r -b binary -o $@ $< + %.fbi: %.bin @echo " MSCIMG " $@ && $(PYTHON) -m misoc.tools.mkmscimg -f -o $@ $<