If anyone cares, here are the changes required to board.c and chcore.c. Do note I've not extensively verified this works but everything I've tested passed without issue; though admittedly barely extends beyond simple scheduling. I'll also point out, all of the changes have been wrapped for conditional compilation against the atmega8 (atmega8-16pu).
board.c file:
/*
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,2011 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
ChibiOS/RT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/RT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
---
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes ChibiOS/RT, without being obliged to provide
the source code for any proprietary components. See the file exception.txt
for full details of how and when the exception can be applied.
*/
#include "ch.h"
#include "hal.h"
#if defined( __AVR_ATmega8__ )
CH_IRQ_HANDLER(TIMER1_COMPA_vect) {
#else
CH_IRQ_HANDLER(TIMER0_COMPA_vect) {
#endif
CH_IRQ_PROLOGUE();
chSysLockFromIsr();
chSysTimerHandlerI();
chSysUnlockFromIsr();
CH_IRQ_EPILOGUE();
}
/*
* Board-specific initialization code.
*/
void boardInit(void) {
#if defined( __AVR_ATmega8__)
// Timer 1 for atmega8 w/ IRQ for compare
TCNT0 = 0 ;
OCR1A = 128 ;
TCCR0 |= (1<<CS00) ; // No pre-scaling
TIMSK |= (1 << OCIE1A) ;
#else
/*
* Timer 0 setup.
*/
OCR0A = 128;
TIMSK0 |= (1 << OCIE0A); /* IRQ on compare. */
#endif
}
And the part I changed at the end of chcore.c:
/**
* @brief Start a thread by invoking its work function.
* @details If the work function returns @p chThdExit() is automatically
* invoked.
*/
void _port_thread_start(void) {
asm volatile ("sei");
asm volatile ("movw r24, r4");
asm volatile ("movw r30, r2");
asm volatile ("icall");
#if defined( __AVR_ATmega8__ )
asm volatile ("rcall chThdExit");
#else
asm volatile ("call chThdExit");
#endif
}
/** @} */