Skip to content

cpu/mips: Integrate better with RIOT newlib layer (v2)#6892

Merged
jnohlgard merged 8 commits intoRIOT-OS:masterfrom
neiljay:pr/mips-newlib-v2
Jul 19, 2017
Merged

cpu/mips: Integrate better with RIOT newlib layer (v2)#6892
jnohlgard merged 8 commits intoRIOT-OS:masterfrom
neiljay:pr/mips-newlib-v2

Conversation

@neiljay
Copy link
Contributor

@neiljay neiljay commented Apr 11, 2017

This is an update to #6639 as contributed by @gebart .
Depends on #6670

  • Copied the relevant parts of mipshal.mk from the toolchain
  • Cleaned up CFLAGS and more in Makefile.include
  • Added syscalls implementation which can be used to interface with the UHI system, in reference to mips: Build system is not aligned with other platforms #6588 (comment)
  • Added a note on why -std=gnu99 is necessary for this CPU presently, should be removed once the toolchain is updated to a more recent newlib version.
  • Various other makefile clean-up for MIPS

@neiljay neiljay changed the title Pr/mips newlib v2 cpu/mips: Integrate better with RIOT newlib layer (v2) Apr 11, 2017
@neiljay neiljay force-pushed the pr/mips-newlib-v2 branch from 74e1582 to f7afe4f Compare April 11, 2017 13:30
@neiljay
Copy link
Contributor Author

neiljay commented Apr 20, 2017

Ok to squash this ?

@neiljay neiljay force-pushed the pr/mips-newlib-v2 branch from 397cac2 to 348d9da Compare June 2, 2017 09:12
Joakim Nohlgård added 3 commits June 2, 2017 10:24
 - 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
@neiljay neiljay force-pushed the pr/mips-newlib-v2 branch from 348d9da to 309b551 Compare June 2, 2017 09:27
@neiljay neiljay added Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Platform: MIPS Platform: This PR/issue effects MIPS-based platforms CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 2, 2017
@neiljay neiljay requested a review from jnohlgard June 2, 2017 10:48
@neiljay
Copy link
Contributor Author

neiljay commented Jun 19, 2017

@gebart can I get a review, ta?

Copy link
Member

@jnohlgard jnohlgard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments inline

else
#Use RIOT to handle syscalls (VFS)
export LINKFLAGS += -Tuhi32.ld
export USEMODULE += vfs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

export USEMODULE += newlib_syscalls_mips_uhi
else
#Use RIOT to handle syscalls (VFS)
export LINKFLAGS += -Tuhi32.ld
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is uhi32.ld the correct linker script for the non UHI build as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply return close(x)? (same goes for the other wrapper functions as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easier to view in a GUI debugger, compiler will optimise away anyway.

* @param r TODO
* @param fd TODO
*
* @return TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

* @param[in] pid the pid to send to
* @param[in] sig the signal to send
*
* @return TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

export USEMODULE += newlib_syscalls_mips_uhi
else
#Use RIOT to handle syscalls (VFS)
export USEMODULE += vfs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

export USEMODULE += newlib_syscalls_mips_uhi
else
#Use RIOT to handle syscalls (VFS)
export USEMODULE += vfs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not -fdata-sections?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

ifeq ($(TARGET_ARCH),mips-mti-elf)
export LINKFLAGS += -lc
else
export LINKFLAGS += -lc -lnosys
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok will give this a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have found a bug in our newlib syscall implementation

@aabadie aabadie modified the milestone: Release 2017.07 Jun 26, 2017
@neiljay neiljay force-pushed the pr/mips-newlib-v2 branch from 392cb44 to cf81c22 Compare June 28, 2017 11:16
Neil Jones added 3 commits June 28, 2017 12:55
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).
@neiljay
Copy link
Contributor Author

neiljay commented Jul 3, 2017

@gebart ok now ?

Copy link
Member

@jnohlgard jnohlgard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All cppcheck suppressions should have an accompanying comment describing why it is a false positive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I would hope this one is fairly obvious why the code is unreachable...

@neiljay
Copy link
Contributor Author

neiljay commented Jul 4, 2017

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 ?

@jnohlgard
Copy link
Member

@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.

@neiljay
Copy link
Contributor Author

neiljay commented Jul 12, 2017

@gebart, Do you want me to make that last minor change or can we merge as-is ?

@jnohlgard
Copy link
Member

@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.

@neiljay neiljay force-pushed the pr/mips-newlib-v2 branch from e191371 to 0b8ab6c Compare July 12, 2017 14:56
@neiljay neiljay force-pushed the pr/mips-newlib-v2 branch from 0b8ab6c to 54eb49a Compare July 17, 2017 16:18
Copy link
Member

@jnohlgard jnohlgard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: MIPS Platform: This PR/issue effects MIPS-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants