cpu/mips: Integrate better with RIOT newlib layer (v2)#6892
cpu/mips: Integrate better with RIOT newlib layer (v2)#6892jnohlgard merged 8 commits intoRIOT-OS:masterfrom
Conversation
74e1582 to
f7afe4f
Compare
|
Ok to squash this ? |
397cac2 to
348d9da
Compare
- Copied the relevant parts of mipshal.mk from the toolchain - Cleaned up CFLAGS and more in Makefile.include - Added empty syscalls implementation which can be used to interface with the UHI system - Added a note on why -std=gnu99 is necessary for this CPU presently
Some headers in the tool chain cause compilation errors with Clang in assembly mode.
Causes compilation error on Clang
348d9da to
309b551
Compare
|
@gebart can I get a review, ta? |
cpu/mips32r2_common/Makefile.include
Outdated
| else | ||
| #Use RIOT to handle syscalls (VFS) | ||
| export LINKFLAGS += -Tuhi32.ld | ||
| export USEMODULE += vfs |
There was a problem hiding this comment.
It should not be necessary to add VFS for the default sys calls. There's a light weight implementation which supports only read and write of stdin/stdout and no open, close etc. That should be used if USEMODULE += VFS is not specified.
| export USEMODULE += newlib_syscalls_mips_uhi | ||
| else | ||
| #Use RIOT to handle syscalls (VFS) | ||
| export LINKFLAGS += -Tuhi32.ld |
There was a problem hiding this comment.
Is uhi32.ld the correct linker script for the non UHI build as well?
There was a problem hiding this comment.
Yes, its the only one we have for a default mips32 implementation, it is copied from the toolchains in-built linker scripts and follows its naming convention.
| */ | ||
| int _close_r(struct _reent *r, int fd) | ||
| { | ||
| int res = close(fd); |
There was a problem hiding this comment.
Why not simply return close(x)? (same goes for the other wrapper functions as well)
There was a problem hiding this comment.
Easier to view in a GUI debugger, compiler will optimise away anyway.
| * @param r TODO | ||
| * @param fd TODO | ||
| * | ||
| * @return TODO |
| * @param[in] pid the pid to send to | ||
| * @param[in] sig the signal to send | ||
| * | ||
| * @return TODO |
cpu/mips_pic32mx/Makefile.include
Outdated
| export USEMODULE += newlib_syscalls_mips_uhi | ||
| else | ||
| #Use RIOT to handle syscalls (VFS) | ||
| export USEMODULE += vfs |
cpu/mips_pic32mz/Makefile.include
Outdated
| export USEMODULE += newlib_syscalls_mips_uhi | ||
| else | ||
| #Use RIOT to handle syscalls (VFS) | ||
| export USEMODULE += vfs |
makefiles/arch/mips.inc.mk
Outdated
| export CFLAGS += -std=gnu99 | ||
| export CFLAGS_CPU = -EL -mabi=$(ABI) | ||
| # Why not -fdata-sections?? /JN | ||
| export CFLAGS_LINK = -ffunction-sections -fno-builtin -fshort-enums #-fdata-sections |
There was a problem hiding this comment.
I was having problems with the linker stripping out the pic32 configuration registers (which have to reside at a specific place in the final flash image), but this was actually due to a missing KEEP() attribute in the linker script, so this can be put back now.
makefiles/libc/newlib.mk
Outdated
| ifeq ($(TARGET_ARCH),mips-mti-elf) | ||
| export LINKFLAGS += -lc | ||
| else | ||
| export LINKFLAGS += -lc -lnosys |
There was a problem hiding this comment.
I think -lnosys might be unused on all platforms now with proper syscall implementations. Could you try unconditionally removing -lnosys and see what Murdock says?
There was a problem hiding this comment.
ok will give this a try.
There was a problem hiding this comment.
hmm, I thought this had worked, but must have missed the error message.
jerryscript is not compiling on arm targets without nosys:
/usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-gettimeofdayr.o): In function _gettimeofday_r': gettimeofdayr.c:(.text._gettimeofday_r+0xe): undefined reference to _gettimeofday'
There was a problem hiding this comment.
I think you have found a bug in our newlib syscall implementation
392cb44 to
cf81c22
Compare
We can either use the UHI syscall implementation or the RIOT default one (targeted at VFS, uart-stdio will be added once uart rx is added to pic32).
cf81c22 to
e191371
Compare
|
@gebart ok now ? |
jnohlgard
left a comment
There was a problem hiding this comment.
Looks good, I can't test the binaries since I don't have a mips board. I assume it has been tested on your side?
Also see my minor comment on cppcheck suppression.
| void _exit(int n) | ||
| { | ||
| exit(n); | ||
| /* cppcheck-suppress unreachableCode */ |
There was a problem hiding this comment.
All cppcheck suppressions should have an accompanying comment describing why it is a false positive.
There was a problem hiding this comment.
Ok, I would hope this one is fairly obvious why the code is unreachable...
|
Yes, I've tested with default syscalls and UHI but not VFS, It would be nice if there was a VFS example in 'examples', a simple ramfs + pre-baked filesystem with a couple of text files you could cat in a console ? |
|
@neiljay it would be fairly easy to add a constfs file system to the default example. See the unittests for VFS which use constfs to provide a test file system without any external dependencies. That should be a separate PR though. |
|
@gebart, Do you want me to make that last minor change or can we merge as-is ? |
|
@neiljay add a comment for the cppcheck suppression, other than that this seem ready to merge. The constfs stuff should be a separate PR of you want to add it. |
e191371 to
0b8ab6c
Compare
0b8ab6c to
54eb49a
Compare
This is an update to #6639 as contributed by @gebart .
Depends on
#6670