IAR AVR Port

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

Moderators: utzig, tfAteba

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: IAR AVR Port

Postby JetForMe » Sun Apr 28, 2013 6:25 am

Fair enough.

Can you tell me what the port_switch() routine is doing? It seems to use r22/r23 and r24/r25 for something related to the stack pointer. It also doesn't save and restore all the registers, which I understand is how you speed up context switches, because the compiler saves and restores some of them. But I don't know which ones.

I'm still trying to understand what's going wrong.

I'm doing this on a Mac without a debugger. I have Windows in a VM and can debug using AVR Studio 6 (which has GCC, too), but it seemed like it would be pretty hard to get ChibiOS to build in that environment; I'd have to make a project and add all the files and I'm not sure how much work it would take to learn AVR Studio 6 and get it to build correctly. I was hoping I could figure it out with printf(), but it's hard to trace through the execution without being able to single step.

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

Re: IAR AVR Port

Postby Giovanni » Sun Apr 28, 2013 7:32 am

Hi,

I think it has been covered in the past, the port_switch() function saves the registers defined in the intctx structure. That structure must contain all the registers that the compiler expects to not be altered by function calls plus the stack frame of port_switch() itself (usually just the return address).

This structure is architecture AND compiler dependent.

The function used registers are the only required in order to switch from thread to thread because the compiler expects the other ones to be altered anyway when calling port_switch().

The extctx structures contains all the other registers, those that are saved and restored by ISRs, this structure must describe the stack frame created by ISR functions, again this is compiler and architecture dependent.

The correct definitions of those structures is the first and most critical step in order to implement a port layer for a new architecture.

I know for sure that there are many users interested in the AVR architecture, I suggest to team up and work on the AVR support, right now the port is not actively maintained.

Giovanni

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: IAR AVR Port

Postby JetForMe » Sun Apr 28, 2013 8:22 pm

Sorry, I didn't mean generally what it's doing. I meant, very specifically, how is the AVR port_switch() doing what it does? I don't know where to find ABI documentation for AVR/GCC, so it's hard for me to understand specifically how it's performing the context switch. In particular around those registers r22/23 and r24/25.

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

Re: IAR AVR Port

Postby Giovanni » Sun Apr 28, 2013 8:33 pm

When I wrote the AVR port the description of the used registers was on the AVRGCC web site documentation, I don't know the status now. You could also ask on the GCC mailing list eventually.

Giovanni

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: IAR AVR Port

Postby JetForMe » Sun Apr 28, 2013 8:34 pm

Okay.

BTW, what do you think about making an AVR section of the forum?

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

Re: IAR AVR Port

Postby Giovanni » Sun Apr 28, 2013 9:12 pm

Usually I create a forum when there is at least a maintainer for the platform. AVR so far is not maintained.

Giovanni

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: IAR AVR Port

Postby JetForMe » Sun Apr 28, 2013 9:18 pm

Well, I'm sure trying to, but I'm having a hard time getting any traction.

I think I'm going to have to give up on ChibiOS for this project. I want to have it ready for Makerfaire May 18, and I've already wasted a three-day weekend with nothing to show in terms of actual functionality.

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

Re: IAR AVR Port

Postby Giovanni » Sun Apr 28, 2013 9:23 pm

Sorry to hear that.

Giovanni


Return to “AVR Support”

Who is online

Users browsing this forum: No registered users and 19 guests