TMS470 port

Hi all, I started to port freeRTOS to an ARM7-based TMS470R1B1M but now I’am facing some problems. At the beginning I thought that it is no big deal as there are already some ARM7 ports available. So I took the ARM7_AT91SAM7S port as example. At the beginning I modified the timer initialization and the timer ISR and both worked. I did not modify the macros portRESTORE_CONTEXT and portSAVE_CONTEXT as the assembler instructions should be the same. But unfortunately, it does not work. After the following commands in RESTORE_CONTEXT, the PC register points to somewhere.     LDMFD    LR, {R0-R14}^                NOP                    LDR    LR, [LR, #+60]     SUBS    PC, LR, #4    Is there anybody who is working on a TMS470 port too or can someone point me to some hints? I use gnu-arm-gcc 4.0.2, arm mode only and I started without using preemption. TIA Torsten

TMS470 port

Well, after some modifications the context switch works. I’ll let you know, when I’m ready with the complete port. Torsten

TMS470 port

I have a tms470 port that was sent to me recently, I’m not sure if it is complete yet and don’t have the means (yet) to test it.  I would be grateful for your port also when it is complete so it can become a supported processor ;-) I’m surprised you had to change the macro definitions.  Did you start with a GCC port as your base, or the IAR SAM7 port? The GCC ports can use inline assembler __attribute__((naked)) to keep all the code in the C files, whereas the IAR ports use a slightly different technique. Also, did you call the first portRESTORE_CONTEXT from supervisor mode?  This is essentail, and the easiest way to do it is by switching the supervisor mode prior to calling main(). Regards.

TMS470 port

>I’m surprised you had to change the macro >definitions. Did you start with a GCC port as >your base, or the IAR SAM7 port? I’m also surprised. So maybe something different is wrong to with my port. So could you send me the TMS470 port you got recently? It would be a great help for me. Regards Torsten

TMS470 port

I can send it when I get back from my business trip. What was it you had to change? Regards.

TMS470 port

Do you think about publishing the TMS470 port ? I’am a newbee with FreeRTOS and TMS470… and i would like to use it on the Olimex TMS470-P256 prototype board.

TMS470 port

Hello there I’m trying to port FreeRTOS to TMS470. I’ve 2 tasks - an LCD driver waiting for an LCDMessage - another task trying to send a message when it starts. The second task starts to work and queues a message to the first one. But when calling taskEXIT_CRITICAL() inside xQueueSend() function my software goes I don’t known where ? I suppose that there is something wrong with task switching and/or interrupts… Can someone help me ?

TMS470 port

Hi Guys, Were you able to port FreeRTOS to TMS470.? I am stuck at context switching part. I am able to initialize tick interrupt timer and after I start a task it doenst come back to the tick interrupt again. Can some one please provide me the port ? It would be a great help. Regards, Winston

TMS470 port

There is a port here: https://interactive.freertos.org/hc/en-us/community/posts/210028366-TMS470M It is VERY old, but may provide the piece you are missing. Are you starting the scheduler from Supervisor mode? That is a requirement.

TMS470 port

Hi Richard, Thanks for this port. But this is not helpful for me since this chip is ARM cortex M series and also its built on CCS compiler. Mine is TMS470R1B1M – High temp chip. Which is ARM7TDMI and using IAR compiler. However I have little progress in setting up timer and interrupts and and starting up the scheduler. But I have a problem. Problem: After the scheduler starts the task runs but hangs after first iterations. (timer interrupt comes only twice). After that PC points to some random location. Observation: When I did step through I can see where exactly its jumping out. —- for the first interrupt when vPortPreemptiveTickEntry() is called.. Context switch is happening. after the portRESTORECONTEXT chip is in System mode.
—- for the second interrupt when vPortPreemptiveTickEntry() is called in portRESTORE
CONTEXT function below two lines ~~~ LDR LR, [LR, #+60] SUBS PC, LR, #4 ~~~ The "LDR LR, [LR, #+60]" puts 0xE59F02F4 address on the LR register. and "SUBS PC, LR, #4"puts the chip to unknown state. And debugger starts running, When I stop the debugger PC points to some where around 0xEC9C9988C which is actually no where. The chip is still in System mode. Any ideas would be so helpful . Regards, Winston

TMS470 port

Little more info. This port is modified from LPC2000 series port of IAR. in the startup.asm I have put the chip into supervisor mode before jumping into main. And my tick interrupt is jumped to IRQHandler which is in C language which is in main.c ~~~ ldr pc,[pc,#+24] ;; Reset ldr pc,[pc,#+24] ;; Undefined instructions
b vPortYieldProcessor ;; Software interrupt (SWI/SVC) ldr pc,[pc,#+24] ;; Prefetch abort ldr pc,[pc,#+24] ;; Data abort ldr pc,[pc,#+24] ;; Reserved b IRQ
Handler ;; IRQ ldr pc,[pc,#+24] ;; FIQ ~~~ IRQ_Handler in main.c ~~~ __irq __arm void IRQHandler(void) { unsigned int a = RTICNTR >> 11; switch((0xff & IRQIVEC)-1) { case CIMCOMP1 : vPortPreemptiveTickEntry();
break; } } ~~~

TMS470 port

It sounds like the stack is getting corrupted, probably because you are using the compiler’s interrupt entry code to enter the interrupt and the RTOS’s interrupt exit code to exit the interrupt. I’m pretty sure you have to have the interrupt entry code in assembler so the context is saved as the scheduler expects and the stack frame is also as the scheduler expects. See https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Source/portable/IAR/LPC2000/portasm.s79 for the handler (as you probably have, and https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Source/portable/IAR/LPC2000/ISR_Support.h for interrupt entry and exit code (for the LPC2000) that must execute as the first thing (before any C code that manipulates the stack as you have it).

TMS470 port

Hi Richard, Thank you. Yes you were right. I removed the timer ISR callback from C and put the vPortPreemptiveTickEntry directly from startup.asm vector address. Now I can run the tasks as expected.
       SECTION .intvec:CODE:NOROOT(2)

    PUBLIC  __vector
    PUBLIC  __iar_program_start
    EXTERN UndefinedInstruction
    EXTERN vPortYieldProcessor
    EXTERN vPortPreemptiveTickEntry

    ARM
__vector: ;; ldr pc,[pc,#+24] ;; Reset ldr pc,[pc,#+24] ;; Undefined instructions
b vPortYieldProcessor ;; Software interrupt (SWI/SVC) ldr pc,[pc,#+24] ;; Prefetch abort ldr pc,[pc,#+24] ;; Data abort ldr pc,[pc,#+24] ;; Reserved b vPortPreemptiveTickEntry ;; IRQ ldr pc,[pc,#+24] ;; FIQ
 Once I clean up the code I can share this port so that you could add it in the supported processors. 
  But this chip is rare. It's Texas instruments SM470R1B1M High Temperature ARM7TDMI™ Flash Microcontroller. Used only in Oil and Gas / Space / millitary applications.  http://www.ti.com/product/sm470r1b1m-ht/description

  Regards,

    Winston