UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor koziotis
Visitor
56 Views

SDSoC Program (zcu102 board) crashes with "Bus error" message, when using the sds_alloc_non_cacheable() and -O3 optimization level

Find following a very simple C program that crashes with the message "Bus error" when compiled with -O3 for

target platform zcu102 and target OS linux.
The program allocates a single array of bytes using the sds_alloc_non_cacheable() function.
It exhibits a very strange behavior and seems to be dependent on the initial value of the memory buffer.
In fact when changing initial value from 0 to 1 the problem disappears.

//----------------------------------------------------------
main.cpp:

#include <stdio.h>
#include <stdlib.h>
#include "sds_lib.h"

#define BYTESIZE 1024

int main(int argc, char** argv) {

  char * buf1 = (char *) sds_alloc_non_cacheable(BYTESIZE * sizeof(char) );
  printf("buf1 = %p\n", buf1);
  for (int i=0; i<BYTESIZE; i++) buf1[i] = 0; // not working
//for (int i=0; i<BYTESIZE; i++) buf1[i] = 1; //     working
}

//----------------------------------------------------------

//----------------------------------------------------------
Makefile:

APPSOURCES = main.cpp
EXECUTABLE = buggy.elf

PLATFORM = zcu102
OS = -target-os linux

SDSCC_FLAGS = -sds-pf ${PLATFORM}

CC = sds++ ${SDSCC_FLAGS}

IDIRS =
LDIRS =
LLIBS =
OLEVEL = -O3

CFLAGS = -Wall ${OLEVEL} -c ${IDIRS} ${OS}
LFLAGS = ${OLEVEL} ${LDIRS} ${LLIBS} ${OS}

SOURCES := $(patsubst %,./%,$(APPSOURCES))   
OBJECTS := $(APPSOURCES:.cpp=.o)
DEPS := $(OBJECTS:.o=.d)

.PHONY: all

all: ${EXECUTABLE}

${EXECUTABLE}: ${OBJECTS}
    ${CC} ${OBJECTS} ${LFLAGS} -o $@  

-include ${DEPS}

%.o: %.cpp
    ${CC} ${CFLAGS} $< -o $@

clean:
    ${RM} ${EXECUTABLE} ${OBJECTS}

ultraclean: clean
    ${RM} -rf _sds sd_card ${EXECUTABLE}.bit
    ${RM} -rf vivado* .Xil

//----------------------------------------------------------

 
When changing -O3 to -O0 the problem also disappears.


I would kindly request Xilinx, to get this solved in the upcoming SDSoC versions.

Thank you,

Michael Koziotis

0 Kudos