diff --git a/apps/hello-world/Debug/makefile b/apps/hello-world/Debug/makefile deleted file mode 100644 index 09b7b1cc..00000000 --- a/apps/hello-world/Debug/makefile +++ /dev/null @@ -1,44 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - --include ../makefile.init - -RM := rm -rf - -# All of the sources participating in the build are defined here --include sources.mk --include src/subdir.mk --include subdir.mk --include objects.mk - -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(strip $(C_DEPS)),) --include $(C_DEPS) -endif -endif - --include ../makefile.defs - -# Add inputs and outputs from these tool invocations to the build variables - -# All Target -all: e_hello_world.elf - -# Tool invocations -e_hello_world.elf: $(OBJS) $(USER_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: Epiphany Linker' - e-gcc -T /opt/adapteva/esdk/bsps/zed_E16G3_512mb/fast.ldf -o "e_hello_world.elf" $(OBJS) $(USER_OBJS) $(LIBS) - @echo 'Finished building target: $@' - @echo ' ' - -# Other Targets -clean: - -$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) e_hello_world.elf - -@echo ' ' - -.PHONY: all clean dependents -.SECONDARY: - --include ../makefile.targets diff --git a/apps/hello-world/Debug/objects.mk b/apps/hello-world/Debug/objects.mk deleted file mode 100644 index 742c2da0..00000000 --- a/apps/hello-world/Debug/objects.mk +++ /dev/null @@ -1,8 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -USER_OBJS := - -LIBS := - diff --git a/apps/hello-world/Debug/sources.mk b/apps/hello-world/Debug/sources.mk deleted file mode 100644 index 57cf3c3f..00000000 --- a/apps/hello-world/Debug/sources.mk +++ /dev/null @@ -1,17 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -O_SRCS := -C_SRCS := -S_UPPER_SRCS := -OBJ_SRCS := -ASM_SRCS := -OBJS := -C_DEPS := -EXECUTABLES := - -# Every subdirectory with source files must be described here -SUBDIRS := \ -src \ - diff --git a/apps/hello-world/Debug/src/subdir.mk b/apps/hello-world/Debug/src/subdir.mk deleted file mode 100644 index 0d59961b..00000000 --- a/apps/hello-world/Debug/src/subdir.mk +++ /dev/null @@ -1,24 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -# Add inputs and outputs from these tool invocations to the build variables -C_SRCS += \ -../src/e_hello_world.c - -OBJS += \ -./src/e_hello_world.o - -C_DEPS += \ -./src/e_hello_world.d - - -# Each subdirectory must supply rules for building sources it contributes -src/%.o: ../src/%.c - @echo 'Building file: $<' - @echo 'Invoking: Epiphany Compiler' - e-gcc -O0 -g3 -Wall -c -fmessage-length=0 -ffp-contract=fast -mlong-calls -mfp-mode=round-nearest -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/apps/hello-world/build.sh b/apps/hello-world/build.sh index 29c9bd8f..cf34ed49 100755 --- a/apps/hello-world/build.sh +++ b/apps/hello-world/build.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Last update: 2016 dec 19. (JLQ). + set -e ESDK=${EPIPHANY_HOME} @@ -11,6 +13,9 @@ SCRIPT=$(readlink -f "$0") EXEPATH=$(dirname "$SCRIPT") cd $EXEPATH +# Create the binaries directory +mkdir -p bin/ + if [ -z "${CROSS_COMPILE+xxx}" ]; then case $(uname -p) in arm*) @@ -25,9 +30,13 @@ esac fi # Build HOST side application -${CROSS_COMPILE}gcc src/hello_world.c -o Debug/hello_world.elf ${EINCS} ${ELIBS} -le-hal -le-loader -lpthread +${CROSS_COMPILE}gcc src/hello_world.c -o bin/hello_world.elf ${EINCS} ${ELIBS} -le-hal -le-loader -lpthread # Build DEVICE side program -e-gcc -T ${ELDF} src/e_hello_world.c -o Debug/e_hello_world.elf -le-lib +e-gcc -T ${ELDF} src/e_hello_world.c -o bin/e_hello_world.elf -le-lib + + + + diff --git a/apps/hello-world/run.sh b/apps/hello-world/run.sh index 3ee8634a..6f6e12ef 100755 --- a/apps/hello-world/run.sh +++ b/apps/hello-world/run.sh @@ -2,8 +2,9 @@ set -e +SCRIPT=$(readlink -f "$0") +EXEPATH=$(dirname "$SCRIPT") -cd Debug +cd $EXEPATH/bin ./hello_world.elf - diff --git a/apps/hello-world/src/e_hello_world.c b/apps/hello-world/src/e_hello_world.c index 87be854d..95822079 100644 --- a/apps/hello-world/src/e_hello_world.c +++ b/apps/hello-world/src/e_hello_world.c @@ -25,41 +25,25 @@ // a message identifying itself to the shared external // memory buffer. +// Last update: 2016 dec 19. (JLQ). + #include #include #include #include "e_lib.h" -int main(void) { - const char ShmName[] = "hello_shm"; - const char Msg[] = "Hello World from core 0x%03x!"; - char buf[256] = { 0 }; - e_coreid_t coreid; - e_memseg_t emem; - unsigned my_row; - unsigned my_col; - - - // Who am I? Query the CoreID from hardware. - coreid = e_get_coreid(); - e_coords_from_coreid(coreid, &my_row, &my_col); +#define buff_sz (4096) - if ( E_OK != e_shm_attach(&emem, ShmName) ) { - return EXIT_FAILURE; - } +char outbuf[buff_sz] SECTION("shared_dram"); - // Attach to the shm segment - snprintf(buf, sizeof(buf), Msg, coreid); - - if ( emem.size >= strlen(buf) + 1 ) { - // Write the message (including the null terminating - // character) to shared memory - e_write((void*)&emem, buf, my_row, my_col, NULL, strlen(buf) + 1); - } else { - // Shared memory region is too small for the message - return EXIT_FAILURE; - } +int main(void) { + e_coreid_t coreid; + coreid = e_get_coreid(); + + sprintf(outbuf, "Hello World from core 0x%03x! \n", coreid); + return EXIT_SUCCESS; } + diff --git a/apps/hello-world/src/hello_world.c b/apps/hello-world/src/hello_world.c index 9e774e7f..74c7dc6a 100644 --- a/apps/hello-world/src/hello_world.c +++ b/apps/hello-world/src/hello_world.c @@ -26,6 +26,8 @@ // shared external memory buffer for the core's output // message. +// Last update: 2016 dec 19. (JLQ). + #include #include #include @@ -34,20 +36,18 @@ #include -const unsigned ShmSize = 128; -const char ShmName[] = "hello_shm"; -const unsigned SeqLen = 20; +#define buff_sz (4096) +#define buff_offset (0x01000000) int main(int argc, char *argv[]) { unsigned row, col, coreid, i; e_platform_t platform; e_epiphany_t dev; - e_mem_t mbuf; + e_mem_t emem; + char emsg[buff_sz]; int rc; - srand(1); - e_set_loader_verbosity(H_D0); e_set_host_verbosity(H_D0); @@ -60,53 +60,51 @@ int main(int argc, char *argv[]) // Allocate a buffer in shared external memory // for message passing from eCore to host. - rc = e_shm_alloc(&mbuf, ShmName, ShmSize); - if (rc != E_OK) - rc = e_shm_attach(&mbuf, ShmName); - - if (rc != E_OK) { - fprintf(stderr, "Failed to allocate shared memory. Error is %s\n", - strerror(errno)); - return EXIT_FAILURE; - } + e_alloc(&emem, buff_offset, buff_sz); + + // Open a workgroup + e_open(&dev, 0, 0, platform.rows, platform.cols); + + // Reset the workgroup + e_reset_group(&dev); + + // Load the device program onto all the eCores + e_load_group("e_hello_world.elf", &dev, 0, 0, platform.rows, platform.cols, E_FALSE); - for (i=0; i