lorenzomalagia

MQX on custom board stuck in dispatch.s

Discussion created by lorenzomalagia on Feb 14, 2013
Latest reply on May 25, 2017 by Gordon Finlay

Hi guys, I hope you can help me

I developed a multitasking application using MQX and a TWR-K60N512 evaluation board. The chip on the tower is a PK60N512VMD100 (0M33Z).

While I was working on the firmware, some collegues developed a custom board using MK60DN512ZVLQ10 (4N30D) chip which apparently seems to

be the same except for the presence of an internal DSP on the second one.

 

My application is made of 3 tasks. The init task is the auto start task and has a priority set to 9. It should run first and initialize the board. Before dying

it creates the other two tasks both with a priority of 10. They should run indefinitely.

 

When I use the tower everything is good. I can execute and debug the code (I'm using IAR and J-Link).

When I switch to the custom board I have many problems. Sometimes an error occurs when I try to upload the code so I need to erease all the memory

and try severl times before it stops tell me that the flash loader reported an error.

I don't know if this problem could be due to the linker file or the flash loader.

When I finally succed in uploading the code, something weird appens. I launch the debugger and I can see that the execution is stuck in "dispatch.s"

before the first task is scheduled.

 

The following code is copied by "dispatch.s" starting from line 432.


  1. ASM_LABEL(find_noempty_que)
  2.                 ldr r2, [r1, #0]                    ; address of first td
  3.                 cmp r2, r1                          ; ready_q structure itself?
  4.                 bne switch_task
  5.                 ldr r1, [r1, #RQ_NEXT_Q]            ; try next queue
  6.                 movs r1, r1
  7.                 bne find_noempty_que
  8.                 ; r1 is 0 -> empty
  9. ASM_LABEL(no_one_to_run)
  10.                 ; TODO set system task ???
  11.                 ; enable all interrupts (r1 = 0)
  12.                 ; TODO maybe (maybe not necessary) restore PendSV priority and BASEPRI after wfi
  13.                 msr BASEPRI, r1
  14.                 ldr r1, =0xE000ED20                    ; SHPR3
  15.                 ldr r2, =0xff
  16.                 strb r2, [r1, #2]
  17.                 ; wait for interrupt
  18.                 cpsie.n i
  19.                 wfi
  20.                 cpsid.n i
  21.                 ; TODO check r0, must be kernel data
  22.                 ldr r1, [r0, #KD_READY_Q_LIST]      ; get first que from ready list
  23.                 b find_noempty_que

 

 

By now the line numbers I will use are the ones used in the following piece of code.

I found the pointer always at line 23. If I go step by step it reaches line 27, then jumps to line 1 and cycles in this function 15 times.

Then it goes on to line 9, 10, 11,.... until it come back to line 1 and repeat the cycle

 

NOTE: the custom board has been tested with other sample code, for example with a demo of FreeRTOS and works perfectly. When I try to upload

a demo of MQX (with multitasking) the result is the same: it stucks in dispatch.s, wheras the same code in the tower works perfectly.

 

 

If someone solved a similar problem before or has some advices to give, I will really appreciate it.

Tanks

 

PS sorry for my English

 

 

 

...

Outcomes