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

Pierre Habraken Pierre.Habraken@imag.fr
Wed Mar 26 21:24:00 GMT 2003

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...


// 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
         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.Habraken@imag.fr
Tél: 04 76 82 72 83 - Fax: 04 76 82 72 87

More information about the Newlib mailing list