MIPS32 port

ChibiOS public support forum for topics related to the micro-controllers based on MIPS32 cores.
Dmytro
Posts: 98
Joined: Sun Oct 07, 2012 11:49 am

MIPS32 port

Postby Dmytro » Sat Oct 27, 2012 6:18 pm

Hi,
I would like to present MIPS32 port.
Currently it supports only MIPS32 ISA however MIPS16 is in TODO list.
Also only execution from memory is supported. Thereby external bootloader is needed to parse, load and then execute ELF.
Boot from flash will be added soon as this is a preferred way for most really tiny MCUs(like PIC32).

At the moment the port is tested only in QEMU where chibios is loaded with u-boot.
You can find minimal information how to build u-boot and how to load and execute chibios after.

Major goal is to run chibios on PIC32.

Git hub repository based on mabl/ChibiOS mirror:
https://github.com/niamster/ChibiOS/tree/mips-qemu

Any comments, remarks and support are very welcome!

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: MIPS32 port

Postby Giovanni » Sat Oct 27, 2012 7:51 pm

Hi,

Good job, I have an Olimex PIC32 board and this work was "in queue", I will be able to help testing.

Giovanni

Dmytro
Posts: 98
Joined: Sun Oct 07, 2012 11:49 am

Re: MIPS32 port

Postby Dmytro » Sun Oct 28, 2012 2:32 pm

Thanks a lot, Giovanni.
So far I don't have any working sample with PIC32 so your help is very welcome!

-- Dmytro

Dmytro
Posts: 98
Joined: Sun Oct 07, 2012 11:49 am

Re: MIPS32 port

Postby Dmytro » Thu Nov 01, 2012 4:32 pm

Hi,
I've updated the branch so now it's possible to boot chibi from qemu flash(w/o external loader).
All process is documented under demos/MIPS_QEMU/readme.txt

I should receive one demo board with pic32, so I hope there will be some updates for this MCU.

cheers,
-- dmytro

Dmytro
Posts: 98
Joined: Sun Oct 07, 2012 11:49 am

Re: MIPS32 port

Postby Dmytro » Sat Nov 10, 2012 7:09 pm

Hi,
I've pushed a new branch mips-pic32mx to the repository which has basic support of PIC32 MCU: https://github.com/niamster/ChibiOS/tree/mips-pic32mx

The demo itself is at demos/MIPS-PIC32MX795F512L-PIC32-MAXI-WEB
Currently it's based on OLIMEX PIC32 MAXI-WEB demo board(https://www.olimex.com/Products/PIC/Dev ... -MAXI-WEB/).
The demo supports only UART and does exactly the same as MIPS-QEMU demo.

All instructions are in readme.txt inside the demo directory.
Basically you need MIPS toolchain and MPLAB-X(to flash the image) with xc32(to compile single file with configuration bits).

In the end I would like to get rid from xc32 dependency.

Next in the TODO list for PIC32/MIPS32:
- support of shadow registers for ISRs
- mips16
- get rid of xc32

Right now vectored interrupts are not supported. The main reason is that I don't see much sense if you do major work in the thread and you wake it up in the ISR. So if ISR does not take too much time it's easier to manage single entry into the interrupt mode.

Remarks and suggestions are very welcome!

cheers,
-- dmytro

etmatrix
Posts: 46
Joined: Sun Oct 21, 2012 10:05 pm

Re: MIPS32 port

Postby etmatrix » Sat Nov 10, 2012 11:57 pm

I trying to build your demo project with xc32 PRO (trial) v1.00
My linuxbox is 32bit so I can't use prebuild mips toolchain.
I changed Makefile
TRGT = xc32-

but I have some problems.

Code: Select all

Compiling ../../os/hal/platforms/MIPS-PIC32MX/eic_lld.c
In file included from /opt/microchip/xc32/lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/peripheral/system.h:39:0,
                 from /opt/microchip/xc32/lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/plib.h:67,
                 from ../../os/hal/platforms/MIPS-PIC32MX/eic_lld.c:35:
/opt/microchip/xc32/lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/peripheral/osc.h:138:30: error: '_REFOCON_RSLP_POSITION' undeclared here (not in a function)
/opt/microchip/xc32/lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/peripheral/osc.h:139:27: error: '_REFOCON_OE_POSITION' undeclared here (not in a function)
/opt/microchip/xc32/lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/peripheral/osc.h:140:30: error: '_REFOCON_SIDL_POSITION' undeclared here (not in a function)
/opt/microchip/xc32/lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/peripheral/osc.h:141:27: error: '_REFOCON_ON_POSITION' undeclared here (not in a function)

I see in peripheral/osc.h there is an if
#if (((__PIC32_FEATURE_SET__ >= 100) && (__PIC32_FEATURE_SET__ <= 299)) || defined(__32MXGENERIC__))
I temporarly removed the #if #endif so compilation go on but on linking I have another problem:

