Skip to content

ports: mips: Add Support for mips32r2 (v2)#5885

Closed
neiljay wants to merge 33 commits intoRIOT-OS:masterfrom
neiljay:pr/add_mips_v2
Closed

ports: mips: Add Support for mips32r2 (v2)#5885
neiljay wants to merge 33 commits intoRIOT-OS:masterfrom
neiljay:pr/add_mips_v2

Conversation

@neiljay
Copy link
Copy Markdown
Contributor

@neiljay neiljay commented Sep 28, 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).

cpu/mips_pic32mz adds basic support for Microchip PIC32MZ devices, including
bootstrapping the device, the build system produces a hex image loadable via
MPLAB-IPE. It has been tested on a Digilent Wifire board.

cpu/mips_pic32mx adds basic support for Microchip PIC32MX devices, including
bootstrapping the device, the build system produces a hex image loadable via
MPLAB-IPE. It has been tested on a MikroElectronic Clicker board.

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/

You cannot use Microchip's MPLAB / Harmony tools to build this port.

All 3 'CPU' types have been tested against the following examples:
hello-world
ipc_pingpong
timer_periodic_wakeup
riot_and_cpp

The following CPU / BOARD combinations are valid:

CPU=mips32r2_common BOARD=mips-malta
CPU=mips_pic32mz BOARD=pic32-wifire
CPU=mips_pic32mx BOARD=pic32-clicker

Changes in v2:

Split into multiple logical commits.
Add LGPL license boilerplate.
Removed some literal usage in pic32 device setup.

Neil Jones added 6 commits September 28, 2016 16:18
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.
cpu/mips_pic32mz adds basic support for Microchip PIC32MZ devices, including
bootstrapping the device, the build system produces a hex image loadable via
MPLAB-IPE. It has been tested on a Digilent Wifire board.
cpu/mips_pic32mx adds basic support for Microchip PIC32MX devices, including
bootstrapping the device, the build system produces a hex image loadable via
MPLAB-IPE. It has been tested on a MikroElectronic Clicker board.
Add basic support for the Digilent Wifire board which features a PIC32MZ device.
Add basic support for the MicroElectonika Clicker board, which features a
pic32mz device.
@miri64 miri64 added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation 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: new feature The issue requests / The PR implemements a new feature for RIOT labels Sep 28, 2016
@OlegHahm
Copy link
Copy Markdown
Member

I think this PR would benefit from some uncrustifying.

@OlegHahm
Copy link
Copy Markdown
Member

Could you advice a good hardware platform to purchase to test this PR?

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Sep 29, 2016

On 09/28/16 23:21, Oleg Hahm wrote:

I think this PR would benefit from some uncrustifying
https://github.com/RIOT-OS/RIOT/blob/master/uncrustify-riot.cfg.

I ran it through checkpatch.pl from the linux kernel, the only errors
were exceptions you allow in your coding standard, I've not tried
uncrustify I'll give it a go.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#5885 (comment), or
mute the thread
https://github.com/notifications/unsubscribe-auth/AUEU6oEhjlE48xeaEV29WR4i134CULV5ks5quuhpgaJpZM4KI-yf.

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Sep 29, 2016

On 09/28/16 23:22, Oleg Hahm wrote:

Could you advice a good hardware platform to purchase to test this PR?

I would recommend the Digilent Wifire:

http://store.digilentinc.com/chipkit-wi-fire-wifi-enabled-mz-microcontroller-board/

and

The MicroElectronica Clicker board, unfortunately MicroE are having
issues with the Radio on the 6lowPan variant of the PIC32 clicker, but
you can buy the standard one and fit a radio to the Mikro bus:

http://www.mikroe.com/pic32/pic32mx-clicker/

Or if cost is an issue, this is pretty cheap (but has a big/fast pic32):

https://www.olimex.com/Products/PIC/Development/PIC32-HMZ144/open-source-hardware

