ChibiOS as bootloader problem
Posted: Fri Nov 02, 2018 12:10 pm
Hello
I would like use ChibiOS stm8l as bootloader, but
I have problem with mapping of vectors, because vectors must be mapped to corrected working.
I use version 2.7.0unstable
Standard vextors with working:
/*File vectors.c */
/**
* @brief Exception handler type.
*/
typedef void @far @interrupt (*interrupt_handler_t)(void);
/*
* Various external symbols.
*/
void _stext(void);
@far @interrupt void vector_trap(void);
@far @interrupt void vector0(void);
.
.
.
@far @interrupt void vector29(void);
/**
* @brief Exception vector type.
*/
typedef struct {
unsigned char ev_instruction;
interrupt_handler_t ev_handler;
} exception_vector_t;
/**
* @brief Unhandled exception handler.
* @default This function is the default handler for all unused entries
* in the vector table.
*/
@far @interrupt void _unhandled_exception (void)
{
while (TRUE)
;
}
/**
* @brief Exceptions table.
*/
exception_vector_t const _vectab[] = {
{0x82, (interrupt_handler_t)_stext}, /* reset */
#if defined(_TRAP_ISR)
{0x82, vector_trap},
#else
{0x82, _unhandled_exception}, /* trap */
#endif
#if defined(_TLI_ISR)
{0x82, vector0},
#else
{0x82, _unhandled_exception}, /* vector0 */
#endif
.
.
.
#if defined(_SPI2_ISR) || defined(_I2C1_ISR)
{0x82, vector29},
#else
{0x82, _unhandled_exception}, /* vector29 */
#endif
};
New file vectors.c with relocated vectors
/***********************************************************************************/
/* My new file vectors.c */
typedef void @far (*interrupt_handler_t)(void);
struct exception_vector_t {
unsigned char ev_instruction;
interrupt_handler_t ev_handler;
};
@far @interrupt void _unhandled_exception (void)
{
while (TRUE)
;
}
#define APP_START 0x0D000
extern void _stext();
struct exception_vector_t const User_IRQ[32] @ APP_START;
//redirected interrupt table
struct exception_vector_t const _vectab[] = {
{0x82, (interrupt_handler_t)_stext},
{0x82, (interrupt_handler_t)(User_IRQ+ 1)}, /* trap */
{0x82, (interrupt_handler_t)(User_IRQ+ 2)}, /* irq0 */
{0x82, (interrupt_handler_t)(User_IRQ+ 3)}, /* irq1 */
{0x82, (interrupt_handler_t)(User_IRQ+ 4)}, /* irq2 */
{0x82, (interrupt_handler_t)(User_IRQ+ 5)}, /* irq3 */
{0x82, (interrupt_handler_t)(User_IRQ+ 6)}, /* irq4 */
...
{0x82, (interrupt_handler_t)(User_IRQ+31)}, /* irq29 */
};
Main problem is in the file chcore.h in line
#define PORT_IRQ_HANDLER(id) @far @interrupt @svlreg void vector##id(void)
How should I change this definition to work correctly
/***********************************************************************************/
/* File chcore.h */)
/**
* @brief IRQ handler function declaration.
* @note @p id can be a function name or a vector number depending on the
* port implementation.
*/
#define PORT_IRQ_HANDLER(id) @far @interrupt @svlreg void vector##id(void)
I would like use ChibiOS stm8l as bootloader, but
I have problem with mapping of vectors, because vectors must be mapped to corrected working.
I use version 2.7.0unstable
Standard vextors with working:
/*File vectors.c */
/**
* @brief Exception handler type.
*/
typedef void @far @interrupt (*interrupt_handler_t)(void);
/*
* Various external symbols.
*/
void _stext(void);
@far @interrupt void vector_trap(void);
@far @interrupt void vector0(void);
.
.
.
@far @interrupt void vector29(void);
/**
* @brief Exception vector type.
*/
typedef struct {
unsigned char ev_instruction;
interrupt_handler_t ev_handler;
} exception_vector_t;
/**
* @brief Unhandled exception handler.
* @default This function is the default handler for all unused entries
* in the vector table.
*/
@far @interrupt void _unhandled_exception (void)
{
while (TRUE)
;
}
/**
* @brief Exceptions table.
*/
exception_vector_t const _vectab[] = {
{0x82, (interrupt_handler_t)_stext}, /* reset */
#if defined(_TRAP_ISR)
{0x82, vector_trap},
#else
{0x82, _unhandled_exception}, /* trap */
#endif
#if defined(_TLI_ISR)
{0x82, vector0},
#else
{0x82, _unhandled_exception}, /* vector0 */
#endif
.
.
.
#if defined(_SPI2_ISR) || defined(_I2C1_ISR)
{0x82, vector29},
#else
{0x82, _unhandled_exception}, /* vector29 */
#endif
};
New file vectors.c with relocated vectors
/***********************************************************************************/
/* My new file vectors.c */
typedef void @far (*interrupt_handler_t)(void);
struct exception_vector_t {
unsigned char ev_instruction;
interrupt_handler_t ev_handler;
};
@far @interrupt void _unhandled_exception (void)
{
while (TRUE)
;
}
#define APP_START 0x0D000
extern void _stext();
struct exception_vector_t const User_IRQ[32] @ APP_START;
//redirected interrupt table
struct exception_vector_t const _vectab[] = {
{0x82, (interrupt_handler_t)_stext},
{0x82, (interrupt_handler_t)(User_IRQ+ 1)}, /* trap */
{0x82, (interrupt_handler_t)(User_IRQ+ 2)}, /* irq0 */
{0x82, (interrupt_handler_t)(User_IRQ+ 3)}, /* irq1 */
{0x82, (interrupt_handler_t)(User_IRQ+ 4)}, /* irq2 */
{0x82, (interrupt_handler_t)(User_IRQ+ 5)}, /* irq3 */
{0x82, (interrupt_handler_t)(User_IRQ+ 6)}, /* irq4 */
...
{0x82, (interrupt_handler_t)(User_IRQ+31)}, /* irq29 */
};
Main problem is in the file chcore.h in line
#define PORT_IRQ_HANDLER(id) @far @interrupt @svlreg void vector##id(void)
How should I change this definition to work correctly
/***********************************************************************************/
/* File chcore.h */)
/**
* @brief IRQ handler function declaration.
* @note @p id can be a function name or a vector number depending on the
* port implementation.
*/
#define PORT_IRQ_HANDLER(id) @far @interrupt @svlreg void vector##id(void)