diff options
| author | bhgv <bhgv.empire@gmail.com> | 2020-05-28 12:49:41 +0300 |
|---|---|---|
| committer | bhgv <bhgv.empire@gmail.com> | 2020-05-28 12:49:41 +0300 |
| commit | 2b3bc21f3f7edb429302e81f54d2e3c0e89e5acb (patch) | |
| tree | a6ddafb5f0ebcdf9bca3fd8e4f56874e6faf15bd | |
| parent | 8d7c6b15fa5733a3070003520a1d869c0635ef82 (diff) | |
sup. FreeRTOS riscV-64 (k210 cpu). 4th step
| -rw-r--r-- | FreeRTOS/riscv64/include/lib9.h | 11 | ||||
| -rwxr-xr-x | bld-lin-fb-k210.sh | 11 | ||||
| -rw-r--r-- | emu/FreeRTOS/devfs-posix.c | 10 | ||||
| -rw-r--r-- | emu/FreeRTOS/emu | 4 | ||||
| -rw-r--r-- | emu/FreeRTOS/kproc-xthreads.c | 7 | ||||
| -rw-r--r-- | emu/FreeRTOS/mkfile | 2 | ||||
| -rw-r--r-- | emu/port/fns.h | 2 | ||||
| -rw-r--r-- | include/interp.h | 6 | ||||
| -rw-r--r-- | include/pool.h | 2 | ||||
| -rw-r--r-- | lib9/getcallerpc-FreeRTOS-riscv64.c | 3 | ||||
| -rw-r--r-- | mkfiles/mkfile-FreeRTOS-riscv64 | 39 |
11 files changed, 83 insertions, 14 deletions
diff --git a/FreeRTOS/riscv64/include/lib9.h b/FreeRTOS/riscv64/include/lib9.h index c1196b0..4302b6e 100644 --- a/FreeRTOS/riscv64/include/lib9.h +++ b/FreeRTOS/riscv64/include/lib9.h @@ -130,6 +130,13 @@ extern int isupperrune(Rune); /* * malloc */ +#define malloc malloc_ +#define free free_ +#define realloc realloc_ +#define calloc calloc_ +#define mallocz mallocz_ +#define msize msize_ + extern void* malloc(size_t); extern void* mallocz(ulong, int); extern void free(void*); @@ -479,6 +486,10 @@ static __inline uintptr getcallerpc(void* dummy) { ); return lr; } +#else +static __inline uintptr getcallerpc(void* dummy) { + return 0; +} #endif extern void setfcr(ulong); diff --git a/bld-lin-fb-k210.sh b/bld-lin-fb-k210.sh index 3024fef..95048f9 100755 --- a/bld-lin-fb-k210.sh +++ b/bld-lin-fb-k210.sh @@ -6,7 +6,9 @@ #mkdir out -export PATH=/opt/kendryte-toolchain/bin:$PWD/Linux/386/bin:$PATH +export K210_TOOLCHAIN_PATH=/opt/kendryte-toolchain + +export PATH=$K210_TOOLCHAIN_PATH/bin:$PWD/Linux/386/bin:$PATH export ROOT=$PWD @@ -16,6 +18,13 @@ export K210_SDK=$ROOT/../kendryte-freertos-sdk export FreeRTOS_ROOT=$K210_SDK/lib/freertos +export K210_SDK_LIBS=$ROOT/extSDK/lib + +#a path where is it: crti.o, crtbegin.o, crtend.o, crtn.o +export K210_CRT_BEGIN_END_PATH=$K210_TOOLCHAIN_PATH/lib/gcc/riscv64-unknown-elf/8.2.0 + +export EMU_LD_SCRIPT=$K210_SDK/lds/kendryte.ld + #unzip -n dis_folders.zip ln -sf mkconfig.FreeRTOS-riscv64 mkconfig diff --git a/emu/FreeRTOS/devfs-posix.c b/emu/FreeRTOS/devfs-posix.c index 800078f..d563de9 100644 --- a/emu/FreeRTOS/devfs-posix.c +++ b/emu/FreeRTOS/devfs-posix.c @@ -65,6 +65,7 @@ struct User char rootdir[MAXROOT] = ROOT; +#if 0 //{} static User* uidmap[NID]; static User* gidmap[NID]; static QLock idl; @@ -74,6 +75,9 @@ static User* newuid(int); static User* newgid(int); static User* newuname(char*); static User* newgname(char*); +#else //{} +static QLock idl; +#endif //{} static Qid fsqid(struct stat *); static void fspath(Cname*, char*, char*); @@ -462,12 +466,15 @@ fsread(Chan *c, void *va, long n, vlong offset) qunlock(&FS(c)->oq); }else{ //{} if(!FS(c)->issocket){ +#if 0 //{} r = pread(FS(c)->fd, va, n, offset); if(r >= 0) return r; if(errno != ESPIPE && errno != EPIPE) oserror(); +#endif //{} //{} } + vfs.lseek(FS(c)->fd, offset, SEEK_SET); r = vfs.read(FS(c)->fd, va, n); if(r < 0) oserror(); @@ -481,12 +488,15 @@ fswrite(Chan *c, void *va, long n, vlong offset) long r; //{} if(!FS(c)->issocket){ +#if 0 //{} r = pwrite(FS(c)->fd, va, n, offset); if(r >= 0) return r; if(errno != ESPIPE && errno != EPIPE) oserror(); +#endif //{} //{} } + vfs.lseek(FS(c)->fd, offset, SEEK_SET); r = vfs.write(FS(c)->fd, va, n); if(r < 0) oserror(); diff --git a/emu/FreeRTOS/emu b/emu/FreeRTOS/emu index 0141c36..513acbf 100644 --- a/emu/FreeRTOS/emu +++ b/emu/FreeRTOS/emu @@ -41,6 +41,8 @@ lib 9 + iot + # lodepng link @@ -59,7 +61,7 @@ mod # freetype port - alloc + alloc-andr cache chan dev diff --git a/emu/FreeRTOS/kproc-xthreads.c b/emu/FreeRTOS/kproc-xthreads.c index ade5e35..2a6cc25 100644 --- a/emu/FreeRTOS/kproc-xthreads.c +++ b/emu/FreeRTOS/kproc-xthreads.c @@ -17,6 +17,10 @@ #include <semphr.h> +void* pvGetLuaState(); +void uxSetLuaState(void*); + + typedef SemaphoreHandle_t sem_t; typedef struct Osdep Osdep; @@ -220,10 +224,13 @@ osready(Proc *p) void kprocinit(Proc *p) { + uxSetLuaState(p); +#if 0 //{} if(pthread_key_create(&prdakey, NULL)) panic("key_create failed"); if(pthread_setspecific(prdakey, p)) panic("set specific thread data failed"); +#endif } #ifdef ANDROID diff --git a/emu/FreeRTOS/mkfile b/emu/FreeRTOS/mkfile index 62ff5bc..f6b9ff0 100644 --- a/emu/FreeRTOS/mkfile +++ b/emu/FreeRTOS/mkfile @@ -48,7 +48,7 @@ CFLAGS='-DROOT="'$ROOT'"' -DEMU \ -I$ROOT/libiot/include \ $CTHREADFLAGS $CFLAGS $EMUOPTIONS #SYSLIBS= $X11LIBS -lm -lpthread -SYSLIBS= -lm +#SYSLIBS= -lm default:V: $O.$CONF diff --git a/emu/port/fns.h b/emu/port/fns.h index ae6c8f6..9ff80f2 100644 --- a/emu/port/fns.h +++ b/emu/port/fns.h @@ -1,5 +1,5 @@ -#ifdef ANDROID +#if defined(ANDROID) || defined(FREERTOS) #define malloc malloc_ #define free free_ #define realloc realloc_ diff --git a/include/interp.h b/include/interp.h index b9fc11f..dbc1f07 100644 --- a/include/interp.h +++ b/include/interp.h @@ -1,6 +1,6 @@ typedef uchar BYTE; /* 8 bits */ -typedef int WORD; /* 32 bits */ -typedef unsigned int UWORD; /* 32 bits */ +typedef long WORD; /* 32 bits */ +typedef unsigned long UWORD; /* 32 bits */ typedef vlong LONG; /* 64 bits */ typedef uvlong ULONG; /* 64 bits */ typedef double REAL; /* 64 double IEEE754 */ @@ -29,7 +29,7 @@ enum /* STRUCTALIGN is the unit to which the compiler aligns structs. */ /* It really should be defined somewhere else */ - STRUCTALIGN = sizeof(int) /* must be >=2 because of Strings */ + STRUCTALIGN = sizeof(long) /* must be >=2 because of Strings */ }; enum diff --git a/include/pool.h b/include/pool.h index 3775148..66b3479 100644 --- a/include/pool.h +++ b/include/pool.h @@ -55,7 +55,7 @@ struct Btail #define B2LIMIT(b) ((Bhdr*)((uchar*)b + b->csize)) -#define BHDRSIZE ((int)(((Bhdr*)0)->u.data)+sizeof(Btail)) +#define BHDRSIZE ((long)(((Bhdr*)0)->u.data)+sizeof(Btail)) extern void (*poolfault)(void *, char *, ulong); extern void poolinit(void); diff --git a/lib9/getcallerpc-FreeRTOS-riscv64.c b/lib9/getcallerpc-FreeRTOS-riscv64.c index 4a4e4fb..669deee 100644 --- a/lib9/getcallerpc-FreeRTOS-riscv64.c +++ b/lib9/getcallerpc-FreeRTOS-riscv64.c @@ -1,5 +1,6 @@ #include <lib9.h> +#if 0 //{} ulong getcallerpc(void *x) { @@ -9,4 +10,4 @@ ulong *lp; return lp[-1]; } - +#endif diff --git a/mkfiles/mkfile-FreeRTOS-riscv64 b/mkfiles/mkfile-FreeRTOS-riscv64 index b0f9e79..6fa18c5 100644 --- a/mkfiles/mkfile-FreeRTOS-riscv64 +++ b/mkfiles/mkfile-FreeRTOS-riscv64 @@ -23,15 +23,44 @@ CFLAGS= -O\ -I$K210_SDK/third_party/lwip/src/include/compat/posix\ -I$K210_SDK/third_party/lwip/src/include\ -I$ROOT/include\ - -DFREERTOS_RISCV64 - -# -DLINUX_ARM + -DFREERTOS_RISCV64\ + -DFREERTOS\ ANSICPP= LD= ${CROSS}gcc -LDFLAGS= +LDFLAGS= \ + -mcmodel=medany -mabi=lp64f -march=rv64imafc\ + -fno-common -ffunction-sections -fdata-sections\ + -fstrict-volatile-bitfields -ffast-math -fno-math-errno\ + -fsingle-precision-constant\ + -O2 -g -ggdb -std=gnu11\ + -Wall -Werror=all -Wno-error=unused-function\ + -Wno-error=unused-but-set-variable -Wno-error=unused-variable\ + -Wno-error=deprecated-declarations -Wno-error=maybe-uninitialized\ + -Wextra -Werror=frame-larger-than=65536 -Wno-unused-parameter\ + -Wno-unused-function -Wno-implicit-fallthrough -Wno-sign-compare\ + -Wno-error=missing-braces -Wno-old-style-declaration\ + -g\ + -nostartfiles -static\ + -Wl,--gc-sections -Wl,-static\ + -Wl,--start-group -Wl,--whole-archive -Wl,--no-whole-archive -Wl,--end-group\ + -Wl,-EL -T $EMU_LD_SCRIPT\ + $K210_CRT_BEGIN_END_PATH/crti.o\ + $K210_CRT_BEGIN_END_PATH/crtbegin.o\ + + +SYSLIBS= \ + $K210_CRT_BEGIN_END_PATH/crtend.o\ + $K210_CRT_BEGIN_END_PATH/crtn.o\ + -L$K210_SDK_LIBS\ + -Wl,--start-group -lm\ + -lfreertos -latomic -lbsp -lc -lstdc++ -ldrivers -lposix\ + -Wl,--end-group\ + -lfreertos -lhal\ + -lm\ + -lfatfs -llwipcore\ + -lstdc++ -lm\ -SYSLIBS= YACC= iyacc YFLAGS= -d |
