From owner-freebsd-arm@FreeBSD.ORG Thu May 15 03:24:07 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 F3195ACD for ; Thu, 15 May 2014 03:24:06 +0000 (UTC) Received: from mail-ee0-x22c.google.com (mail-ee0-x22c.google.com [IPv6:2a00:1450:4013:c00::22c]) (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 87C9629F4 for ; Thu, 15 May 2014 03:24:06 +0000 (UTC) Received: by mail-ee0-f44.google.com with SMTP id c41so194321eek.17 for ; Wed, 14 May 2014 20:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=rtAGWDtrlOPEaBKeLGJMkGFmy2IDhRkxkeqIR3VOs1A=; b=XrfDJJ7/4o95U1u1Cl+cmqBRxKdCC3Mtruf5EVg8fI1mO+DFWevcc5kijuH4x7ccti ed1iiNJU+ujf9+QobIXNkUtTlHvWnKnlpI7GFKLSPICVcuBlaKMG3dXQ+LisSCXsbMl1 g06Y0q0BPuOmo5cI5398tfP2YGBb1rJ2tWP0swYFTfKj9pep7iOIU9y0+hxi2HDlUoGt 9PWsRNGAzsaxVZ9mrh8b6wKXCD2nxG8GSymsd5KfFIoAF6egg8gjkClrqvocDFrwCh28 wpJDNIi4yZ0GF1iH13XYozNr4L0dQrea5TpIW02H/+s4Emgd25TTu8Y5/ZDDR0HwDHwF FHBg== X-Received: by 10.14.205.196 with SMTP id j44mr584665eeo.72.1400124244414; Wed, 14 May 2014 20:24:04 -0700 (PDT) Received: from ketas-laptop.mydomain (ketas-laptop6.si.pri.ee. [2001:ad0:91f:0:21a:6bff:fe66:2ad3]) by mx.google.com with ESMTPSA id x45sm9331510eeu.23.2014.05.14.20.24.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 May 2014 20:24:02 -0700 (PDT) Sender: Sulev-Madis Silber Message-ID: <53743350.6080001@hot.ee> Date: Thu, 15 May 2014 06:24:00 +0300 From: "Sulev-Madis Silber (ketas)" User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: Warner Losh Subject: Re: Patch to make BBB properly boot from eMMC every time References: <5371E1F3.6080002@hot.ee> <8FE89E4A-1398-4321-BBBC-CA377C7981B1@bsdimp.com> In-Reply-To: <8FE89E4A-1398-4321-BBBC-CA377C7981B1@bsdimp.com> X-TagToolbar-Keys: D20140515062400069 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Thu, 15 May 2014 03:24:07 -0000 On 2014-05-13 17:03, Warner Losh wrote: > > On May 13, 2014, at 3:12 AM, 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). >> >> Actually, that code looks like weird way to implement sleep(), or at >> least it has such (side) effect. > > So you added a printf and the problem went away. That’s good info, but not sufficient. Does the problem go away if you put a DELAY(10) or something like that instead? That’s a better fix, or better yet, more nuanced retry... > I should try. Recently, even printf doesn't fix it (~5 fails already, sometimes repeatedly after hw reset)... it takes tens of seconds and then fails. Probably retry or something entirely different in detection code should be used there. > Warner > >> Actually ian@ made that patch, and was confused about results. >> >> >> ------------------------------------------------------------------------- >> Index: sys/dev/mmc/mmc.c >> =================================================================== >> --- 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 = p8; >> data.len = 8; >> data.flags = MMC_DATA_WRITE; >> - mmc_wait_for_cmd(sc, &cmd, 0); >> - >> + err = mmc_wait_for_cmd(sc, &cmd, 0); >> + if (err != 0) >> + device_printf(sc->dev, "BUSTEST_W err %d\n", err); >> + >> memset(&cmd, 0, sizeof(cmd)); >> memset(&data, 0, sizeof(data)); >> cmd.opcode = MMC_BUSTEST_R; >> @@ -782,7 +784,12 @@ mmc_test_bus_width(struct mmc_softc *sc) >> data.len = 8; >> data.flags = MMC_DATA_READ; >> err = mmc_wait_for_cmd(sc, &cmd, 0); >> - >> + if (err != 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); >> ------------------------------------------------------------------------- >> _______________________________________________ >> 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" >