From mboxrd@z Thu Jan 1 00:00:00 1970 From: Felipe Balbi Date: Tue, 21 Apr 2015 12:57:09 -0500 Subject: [U-Boot] [PATCH v2 2/6] common/cmd_boot: keep ARM v7M in thumb mode during do_go_exec() In-Reply-To: <20150421175426.GB7166@saruman.tx.rr.com> References: <1429637818-11529-1-git-send-email-mporter@konsulko.com> <1429637818-11529-3-git-send-email-mporter@konsulko.com> <20150421174724.GA7166@saruman.tx.rr.com> <20150421175426.GB7166@saruman.tx.rr.com> Message-ID: <20150421175709.GC7166@saruman.tx.rr.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, Apr 21, 2015 at 12:54:26PM -0500, Felipe Balbi wrote: > On Tue, Apr 21, 2015 at 12:47:24PM -0500, Felipe Balbi wrote: > > On Tue, Apr 21, 2015 at 01:36:54PM -0400, Matt Porter wrote: > > > On ARM v7M, the processor will return to ARM mode when executing > > > a blx instruction with bit 0 of the address == 0. Always set it > > > > but that's what the 'x' is for, right ? eXchange the CPU mode. > > > > > to 1 to stay in thumb mode. > > > > > > Signed-off-by: Matt Porter > > > --- > > > common/cmd_boot.c | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/common/cmd_boot.c b/common/cmd_boot.c > > > index 8f2e070..20ce652 100644 > > > --- a/common/cmd_boot.c > > > +++ b/common/cmd_boot.c > > > @@ -38,6 +38,10 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) > > > * pass address parameter as argv[0] (aka command name), > > > * and all remaining args > > > */ > > > +#ifdef CONFIG_CPU_V7M > > > + /* For ARM V7M, set bit zero to stay in Thumb mode */ > > > + addr++; > > > +#endif > > > > what if we were in ARM state when we reached this point ? You're now > > telling CPU to always switch to Thumb. Is this really what we want ? > > > > From ARM's instruction manual: > > > > > > > > " > > The BX and BLX instructions can change the processor state from ARM to > > Thumb, or from Thumb to ARM. > > > > BLX label always changes the state. > > > > BX Rm and BLX Rm derive the target state from bit[0] of Rm: > > > > if bit[0] of Rm is 0, the processor changes to, or remains in, ARM > > state > > > > if bit[0] of Rm is 1, the processor changes to, or remains in, Thumb > > state. > > " > > oh wait, this is cortex-m, it's supposed to be thumb2 only, why do we > even need that bit ? seems like it must be set for cortex-m, but then shouldn't this be done by GCC ? Are we, perhaps, using wrong GCC arguments when building for cortex-m ? -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: