Skip to content

mips: Import of mips32r2_common module#6060

Merged
kaspar030 merged 9 commits intoRIOT-OS:masterfrom
neiljay:pr/add_mips32r2_common_v2
Feb 9, 2017
Merged

mips: Import of mips32r2_common module#6060
kaspar030 merged 9 commits intoRIOT-OS:masterfrom
neiljay:pr/add_mips32r2_common_v2

Conversation

@neiljay
Copy link
Copy Markdown
Contributor

@neiljay neiljay commented Nov 4, 2016

Add support for the mips32r2 architecture to RIOT.

cpu/mips32r2_common adds base architecture support for mips32r2 cores it can be
built in it own right as a 'CPU', but is dependant on a bootloader (like u-boot)
to have bootstrapped the system, this has been tested on a 'malta' FPGA system
(BOARD=mips-malta) with various mips32r2 compliant cores (interAptiv, P5600,
etc).

NOTE: This port requires the use of the GCC based MIPS Codescape SDK toolchain
available here:

https://community.imgtec.com/developers/mips/tools/codescape-mips-sdk/download-codescape-mips-sdk-essentials/

This has been tested against the following examples:
hello-world
default
ipc_pingpong
timer_periodic_wakeup
riot_and_cpp


Note this is a re-work of #5885 with review comments addressed but now broken down into 3 separate PR's of which this is the first.

@miri64 miri64 added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Type: new feature The issue requests / The PR implemements a new feature for RIOT Impact: major The PR changes a significant part of the code base. It should be reviewed carefully Platform: MIPS Platform: This PR/issue effects MIPS-based platforms labels Nov 4, 2016
@miri64 miri64 added this to the Release 2017.01 milestone Nov 4, 2016
@miri64 miri64 changed the title Pr/add mips32r2 common v2 mips: Import of mips32r2_common module Nov 4, 2016
@miri64
Copy link
Copy Markdown
Member

miri64 commented Nov 4, 2016

Took the freedom to rename the PR :-)

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Nov 4, 2016

@miri64 No worries, much nicer ;-)

This was referenced Nov 7, 2016
@@ -0,0 +1,3 @@
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += cpp
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use some existing Makefile.features as template for structuring this file:

# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart

# Various other features (if any)
FEATURES_PROVIDED += cpp

# The board MPU family (used for grouping by the CI system)
FEATURES_MCU_GROUP = mips32

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do.

* @file
* @brief Board specific definitions for the MIPS Malta FPGA System.
*
* @author Imagination Technologies.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The author should AFAIK be person(s)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

does it matter, I'm not vain ;-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, yes. We want to know who to ask when something breaks. ;)

#endif

/**
* @brief Set how many increments of the count register per uS
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

indention...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

* @brief Set how many increments of the count register per uS
* needed by timer code
*/
#define TICKS_PER_US (15)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this is configuring the timer, I would expect it to be placed in the periph_conf.h

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The timer uses it, its the number of CPU core ticks per uS, so its not necessarily peripheral specific, peripherals could be (and often are) running from a different clock.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see, so never mind