I could potentially arrange donation of hardware to the RIOT project,
assuming you have some centralised build + test system ?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#5885 (comment), or
mute the thread
https://github.com/notifications/unsubscribe-auth/AUEU6rNGQaevu6JJjhTge2gbp8xSqcSOks5quuiSgaJpZM4KI-yf.

Having ran through uncrustify the only change appear to be swapping tabs for
spaces.
@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Sep 29, 2016

Files now uncrustified.

@OlegHahm
Copy link
Copy Markdown
Member

Thanks for your fast response!

I could potentially arrange donation of hardware to the RIOT project, assuming you have some centralised build + test system ?

Such a test system is under development and we should definitely integrate a MIPS platform as soon as it is ready and this PR is merged.


/* Note this file must exist for xtimer code to build */
#define TIMER_NUMOF (1U)
#define TIMER_0_CHANNELS 3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer to have parens around macro definitions in a consistent style, i.e. either always put them (I would prefer that) or never put them.

{
if (state & SR_IE) {
mips32_bs_c0(C0_STATUS, SR_IE);
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Style


void lpm_arch_init(void)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please add according TODO comments here and everywhere else where applicable?

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.

I have implemented all that is possible for power management in the base mips32r2 architecture (ie execute a 'wait' instruction), anything else would be SoC specific.

I will delete these unimplemented functions.

MIPS_ELF_ROOT?=C:\cross-mips-mti-elf
else
MIPS_ELF_ROOT?=/opt/imgtec/Toolchains/mips-mti-elf/2016.05-03
endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

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.

They are '?=' ie defaults if nothing else is set and are the default locations the toolchain install too, but can remove them it thats what you prefer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I would prefer to remove the absolute paths.

/* Pass all other exceptions through to the toolchain handler */
__exception_handle(ctx, exception);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Haven't checked for all the other files, but at least this one has tabs instead of spaces.

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.

Are you sure you pulled the latest version, uncrustify changed all the tabs to spaces ?

#define THREAD_EXTRA_STACKSIZE_PRINTF (2048)
#endif
#ifndef THREAD_STACKSIZE_DEFAULT
#define THREAD_STACKSIZE_DEFAULT (4096)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Out of curiosity: are stacks really required to be that big on MIPS or is this just a very conservative guess for now?

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.

Debug builds possibly, we have no interrupt stack currently and I'm yet to push FPU + DSP + MSA context saving.

On the subject of debug builds is there a RIOT standard way of doing debug vs release builds and a define we can use, so we can have different sizes for stacks for debug vs release ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are there other space requirements accept for printf you need for debug? If not, than just add THREAD_EXTRA_STACKSIZE_PRINTF to the stacksize if debug is enabled.

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.

Well code built at -O0 is very stupid and always uses the stack, so stack usage is always higher in debug builds than release.

What symbol(s) do you use to differentiate between a debug vs release build in RIOT ?

Neil Jones added 2 commits October 3, 2016 11:02
Refactor out common code into cpu/mips_pic32_common.

Move configuration settings to board files as this is a more natural fit,
different boards with the same CPU may require diferent config bit settings.

Add CPU register definition files and clean-up some literal usage.
@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Oct 3, 2016

I have re-factored the pic32 support to remove common code, restructured it somewhat and fixed various style issues.

Neil Jones added 3 commits October 3, 2016 16:29
Clock out is enabled when the setting is 0 not 1.
Clock out is not connected up on the Wifire board so turn it off.
@@ -0,0 +1 @@
# This file must exist for RIOT to build.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file should at least add the include directory to RIOT's include path, so that one can include the "board.h".

@@ -0,0 +1 @@
/* This file must exist to get timer code to build */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file should go into the cpu directory and contain the MCU's peripheral configuration


void board_init(void)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Who's performing the board's and CPU's initialization then?

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.

Malta is our FPGA evaluation platform it has a bootloader pre-installed, typically u-boot.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then maybe you can add a comment explaining this here.

@@ -0,0 +1 @@
#This file must exist for RIOT to build.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

see above

unsigned int timer_read(tim_t dev)
{
if (dev != 0) {
return -1;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

-1 is not unsigned.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should rather for an assert here anyway.

compares[i] = 0;
}

counter = 1 << TIMER_ACCURACY_SHIFT;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

parens please

/* Clear down soft counters */
for (i = 0; i < CHANNELS; i++) {
compares[i] = 0;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

memset


if (channel >= CHANNELS) {
return -1;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer asserts here, too.

MIPS_ELF_ROOT?=C:\cross-mips-mti-elf
else
MIPS_ELF_ROOT?=/opt/imgtec/Toolchains/mips-mti-elf/2016.05-03
endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I would prefer to remove the absolute paths.

#define THREAD_EXTRA_STACKSIZE_PRINTF (2048)
#endif
#ifndef THREAD_STACKSIZE_DEFAULT
#define THREAD_STACKSIZE_DEFAULT (4096)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are there other space requirements accept for printf you need for debug? If not, than just add THREAD_EXTRA_STACKSIZE_PRINTF to the stacksize if debug is enabled.

@OlegHahm
Copy link
Copy Markdown
Member

Sorry, that it took a while.

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Oct 31, 2016

@OlegHahm, No worries, I was feeling a little unappreciated last week.

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Oct 31, 2016

How do you build the doxygen docs ?
I tried 'make' in /docs/doxygen/ but got this error:

~/src/RIOT/doc/doxygen]
$ make
( cat riot.doxyfile ; echo "GENERATE_HTML = yes" ) | doxygen -
Warning: ignoring unsupported tag PROJECT_BRIEF =' at line 47, file - Warning: ignoring unsupported tagPROJECT_LOGO =' at line 54, file -
Warning: ignoring unsupported tag ALLOW_UNICODE_NAMES =' at line 79, file - Warning: ignoring unsupported tagTCL_SUBST =' at line 237, file -
Warning: ignoring unsupported tag MARKDOWN_SUPPORT =' at line 294, file - Warning: ignoring unsupported tagAUTOLINK_SUPPORT =' at line 302, file -
Warning: ignoring unsupported tag INLINE_GROUPED_CLASSES =' at line 364, file - Warning: ignoring unsupported tagINLINE_SIMPLE_STRUCTS =' at line 374, file -
Warning: ignoring unsupported tag LOOKUP_CACHE_SIZE =' at line 398, file - Warning: ignoring unsupported tagEXTRACT_PACKAGE =' at line 424, file -
Warning: ignoring unsupported tag SHOW_GROUPED_MEMB_INC =' at line 521, file - Warning: ignoring unsupported tagFORCE_LOCAL_INCLUDES =' at line 527, file -
Warning: ignoring unsupported tag STRICT_PROTO_MATCHING =' at line 587, file - Warning: ignoring unsupported tagCITE_BIB_FILES =' at line 685, file -
Warning: ignoring unsupported tag FILTER_SOURCE_PATTERNS =' at line 923, file - Warning: ignoring unsupported tagUSE_MDFILE_AS_MAINPAGE =' at line 930, file -
Warning: ignoring unsupported tag SOURCE_TOOLTIPS =' at line 986, file - Warning: ignoring unsupported tagHTML_EXTRA_STYLESHEET =' at line 1121, file -
Warning: ignoring unsupported tag HTML_EXTRA_FILES =' at line 1131, file - Warning: ignoring unsupported tagHTML_COLORSTYLE_HUE =' at line 1142, file -
Warning: ignoring unsupported tag HTML_COLORSTYLE_SAT =' at line 1150, file - Warning: ignoring unsupported tagHTML_COLORSTYLE_GAMMA =' at line 1161, file -
Warning: ignoring unsupported tag HTML_INDEX_NUM_ENTRIES =' at line 1190, file - Warning: ignoring unsupported tagDOCSET_PUBLISHER_ID =' at line 1228, file -
Warning: ignoring unsupported tag DOCSET_PUBLISHER_NAME =' at line 1234, file - Warning: ignoring unsupported tagGENERATE_ECLIPSEHELP =' at line 1370, file -
Warning: ignoring unsupported tag ECLIPSE_DOC_ID =' at line 1378, file - Warning: ignoring unsupported tagEXT_LINKS_IN_WINDOW =' at line 1430, file -
Warning: ignoring unsupported tag FORMULA_TRANSPARENT =' at line 1450, file - Warning: ignoring unsupported tagUSE_MATHJAX =' at line 1461, file -
Warning: ignoring unsupported tag MATHJAX_FORMAT =' at line 1471, file - Warning: ignoring unsupported tagMATHJAX_RELPATH =' at line 1484, file -
Warning: ignoring unsupported tag MATHJAX_EXTENSIONS =' at line 1491, file - Warning: ignoring unsupported tagMATHJAX_CODEFILE =' at line 1499, file -
Warning: ignoring unsupported tag SERVER_BASED_SEARCH =' at line 1532, file - Warning: ignoring unsupported tagEXTERNAL_SEARCH =' at line 1548, file -
Warning: ignoring unsupported tag SEARCHENGINE_URL =' at line 1559, file - Warning: ignoring unsupported tagSEARCHDATA_FILE =' at line 1567, file -
Warning: ignoring unsupported tag EXTERNAL_SEARCH_ID =' at line 1575, file - Warning: ignoring unsupported tagEXTRA_SEARCH_MAPPINGS =' at line 1585, file -
Warning: ignoring unsupported tag LATEX_FOOTER =' at line 1673, file - Warning: ignoring unsupported tagLATEX_EXTRA_FILES =' at line 1681, file -
Warning: ignoring unsupported tag LATEX_BIB_STYLE =' at line 1732, file - Warning: ignoring unsupported tagMAN_SUBDIR =' at line 1823, file -
Warning: ignoring unsupported tag GENERATE_DOCBOOK =' at line 1869, file - Warning: ignoring unsupported tagDOCBOOK_OUTPUT =' at line 1877, file -
Warning: ignoring unsupported tag DOCBOOK_PROGRAMLISTING =' at line 1886, file - Warning: ignoring unsupported tagEXTERNAL_PAGES =' at line 2083, file -
Warning: ignoring unsupported tag DIA_PATH =' at line 2118, file - Warning: ignoring unsupported tagDOT_NUM_THREADS =' at line 2143, file -
Warning: ignoring unsupported tag UML_LIMIT_NUM_FIELDS =' at line 2212, file - Warning: ignoring unsupported tagINTERACTIVE_SVG =' at line 2299, file -
Warning: ignoring unsupported tag MSCFILE_DIRS =' at line 2318, file - Warning: ignoring unsupported tagDIAFILE_DIRS =' at line 2324, file -
Warning: ignoring unsupported tag `PLANTUML_JAR_PATH =' at line 2333, file -
Warning: the type '(null)' is not supported for the entry tag within a navindex! Check your layout file!
Warning: the type '(null)' is not supported for the entry tag within a navindex! Check your layout file!
/bin/sh: line 1: 29979 Done ( cat riot.doxyfile; echo "GENERATE_HTML = yes" )
29980 Segmentation fault (core dumped) | doxygen -
make: *** [html] Error 139

@miri64
Copy link
Copy Markdown
Member

miri64 commented Oct 31, 2016

I just tried this on master (I usually build from root with make doc) and I did not have a segmentation fault oO. Which doxygen version are you using? Mine's

$ doxygen --version
1.8.11

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Oct 31, 2016

Which doxygen version are you using?

$ doxygen --version
1.6.1

( I'm using a pretty old version of CentOS )

@miri64
Copy link
Copy Markdown
Member

miri64 commented Oct 31, 2016

Mhhh can you maybe try it with our vagrant image if you have the time? In the end the CI server will check this, too but it would make things quicker if we can reduce the load on that.

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Oct 31, 2016

I've installed 1.8.12 which seems to work, albeit lots of warnings / errors.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Oct 31, 2016

That's normal :D we try to reduce those ;-).

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Nov 2, 2016

I just realized that the CPU build system variable should be set in the according Makefile.include in boards.

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Nov 2, 2016

Ah ok, so you can just do:

make BOARD='pic32-wifire' and not have to explicitly set the CPU it uses ?

That makes sense.

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Nov 2, 2016

Exactly.

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Nov 2, 2016

Okay, I succeeded to build the hello-world example for the pic32-clicker, but how am I supposed to flash the binary onto the board? make flash doesn't work, because FLASHER is not defined in the board's Makefile.include.

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Nov 2, 2016

It depends on what tools you have available to you ?

I typically reflash using our own tools (via JTAG) but I doubt you'll have access to one of these:
https://community.imgtec.com/developers/mips/tools/mips-debug-and-trace-probes/sp55e/

The default make target will generate a hex file which is compatible with Microchips MP-IPE programmer and I have tested it using a Microchip pickit3:

http://microchip.wikidot.com/ipe:start
http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=PG164130

Instructions for the Wifire are here:

https://docs.creatordev.io/wifire/guides/wifire-programming/

If you have some form of basic JTAG bus-blaster compatible with open-ocd like:
https://community.imgtec.com/developers/mips/tools/mips-debug-and-trace-probes/bus-blaster
(something FTDI chip based), then we are currently in the process of adding PIC32 re-flash support to open-ocd. I'll chase up the status of this.

Sorry just re-read you comment do you have a pic32 clicker or pic32 wifire ?

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Nov 2, 2016

Sorry just re-read you comment do you have a pic32 clicker or pic32 wifire ?

Both of them, but I tried first with the clicker.

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Nov 2, 2016

So, do I get this right: there is no programming device or serial bootloader available on the boards (clicker and wifire) that would make it possible to just flash the device using a USB cable? I.e., we first need to purchase some mips JTAG device or similar to flash it, right?

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Nov 2, 2016

Cool,

The wifire is probably better as an initial development platform as it has JTAG pins exposed + it has more flash + ram. But the radio is Wifi and documentation on it isn't great.

The pic32 clicker doesn't have JTAG bonded out and is a smaller slower PIC32 device but it does have a more interesting 6LowPan radio, and will probably be the first MIPS board to get radio support added for that reason.

details on how to program the clicker are here:

https://docs.creatordev.io/clicker/guides/quick-start-guide/#in-circuit-programming

@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Nov 2, 2016

So, do I get this right: there is no programming device or serial bootloader available on the boards (clicker and wifire) that would make it possible to just flash the device using a USB cable? I.e., we first need to purchase some mips JTAG device or similar to flash it, right?

Yes, unless you have the very latest revD wifire which now includes the FTDI JTAG device on the board.

Well actually bootloaders are available for both board I think (certainly wifire) which support programming via USB - some AVR standard? But this obviously takes up flash space. The flash images produced for RIOT contain custom boot + app code without any reflash support, so once you flash a RIOT image you would loose your existing bootcode, also these (3rd party) bootloaders don't allow making use of advanced features like microMIPS code compression and from what I have seen are not 'production' ready.

* Note Microchip number the UARTS 1->4.
* @{
*/
#define UART_NUMOF (6)
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.

Seems like there is a logical layer missing here: RIOT makes use of 'logical' periph devices (e.g. UART_DEV(x)), which should be freely mappable to the actual hardware devices (e.g. UART1-6 or similar). This enables us to to be completely free when mapping peripheral devices and their pins. So would expect this mapping to be made here...

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.

Can you point me to an example to follow ?

* @brief The peripheral clock is required for the UART Baud rate calculation
* It is configured by the 'config' registers (see pic32_config_settings.c)
*/
#define PERIPHERAL_CLOCK (100000000) /* Hz */
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.

For consistency over all boards, I would expect this kind of define in the periph_conf.h file...

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, will move.

@@ -0,0 +1 @@
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/
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.

Where do you define the CPU and the CPU_MODEL defines?

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.

Oleg just pointed this out and is now fixed.

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.

( I was always specifying CPU and BOARD at the prompt when building)

#define PORTFCLR 0xBF860524
#define TRISFCLR 0xBF860514
#define TRISFSET 0xBF860518
#define ODCFCLR 0xBF860544
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.

Are these really board specific?

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, this is fixed in my WIP branch (https://github.com/neiljay/RIOT/tree/wip) there is another vendor supplied file with all these definitions in. I'll submit another PR for this, this one is already too big.

@@ -0,0 +1,403 @@
/*
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 am not really familiar with the MIPS architecture: looking at this file, it seems like it contains many configuration options that I would expect to be done by their connected modules/periph drivers. Do all of these options need to be set during compile time? And are they read only later on? In the current form these options seem to be very hard to maintain/to configure for others...

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.

This has nothing to do with MIPS architecture. This is a weird quirk of the PIC32 implementation from Microchip (and there odd programming tools). These value map onto registers which overlay the flash, when a reflash occurs these register get 'erased' and must be programmed when a new firmware image is loaded and thus these values must exist at the correct addresses in the resultant elf file / binary image.
I agree its horrible but a necessity for PIC32 devices, Microchip in there own tools (XC32) have implemented a #pragma for these values which make it a bit nicer:
https://people.ece.cornell.edu/land/courses/ece4760/PIC32/PLIB_examples/plib_examples/uart/uart_basic/source/main.c
We don't have that ability in generic tools.

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.

(So yes they are effectively read-only once programmed)

* Setup pin mux for UART4 this is the one connected
* to the ftdi chip (usb<->uart)
*/
w32(U4RXR, 0xb); /* connect pin RPF2 to UART 4 RX */
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.

Pin configuration should be part of the periph_conf.h and then be handled by the actual peripheral driver module (possibly by using the GPIO driver).

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.

I agree a whole pin-mux driver needs implemented and we have started work on one.
peripheral support is a bit hacky at the moment, we just wanted to get the UART going so we can show that the 'core' architecture port works. get that merged then improve pic32 device support so it can be used for actual products.

@@ -0,0 +1,3 @@
/* This file must exist to get timer code to build */
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.

hm, as there are periph_cpu.h files in the specific cpu folders, there should be no need for this file here? Seems like something is not quite in order if this file is really needed...

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.

mips32r2_common can be selected as a CPU on its own for testing on FPGA systems with minimal peripherals, this is what BOARD=mips-malta uses.

#endif

#define ISR_STACKSIZE (0)
/** @} */
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 values are equal for all mips32r2 cpus, right? So I would suggest to move them into cpu/mips32r2_common/include/cpu.h as done for the cortexm_common cpus.

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.

Currently yes. But they may change in the future.
pic32mz supports FPU, pic32mx does not for example.

/* pic uarts are numbered 1 to 6 */
PIC32_UART_T pic_uart[UART_NUMOF + 1];

int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
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.

are incoming chars handled anywhere?

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 not yet.
As said previously we just want to get something going to prove the core architecture port works on real hardware.
It will be coming of course.

#define UxTXREG(U) (U.regs[0x20/4])
#define UxRXREG(U) (U.regs[0x30/4])
#define UxBRG(U) (U.regs[0x40/4])
#define REGS_SPACING (0x200)
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 think it would make sense to put these into a header file?! And are the UART peripherals the same for each mips32r2 based CPU? Or is this like with other MCU families, where each vendor uses their own UART peripheral?

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.

This is in 'pic32_common' not 'mips32r2_common' this UART is common across all PIC32 implementations, obviously not across all mips32r2 implementations, I'm happy to move these to a header file though.

Neil Jones added 3 commits November 4, 2016 09:41
Remove unused defines
Remove duplicate defines available in cpu part files.
Make uart data static.
@neiljay
Copy link
Copy Markdown
Contributor Author

neiljay commented Nov 4, 2016

Hi All,

After discussion with Oleg and Martine, I'll split this up into 3 separate PRs.

Thanks for the reviews so far.

@PeterKietzmann
Copy link
Copy Markdown
Member

@neiljay I didn't check in detail. Can we close this in favour of the above mentioned three PRs? If yes, please do so.

@neiljay neiljay closed this Jan 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

7 participants