From owner-freebsd-arm@FreeBSD.ORG Tue May 13 14:12:23 2014 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A7E5C6D2 for ; Tue, 13 May 2014 14:12:23 +0000 (UTC) Received: from mail-ig0-f181.google.com (mail-ig0-f181.google.com [209.85.213.181]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6CCA92A84 for ; Tue, 13 May 2014 14:12:23 +0000 (UTC) Received: by mail-ig0-f181.google.com with SMTP id h3so423530igd.8 for ; Tue, 13 May 2014 07:12:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=RyK6td3dVh6R3GQkDqFidv+TwSipuEmWdkKPtdrGLNc=; b=dqy4e/cNqR94kpY7QqX9aKibqNSjxLAWJmF2H0kkwkcIy4Bkr8OU0QMMFQFDlo4cpy NYPDh5TNkygvpcjPckK0tr+8fj6OETyLx/NGCVN11SU+xQBwqOJyDpyBszXrhCHWT6Lp 1VDmFm2dzxXXFsDSq7DdDsfG0bXJmlQ3kopKcvvd5kpfwANkXpL2KZwVNRCGhOv6nR3d qD9asTvsvCtwLZ5aMEVfo6RihzX3b5c0AVID7Es21wamaMZogqQohmyqIGATDXPgKWUo ONLNwN6w5uA4wFgUGL1O1HqhDsgm7140qIbHfAAvME1Ext8GQM4J3HymBN1/XYtpfvWu ph3A== X-Gm-Message-State: ALoCoQnH3xm6fDSdCeOzy9J5G/YWKDNTXXMfKa2kUojvDiHPPk+y9l51+fb75rq/sMANxLa3GPqZ X-Received: by 10.50.238.229 with SMTP id vn5mr56747918igc.45.1399989851842; Tue, 13 May 2014 07:04:11 -0700 (PDT) Received: from [172.29.67.66] (63-156-62-129.dia.static.qwest.net. [63.156.62.129]) by mx.google.com with ESMTPSA id pi3sm30327867igb.5.2014.05.13.07.04.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 07:04:11 -0700 (PDT) Sender: Warner Losh Content-Type: multipart/signed; boundary="Apple-Mail=_A79B79DD-6A0B-4280-9C9F-20AEC9DADD29"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: Patch to make BBB properly boot from eMMC every time From: Warner Losh In-Reply-To: <1399987808.56626.2.camel@revolution.hippie.lan> Date: Tue, 13 May 2014 08:04:10 -0600 Message-Id: References: <5371E1F3.6080002@hot.ee> <1399987808.56626.2.camel@revolution.hippie.lan> To: Ian Lepore X-Mailer: Apple Mail (2.1874) Cc: freebsd-arm X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 May 2014 14:12:23 -0000 --Apple-Mail=_A79B79DD-6A0B-4280-9C9F-20AEC9DADD29 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 On May 13, 2014, at 7:30 AM, Ian Lepore wrote: > On Tue, 2014-05-13 at 12:12 +0300, Sulev-Madis Silber (ketas) wrote: >> On my BBB, I need following patch to boot from eMMC 100% of cases. >> Without that, device is detected with 1 / 4 bit bus (it's actually 8 >> bit) or not at all (then boot fails). >>=20 >> Actually, that code looks like weird way to implement sleep(), or at >> least it has such (side) effect. >>=20 >> Actually ian@ made that patch, and was confused about results. >>=20 >>=20 >> = ------------------------------------------------------------------------- >> Index: sys/dev/mmc/mmc.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- sys/dev/mmc/mmc.c (revision 264141) >> +++ sys/dev/mmc/mmc.c (working copy) >> @@ -769,8 +769,10 @@ mmc_test_bus_width(struct mmc_softc *sc) >> data.data =3D p8; >> data.len =3D 8; >> data.flags =3D MMC_DATA_WRITE; >> - mmc_wait_for_cmd(sc, &cmd, 0); >> - >> + err =3D mmc_wait_for_cmd(sc, &cmd, 0); >> + if (err !=3D 0) >> + device_printf(sc->dev, "BUSTEST_W err %d\n", = err); >> + >> memset(&cmd, 0, sizeof(cmd)); >> memset(&data, 0, sizeof(data)); >> cmd.opcode =3D MMC_BUSTEST_R; >> @@ -782,7 +784,12 @@ mmc_test_bus_width(struct mmc_softc *sc) >> data.len =3D 8; >> data.flags =3D MMC_DATA_READ; >> err =3D mmc_wait_for_cmd(sc, &cmd, 0); >> - >> + if (err !=3D 0) >> + device_printf(sc->dev, "BUSTEST_R err %d\n", = err); >> + >> + device_printf(sc->dev, "read %02x %02x %02x %02x %02x >> %02x %02x %02x\n", >> + buf[0], buf[1], buf[2], buf[3], buf[4], = buf[5], >> buf[6], buf[7]); >> + >> mmcbr_set_bus_width(sc->dev, bus_width_1); >> mmcbr_update_ios(sc->dev); >> = ------------------------------------------------------------------------- >=20 > Confused about the cause of the results, yes. I think the printf I = had > you add to help me figure out the problem just changed the timing of = the > retry to make it work on the second try, but I have no idea why. >=20 > Does anybody else with a BBB see the device randomly boot up as 1 or 4 > or 8 bits, changing from one boot to the next? The bits are reported = in > the mmcsd0 line: >=20 > mmcsd0: 8GB at mmc0 > 50.0MHz/4bit/65535-block >=20 > That's from a wandboard, but a BBB eMMC should always be 8 bits. I=92m away from my BBB atm, but I=92ll test this when I get back=85 Warner --Apple-Mail=_A79B79DD-6A0B-4280-9C9F-20AEC9DADD29 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJTciZaAAoJEGwc0Sh9sBEAMQUQANejoxbxDy6dpkDKXF4P+OQ5 yzUvqGWgRORGv9qlks88iEWSt/Cz5lgaI1NhFfGt0r+HOPGPrk2WHXnFwxfALm9X Jj7LKzK90jwLAi2YeIGdMQoKceIELIS8c5tZi+C0PnOdWIq3x21c/4pAOCS/Mhxa t7euol7/oCA9kspVerrGHiq2ascRsp93rJlQenmcyedWMg6fChT1/AUqMpcE6qxk /mzL7GFKe8guQvxt+qKhzdC+KyKOSfgo1GPBqfIzHnFoRZbbMWCtQJnaEe0KPhws w2l3mp22e0eiefppal+Du7ql7fsXLMvkvwh5RuXYdR1gDw55TQoH1CIvP1drc4mO k+9us9+aCO2QwR7sgyJUTqDdwyVS+1nVsGiwkNdT7Fe9NSPhktis2xQkV/b+2W1t QcEMLSolK7PH/fFPQsb4X7JoBO6HBJCl8XbC7oKO+hOeer8A006FTDTmeC87hsEg ZNNdTLcSNc/c6BEtgxrIpCQK8Mfy8vKsRTiYE/Ub7OFeCB5aaAZxhfPM6tNWFxAd 8eAH5oSNmNRQtLoyzT89JdolahDWf+43mJ21vEDcXMQiwtUPD27Bjhs08M6QORlu LFxV/MD/ucYvE7NFBS2b8xw1xSbWJpQTbtaJ3RSG7UmU5R8Zf2d6Jxp2G1uZkw4z 2Eh8KZoghXR1AnB7XsRQ =mwjJ -----END PGP SIGNATURE----- --Apple-Mail=_A79B79DD-6A0B-4280-9C9F-20AEC9DADD29--