/*
* Copyright 2016, Imagination Technologies Limited and/or its
* affiliated group companies.
* This file is subject to the terms and conditions of the GNU Lesser
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

newline missing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok.

#define MIPS_MALTA_ADDR (0xbf000500)
#define MIPS_MALTA_VAL_RST (0x42)

static void malta_reset(void)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these addresses are CPU dependent, right? So they should go into the CPU code?!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, they are specific to the Malta FPGA platform only.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah ok.

*/
static inline void cpu_init_early(void)
{
/* This function must exist else RIOT won't compile */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this function mandatory by some parts of the MIPS toolchain or similar? RIOT itself does not care about it...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope, looks like that one can go.

@@ -0,0 +1,3 @@
export CPU = mips32r2_common
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/
export CFLAGS += -mhard-float -mdsp
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about a simple variable like USE_HARD_FLOAT and then checking that in the mips_common/Makefile.include and set the CFLAGS there?

p--;
*p-- = STACK_END_PAINT;


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

newline...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

?? where ? Do you want the double newline removing #74 or one adding between #71 and #72 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sorry, I meant to remove the double newline l74

@haukepetersen
Copy link
Copy Markdown
Contributor

Sorry for the late review and about being so picky about formatting and such...

IMHO the PR looks quite good to me, mainly minor things that I noticed.

Now when trying to compile it, I get and error resulting from MIPS_ELF_ROOT not being set on my system. I simply downloaded the mips-mti-elf- MTI Bare Metal binaries tarball and used it right away. Seems like there is some more configuration effort needed here?!

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Dec 12, 2016

@haukepetersen

Thanks for the review.

Now when trying to compile it, I get and error resulting from MIPS_ELF_ROOT not being set on my system.

There are two toolchains for MIPS pre r6 (mips-mti-elf) and r6 onwards (mips-img-elf), MIPS_ELF_ROOT thus needs setting appropriately, I did add default paths to the makefile but Oleg asked me to remove them:

cpu/mips_pic32mx/Makefile
@@ -0,0 +1,15 @@
+ifeq ("$(OS)","Windows_NT")
+MIPS_ELF_ROOT?=C:\cross-mips-mti-elf
+else
+MIPS_ELF_ROOT?=/opt/imgtec/Toolchains/mips-mti-elf/2016.05-03
+endif

@OlegHahm on Sep 29 Member

I don't think we want to have absolute paths here. 😉

@neiljay on Sep 30

They are '?=' ie defaults if nothing else is set and are the default locations the toolchain installs too, but I can remove them if that's what you prefer.

@OlegHahm on Oct 13 Member

Yes, I would prefer to remove the absolute paths.

@OlegHahm
Copy link
Copy Markdown
Member

Hm, okay, maybe I misjudged. Not sure. On the one hand, I still don't like to have these absolute paths in the build system, on the other hand that's probably the most convenient to do for most of the users.

@haukepetersen, do you have a preference?

@haukepetersen
Copy link
Copy Markdown
Contributor

Hmm, I think not setting a default value sounds better to me, but how about some descriptive error message in case the variable is not set?!

@haukepetersen
Copy link
Copy Markdown
Contributor

Before I forget, there is one more important problem we have to solve before we can merge this PR: we need to integrate the MIPS toolchain into our CI system.

@kaspar030: is it easy to integrate the toolchain into Murdock?!

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Dec 16, 2016

Hmm, I think not setting a default value sounds better to me, but how about some descriptive error
message in case the variable is not set?!

done, along with the other changes you requested.

Neill

@haukepetersen
Copy link
Copy Markdown
Contributor

Cool, thanks. I already triggered @kaspar030 offline, to include the MIPS toolchain into the CI system, so we can put Murdock onto this PR

@kaspar030
Copy link
Copy Markdown
Contributor

kaspar030 commented Jan 11, 2017 via email

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Jan 11, 2017 via email

@kaspar030
Copy link
Copy Markdown
Contributor

Thanks @neiljay.

The Docker image update is PR'ed here: RIOT-OS/riotdocker#24

Once that is merged, I'll update the image Murdock is using, and we should be able to test this.

@kaspar030
Copy link
Copy Markdown
Contributor

Murdock should be ready, let's see!

@kaspar030 kaspar030 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 13, 2017
@OlegHahm
Copy link
Copy Markdown
Member

The CI found a couple of problems.

@PeterKietzmann
Copy link
Copy Markdown
Member

@neiljay would you please rebase to latest master?

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Jan 16, 2017

The rebase was clean, so I pushed it without a compile check first :-s
But it doesn't build.
It appears at some point, someone has turned on C99 in your build system: -std=c99
This breaks in-line asm code (as this is just a GCC'ism).
I assume you have hit this elsewhere ? What is your preferred solution ?

@OlegHahm
Copy link
Copy Markdown
Member

See #5824 for the change. __asm__ should work.

Neil Jones and others added 7 commits February 9, 2017 12:16
 cpu/mips32r2_common adds base architecture support for mips32r2 cores it can be
 built in it own right as a 'CPU', but is dependant on a bootloader (like
 u-boot) to have bootstrapped the system, this has been tested on a 'malta'
 FPGA system (BOARD=mips-malta) with various mips32r2 compliant cores
 (interAptiv, P5600, etc).
Add basic support for the MIPS malta FPGA platform.
No UART is available on the mips-malta board so blacklist this board.
@neiljay neiljay force-pushed the pr/add_mips32r2_common_v2 branch from d8a66c4 to 00f2ae3 Compare February 9, 2017 12:45
#include "board.h"
#include "periph_conf.h"


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this one wasn't here before...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm how did that get in, I'll fix.

@kaspar030 kaspar030 removed the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Feb 9, 2017
@neiljay neiljay force-pushed the pr/add_mips32r2_common_v2 branch from 00f2ae3 to 8434f9c Compare February 9, 2017 14:20
@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Feb 9, 2017

@haukepetersen Can you please revert your review request so we can finally get this merged!

haukepetersen on Dec 12, 2016 Member

these addresses are CPU dependent, right? So they should go into the CPU code?!
@neiljay
neiljay on Dec 12, 2016 Member

No, they are specific to the Malta FPGA platform only.
@haukepetersen
haukepetersen on Dec 13, 2016 Member

ah ok.

@jnohlgard
Copy link
Copy Markdown
Member

Please update dist/tools/ci/print_toolchain_versions.sh to include a version line for the compiler and libc. This will let you see the toolchain version in the output from the static tests on Jenkins and Murdock, makes it easier to track down problems.

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Feb 9, 2017

@gebart In a separate PR ?

@jnohlgard
Copy link
Copy Markdown
Member

@neiljay I'm fine with having the info script update in a separate PR.

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Feb 9, 2017

@gebart see #6585

Copy link
Copy Markdown
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

There's minor stuff, but I think we should get this in and improve later. ACK.

@kaspar030
Copy link
Copy Markdown
Contributor

@haukepetersen I'll dismiss your review, reading your comment it seems your comment has been addressed.

@kaspar030 kaspar030 dismissed haukepetersen’s stale review February 9, 2017 17:00

All comments addressed, last one @haukepetersen said "ahok".

@kaspar030 kaspar030 merged commit ef958cc into RIOT-OS:master Feb 9, 2017
@kaspar030
Copy link
Copy Markdown
Contributor

Congrats @neiljay for adding the first new architecture in years! Thanks for all the work!

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Feb 9, 2017

Thanks all !

@neiljay neiljay deleted the pr/add_mips32r2_common_v2 branch February 9, 2017 17:05
@ghost
Copy link
Copy Markdown

ghost commented Feb 9, 2017

Thank you very much everyone for your great work !

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 9, 2017

At last! Congratz and thanks for your big contribution and your patience @neiljay :party: ✨

@emmanuelsearch
Copy link
Copy Markdown
Member

yay! Congrats!

@kYc0o
Copy link
Copy Markdown
Contributor

kYc0o commented Feb 10, 2017

Wow congrats! I'm looking forward to test it! Thanks to all people here.

@jnohlgard
Copy link
Copy Markdown
Member

Congratulations on getting this large PR merged!
@neiljay I did run into some trouble trying to build this on my machine, as well as when testing #5616 on Jenkins. I have create a tracking issue for the issues in #6588. Please don't take this as a lack of appreciation, I think it's great that we are getting new hardware supported, I only want to improve on it.

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 Impact: major The PR changes a significant part of the code base. It should be reviewed carefully Platform: MIPS Platform: This PR/issue effects MIPS-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.