build/nexus: move CAmkES components from capdl-loader to ext_flash.tar

Change-Id: I5f5e14932804e794b7bc07b910da515f0d12f2c9
diff --git a/platforms/nexus/sim.mk b/platforms/nexus/sim.mk
index 05b2779..d9ecb7d 100644
--- a/platforms/nexus/sim.mk
+++ b/platforms/nexus/sim.mk
@@ -50,16 +50,13 @@
 	tar -C $(TMP_RELEASE) -cvhf $@ matcha-tock-bundle.bin kernel capdl-loader
 
 ## Packages the builtins in the tarball for writing to SPI flash.
+# TODO(sleffler): reorder builtins to before build artifacts to reduce lookup time
 ext_flash_release: $(EXT_FLASH_RELEASE) $(EXT_BUILTINS_RELEASE) | $(TMP_RELEASE)
+	cd $(CANTRIP_OUT_RELEASE)/builtins && \
+			${CPIO} -i < ${CANTRIP_OUT_RELEASE}/archive.capdl-loader_archive.o.cpio && \
+			tar -rvhf ${EXT_FLASH_RELEASE} $$(${CPIO} -t < ${CANTRIP_OUT_RELEASE}/archive.capdl-loader_archive.o.cpio)
 	tar -C $(CANTRIP_OUT_RELEASE)/builtins -rvhf ${EXT_FLASH_RELEASE} $$(${CPIO} -t < ${EXT_BUILTINS_RELEASE})
 
-# Dredge the platform configuration for the physical address where the
-# cpio archive is expected.
-# NB: #define must be at the start of the line so any commented out
-#    copies are skipped
-CPIO_LOAD_ADDRESS=$(shell awk '/^#define[ \t]+CPIO_BASE_ADDR/ { print $$3 }' \
-    $(CANTRIP_SRC_DIR)/apps/system/platforms/nexus/platform.camkes)
-
 # Renode commands to issue before the initial start of a simulation.
 # This pauses all cores and then sets cpu0 (SC) & cpu1 (SMC) running.
 RENODE_PRESTART_CMDS=pause; cpu0 IsHalted false;
@@ -77,8 +74,7 @@
 	$(RENODE_CMD) -e "\
     \$$repl_file = @sim/config/platforms/nexus.repl; \
     \$$tar = @$(EXT_FLASH_RELEASE); \
-    \$$cpio = @$(EXT_BUILTINS_RELEASE); \
-    \$$cpio_load_address = ${CPIO_LOAD_ADDRESS}; \
+    \$$cpio = @/dev/null; \
     \$$kernel = @$(CANTRIP_KERNEL_RELEASE); \
     \$$sc_bin =@$(TMP_RELEASE)/matcha-tock-bundle.bin; \
     $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \
@@ -95,8 +91,7 @@
 	$(RENODE_CMD) -e "\
     \$$repl_file = @sim/config/platforms/nexus-debug.repl; \
     \$$tar = @$(EXT_FLASH_DEBUG); \
-    \$$cpio = @$(EXT_BUILTINS_DEBUG); \
-    \$$cpio_load_address = ${CPIO_LOAD_ADDRESS}; \
+    \$$cpio = @/dev/null; \
     \$$kernel = @$(CANTRIP_KERNEL_DEBUG); \
     \$$sc_bin =@$(TMP_DEBUG)/matcha-tock-bundle.bin; \
     $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \
@@ -114,8 +109,7 @@
 	$(RENODE_CMD) -e "\
     \$$repl_file = @sim/config/platforms/nexus-debug.repl; \
     \$$tar = @$(EXT_FLASH_DEBUG); \
-    \$$cpio = @$(EXT_BUILTINS_DEBUG); \
-    \$$cpio_load_address = ${CPIO_LOAD_ADDRESS}; \
+    \$$cpio = @/dev/null; \
     \$$kernel = @$(CANTRIP_KERNEL_DEBUG); \
     \$$sc_bin =@$(TMP_DEBUG)/matcha-tock-bundle.bin; \
     $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; start"