~aleteoryx/muditaos

3178bc7256fcdc7319f97ce803a0e63510976479 — Lucjan Bryndza 5 years ago 43b9c45
[EGD-4524] Fix unable to build Linux Release tgt (#1093)

Due to the errors in the libiosyscalls it was impossible
to build emulator for Linux Debug target. This commit will fix this
problem.

Co-authored-by: Lucjan Bryndza <lucjan.bryndza@mudita.com>
M board/linux/libiosyscalls/src/syscalls_scan_family.cpp => board/linux/libiosyscalls/src/syscalls_scan_family.cpp +1 -1
@@ 170,7 170,7 @@ extern "C" {
    __asm__(".symver vfscanf,vfscanf@GLIBC_2.2.5");

    int fscanf (FILE *__restrict fp,
                   const char *__restrict fmt, ...) __wur
                   const char *__restrict fmt, ...)
    {
        TRACE_SYSCALL();
        va_list ap;

M board/linux/libiosyscalls/src/syscalls_stdio.cpp => board/linux/libiosyscalls/src/syscalls_stdio.cpp +9 -9
@@ 179,7 179,7 @@ extern "C"
    }
    __asm__(".symver fclose,fclose@GLIBC_2.2.5");

    FILE *fdopen(int __fd, const char *__modes) __THROW __wur
    FILE *fdopen(int __fd, const char *__modes) __THROW
    {
        TRACE_SYSCALL();
        real_fprintf(stderr, "unimplemented call %s\n", __PRETTY_FUNCTION__  );


@@ 188,7 188,7 @@ extern "C"
    }
    __asm__(".symver fdopen,fdopen@GLIBC_2.2.5");

    int feof(FILE *__stream) __THROW __wur
    int feof(FILE *__stream) __THROW
    {
        TRACE_SYSCALL();
        if(!vfs::is_ff_handle(__stream)) {


@@ 204,7 204,7 @@ extern "C"
    }
    __asm__(".symver feof,feof@GLIBC_2.2.5");

    int ferror(FILE * stream) __THROW __wur
    int ferror(FILE * stream) __THROW
    {
        TRACE_SYSCALL();
        if(vfs::is_ff_handle(stream)) {


@@ 287,7 287,7 @@ extern "C"
    }
    __asm__(".symver fgetpos64,fgetpos64@GLIBC_2.2.5");

    char *fgets(char *__restrict __s, int __n, FILE *__restrict __stream) __wur
    char *fgets(char *__restrict __s, int __n, FILE *__restrict __stream)
    {
        TRACE_SYSCALL();
        if(!vfs::is_ff_handle(__stream)) {


@@ 303,7 303,7 @@ extern "C"
    }
    __asm__(".symver fgets,fgets@GLIBC_2.2.5");

    int fileno(FILE *__stream) __THROW __wur
    int fileno(FILE *__stream) __THROW
    {
        auto ret = vfsn::linux::internal::ff_file_to_fd(reinterpret_cast<FF_FILE*>(__stream));
        if(ret<0) {


@@ 386,7 386,7 @@ extern "C"
            errno = EIO;
            return -1;
        }
        int ret;
        int ret{-1};
        while (*__s) {
            ret = ff_fputc(*__s++, reinterpret_cast<FF_FILE *>(__stream));
            if (ret < 0)


@@ 397,7 397,7 @@ extern "C"
    }
    __asm__(".symver fputs,fputs@GLIBC_2.2.5");

    size_t fread(void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) __wur
    size_t fread(void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream)
    {
        TRACE_SYSCALL();
        if(!vfs::is_ff_handle(__stream)) {


@@ 416,7 416,7 @@ extern "C"

    FILE *freopen (const char *__restrict __filename,
                      const char *__restrict __modes,
                      FILE *__restrict __stream) __wur
                      FILE *__restrict __stream)
    {
        TRACE_SYSCALL();
        if(!vfs::is_ff_handle(__stream)) {


@@ 486,7 486,7 @@ extern "C"
    __asm__(".symver fsetpos64,fsetpos64@GLIBC_2.2.5");


    long int ftell (FILE *__stream) __wur
    long int ftell (FILE *__stream)
    {
        TRACE_SYSCALL();
        if(!vfs::is_ff_handle(__stream)) {

M changelog.md => changelog.md +1 -0
@@ 8,6 8,7 @@
### Fixed

* `[audio]` Fix playback of mono sound using headphones
* `[vfs]` Fix emulator build error for target Linux Release

## Changed


M module-vfs/CMakeLists.txt => module-vfs/CMakeLists.txt +1 -1
@@ 26,7 26,7 @@ third_party_source_optimization(${FREERTOS_FAT_SOURCES})
# in the FREERTOS FAT implementation
if(${PROJECT_TARGET}  STREQUAL "TARGET_Linux")
set_property(SOURCE ${FREERTOS_FAT_SOURCES} APPEND_STRING PROPERTY COMPILE_FLAGS
" -Wno-overflow -Wno-type-limits -Wno-format -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast")
" -Wno-overflow -Wno-type-limits -Wno-format -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-stringop-truncation")
endif()

set(PROJECT_INCLUDES

M run_emulator_on_filesystem_image.sh => run_emulator_on_filesystem_image.sh +42 -4
@@ 1,8 1,46 @@
#!/bin/bash
#!/bin/bash -e
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

cd ./build-linux-*
export LD_PRELOAD=$(realpath board/linux/libiosyscalls/libiosyscalls.so)
./PurePhone.elf
arraymenu ()
{
  echo "Number of build images: $#"
  echo "$@"
  select option; do # in "$@" is the default
    if [ "$REPLY" -eq "$#" ];
    then
      echo "Exiting..."
      break;
    elif [ 1 -le "$REPLY" ] && [ "$REPLY" -le $(($#-1)) ];
    then
      echo "You selected $option emulator image."
      break;
    else
      echo "Incorrect Input: Select a number 1-$#"
    fi
  done
}

readarray -t dirs < <(find . -maxdepth 1 -type d -iname 'build-linux-*' -printf '%P\n')

if [ ${#dirs[@]} -eq 1 ]; then
    cd "${dirs[0]}"
elif [ ${#dirs[@]} -gt 1 ]; then
    arraymenu "${dirs[@]}"
    cd "${dirs[$REPLY-1]}"
else
    echo "Error: Emulator directory doesn't exists"
    exit -1
fi

PRELOAD_LIB=$(realpath board/linux/libiosyscalls/libiosyscalls.so)
APP_BINARY="./PurePhone.elf"
if [ ! -x "$APP_BINARY" ]; then
    echo "Error: $APP_BINARY doesn't exists"
elif [ ! -x "$PRELOAD_LIB" ]; then
    echo "Error: $PRELOAD_LIB doesn't exists"
else
    echo "Running emulator in directory: $(pwd)"
    export LD_PRELOAD=$PRELOAD_LIB
    exec "$APP_BINARY"
fi