Do not link against newlib anymore.
Add required stubs used by the startup code.
Add own (very slow!) implementations of memcpy() and memset().
This frees about 2k in SRAM bank 0.
ECC = e-gcc
EOC = e-objcopy
ECFLAGS = -Os -std=c99 -falign-loops=8 -falign-functions=8 -Wall -fsingle-precision-constant -ffast-math
-ELFLAGS = -T$(EPIPHANY_HOME)/bsps/current/internal.ldf -le-lib
+ELFLAGS = -T$(EPIPHANY_HOME)/bsps/current/internal.ldf -nodefaultlibs -lgcc -le-lib
EOFLAGS = -R .shared_dram -R .data_bank1 -R .data_bank2 -R .data_bank3
# host application
# epiphany applications
EAPPS = $(DEST)/main.srec
-ECOMMON = $(EDEST)/d3q19.o
+ECOMMON = $(EDEST)/d3q19.o $(EDEST)/hack.o
# folders
HSRC = hsrc
for(int q = 0; q < 19; q++)
f[z][y][x][q] = 0.1 * d3q19_w[q];
-#if 1
+#if 0
/* except here */
if(core == 0)
for(int q = 0; q < 19; q++)
void collide(block_t f, int x, int y, int z, FLOAT omega)
{
-#if 0
+#if 1
/* Zou/He boundary conditions */
if(row == 0 && z == 0) { /* top */
const FLOAT Ux = 0.0; /* wall speed */
--- /dev/null
+/* hack to enable libc-less project */
+
+#include <stddef.h>
+
+/* since we need to compile with -nodefaultlibs
+ because of insufficient memory, we need to
+ implement everything ourselves */
+
+/* NOTE: NEVER RETURN FROM MAIN - THERE BE DRAGONS */
+
+/* points to a reentrancy structure in libc;
+ since we don't use the libc, point it to data memory,
+ it will be overwritten later */
+void* _impure_ptr = (void*)0x4000;
+
+void exit(int code)
+{
+ while(1) __asm__ volatile("idle");
+}
+
+/* ================================================================== */
+
+void *memcpy(void *dest, const void *src, size_t n)
+{
+ char *s = (char*)src;
+ char *d = (char*)dest;
+
+ while(n--) {
+ *d++ = *s++;
+ }
+
+ return(dest);
+}
+
+void *memset(void *s, int c , size_t n)
+{
+ char *buf = (char*)s;
+
+ while(n--) {
+ *buf++ = (char)c;
+ }
+
+ return(s);
+}
+
/* write data */
//write_populations(shm.lattice, shm.iteration);
- write_density(shm.lattice, shm.iteration);
- //write_velocity(shm.lattice, shm.iteration);
+ //write_density(shm.lattice, shm.iteration);
+ write_velocity(shm.lattice, shm.iteration);
write_timers(shm.times, shm.iteration);
}
/* ================================================================ */