ChibiOS as bootloader problem

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: barthess, RoccoMarco, utzig, lbednarz, tfAteba

miki07
Posts: 2
Joined: Tue Oct 30, 2018 4:25 pm

ChibiOS as bootloader problem

Postby miki07 » 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)

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

Re: ChibiOS as bootloader problem

Postby Giovanni » Fri Nov 02, 2018 1:11 pm

Hi,

You should change the macro to use your new names instead of vectorXX. I don't know what you are trying to do so cannot help much.

STM8 support ceased 5 years ago, I don't even have HW and compilers to test it anymore.

Giovanni

miki07
Posts: 2
Joined: Tue Oct 30, 2018 4:25 pm

Re: ChibiOS as bootloader problem

Postby miki07 » Fri Nov 02, 2018 1:45 pm

Hi
Sure, I understand it is old platform.
but maybe some one can halp.

I change the name vectorXXid to new name.
Bat before was a many function from void vectors0 (void) to void vectors29 (void)
to remap the vectors I use array User_IRQ[32] plus APPL_START
And compiler doesn't use this array because he expect function with number.
map file:
f_vector19 ******** *** removed from Debug\shared_isr.o ***
f_vector2 ******** *** removed from Debug\shared_isr.o ***
f_vector20 ******** *** removed from Debug\shared_isr.o ***
f_vector26 ******** *** removed from Debug\shared_isr.o ***
f_vector27 ******** *** removed from Debug\shared_isr.o ***
f_vector28 ******** *** removed from Debug\shared_isr.o ***
f_vector3 ******** *** removed from Debug\shared_isr.o ***


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 6 guests