From owner-freebsd-arm@FreeBSD.ORG Mon Mar 21 11:06:53 2011 Return-Path: Delivered-To: freebsd-arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C1C0106567D for ; Mon, 21 Mar 2011 11:06:53 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8CFE08FC22 for ; Mon, 21 Mar 2011 11:06:53 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p2LB6ra8085922 for ; Mon, 21 Mar 2011 11:06:53 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p2LB6qRL085920 for freebsd-arm@FreeBSD.org; Mon, 21 Mar 2011 11:06:52 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 21 Mar 2011 11:06:52 GMT Message-Id: <201103211106.p2LB6qRL085920@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-arm@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-arm@FreeBSD.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Mar 2011 11:06:53 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o arm/155214 arm [patch] MMC/SD IO slow on Atmel ARM with modern large o arm/154306 arm named crashes with signal 11 o arm/154227 arm [geli] using GELI leads to panic on ARM o arm/154189 arm lang/perl5.12 doesn't build on arm o arm/153380 arm Panic / translation fault with wlan on ARM o arm/150581 arm [irq] Unknown error generates IRQ address decoding err o arm/149288 arm mail/dovecot causes panic during configure on Sheevapl o arm/134368 arm [patch] nslu2_led driver for the LEDs on the NSLU2 p arm/134338 arm [patch] Lock GPIO accesses on ixp425 9 problems total. From owner-freebsd-arm@FreeBSD.ORG Tue Mar 22 13:49:43 2011 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0BD44106564A for ; Tue, 22 Mar 2011 13:49:43 +0000 (UTC) (envelope-from mjurczuk@gmail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id BB4148FC08 for ; Tue, 22 Mar 2011 13:49:42 +0000 (UTC) Received: by qyk27 with SMTP id 27so5869672qyk.13 for ; Tue, 22 Mar 2011 06:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=dP4gKyvLckJd0GCeoVJjNMvcSAZsraTi4njs8Na4u4Q=; b=YjpMD7HtJg03O4xBG7d1UL5yPPf7A0GETW0xEAF+H1a59eElZXQMauFwaDFYYT2ZfG 1THHYxMQW54u40HE6Fp3ccY6zFVgI/39VfRGwGmRdfNB7rCKgdBcLVvZmUDBrJZW5GcF pb8aRoMZeSNEcSdX1KYAJm5eAWWo5OsFON1dE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=fmsAvQDumezjm2YNb3F+pyvhGCDT9Vzn4DSbjN1hZT8dz0UxrwZo9cLrp2g2kSSp49 f1dqclKCu8ePkonjbzNBnh74cXiYsVYut1N+XFiTYktYh8x3LOvIgPptcnxIZr3+uAy0 sXGoZAjWQU1Flw3ssy/58+cymUJHkWVcAZmf4= MIME-Version: 1.0 Received: by 10.224.173.79 with SMTP id o15mr4763372qaz.221.1300800006689; Tue, 22 Mar 2011 06:20:06 -0700 (PDT) Received: by 10.52.166.129 with HTTP; Tue, 22 Mar 2011 06:20:06 -0700 (PDT) Date: Tue, 22 Mar 2011 14:20:06 +0100 Message-ID: From: Marcin Jurczuk To: freebsd-arm@freebsd.org Content-Type: text/plain; charset=UTF-8 Subject: Iomega iConnect and FreeBSD (kirkwood) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2011 13:49:43 -0000 Hello, I'm trying to setup FreeBSD 8.2 on iomega iConnect device which is based on platform similar/(identical) to SheevaPlug and Segate Dockstar. However not everything seems to beexactly the same bacause I have problems with kernel boot and mge0 ethernet adapter. I used DB-88F6XXX kernel conifig since this platform is CPU: Feroceon 88FR131 rev 1 (Marvell core) I'm able to boot system however kernel panic occurs with folowing message: ---------------------------------------- mge0: at mem 0xf1072000-0xf1073fff irq 12,13,14,11,46 on mbus0 mge0: Ethernet address: 00:d0:b8:0d:f6:5d mge0: attaching PHYs failed vm_fault(0xc0bfcd18, 0, 1, 0) -> 1 Fatal kernel mode data abort: 'Translation Fault (S)' trapframe: 0xc0d7cc2c FSR=00000005, FAR=00000008, spsr=600000d3 r0 =00000016, r1 =f1020200, r2 =00000004, r3 =00080002 r4 =00000000, r5 =00000000, r6 =0000000c, r7 =00000000 r8 =c0b58b50, r9 =c229c080, r10=c22c7000, r11=c0d7cc90 r12=c0d7cc78, ssp=c0d7cc78, slr=c0b30a00, pc =c0b30a00 [thread pid 0 tid 100000 ] Stopped at arm_remove_irqhandler+0x28: ldr r3, [r5, #0x008] db> -------------------------------------------- Is there anyone who have some experience with this platform ? Regards, -- Matin, From owner-freebsd-arm@FreeBSD.ORG Tue Mar 22 15:57:16 2011 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DABB1065673 for ; Tue, 22 Mar 2011 15:57:16 +0000 (UTC) (envelope-from kristof@sigsegv.be) Received: from wilson.telenet-ops.be (wilson.telenet-ops.be [195.130.132.42]) by mx1.freebsd.org (Postfix) with ESMTP id 0C7638FC0C for ; Tue, 22 Mar 2011 15:57:15 +0000 (UTC) Received: from jacques.telenet-ops.be (unknown [195.130.132.50]) by wilson.telenet-ops.be (Postfix) with ESMTP id 7947E70F2D for ; Tue, 22 Mar 2011 16:45:10 +0100 (CET) Received: from triton.sigsegv.be ([94.224.101.111]) by jacques.telenet-ops.be with bizsmtp id NFl81g0082QCY5q0JFl8Qa; Tue, 22 Mar 2011 16:45:08 +0100 Received: from nereid (nereid.neptune.sigsegv.be [IPv6:2001:470:c8f4:0:200:ff:fe00:8]) by triton.sigsegv.be (Postfix) with SMTP id 1092F1C269; Tue, 22 Mar 2011 16:45:07 +0100 (CET) Received: by nereid (sSMTP sendmail emulation); Tue, 22 Mar 2011 16:45:06 +0100 Date: Tue, 22 Mar 2011 16:45:05 +0100 From: Kristof Provost To: Marcin Jurczuk Message-ID: <20110322154505.GH1351@nereid> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-PGP-Fingerprint: E114 D9EA 909E D469 8F57 17A5 7D15 91C6 9EFA F286 User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-arm@freebsd.org Subject: Re: Iomega iConnect and FreeBSD (kirkwood) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2011 15:57:16 -0000 On 2011-03-22 14:20:06 (+0100), Marcin Jurczuk wrote: > Hello, > > I'm trying to setup FreeBSD 8.2 on iomega iConnect device which is > based on platform similar/(identical) to SheevaPlug and Segate > Dockstar. However not everything seems to beexactly the same bacause I > have problems with kernel boot and mge0 ethernet adapter. > I used DB-88F6XXX kernel conifig since this platform is CPU: Feroceon > 88FR131 rev 1 (Marvell core) > I'm able to boot system however kernel panic occurs with folowing message: > ---------------------------------------- > mge0: at mem > 0xf1072000-0xf1073fff irq 12,13,14,11,46 on mbus0 > mge0: Ethernet address: 00:d0:b8:0d:f6:5d > mge0: attaching PHYs failed > > vm_fault(0xc0bfcd18, 0, 1, 0) -> 1 > Fatal kernel mode data abort: 'Translation Fault (S)' > trapframe: 0xc0d7cc2c > FSR=00000005, FAR=00000008, spsr=600000d3 > r0 =00000016, r1 =f1020200, r2 =00000004, r3 =00080002 > r4 =00000000, r5 =00000000, r6 =0000000c, r7 =00000000 > r8 =c0b58b50, r9 =c229c080, r10=c22c7000, r11=c0d7cc90 > r12=c0d7cc78, ssp=c0d7cc78, slr=c0b30a00, pc =c0b30a00 > > [thread pid 0 tid 100000 ] > Stopped at arm_remove_irqhandler+0x28: ldr r3, [r5, #0x008] > db> > -------------------------------------------- > Is there anyone who have some experience with this platform ? I'm not familiar with that platform, but I remember seeing a very similar error when I was playing with an Orion based board. The driver should be the same (mge). The panic occurs because the cleanup code is incorrect. This problem is fixed in current I think. In this case you probably don't need to worry about the cleanup code though. It's only triggered when the PHY is not found. If you can fix the PHY detection you won't run into the panic any more. In 8.2 mge assumes a static mapping between interface number and PHY address (i.e. PHY address = interface number (0 here) + 8). You can overrule the offset by defining MII_ADDRESS_BASE. Of course, you'll need to know the correct offset first. Regards, Kristof From owner-freebsd-arm@FreeBSD.ORG Tue Mar 22 19:37:16 2011 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39EB9106566C; Tue, 22 Mar 2011 19:37:16 +0000 (UTC) (envelope-from tinderbox@freebsd.org) Received: from freebsd-current.sentex.ca (freebsd-current.sentex.ca [64.7.128.98]) by mx1.freebsd.org (Postfix) with ESMTP id E81E78FC21; Tue, 22 Mar 2011 19:37:15 +0000 (UTC) Received: from freebsd-current.sentex.ca (localhost [127.0.0.1]) by freebsd-current.sentex.ca (8.14.4/8.14.4) with ESMTP id p2MJbEad066205; Tue, 22 Mar 2011 15:37:14 -0400 (EDT) (envelope-from tinderbox@freebsd.org) Received: (from tinderbox@localhost) by freebsd-current.sentex.ca (8.14.4/8.14.4/Submit) id p2MJbE9W066204; Tue, 22 Mar 2011 19:37:14 GMT (envelope-from tinderbox@freebsd.org) Date: Tue, 22 Mar 2011 19:37:14 GMT Message-Id: <201103221937.p2MJbE9W066204@freebsd-current.sentex.ca> X-Authentication-Warning: freebsd-current.sentex.ca: tinderbox set sender to FreeBSD Tinderbox using -f Sender: FreeBSD Tinderbox From: FreeBSD Tinderbox To: FreeBSD Tinderbox , , Precedence: bulk Cc: Subject: [head tinderbox] failure on arm/arm X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2011 19:37:16 -0000 TB --- 2011-03-22 18:50:00 - tinderbox 2.6 running on freebsd-current.sentex.ca TB --- 2011-03-22 18:50:00 - starting HEAD tinderbox run for arm/arm TB --- 2011-03-22 18:50:00 - cleaning the object tree TB --- 2011-03-22 18:50:13 - cvsupping the source tree TB --- 2011-03-22 18:50:13 - /usr/bin/csup -z -r 3 -g -L 1 -h cvsup.sentex.ca /tinderbox/HEAD/arm/arm/supfile TB --- 2011-03-22 18:50:36 - building world TB --- 2011-03-22 18:50:36 - MAKEOBJDIRPREFIX=/obj TB --- 2011-03-22 18:50:36 - PATH=/usr/bin:/usr/sbin:/bin:/sbin TB --- 2011-03-22 18:50:36 - TARGET=arm TB --- 2011-03-22 18:50:36 - TARGET_ARCH=arm TB --- 2011-03-22 18:50:36 - TZ=UTC TB --- 2011-03-22 18:50:36 - __MAKE_CONF=/dev/null TB --- 2011-03-22 18:50:36 - cd /src TB --- 2011-03-22 18:50:36 - /usr/bin/make -B buildworld >>> World build started on Tue Mar 22 18:50:36 UTC 2011 >>> Rebuilding the temporary build tree >>> stage 1.1: legacy release compatibility shims >>> stage 1.2: bootstrap tools >>> stage 2.1: cleaning up the object tree >>> stage 2.2: rebuilding the object tree >>> stage 2.3: build tools >>> stage 3: cross tools >>> stage 4.1: building includes >>> stage 4.2: building libraries >>> stage 4.3: make dependencies >>> stage 4.4: building everything [...] cc -O -pipe -I/src/sbin/hastctl/../hastd -DINET -DINET6 -DYY_NO_UNPUT -DYY_NO_INPUT -DHAVE_CRYPTO -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wno-format -c /src/sbin/hastctl/../hastd/proto_common.c cc -O -pipe -I/src/sbin/hastctl/../hastd -DINET -DINET6 -DYY_NO_UNPUT -DYY_NO_INPUT -DHAVE_CRYPTO -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wno-format -c /src/sbin/hastctl/../hastd/proto_tcp4.c /src/sbin/hastctl/../hastd/proto_tcp4.c: In function 'tcp4_setup_new': /src/sbin/hastctl/../hastd/proto_tcp4.c:188: error: 'PROTO_TCP4_DEFAULT_PORT' undeclared (first use in this function) /src/sbin/hastctl/../hastd/proto_tcp4.c:188: error: (Each undeclared identifier is reported only once /src/sbin/hastctl/../hastd/proto_tcp4.c:188: error: for each function it appears in.) /src/sbin/hastctl/../hastd/proto_tcp4.c: In function 'tcp4_address_match': /src/sbin/hastctl/../hastd/proto_tcp4.c:513: error: 'PROTO_TCP4_DEFAULT_PORT' undeclared (first use in this function) *** Error code 1 Stop in /src/sbin/hastctl. *** Error code 1 Stop in /src/sbin. *** Error code 1 Stop in /src. *** Error code 1 Stop in /src. *** Error code 1 Stop in /src. TB --- 2011-03-22 19:37:14 - WARNING: /usr/bin/make returned exit code 1 TB --- 2011-03-22 19:37:14 - ERROR: failed to build world TB --- 2011-03-22 19:37:14 - 2058.62 user 571.45 system 2833.65 real http://tinderbox.freebsd.org/tinderbox-head-HEAD-arm-arm.full From owner-freebsd-arm@FreeBSD.ORG Tue Mar 22 22:57:15 2011 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A8991065673; Tue, 22 Mar 2011 22:57:15 +0000 (UTC) (envelope-from tinderbox@freebsd.org) Received: from freebsd-current.sentex.ca (freebsd-current.sentex.ca [64.7.128.98]) by mx1.freebsd.org (Postfix) with ESMTP id 370A48FC15; Tue, 22 Mar 2011 22:57:15 +0000 (UTC) Received: from freebsd-current.sentex.ca (localhost [127.0.0.1]) by freebsd-current.sentex.ca (8.14.4/8.14.4) with ESMTP id p2MMvEWW048218; Tue, 22 Mar 2011 18:57:14 -0400 (EDT) (envelope-from tinderbox@freebsd.org) Received: (from tinderbox@localhost) by freebsd-current.sentex.ca (8.14.4/8.14.4/Submit) id p2MMvE2I048217; Tue, 22 Mar 2011 22:57:14 GMT (envelope-from tinderbox@freebsd.org) Date: Tue, 22 Mar 2011 22:57:14 GMT Message-Id: <201103222257.p2MMvE2I048217@freebsd-current.sentex.ca> X-Authentication-Warning: freebsd-current.sentex.ca: tinderbox set sender to FreeBSD Tinderbox using -f Sender: FreeBSD Tinderbox From: FreeBSD Tinderbox To: FreeBSD Tinderbox , , Precedence: bulk Cc: Subject: [head tinderbox] failure on arm/arm X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2011 22:57:15 -0000 TB --- 2011-03-22 22:10:00 - tinderbox 2.6 running on freebsd-current.sentex.ca TB --- 2011-03-22 22:10:00 - starting HEAD tinderbox run for arm/arm TB --- 2011-03-22 22:10:00 - cleaning the object tree TB --- 2011-03-22 22:10:07 - cvsupping the source tree TB --- 2011-03-22 22:10:07 - /usr/bin/csup -z -r 3 -g -L 1 -h cvsup.sentex.ca /tinderbox/HEAD/arm/arm/supfile TB --- 2011-03-22 22:10:47 - building world TB --- 2011-03-22 22:10:47 - MAKEOBJDIRPREFIX=/obj TB --- 2011-03-22 22:10:47 - PATH=/usr/bin:/usr/sbin:/bin:/sbin TB --- 2011-03-22 22:10:47 - TARGET=arm TB --- 2011-03-22 22:10:47 - TARGET_ARCH=arm TB --- 2011-03-22 22:10:47 - TZ=UTC TB --- 2011-03-22 22:10:47 - __MAKE_CONF=/dev/null TB --- 2011-03-22 22:10:47 - cd /src TB --- 2011-03-22 22:10:47 - /usr/bin/make -B buildworld >>> World build started on Tue Mar 22 22:10:49 UTC 2011 >>> Rebuilding the temporary build tree >>> stage 1.1: legacy release compatibility shims >>> stage 1.2: bootstrap tools >>> stage 2.1: cleaning up the object tree >>> stage 2.2: rebuilding the object tree >>> stage 2.3: build tools >>> stage 3: cross tools >>> stage 4.1: building includes >>> stage 4.2: building libraries >>> stage 4.3: make dependencies >>> stage 4.4: building everything [...] cc -O -pipe -I/src/sbin/hastctl/../hastd -DINET -DINET6 -DYY_NO_UNPUT -DYY_NO_INPUT -DHAVE_CRYPTO -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wno-format -c /src/sbin/hastctl/../hastd/proto_common.c cc -O -pipe -I/src/sbin/hastctl/../hastd -DINET -DINET6 -DYY_NO_UNPUT -DYY_NO_INPUT -DHAVE_CRYPTO -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wno-format -c /src/sbin/hastctl/../hastd/proto_tcp4.c /src/sbin/hastctl/../hastd/proto_tcp4.c: In function 'tcp4_setup_new': /src/sbin/hastctl/../hastd/proto_tcp4.c:188: error: 'PROTO_TCP4_DEFAULT_PORT' undeclared (first use in this function) /src/sbin/hastctl/../hastd/proto_tcp4.c:188: error: (Each undeclared identifier is reported only once /src/sbin/hastctl/../hastd/proto_tcp4.c:188: error: for each function it appears in.) /src/sbin/hastctl/../hastd/proto_tcp4.c: In function 'tcp4_address_match': /src/sbin/hastctl/../hastd/proto_tcp4.c:513: error: 'PROTO_TCP4_DEFAULT_PORT' undeclared (first use in this function) *** Error code 1 Stop in /src/sbin/hastctl. *** Error code 1 Stop in /src/sbin. *** Error code 1 Stop in /src. *** Error code 1 Stop in /src. *** Error code 1 Stop in /src. TB --- 2011-03-22 22:57:13 - WARNING: /usr/bin/make returned exit code 1 TB --- 2011-03-22 22:57:13 - ERROR: failed to build world TB --- 2011-03-22 22:57:13 - 2055.55 user 572.19 system 2833.41 real http://tinderbox.freebsd.org/tinderbox-head-HEAD-arm-arm.full From owner-freebsd-arm@FreeBSD.ORG Thu Mar 24 00:40:01 2011 Return-Path: Delivered-To: freebsd-arm@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C30CC106566B for ; Thu, 24 Mar 2011 00:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 76A438FC1C for ; Thu, 24 Mar 2011 00:40:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p2O0e1R2029032 for ; Thu, 24 Mar 2011 00:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p2O0e1rQ029031; Thu, 24 Mar 2011 00:40:01 GMT (envelope-from gnats) Resent-Date: Thu, 24 Mar 2011 00:40:01 GMT Resent-Message-Id: <201103240040.p2O0e1rQ029031@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-arm@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ian Lepore Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E71BD1065670 for ; Thu, 24 Mar 2011 00:33:24 +0000 (UTC) (envelope-from root@damnhippie.dyndns.org) Received: from qmta01.westchester.pa.mail.comcast.net (qmta01.westchester.pa.mail.comcast.net [76.96.62.16]) by mx1.freebsd.org (Postfix) with ESMTP id 942088FC15 for ; Thu, 24 Mar 2011 00:33:24 +0000 (UTC) Received: from omta16.westchester.pa.mail.comcast.net ([76.96.62.88]) by qmta01.westchester.pa.mail.comcast.net with comcast id No8T1g0031uE5Es51oL96A; Thu, 24 Mar 2011 00:20:09 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta16.westchester.pa.mail.comcast.net with comcast id NoL81g00H4NgCEG3coL8sF; Thu, 24 Mar 2011 00:20:09 +0000 Received: from revolution.hippie.lan (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id p2O0K5Vp025918 for ; Wed, 23 Mar 2011 18:20:05 -0600 (MDT) (envelope-from root@damnhippie.dyndns.org) Received: (from root@localhost) by revolution.hippie.lan (8.14.4/8.14.4/Submit) id p2O0K5KZ043860; Wed, 23 Mar 2011 18:20:05 -0600 (MDT) (envelope-from root) Message-Id: <201103240020.p2O0K5KZ043860@revolution.hippie.lan> Date: Wed, 23 Mar 2011 18:20:05 -0600 (MDT) From: Ian Lepore To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: arm/155894: [patch] Enable at91 booting from SDHC (high capacity) cards X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Ian Lepore List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2011 00:40:01 -0000 >Number: 155894 >Category: arm >Synopsis: [patch] Enable at91 booting from SDHC (high capacity) cards >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-arm >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Thu Mar 24 00:40:01 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Ian Lepore >Release: FreeBSD 8.2-RC3 arm >Organization: none >Environment: FreeBSD dvb 8.2-RC3 FreeBSD 8.2-RC3 #49: Tue Feb 15 22:52:14 UTC 2011 root@revolution.hippie.lan:/usr/obj/arm/usr/src/sys/DVB arm >Description: This change enables at91 systems to boot from high capacity SD cards. It also fixes a few minor violations of the SD protocol, such as running the bus at high speed during the card identification sequence. The sdcard_init() routine now probes for SDHC cards so that later read requests can make needed adjustments between block and byte offsets based on card type. There is a new MCI_readblocks() function that takes block number and block count parameters instead of byte-offset values. Using this routine, boot loader code can load a kernel from any location on an SDHC or standard SD card. The old MCI_read() interface remains unchanged so that existing customized boot loader code will still keep working without changes. Using this routine, boot loaders can load a kernel from anywhere in the first 4GB of an SDHC card (or of course any location on a standard SD card). A new sdcard_use4wire() routine allows boot loaders to request 4-bit transfers; it should be called after sdcard_init(). The sdcard_init() routine no longer assumes the hardware is 4-wire capable and by default sets things up for 1-bit transfers. >How-To-Repeat: n/a >Fix: This patch should apply cleanly to any FreeBSD from 6.2 through -current. --- patch-boot-arm-libat91-sdhc begins here --- Index: sys/boot/arm/at91/libat91/mci_device.h =================================================================== --- sys/boot/arm/at91/libat91/mci_device.h 2 Apr 2007 21:14:02 -0000 1.3 +++ sys/boot/arm/at91/libat91/mci_device.h 23 Mar 2011 16:59:05 -0000 @@ -90,6 +90,8 @@ typedef struct _AT91S_MciDevice { volatile unsigned char state; unsigned char SDCard_bus_width; + unsigned char IsSDv2; + unsigned char IsSDHC; unsigned int RCA; // RCA unsigned int READ_BL_LEN; #ifdef REPORT_SIZE @@ -202,7 +204,9 @@ typedef struct _AT91S_MciDevice MMC_MAXLAT) #define GO_INACTIVE_STATE_CMD \ (15 | MMC_RSPTYP_NO) - +#define SD_SEND_IF_COND_CMD \ + (8 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ + MMC_MAXLAT) //*------------------------------------------------ //* Class 2 commands: Block oriented Read commands //*------------------------------------------------ @@ -264,7 +268,7 @@ typedef struct _AT91S_MciDevice #define SDCARD_STATUS_CMD (13 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) #define SDCARD_SEND_NUM_WR_BLOCKS_CMD (22 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) #define SDCARD_SET_WR_BLK_ERASE_COUNT_CMD (23 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) -#define SDCARD_APP_OP_COND_CMD (41 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO ) +#define SDCARD_APP_OP_COND_CMD (41 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) #define SDCARD_SET_CLR_CARD_DETECT_CMD (42 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) #define SDCARD_SEND_SCR_CMD (51 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) @@ -306,7 +310,8 @@ typedef struct _AT91S_MciDevice #define AT91C_VDD_33_34 (1 << 21) #define AT91C_VDD_34_35 (1 << 22) #define AT91C_VDD_35_36 (1 << 23) -#define AT91C_CARD_POWER_UP_BUSY (1 << 31) +#define AT91C_CCS (1 << 30) +#define AT91C_CARD_POWER_UP_DONE (1 << 31) #define AT91C_MMC_HOST_VOLTAGE_RANGE (AT91C_VDD_27_28 | AT91C_VDD_28_29 | \ AT91C_VDD_29_30 | AT91C_VDD_30_31 | AT91C_VDD_31_32 | AT91C_VDD_32_33) Index: sys/boot/arm/at91/libat91/sd-card.c =================================================================== --- sys/boot/arm/at91/libat91/sd-card.c 2 Apr 2007 21:14:02 -0000 1.3 +++ sys/boot/arm/at91/libat91/sd-card.c 23 Mar 2011 21:33:07 -0000 @@ -47,35 +47,38 @@ #include "lib.h" #include "sd-card.h" -#define AT91C_MCI_TIMEOUT 1000000 /* For AT91F_MCIDeviceWaitReady */ -#define BUFFER_SIZE_MCI_DEVICE 512 -#define MASTER_CLOCK 60000000 +#define AT91C_MCI_TIMEOUT 1000000 /* For AT91F_MCIDeviceWaitReady */ +#define SD_BLOCK_SIZE 512 //* Global Variables -AT91S_MciDevice MCI_Device; -char Buffer[BUFFER_SIZE_MCI_DEVICE]; +static AT91S_MciDevice MCI_Device; /****************************************************************************** **Error return codes ******************************************************************************/ -#define MCI_UNSUPP_SIZE_ERROR 5 +#define MCI_UNSUPP_SIZE_ERROR 5 #define MCI_UNSUPP_OFFSET_ERROR 6 //*---------------------------------------------------------------------------- //* \fn MCIDeviceWaitReady //* \brief Wait for MCI Device ready //*---------------------------------------------------------------------------- -static void +static unsigned int MCIDeviceWaitReady(unsigned int timeout) { - volatile int status; - + volatile unsigned int status; + int waitfor; + + if (MCI_Device.state == AT91C_MCI_RX_SINGLE_BLOCK) + waitfor = AT91C_MCI_RXBUFF; + else + waitfor = AT91C_MCI_NOTBUSY; do { status = AT91C_BASE_MCI->MCI_SR; timeout--; } - while( !(status & AT91C_MCI_NOTBUSY) && (timeout>0) ); + while( !(status & waitfor) && (timeout>0) ); status = AT91C_BASE_MCI->MCI_SR; @@ -92,25 +95,39 @@ MCIDeviceWaitReady(unsigned int timeout) AT91C_BASE_PDC_MCI->PDC_PTCR = AT91C_PDC_RXTDIS; MCI_Device.state = AT91C_MCI_IDLE; } // End of if AT91C_MCI_RXBUFF + + //printf("WaitReady returning status %x\n", status); + + return status; } -inline static unsigned int -swap(unsigned int a) +static inline unsigned int +swap(unsigned int v) { - return (((a & 0xff) << 24) | ((a & 0xff00) << 8) | ((a & 0xff0000) >> 8) - | ((a & 0xff000000) >> 24)); + unsigned int t1; + + __asm __volatile("eor %1, %0, %0, ror #16\n" + "bic %1, %1, #0x00ff0000\n" + "mov %0, %0, ror #8\n" + "eor %0, %0, %1, lsr #8\n" + : "+r" (v), "=r" (t1)); + + return (v); } -inline static void +inline static unsigned int wait_ready() { int status; + int timeout = AT91C_MCI_TIMEOUT; // wait for CMDRDY Status flag to read the response do { status = AT91C_BASE_MCI->MCI_SR; - } while( !(status & AT91C_MCI_CMDRDY) ); + } while( !(status & AT91C_MCI_CMDRDY) && (--timeout > 0) ); + + return status; } //*---------------------------------------------------------------------------- @@ -122,18 +139,24 @@ MCI_SendCommand( unsigned int Cmd, unsigned int Arg) { - unsigned int error; + unsigned int error; + unsigned int errorMask = AT91C_MCI_SR_ERROR; + unsigned int opcode = Cmd & 0x3F; + + //printf("SendCmd %d (%x) arg %x\n", opcode, Cmd, Arg); + + // Don't check response CRC on ACMD41 (R3 response type). + + if (opcode == 41) + errorMask &= ~AT91C_MCI_RCRCE; AT91C_BASE_MCI->MCI_ARGR = Arg; AT91C_BASE_MCI->MCI_CMDR = Cmd; -// printf("CMDR %x ARG %x\n", Cmd, Arg); - wait_ready(); - // Test error ==> if crc error and response R3 ==> don't check error - error = (AT91C_BASE_MCI->MCI_SR) & AT91C_MCI_SR_ERROR; - if (error != 0) { - if (error != AT91C_MCI_RCRCE) - return (1); + error = wait_ready(); + + if ((error & errorMask) != 0) { + return (1); } return 0; } @@ -146,94 +169,98 @@ static unsigned int MCI_GetStatus() { if (MCI_SendCommand(SEND_STATUS_CMD, MCI_Device.RCA << 16)) - return AT91C_CMD_SEND_ERROR; + return 0; return (AT91C_BASE_MCI->MCI_RSPR[0]); + } //*---------------------------------------------------------------------------- //* \fn MCI_ReadBlock -//* \brief Read an ENTIRE block or PARTIAL block +//* \brief Start the read for a single 512-byte block //*---------------------------------------------------------------------------- static int -MCI_ReadBlock(int src, unsigned int *dataBuffer, int sizeToRead) +MCI_StartReadBlock(unsigned blknum, void *dataBuffer) { -// unsigned log2sl = MCI_Device.READ_BL_LEN; -// unsigned sectorLength = 1 << log2sl; - unsigned sectorLength = 512; - - /////////////////////////////////////////////////////////////////////// - if (MCI_Device.state != AT91C_MCI_IDLE) - return 1; - - if ((MCI_GetStatus() & AT91C_SR_READY_FOR_DATA) == 0) - return 1; - - /////////////////////////////////////////////////////////////////////// - // Init Mode Register - AT91C_BASE_MCI->MCI_MR |= ((sectorLength << 16) | AT91C_MCI_PDCMODE); + AT91C_BASE_MCI->MCI_MR |= ((SD_BLOCK_SIZE << 16) | AT91C_MCI_PDCMODE); - sizeToRead = sizeToRead / 4; - + // (PDC) Receiver Transfer Enable AT91C_BASE_PDC_MCI->PDC_PTCR = (AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS); AT91C_BASE_PDC_MCI->PDC_RPR = (unsigned int)dataBuffer; - AT91C_BASE_PDC_MCI->PDC_RCR = sizeToRead; + AT91C_BASE_PDC_MCI->PDC_RCR = SD_BLOCK_SIZE / 4;; + AT91C_BASE_PDC_MCI->PDC_PTCR = AT91C_PDC_RXTEN; + + // SDHC wants block offset, non-HC wants byte offset. + if (!MCI_Device.IsSDHC) + blknum *= SD_BLOCK_SIZE; // Send the Read single block command - if (MCI_SendCommand(READ_SINGLE_BLOCK_CMD, src)) + if (MCI_SendCommand(READ_SINGLE_BLOCK_CMD, blknum)) { return AT91C_READ_ERROR; + } MCI_Device.state = AT91C_MCI_RX_SINGLE_BLOCK; - // Enable AT91C_MCI_RXBUFF Interrupt - AT91C_BASE_MCI->MCI_IER = AT91C_MCI_RXBUFF; - - // (PDC) Receiver Transfer Enable - AT91C_BASE_PDC_MCI->PDC_PTCR = AT91C_PDC_RXTEN; - return 0; } +//*---------------------------------------------------------------------------- +//* \fn MCI_readblocks +//* \brief Read one or more blocks +//*---------------------------------------------------------------------------- int -MCI_read(char* dest, unsigned source, unsigned length) +MCI_readblocks(char* dest, unsigned blknum, unsigned blkcount) { -// unsigned log2sl = MCI_Device.READ_BL_LEN; -// unsigned sectorLength = 1 << log2sl; - unsigned sectorLength = 512; - int sizeToRead; + unsigned int status; unsigned int *walker; - //As long as there is data to read - while (length) - { - if (length > sectorLength) - sizeToRead = sectorLength; - else - sizeToRead = length; + if (MCI_Device.state != AT91C_MCI_IDLE) { + return 1; + } - MCIDeviceWaitReady(AT91C_MCI_TIMEOUT); + if ((MCI_GetStatus() & AT91C_SR_READY_FOR_DATA) == 0) { + return 1; + } + + // As long as there is data to read + while (blkcount) + { //Do the reading - if (MCI_ReadBlock(source, - (unsigned int*)dest, sizeToRead)) + if (MCI_StartReadBlock(blknum, dest)) return -1; - //* Wait MCI Device Ready - MCIDeviceWaitReady(AT91C_MCI_TIMEOUT); + // Wait MCI Device Ready + status = MCIDeviceWaitReady(AT91C_MCI_TIMEOUT); + if (status & AT91C_MCI_SR_ERROR) + return 1; - // Fix erratum in MCI part + // Fix erratum in MCI part - endian-swap all data. for (walker = (unsigned int *)dest; - walker < (unsigned int *)(dest + sizeToRead); walker++) + walker < (unsigned int *)(dest + SD_BLOCK_SIZE); walker++) *walker = swap(*walker); - //Update counters & pointers - length -= sizeToRead; - dest += sizeToRead; - source += sizeToRead; + // Update counters & pointers + ++blknum; + --blkcount; + dest += SD_BLOCK_SIZE; } + return 0; } //*---------------------------------------------------------------------------- +//* \fn MCI_read +//* \brief Legacy read function, takes byte offset and length but was always +//* used to read full blocks; interface preserved for existing boot code. +//*---------------------------------------------------------------------------- +int +MCI_read(char* dest, unsigned byteoffset, unsigned length) +{ + return MCI_readblocks(dest, + byteoffset/SD_BLOCK_SIZE, length/SD_BLOCK_SIZE); +} + +//*---------------------------------------------------------------------------- //* \fn MCI_SDCard_SendAppCommand //* \brief Specific function to send a specific command to the SDCard //*---------------------------------------------------------------------------- @@ -242,15 +269,11 @@ MCI_SDCard_SendAppCommand( unsigned int Cmd_App, unsigned int Arg) { - // Send the CMD55 for application specific command - AT91C_BASE_MCI->MCI_ARGR = (MCI_Device.RCA << 16 ); - AT91C_BASE_MCI->MCI_CMDR = APP_CMD; - - wait_ready(); - // if an error occurs - if (AT91C_BASE_MCI->MCI_SR & AT91C_MCI_SR_ERROR) - return (1); - return (MCI_SendCommand(Cmd_App,Arg)); + int status; + + if ((status = MCI_SendCommand(APP_CMD, (MCI_Device.RCA << 16))) == 0) + status = MCI_SendCommand(Cmd_App,Arg); + return status; } //*---------------------------------------------------------------------------- @@ -260,12 +283,11 @@ MCI_SDCard_SendAppCommand( static int MCI_GetCSD(unsigned int rca, unsigned int *response) { - - if (MCI_SendCommand(SEND_CSD_CMD, (rca << 16))) + if (MCI_SendCommand(SEND_CSD_CMD, (rca << 16))) return 1; response[0] = AT91C_BASE_MCI->MCI_RSPR[0]; - response[1] = AT91C_BASE_MCI->MCI_RSPR[1]; + response[1] = AT91C_BASE_MCI->MCI_RSPR[1]; response[2] = AT91C_BASE_MCI->MCI_RSPR[2]; response[3] = AT91C_BASE_MCI->MCI_RSPR[3]; @@ -274,22 +296,64 @@ MCI_GetCSD(unsigned int rca, unsigned in //*---------------------------------------------------------------------------- //* \fn MCI_SDCard_GetOCR -//* \brief Asks to all cards to send their operations conditions +//* \brief Wait for card to power up and determine whether it's SDHC or not. //*---------------------------------------------------------------------------- static int MCI_SDCard_GetOCR() { - unsigned int response=0x0; + unsigned int response; + unsigned int arg = AT91C_MMC_HOST_VOLTAGE_RANGE; + int timeout = AT91C_MCI_TIMEOUT; + + // Force card to idle state. + + MCI_SendCommand(GO_IDLE_STATE_CMD, AT91C_NO_ARGUMENT); + + // Begin probe for SDHC by sending CMD8; only v2.0 cards respond to it. + // + // Arg is vvpp where vv is voltage range and pp is an arbitrary bit + // pattern that gets echoed back in the response. The only voltage + // ranges defined are: + // 0x01 = 2.7 - 3.6 + // 0x02 = "reserved for low voltage" whatever that means. + // + // If the card fails to respond then it's not v2.0. If it responds by + // echoing back exactly the arg we sent, then it's a v2.0 card and can + // run at our voltage. That means that when we send the ACMD41 (in + // MCI_SDCard_GetOCR) we can include the HCS bit to inquire about SDHC. + + if (MCI_SendCommand(SD_SEND_IF_COND_CMD, 0x01AA) == 0) { + MCI_Device.IsSDv2 = (AT91C_BASE_MCI->MCI_RSPR[0] == 0x01AA); + } + + // If we've determined the card supports v2.0 functionality, set the + // HCS/CCS bit to indicate that we support SDHC. This will cause a + // v2.0 card to report whether it is SDHC in the ACMD41 response. + + if (MCI_Device.IsSDv2) { + arg |= AT91C_CCS; + } + + // The RCA to be used for CMD55 in Idle state shall be the card's + // default RCA=0x0000. - // The RCA to be used for CMD55 in Idle state shall be the card's default RCA=0x0000. MCI_Device.RCA = 0x0; - - while( (response & AT91C_CARD_POWER_UP_BUSY) != AT91C_CARD_POWER_UP_BUSY ) { - if (MCI_SDCard_SendAppCommand(SDCARD_APP_OP_COND_CMD, - AT91C_MMC_HOST_VOLTAGE_RANGE)) + + // Repeat ACMD41 until the card comes out of power-up-busy state. + + do { + if (MCI_SDCard_SendAppCommand(SDCARD_APP_OP_COND_CMD, arg)) { return 1; + } response = AT91C_BASE_MCI->MCI_RSPR[0]; + } while (!(response & AT91C_CARD_POWER_UP_DONE) && (--timeout > 0)); + + // A v2.0 card sets CCS (card capacity status) in the response if it's SDHC. + + if (MCI_Device.IsSDv2) { + MCI_Device.IsSDHC = ((response & AT91C_CCS) == AT91C_CCS); } + return (0); } @@ -304,7 +368,7 @@ MCI_SDCard_GetCID(unsigned int *response return 1; response[0] = AT91C_BASE_MCI->MCI_RSPR[0]; - response[1] = AT91C_BASE_MCI->MCI_RSPR[1]; + response[1] = AT91C_BASE_MCI->MCI_RSPR[1]; response[2] = AT91C_BASE_MCI->MCI_RSPR[2]; response[3] = AT91C_BASE_MCI->MCI_RSPR[3]; @@ -312,47 +376,62 @@ MCI_SDCard_GetCID(unsigned int *response } //*---------------------------------------------------------------------------- -//* \fn MCI_SDCard_SetBusWidth -//* \brief Set bus width for SDCard +//* \fn sdcard_4wire +//* \brief Set bus width to 1-bit or 4-bit according to the parm. +//* +//* Unlike most functions in this file, the return value from this one is +//* bool-ish; returns 0 on failure, 1 on success. //*---------------------------------------------------------------------------- -static int -MCI_SDCard_SetBusWidth() +int +sdcard_use4wire(int use4wire) { volatile int ret_value; - char bus_width; do { ret_value=MCI_GetStatus(); } while((ret_value > 0) && ((ret_value & AT91C_SR_READY_FOR_DATA) == 0)); - // Select Card - MCI_SendCommand(SEL_DESEL_CARD_CMD, (MCI_Device.RCA)<<16); + // If going to 4-wire mode, ask the card to turn off the DAT3 card detect + // pullup resistor, if going to 1-wire ask it to turn it back on. - // Set bus width for Sdcard - if (MCI_Device.SDCard_bus_width == AT91C_MCI_SCDBUS) - bus_width = AT91C_BUS_WIDTH_4BITS; - else - bus_width = AT91C_BUS_WIDTH_1BIT; + ret_value = MCI_SDCard_SendAppCommand(SDCARD_SET_CLR_CARD_DETECT_CMD, + use4wire ? 0 : 1); + if (ret_value != AT91C_CMD_SEND_OK) + return 0; - if (MCI_SDCard_SendAppCommand( - SDCARD_SET_BUS_WIDTH_CMD,bus_width) != AT91C_CMD_SEND_OK) - return 1; + // Ask the card to go into the requested mode. - return 0; + ret_value = MCI_SDCard_SendAppCommand(SDCARD_SET_BUS_WIDTH_CMD, + use4wire ? AT91C_BUS_WIDTH_4BITS : + AT91C_BUS_WIDTH_1BIT); + if (ret_value != AT91C_CMD_SEND_OK) + return 0; + + // Set the MCI device to match the mode we set in the card. + + if (use4wire) { + MCI_Device.SDCard_bus_width = AT91C_BUS_WIDTH_4BITS; + AT91C_BASE_MCI->MCI_SDCR |= AT91C_MCI_SCDBUS; + } else { + MCI_Device.SDCard_bus_width = AT91C_BUS_WIDTH_1BIT; + AT91C_BASE_MCI->MCI_SDCR &= ~AT91C_MCI_SCDBUS; + } + + return 1; } //*---------------------------------------------------------------------------- -//* \fn main -//* \brief main function +//* \fn sdcard_init +//* \brief get the mci device ready to read from an SD or SDHC card. +//* +//* Unlike most functions in this file, the return value from this one is +//* bool-ish; returns 0 on failure, 1 on success. //*---------------------------------------------------------------------------- int sdcard_init(void) { unsigned int tab_response[4]; -#ifdef REPORT_SIZE - unsigned int mult,blocknr; -#endif int i; // Init MCI for MMC and SDCard interface @@ -362,51 +441,77 @@ sdcard_init(void) // Init Device Structure MCI_Device.state = AT91C_MCI_IDLE; - MCI_Device.SDCard_bus_width = AT91C_MCI_SCDBUS; + MCI_Device.SDCard_bus_width = 0; + MCI_Device.IsSDv2 = 0; + MCI_Device.IsSDHC = 0; + + // Reset the MCI and set the bus speed. + // Using MCK/230 gives a legal (under 400khz) bus speed for the card id + // sequence for all reasonable master clock speeds. - //* Reset the MCI - AT91C_BASE_MCI->MCI_CR = AT91C_MCI_MCIEN | AT91C_MCI_PWSEN; + AT91C_BASE_MCI->MCI_CR = AT91C_MCI_MCIDIS | 0x80; AT91C_BASE_MCI->MCI_IDR = 0xFFFFFFFF; AT91C_BASE_MCI->MCI_DTOR = AT91C_MCI_DTOR_1MEGA_CYCLES; - AT91C_BASE_MCI->MCI_MR = AT91C_MCI_PDCMODE; - AT91C_BASE_MCI->MCI_SDCR = AT91C_MCI_SDCARD_4BITS_SLOTA; - MCI_SendCommand(GO_IDLE_STATE_CMD, AT91C_NO_ARGUMENT); + AT91C_BASE_MCI->MCI_MR = AT91C_MCI_PDCMODE | 114; /* clkdiv 114 = MCK/230 */ + AT91C_BASE_MCI->MCI_SDCR = AT91C_MCI_MMC_SLOTA; + AT91C_BASE_MCI->MCI_CR = AT91C_MCI_MCIEN|AT91C_MCI_PWSEN; + + // Wait for the card to come out of power-up-busy state by repeatedly + // sending ACMD41. This also probes for SDHC versus standard cards. for (i = 0; i < 100; i++) { - if (!MCI_SDCard_GetOCR(&MCI_Device)) + if (MCI_SDCard_GetOCR(&MCI_Device) == 0) break; - printf("."); + if ((i & 0x01) == 0) { + printf("."); + } } if (i >= 100) return 0; + if (MCI_SDCard_GetCID(tab_response)) return 0; + + // Tell the card to set its address, and remember the result. + if (MCI_SendCommand(SET_RELATIVE_ADDR_CMD, 0)) return 0; - MCI_Device.RCA = (AT91C_BASE_MCI->MCI_RSPR[0] >> 16); + + // After sending CMD3 (set addr) we can increase the clock to full speed. + // Using MCK/4 gives a legal (under 25mhz) bus speed for all reasonable + // master clock speeds. + + AT91C_BASE_MCI->MCI_MR = AT91C_MCI_PDCMODE | 1; /* clkdiv 1 = MCK/4 */ + if (MCI_GetCSD(MCI_Device.RCA,tab_response)) return 0; MCI_Device.READ_BL_LEN = (tab_response[1] >> CSD_1_RD_B_LEN_S) & CSD_1_RD_B_LEN_M; + #ifdef REPORT_SIZE - // compute MULT - mult = 1 << ( ((tab_response[2] >> CSD_2_C_SIZE_M_S) & - CSD_2_C_SIZE_M_M) + 2 ); - // compute MSB of C_SIZE - blocknr = ((tab_response[1] >> CSD_1_CSIZE_H_S) & - CSD_1_CSIZE_H_M) << 2; - // compute MULT * (LSB of C-SIZE + MSB already computed + 1) = BLOCKNR - blocknr = mult * ((blocknr + ((tab_response[2] >> CSD_2_CSIZE_L_S) & - CSD_2_CSIZE_L_M)) + 1); - MCI_Device.Memory_Capacity = (1 << MCI_Device.READ_BL_LEN) * blocknr; + { + unsigned int mult,blocknr; + // compute MULT + mult = 1 << ( ((tab_response[2] >> CSD_2_C_SIZE_M_S) & + CSD_2_C_SIZE_M_M) + 2 ); + // compute MSB of C_SIZE + blocknr = ((tab_response[1] >> CSD_1_CSIZE_H_S) & + CSD_1_CSIZE_H_M) << 2; + // compute MULT * (LSB of C-SIZE + MSB already computed + 1) = BLOCKNR + blocknr = mult * ((blocknr + ((tab_response[2] >> CSD_2_CSIZE_L_S) & + CSD_2_CSIZE_L_M)) + 1); + MCI_Device.Memory_Capacity = (1 << MCI_Device.READ_BL_LEN) * blocknr; + printf("Found SD card %u bytes\n", MCI_Device.Memory_Capacity); + } #endif - if (MCI_SDCard_SetBusWidth()) + + // Select card and set block length for following transfers. + + if (MCI_SendCommand(SEL_DESEL_CARD_CMD, (MCI_Device.RCA)<<16)) return 0; - if (MCI_SendCommand(SET_BLOCKLEN_CMD, 1 << MCI_Device.READ_BL_LEN)) + if (MCI_SendCommand(SET_BLOCKLEN_CMD, SD_BLOCK_SIZE)) return 0; -#ifdef REPORT_SIZE - printf("Found SD card %u bytes\n", MCI_Device.Memory_Capacity); -#endif + return 1; } Index: sys/boot/arm/at91/libat91/sd-card.h =================================================================== --- sys/boot/arm/at91/libat91/sd-card.h 2 Apr 2007 21:14:02 -0000 1.2 +++ sys/boot/arm/at91/libat91/sd-card.h 23 Mar 2011 21:34:54 -0000 @@ -30,9 +30,35 @@ #ifndef __SD_CARD_H #define __SD_CARD_H -int MCI_write (unsigned dest, char* source, unsigned length); -int MCI_read (char* dest, unsigned source, unsigned length); +/* MCI_read() is the original read function, taking a byte offset and byte + * count. It is preserved to support existing customized boot code that still + * refers to it; it will work fine even on SDHC cards as long as the kernel and + * the metadata for locating it all exist within the first 4GB of the card. + * + * MCI_readblocks() is the new read function, taking offset and length in terms + * of block counts (where the SD spec defines a block as 512 bytes), allowing + * the kernel and filesystem metadata to be located anywhere on an SDHC card. + * + * Returns 0 on success, non-zero on failure. + */ + +int MCI_read (char* dest, unsigned bytenum, unsigned length); +int MCI_readblocks (char* dest, unsigned blknum, unsigned blkcount); + +/* sdcard_init() - get things set up to read from an SD or SDHC card. + * + * Returns 0 on failure, non-zero on success. + */ + int sdcard_init(void); +/* By default sdcard_init() sets things up for a 1-wire interface to the + * SD card. Calling sdcard_4wire(true) after sdcard_init() allows customized + * boot code to change to 4-bit transfers when the hardware supports it. + * + * Returns 0 on failure, non-zero on success. + */ +int sdcard_use4wire(int use4wire); + #endif --- patch-boot-arm-libat91-sdhc ends here --- >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-arm@FreeBSD.ORG Fri Mar 25 12:07:27 2011 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 52681106564A for ; Fri, 25 Mar 2011 12:07:27 +0000 (UTC) (envelope-from fbsd-arm@bzerk.org) Received: from ei.bzerk.org (tunnel490.ipv6.xs4all.nl [IPv6:2001:888:10:1ea::2]) by mx1.freebsd.org (Postfix) with ESMTP id BBA688FC16 for ; Fri, 25 Mar 2011 12:07:26 +0000 (UTC) Received: from ei.bzerk.org (BOFH@localhost [127.0.0.1]) by ei.bzerk.org (8.14.4/8.14.4) with ESMTP id p2PC7LCm001048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 25 Mar 2011 13:07:21 +0100 (CET) (envelope-from fbsd-arm@bzerk.org) Received: (from bulk@localhost) by ei.bzerk.org (8.14.4/8.14.4/Submit) id p2PC7LSI001047 for arm@freebsd.org; Fri, 25 Mar 2011 13:07:21 +0100 (CET) (envelope-from fbsd-arm@bzerk.org) Date: Fri, 25 Mar 2011 13:07:21 +0100 From: Ruben de Groot To: arm@freebsd.org Message-ID: <20110325120721.GA977@ei.bzerk.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on ei.bzerk.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0.1 (ei.bzerk.org [127.0.0.1]); Fri, 25 Mar 2011 13:07:25 +0100 (CET) Cc: Subject: crosscompile broken? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2011 12:07:27 -0000 This used to work until yesterday. Building arm (SHEEVAPLUG) world + kernel on i386. With freshly csupped -current sources my crosscompile gives me the following error: # make -j 8 buildworld TARGET_ARCH=arm ... # make buildkernel TARGET_ARCH=arm KERNCONF=SHEEVAPLUG ... cc -mlittle-endian -c -O2 -pipe -fno-strict-aliasing -std=c99 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -nostdinc -I. -I/usr/build/current/src/sys -I/usr/build/current/src/sys/contrib/altq -I/usr/build/current/src/sys/contrib/libfdt -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -march=armv5te -ffreestanding -Werror /usr/build/current/src/sys/ufs/ffs/ffs_softdep.c /usr/build/current/src/sys/ufs/ffs/ffs_softdep.c: In function 'softdep_request_cleanup': /usr/build/current/src/sys/ufs/ffs/ffs_softdep.c:520: error: number of arguments doesn't match prototype /usr/build/current/src/sys/ufs/ffs/ffs_extern.h:123: error: prototype declaration *** Error code 1 Stop in /usr/obj/arm.arm/usr/build/current/src/sys/SHEEVAPLUG *** Error code 1 Stop in /usr/build/current/src. *** Error code 1 From owner-freebsd-arm@FreeBSD.ORG Fri Mar 25 18:06:41 2011 Return-Path: Delivered-To: arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 95836106566B for ; Fri, 25 Mar 2011 18:06:41 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 579DD8FC12 for ; Fri, 25 Mar 2011 18:06:41 +0000 (UTC) Received: from 63.imp.bsdimp.com (63.imp.bsdimp.com [10.0.0.63] (may be forged)) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id p2PHuAKi049525; Fri, 25 Mar 2011 11:56:10 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <20110325120721.GA977@ei.bzerk.org> Date: Fri, 25 Mar 2011 11:56:10 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20110325120721.GA977@ei.bzerk.org> To: Ruben de Groot X-Mailer: Apple Mail (2.1082) Cc: arm@FreeBSD.org Subject: Re: crosscompile broken? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2011 18:06:41 -0000 On Mar 25, 2011, at 6:07 AM, Ruben de Groot wrote: > This used to work until yesterday. >=20 > Building arm (SHEEVAPLUG) world + kernel on i386. > With freshly csupped -current sources my crosscompile gives me the = following error: >=20 > # make -j 8 buildworld TARGET_ARCH=3Darm > ... > # make buildkernel TARGET_ARCH=3Darm KERNCONF=3DSHEEVAPLUG > ... > cc -mlittle-endian -c -O2 -pipe -fno-strict-aliasing -std=3Dc99 = -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes = -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef = -Wno-pointer-sign -fformat-extensions -nostdinc -I. = -I/usr/build/current/src/sys -I/usr/build/current/src/sys/contrib/altq = -I/usr/build/current/src/sys/contrib/libfdt -D_KERNEL = -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common = -finline-limit=3D8000 --param inline-unit-growth=3D100 --param = large-function-growth=3D1000 -march=3Darmv5te -ffreestanding -Werror = /usr/build/current/src/sys/ufs/ffs/ffs_softdep.c > /usr/build/current/src/sys/ufs/ffs/ffs_softdep.c: In function = 'softdep_request_cleanup': > /usr/build/current/src/sys/ufs/ffs/ffs_softdep.c:520: error: number of = arguments doesn't match prototype > /usr/build/current/src/sys/ufs/ffs/ffs_extern.h:123: error: prototype = declaration > *** Error code 1 Looks more like a normal compilation error. Have you checked to see if = ffs_extern.h and ffs_softdep.c have the same prototypes for = softdep_request_cleanup? Warner >=20 > Stop in /usr/obj/arm.arm/usr/build/current/src/sys/SHEEVAPLUG > *** Error code 1 >=20 > Stop in /usr/build/current/src. > *** Error code 1 > _______________________________________________ > freebsd-arm@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arm > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" >=20 >=20