This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ECOS] printf does not work in user mode on Arm E7T


Jonathan Larmour wrote:
> [...]
> > Actually, it seems that it is the 'branch to subroutine' (Arm BL)
> > instruction which hangs when executed in user mode: I wrote a
> > small C program the main function of which merely switches to
> > usr mode and then call a dummy subprogram, and could observe the
> > same behavior, ie the BL instruction hangs.
> > I fear that the problem is related neither to printf nor to newlib
> > or redboot but to the Arm (Samsung implementation) processor...
> 
> Theoretically it could be RedBoot since it's up to RedBoot to set the
> next breakpoint to implement the single stepping, although that
> functionality itself is known to work fine elsewhere. It could also be
> some problem with RedBoot's ability to restore state back to user
> mode, although it's not clear why it would work for other
> instructions, but not prior to a BL. What age is this RedBoot?
> There were some significant patches from Mark Salter in this area
> a while back - April 2002.

I re-built Redboot from CVS sources on last March 3rd.
I attach below the test program I mentioned in my previous message.


> A hardware problem is always possible, but seems improbable really.

I agree. BTW, both programs (the one with printf's and the test program)
work fine and behave as expected when compiled/linked without Redboot
support and run on target sim...

Pierre

============================================================
// tryusermode.c

#include <stdio.h>

extern void toUsr();

int dummy() { return 0x1234; }

int main()
{
   int i, j;

   toUsr();     // go to user mode

   j = dummy(); // dummy() never entered if Redboot active

   for (i = 0; i < 10; i++) printf("%d\n", i);
}
============================================================
// tousr.S
         .global  toUsr
toUsr:
         mov      r0, sp
         stmfd    sp!, {r0, lr} // make sp_usr = sp_svc
         ldmfd    sp, {sp, lr}^ // and  lr_usr = lr_svc
         mov      r0, #0x10
         msr      cpsr, r0      // go to usr mode
         mov      pc, lr
============================================================
-- 
________________________________________________________________________
Pierre HABRAKEN - mailto:Pierre dot Habraken at imag dot fr
Tél: 04 76 82 72 83 - Fax: 04 76 82 72 87
IMAG-LSR BP72 38402 SAINT MARTIN D'HERES Cedex
________________________________________________________________________


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]