Code: Select all

Linking build/ch.elf
/opt/microchip/xc32/lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld: Link Error: attributes for input section '.core.entry' conflict with output section '.boot'
collect2: ld returned 1 exit status
make: *** [build/ch.elf] Error 1

Do I need to change another files for compile with xc32? Maybe the problem is my xc32 v1.00 too old.

Thank you

etmatrix
Posts: 46
Joined: Sun Oct 21, 2012 10:05 pm

Re: MIPS32 port

Postby etmatrix » Sun Nov 11, 2012 10:39 am

I installed xc32 1.11.
I changed this row
USE_OPT += -mprocessor=32MX795F512L -D__32MX795F512L__ -D__PIC32_FEATURE_SET__=795
in
USE_OPT += -mprocessor=32MX795F512L

this row
USE_XCOPT = -mprocessor=32MX795F512L -O2
in
USE_XCOPT =
double "-mprocessor=32MX795F512L" make problem in compilation.

this row
USE_LDOPT = -EL
in
USE_LDOPT = -EL -mprocessor=32MX795F512L
and now compilation with xc32 works.
The same changes with XC32 v1.00 make the same previous error " Link Error: attributes for input section '.core.entry' conflict with output section '.boot'"

I have a UBW32 which has a PIC32MX795F512L, I attach to RF2 and RF8 my USB-TTL converter but I don't receive data.

Dmytro
Posts: 98
Joined: Sun Oct 07, 2012 11:49 am

Re: MIPS32 port

Postby Dmytro » Sun Nov 11, 2012 4:23 pm

Hi, etmatrix,

first of all thanks for trying this =)

My linuxbox is 32bit so I can't use prebuild mips toolchain.

Hum, as far as I remember the toolchain at http://developer.mips.com/tools/compile ... toolchain/ is for x86.
Anyway there's a way to build it yourself - on the same page a HOW-TO titled "Building a Toolchain from Source". Also you can try to build it using crosstool-ng.
Unfortunately I didn't try too much to build complete image with xc32. I don't like it a lot ...

Anyway you have to change the way the linker script is provided to the linker:
Go to os/ports/GCC/MIPS/rules.mk and change

Code: Select all

ifeq ($(USE_LINK_GC),yes)
  LDFLAGS = $(MCFLAGS) -G0 -fno-pic -fno-PIC -static -n -nostdlib -nostartfiles $(LDOPT) -T$(LDSCRIPT) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR)
else
  LDFLAGS = $(MCFLAGS) -G0 -fno-pic -fno-PIC -static -n -nostdlib -nostartfiles $(LDOPT) -T$(LDSCRIPT) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR)
endif
to

Code: Select all

ifeq ($(USE_LINK_GC),yes)
  LDFLAGS = $(MCFLAGS) -G0 -fno-pic -fno-PIC -static -n -nostdlib -nostartfiles $(LDOPT) -Wl,--script=$(LDSCRIPT) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR)
else
  LDFLAGS = $(MCFLAGS) -G0 -fno-pic -fno-PIC -static -n -nostdlib -nostartfiles $(LDOPT) -Wl,--script=$(LDSCRIPT) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR)
endif


I have a UBW32 which has a PIC32MX795F512L, I attach to RF2 and RF8 my USB-TTL converter but I don't receive data.

Maybe you have to change your UART port? Try to change it in os/hal/platforms/MIPS-PIC32MX/serial_lld.c:sd_lld_init.

regards,
-- dmytro

mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Location: Karlsruhe, Germany
Been thanked: 1 time
Contact:

Re: MIPS32 port

Postby mabl » Sun Nov 11, 2012 5:05 pm

Hi Dmytro,

do you run the kernel test cases in qemu? If so, is there a documentation on how to get the serial output? What hardware does qemu simulate for serial?

Best,
MaBl

Dmytro
Posts: 98
Joined: Sun Oct 07, 2012 11:49 am

Re: MIPS32 port

Postby Dmytro » Sun Nov 11, 2012 5:06 pm

I have a UBW32 which has a PIC32MX795F512L, I attach to RF2 and RF8 my USB-TTL converter but I don't receive data.

Maybe you have to change your UART port? Try to change it in os/hal/platforms/MIPS-PIC32MX/serial_lld.c:sd_lld_init.
According to the pinout RF2 and RF8 correspond to UART1 RX and TX respectively, so here you were right.

There's a problem either with your UART connection either with the wrong location of vectors and entry code which is not expected by current chibios-mips implementation.
If you follow my suggestion for a linker script the location of the sections should be at expected place.

cheers,
-- dmytro


Return to “MIPS32 Support”

Who is online

Users browsing this forum: No registered users and 6 guests