Chibios on PIC32MX2xx

ChibiOS public support forum for topics related to the micro-controllers based on MIPS32 cores.

Moderator: Dmytro

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

Re: Chibios on PIC32MX2xx

Postby etmatrix » Sun Apr 21, 2013 3:39 pm

For these PIC32MX there is also PDIP format. I bought one from Mouser some months ago for testing.
You can use with breadboard without soldering. SMD for me is always a big problem.

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

Re: Chibios on PIC32MX2xx

Postby Dmytro » Sun Apr 21, 2013 6:21 pm

There are no dealers of these chips around me so it's cheaper to purchase whole board from ebay rather than paying 20-30 Euros for delivery.

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

Re: Chibios on PIC32MX2xx

Postby etmatrix » Sun Apr 21, 2013 6:22 pm

I understand which was the problem with DEVCFG.
Macro __PIC32MX_DEVCFG in os/hal/platforms/MIPS-PIC32MX/hal_lld.h make a mask with _UNIMPLEMENTED and _DEFAULT
I changed temporarily with:

Code: Select all

 #define __PIC32MX_DEVCFG(c, v)                                          \
   const uint32_t __DEVCFG ## c ## __                                    \
  __attribute__ ((section (".devcfg" #c))) = v;

and config is ok. Now I trying to debug with PicKit3, if my simple code is running.

Dmytro wrote:There are no dealers of these chips around me so it's cheaper to purchase whole board from ebay rather than paying 20-30 Euros for delivery.

You can try with Microchip's samples.

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

Re: Chibios on PIC32MX2xx

Postby Dmytro » Sun Apr 21, 2013 6:46 pm

Good catch! I completely forgot about that magic. I'm going to add support for 1xx/2xx and 3xx/4xx there.

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

Re: Chibios on PIC32MX2xx

Postby etmatrix » Sun Apr 21, 2013 7:00 pm

I can debug with PicKit3, I can see step-by-step the running but a simple palSetPad not make effect.
This is my simple code in main

Code: Select all

  ANSELA = 0;
  ANSELB = 0;
  palSetPadMode(IOPORTA, 0, PAL_MODE_OUTPUT);
  palSetPadMode(IOPORTB, 7, PAL_MODE_OUTPUT);
  palSetPadMode(IOPORTB, 8, PAL_MODE_OUTPUT);
  palSetPad(IOPORTA, 0);
  palSetPad(IOPORTB, 7);
  palSetPad(IOPORTB, 8);

I tried also ANSELASET = 0; and ANSELBSET = 0; I don't understand very well which is the difference with registers SET, CLEAR and INV.
Pins A0, B7 and B8, stay always to 0V.

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

Re: Chibios on PIC32MX2xx

Postby Dmytro » Sun Apr 21, 2013 7:30 pm

That's because in 1xx/2xx series the layout of registers for GPIOs is slightly different.
I just pushed support for those in pal. Can you try?

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

Re: Chibios on PIC32MX2xx

Postby etmatrix » Sun Apr 21, 2013 8:09 pm

Great works. Thank you.
Now I try a USB CDC with shell.

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

Re: Chibios on PIC32MX2xx

Postby Dmytro » Sun Apr 21, 2013 9:25 pm

Cool!
I pushed definition of devcfg for 1xx/2xx and 3xx/4xx. Can you try them out?

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

Re: Chibios on PIC32MX2xx

Postby etmatrix » Sun Apr 21, 2013 9:46 pm

USB CDC is working and with shell I have some benchmarks.

GCC 4.4.6

Code: Select all

*** ChibiOS/RT test suite
***
*** Kernel:       2.5.2unstable
*** Compiled:     Apr 21 2013 - 22:38:13
*** Compiler:     GCC 4.4.6
*** Architecture: MIPS32
*** Core Variant: MIPS32r2
*** Port Info:    Pure MIPS mode
*** Platform:     MIPS-PIC32MX

----------------------------------------------------------------------------
--- Test Case 1.1 (Threads, enqueuing test #1)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.2 (Threads, enqueuing test #2)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.3 (Threads, priority change)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.4 (Threads, delays)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.1 (Semaphores, enqueuing)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.2 (Semaphores, timeout)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.3 (Semaphores, atomic signal-wait)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.4 (Binary Semaphores, functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.1 (Mutexes, priority enqueuing test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.2 (Mutexes, priority inheritance, simple case)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.3 (Mutexes, priority inheritance, complex case)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.4 (Mutexes, priority return)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.5 (Mutexes, status)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.6 (CondVar, signal test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.7 (CondVar, broadcast test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.8 (CondVar, boost test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 4.1 (Messages, loop)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 5.1 (Mailboxes, queuing and timeouts)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.1 (Events, registration and dispatch)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.2 (Events, wait and broadcast)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.3 (Events, timeouts)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.1 (Heap, allocation and fragmentation test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 8.1 (Memory Pools, queue/dequeue)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.1 (Dynamic APIs, threads creation from heap)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.2 (Dynamic APIs, threads creation from memory pool)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.3 (Dynamic APIs, registry and references)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 10.1 (Queues, input queues)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 10.2 (Queues, output queues)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.1 (Benchmark, messages #1)
--- Score : 136331 msgs/S, 272662 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Benchmark, messages #2)
--- Score : 117332 msgs/S, 234664 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.3 (Benchmark, messages #3)
--- Score : 117332 msgs/S, 234664 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.4 (Benchmark, context switch)
--- Score : 368000 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.5 (Benchmark, threads, full cycle)
--- Score : 23999 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.6 (Benchmark, threads, create only)
--- Score : 25998 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.7 (Benchmark, mass reschedule, 5 threads)
--- Score : 37500 reschedules/S, 225000 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Benchmark, round robin context switching)
--- Score : 251960 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
--- Score : 641996 bytes/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.10 (Benchmark, virtual timers set/reset)
--- Score : 512116 timers/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.11 (Benchmark, semaphores wait/signal)
--- Score : 699492 wait+signal/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.12 (Benchmark, mutexes lock/unlock)
--- Score : 664492 lock+unlock/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.13 (Benchmark, RAM footprint)
--- System: 620 bytes
--- Thread: 76 bytes
--- Timer : 20 bytes
--- Semaph: 12 bytes
--- EventS: 4 bytes
--- EventL: 16 bytes
--- Mutex : 16 bytes
--- CondV.: 8 bytes
--- Queue : 36 bytes
--- MailB.: 40 bytes
--- Result: SUCCESS
----------------------------------------------------------------------------

Final result: SUCCESS


XC32 PRO a bit better of GCC 4.4.6

Code: Select all

*** ChibiOS/RT test suite
***
*** Kernel:       2.5.2unstable
*** Compiled:     Apr 21 2013 - 22:40:10
*** Compiler:     GCC 4.5.2 MPLAB XC32 Compiler v1.20
*** Architecture: MIPS32
*** Core Variant: MIPS32r2
*** Port Info:    Pure MIPS mode
*** Platform:     MIPS-PIC32MX

----------------------------------------------------------------------------
--- Test Case 1.1 (Threads, enqueuing test #1)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.2 (Threads, enqueuing test #2)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.3 (Threads, priority change)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.4 (Threads, delays)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.1 (Semaphores, enqueuing)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.2 (Semaphores, timeout)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.3 (Semaphores, atomic signal-wait)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.4 (Binary Semaphores, functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.1 (Mutexes, priority enqueuing test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.2 (Mutexes, priority inheritance, simple case)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.3 (Mutexes, priority inheritance, complex case)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.4 (Mutexes, priority return)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.5 (Mutexes, status)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.6 (CondVar, signal test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.7 (CondVar, broadcast test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.8 (CondVar, boost test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 4.1 (Messages, loop)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 5.1 (Mailboxes, queuing and timeouts)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.1 (Events, registration and dispatch)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.2 (Events, wait and broadcast)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.3 (Events, timeouts)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.1 (Heap, allocation and fragmentation test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 8.1 (Memory Pools, queue/dequeue)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.1 (Dynamic APIs, threads creation from heap)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.2 (Dynamic APIs, threads creation from memory pool)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.3 (Dynamic APIs, registry and references)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 10.1 (Queues, input queues)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 10.2 (Queues, output queues)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.1 (Benchmark, messages #1)
--- Score : 140248 msgs/S, 280496 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Benchmark, messages #2)
--- Score : 120498 msgs/S, 240996 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.3 (Benchmark, messages #3)
--- Score : 120498 msgs/S, 240996 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.4 (Benchmark, context switch)
--- Score : 383984 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.5 (Benchmark, threads, full cycle)
--- Score : 24273 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.6 (Benchmark, threads, create only)
--- Score : 26273 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.7 (Benchmark, mass reschedule, 5 threads)
--- Score : 38499 reschedules/S, 230994 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Benchmark, round robin context switching)
--- Score : 256960 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
--- Score : 663988 bytes/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.10 (Benchmark, virtual timers set/reset)
--- Score : 512416 timers/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.11 (Benchmark, semaphores wait/signal)
--- Score : 699548 wait+signal/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.12 (Benchmark, mutexes lock/unlock)
--- Score : 664608 lock+unlock/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.13 (Benchmark, RAM footprint)
--- System: 620 bytes
--- Thread: 76 bytes
--- Timer : 20 bytes
--- Semaph: 12 bytes
--- EventS: 4 bytes
--- EventL: 16 bytes
--- Mutex : 16 bytes
--- CondV.: 8 bytes
--- Queue : 36 bytes
--- MailB.: 40 bytes
--- Result: SUCCESS
----------------------------------------------------------------------------

Final result: SUCCESS


The clock is 40MHz, but I can clock also to 50MHz, I will test in the next days.
For DEVCFG I try now.
Thank you for your support.

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

Re: Chibios on PIC32MX2xx

Postby etmatrix » Sun Apr 21, 2013 10:17 pm

Dmytro wrote:Cool!
I pushed definition of devcfg for 1xx/2xx and 3xx/4xx. Can you try them out?

There was a typo and I added 2 bit in DEVCFG3, now is OK.

Code: Select all

diff --git a/os/hal/platforms/MIPS-PIC32MX/hal_lld.h b/os/hal/platforms/MIPS-PIC32MX/hal_lld.h
index 75396e9..696527a 100644
--- a/os/hal/platforms/MIPS-PIC32MX/hal_lld.h
+++ b/os/hal/platforms/MIPS-PIC32MX/hal_lld.h
@@ -217,16 +217,18 @@
  * DEVCFG3 register.
  */
 #if defined(PIC32MX1XX) || defined(PIC32MX2XX)
-#define DEVCFG0_UNIMPLEMENTED   0x0FFF0000
-#define DEVCFG0_DEFAULT         0x00000000
-#define DEVCFG0_INVERTED        0x00000000
+#define DEVCFG3_UNIMPLEMENTED   0x0FFF0000
+#define DEVCFG3_DEFAULT         0x00000000
+#define DEVCFG3_INVERTED        0x00000000

+#define DEVCFG3_PMDl1WAY        0x10000000 /* Peripheral Module Disable Configuration bit */
+#define DEVCFG3_IOLWAY          0x20000000 /* Peripheral Pin Select Configuration bit */
 #define DEVCFG3_FUSBIDIO        0x40000000 /* USBID controlled by port function */
 #define DEVCFG3_FVBUSONIO       0x80000000 /* VBUS_ON controlled by port function */
 #elif defined(PIC32MX3XX) || defined(PIC32MX4XX)
-#define DEVCFG0_UNIMPLEMENTED   0xFFFF0000
-#define DEVCFG0_DEFAULT         0x00000000
-#define DEVCFG0_INVERTED        0x00000000
+#define DEVCFG3_UNIMPLEMENTED   0xFFFF0000
+#define DEVCFG3_DEFAULT         0x00000000
+#define DEVCFG3_INVERTED        0x00000000
 #elif defined(PIC32MX5XX) || defined(PIC32MX6XX) || defined(PIC32MX7XX)
 #define DEVCFG3_UNIMPLEMENTED   0x38F80000
 #define DEVCFG3_DEFAULT         0x00000000


Return to “MIPS32 Support”

Who is online

Users browsing this forum: No registered users and 1 guest