Arduino Mega 2560 support

ChibiOS public support forum for topics related to the Atmel AVR family of micro-controllers.

Moderator: tfAteba

Post Reply
giometti
Posts: 6
Joined: Fri Mar 28, 2014 11:30 am

Arduino Mega 2560 support

Post by giometti »

Hello,

I'd like running ChibiOS on Arduino Mega 2560 CPU and looking at the post http://forum.chibios.org/phpbb/viewtopic.php?f=2&t=197 I did the following patch:

Code: Select all

diff --git a/demos/AVR-ArduinoMega-GCC/Makefile b/demos/AVR-ArduinoMega-GCC/Make
index 9113e88..6a76ccb 100644
--- a/demos/AVR-ArduinoMega-GCC/Makefile
+++ b/demos/AVR-ArduinoMega-GCC/Makefile
@@ -41,7 +41,7 @@
 
 
 # MCU name
-MCU = atmega1280
+MCU = atmega2560
 
 
 # Processor frequency.
diff --git a/os/ports/GCC/AVR/chcore.h b/os/ports/GCC/AVR/chcore.h
index 203c688..2552833 100644
--- a/os/ports/GCC/AVR/chcore.h
+++ b/os/ports/GCC/AVR/chcore.h
@@ -97,6 +97,7 @@ struct extctx {
   uint8_t       sr;
   uint8_t       r1;
   uint8_t       r0;
+  uint8_t      pcx;
   uint16_t      pc;
 };
 
@@ -127,6 +128,7 @@ struct intctx {
   uint8_t       r4;
   uint8_t       r3;
   uint8_t       r2;
+  uint8_t      pcx;
   uint8_t       pcl;
   uint8_t       pch;
 };
@@ -153,6 +155,7 @@ struct context {
   tp->p_ctx.sp->r3  = (int)pf >> 8;                                         \
   tp->p_ctx.sp->r4  = (int)arg;                                             \
   tp->p_ctx.sp->r5  = (int)arg >> 8;                                        \
+  tp->p_ctx.sp->pcx = 0;                                                   \
   tp->p_ctx.sp->pcl = (int)_port_thread_start >> 8;                         \
   tp->p_ctx.sp->pch = (int)_port_thread_start;                              \
 }


Now the demo program into directory

Code: Select all

demos/AVR-ArduinoMega-GCC/
works correctly!

Since I'm a newbie, can someone help me in adding my patch into main line in order to fix Mega2560 support? Should I use a special #define as in the post above or...?

Thanks in advance,

Rodolfo
Post Reply