<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p dir="ltr">Hi,</p>
    <p dir="ltr">I guess it my fault for not 100% copying the rtl22xx
      BSP into my new one, i had the cpsr register in a different state
      at boot_card() time than the generic ARM context switch code
      expects. I think that common binary blob commercial RTOS must do a
      cpsr read before the first context switch, rather than rely on a
      fixed state as i've not encountered this type of issue before.</p>
    <p dir="ltr"><br>
    </p>
    <div class="gmail_quote">On 25 Feb 2013 17:40, "Joel Sherrill" <<a
        href="mailto:joel.sherrill@oarcorp.com">joel.sherrill@oarcorp.com</a>>
      wrote:<br type="attribution">
      <blockquote class="gmail_quote" style="margin:0 0 0
        .8ex;border-left:1px #ccc solid;padding-left:1ex">
        <div text="#000000" bgcolor="#FFFFFF">
          <div>On 2/25/2013 11:25 AM, Matthew J Fletcher wrote:<br>
          </div>
          <blockquote type="cite">Sebastain,<br>
            <br>
            I changed the code so now with the cpsr set as expected
            before main() the context switch occurs fine and we end up
            in Init().<br>
            <br>
          </blockquote>
          Is this a generic issue that needs addressing in the RTEMS<br>
          git repo? Or something you broke accidentally when making<br>
          other changes?<br>
          <blockquote type="cite">Thanks for all your help.<br>
            <br>
          </blockquote>
          A little early for a beer here but it is definitely after 5
          for<br>
          Sebastian. Good job Sebastian!<br>
          <br>
          --joel<br>
          <blockquote type="cite"><br>
            <div class="gmail_quote">On 25 February 2013 17:10, Matthew
              J Fletcher <span dir="ltr"><<a
                  href="mailto:amimjf@gmail.com" target="_blank">amimjf@gmail.com</a>></span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
                <br>
                The cpsr thats saved out to r2 is 0x800000df, but is
                restored back to 0x13. Thanks for pointing out that no
                cpsr change must happen, i will check how the rtl22xx_t
                bsp sets up the cpsr.
                <div>
                  <div><br>
                    <br>
                    <br>
                    <div class="gmail_quote"> On 25 February 2013 16:52,
                      Sebastian Huber <span dir="ltr"><<a
                          href="mailto:sebastian.huber@embedded-brains.de"
                          target="_blank">sebastian.huber@embedded-brains.de</a>></span>
                      wrote:<br>
                      <blockquote class="gmail_quote" style="margin:0 0
                        0 .8ex;border-left:1px #ccc
                        solid;padding-left:1ex"> On 02/25/2013 05:47 PM,
                        Matthew J Fletcher wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex"> Hi,<br>
                          <br>
                          r2 is 0x13 before the msr, so I guess
                          new_level must have been 0.<br>
                          <br>
                          On 25 Feb 2013 15:02, "Sebastian Huber" <<a
href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a><br>
                          <mailto:<a
                            href="mailto:sebastian.huber@embedded-brains.de"
                            target="_blank">sebastian.huber@embedded-brains.de</a>>>

                          wrote:<br>
                          <br>
                              On 02/25/2013 03:15 PM, Matthew J Fletcher
                          wrote:<br>
                          <br>
                                  Sebastian,<br>
                          <br>
                                  The _Thread_Heir->Registers are ok
                          into the _Context_Switch() call, sp<br>
                                  and lr<br>
                                  both sensible.<br>
                          <br>
                                  At the 'mrs r2, cpsr' line sp is
                          0x40001b2c (rubbish) and pc sensible.<br>
                          <br>
                                  In _restore, after the 'ldmia r1, ...'
                          instruction the sp and lr are loaded<br>
                                  with the correct values from
                          _Thread_Heir->Registers.<br>
                          <br>
                                  Its the 'msr cpsr, r2' messes up the
                          sp and lr<br>
                          <br>
                          <br>
                              Ok, if you load undefined values into the
                          CPSR, then a lot of things may<br>
                              happen.  What is the value of r2 before
                          the msr?  It should be 0x13.<br>
                        </blockquote>
                        <br>
                        Ok, then maybe the mode in the BSP execution
                        context is wrong.  During _Context_Switch() no
                        mode change must happen.  What is the CPSR
                        before the msr?<span><font color="#888888"><br>
                            <br>
                            -- <br>
                            Sebastian Huber, embedded brains GmbH<br>
                            <br>
                            Address : Dornierstr. 4, D-82178 Puchheim,
                            Germany<br>
                            Phone   : <a
                              href="tel:%2B49%2089%20189%2047%2041-16"
                              value="+4989189474116" target="_blank">+49
                              89 189 47 41-16</a><br>
                            Fax     : <a
                              href="tel:%2B49%2089%20189%2047%2041-09"
                              value="+4989189474109" target="_blank">+49
                              89 189 47 41-09</a><br>
                            E-Mail  : <a
                              href="mailto:sebastian.huber@embedded-brains.de"
                              target="_blank">sebastian.huber@embedded-brains.de</a><br>
                            PGP     : Public key available on request.<br>
                            <br>
                            Diese Nachricht ist keine geschäftliche
                            Mitteilung im Sinne des EHUG.<br>
                          </font></span></blockquote>
                    </div>
                    <br>
                    <br clear="all">
                    <br>
                  </div>
                </div>
                <span><font color="#888888">-- <br>
                    <div><br>
                      regards</div>
                    <div>---</div>
                    <div>Matthew J Fletcher</div>
                    <br>
                  </font></span></blockquote>
            </div>
            <br>
            <br clear="all">
            <br>
            -- <br>
            <div><br>
              regards</div>
            <div>---</div>
            <div>Matthew J Fletcher</div>
            <br>
          </blockquote>
          <br>
          <br>
          <pre cols="72">-- 
Joel Sherrill, Ph.D.             Director of Research & Development 
<a href="mailto:joel.sherrill@OARcorp.com" target="_blank">joel.sherrill@OARcorp.com</a>        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805 
Support Available                (256) 722-9985 </pre>
        </div>
      </blockquote>
    </div>
  </body>
</html>