From owner-freebsd-arm@freebsd.org Wed Sep 7 06:46:45 2016 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24AE1AC4AC2 for ; Wed, 7 Sep 2016 06:46:45 +0000 (UTC) (envelope-from e.moe@rcn.com) Received: from smtp.rcn.com (smtp.rcn.com [69.168.97.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E9EEB15E for ; Wed, 7 Sep 2016 06:46:44 +0000 (UTC) (envelope-from e.moe@rcn.com) X_CMAE_Category: , , X-CNFS-Analysis: v=2.2 cv=Ctr9STwD c=1 sm=1 tr=0 a=dx250bZxW1HngxdpQMIA3g==:117 a=dx250bZxW1HngxdpQMIA3g==:17 a=IkcTkHD0fZMA:10 a=IiXSZ56xeqxIh00RkbsA:9 a=QEXdDO2ut3YA:10 X-CM-Score: 0 X-Scanned-by: Cloudmark Authority Engine X-Authed-Username: ZS5tb2VAcmNuLmNvbQ== Authentication-Results: smtp01.rcn.cmh.synacor.com header.from=e.moe@rcn.com; sender-id=neutral Authentication-Results: smtp01.rcn.cmh.synacor.com smtp.mail=e.moe@rcn.com; spf=neutral; sender-id=neutral Authentication-Results: smtp01.rcn.cmh.synacor.com smtp.user=e.moe; auth=pass (PLAIN) Received-SPF: neutral (smtp01.rcn.cmh.synacor.com: 24.148.20.233 is neither permitted nor denied by domain of rcn.com) Received: from [24.148.20.233] ([24.148.20.233:53752] helo=[192.168.3.100]) by smtp.rcn.com (envelope-from ) (ecelerity 3.6.23.54417 r(Core:3.6.23.0)) with ESMTPSA (cipher=DHE-RSA-AES256-SHA) id BA/E8-04139-2D7BFC75; Wed, 07 Sep 2016 02:46:42 -0400 From: Erik Moe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Unaligned access in ubldr.bin Message-Id: Date: Wed, 7 Sep 2016 01:46:42 -0500 To: freebsd-arm Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Sep 2016 06:46:45 -0000 Hello, I=E2=80=99ve been trying to bring up FreeBSD on the USB Armory based on = the i.MX53. I=E2=80=99ve made myself a u-boot patch that will load and = start ubldr.bin but I=E2=80=99m running into a issue with what I think = is an unaligned access issue: ## Starting application at 0x70800000 ... data abort pc : [<70824bac>] lr : [<7081846c>] sp : 8f550c98 ip : 70835a00 fp : 8f550cb0 r10: 00000002 r9 : 70838d58 r8 : 70833cd9 r7 : 707fff08 r6 : 000054f0 r5 : 70833cd9 r4 : 00000000 r3 : 70828fc4 r2 : 70833cd9 r1 : 00000001 r0 : 7083705c Flags: Nzcv IRQs off FIQs off Mode SVC_32 Resetting CPU ... I=E2=80=99ve hand dissambled the code at pc=3D0x70824bac: 0x70824ba8: 0xe59f21d0 ldr r2, [pc, #464] 0x70824bac: 0xe5825000 str r5, [r2] 0x70824bb0: 0xe5d53000 ldrb r3, [r5] 0x70824bb4: 0xe353002d cmp r3, #45 0x70824bb8: 0x1a00000b bne #+44 The offending instructions is "str r5, [r2]=E2=80=9D where r2 =3D = 0x70833cd9, which sort of makes sense since it isn=E2=80=99t aligned on = a 4 byte boundary. I=E2=80=99m new to arm ARM, so I=E2=80=99m not = really sure. My questions are these: 1.) Doesn=E2=80=99t ARMv6 and higher architecture allow unaligned = access? Is there something that u-boot needs be doing in initialization = to allow unaligned access? 2.) Does ubldr make the assumption that unaligned access is allowed and = maybe shouldn=E2=80=99t? I would think not since ubldr has been around = for a while and works on numerous ARM processors. Any thoughts at which direction to investigate would be appreciated. Thanks, Erik FYI, ubldr is failing in =E2=80=9Cgetopt=E2=80=9D. I=E2=80=99ve used = objdump to disassemble ubldr.bin. You=E2=80=99ll have to subtract the = offset 0xf8 and add 0x7080000 to the addresses bellow to get them to = align with the addresses above. getopt(int nargc, char * const *nargv, const char *ostr) { 24c4c: e92d4df0 push {r4, r5, r6, r7, r8, sl, fp, lr} 24c50: e28db018 add fp, sp, #24 24c54: e1a07000 mov r7, r0 static char *place =3D EMSG; /* option letter = processing */ char *oli; /* option letter list = index */ if (optreset || !*place) { /* update scanning = pointer */ 24c58: e59f0214 ldr r0, [pc, #532] ; 24e74 = 24c5c: e1a06001 mov r6, r1 24c60: e1a08002 mov r8, r2 24c64: e5901000 ldr r1, [r0] 24c68: e3510000 cmp r1, #0 24c6c: 1a000004 bne 24c84 24c70: e59f1200 ldr r1, [pc, #512] ; 24e78 = 24c74: e5913000 ldr r3, [r1] 24c78: e5d34000 ldrb r4, [r3] 24c7c: e3540000 cmp r4, #0 24c80: 1a00001d bne 24cfc 24c84: e3a01000 mov r1, #0 optreset =3D 0; 24c88: e5801000 str r1, [r0] if (optind >=3D nargc || *(place =3D nargv[optind]) !=3D = '-') { place =3D EMSG; return (-1); } if (place[1] && *++place =3D=3D '-') { /* found = "--" */ ++optind; 24c8c: e59f01e8 ldr r0, [pc, #488] ; 24e7c = 24c90: e5901000 ldr r1, [r0] static char *place =3D EMSG; /* option letter = processing */ char *oli; /* option letter list = index */ if (optreset || !*place) { /* update scanning = pointer */ optreset =3D 0; if (optind >=3D nargc || *(place =3D nargv[optind]) !=3D = '-') { 24c94: e1510007 cmp r1, r7 24c98: aa000011 bge 24ce4 24c9c: e7965101 ldr r5, [r6, r1, lsl #2] 24ca0: e59f21d0 ldr r2, [pc, #464] ; 24e78 = 24ca4: e5825000 str r5, [r2] 24ca8: e5d53000 ldrb r3, [r5] 24cac: e353002d cmp r3, #45 ; 0x2d