From owner-freebsd-arm@FreeBSD.ORG Tue May 13 14:26:40 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 01422A19; Tue, 13 May 2014 14:26:40 +0000 (UTC) Received: from courriel.site.uottawa.ca (eecsmail.engineering.uottawa.ca [137.122.24.224]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.site.uottawa.ca", Issuer "PositiveSSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AE28F2B8E; Tue, 13 May 2014 14:26:38 +0000 (UTC) Received: from admin16.site.uottawa.ca (admin16.site.uottawa.ca [137.122.90.250]) (authenticated bits=0) by courriel.site.uottawa.ca (8.14.5/8.14.4) with ESMTP id s4DE3vSj046994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 13 May 2014 10:03:57 -0400 (EDT) (envelope-from kwhite@site.uottawa.ca) Date: Tue, 13 May 2014 10:03:57 -0400 (EDT) From: Keith White To: Ian Lepore Subject: Re: Patch to make BBB properly boot from eMMC every time In-Reply-To: <1399987808.56626.2.camel@revolution.hippie.lan> Message-ID: <20140513100155.M27352@admin16.site.uottawa.ca> References: <5371E1F3.6080002@hot.ee> <1399987808.56626.2.camel@revolution.hippie.lan> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed 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:26:40 -0000 On Tue, 13 May 2014, 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). >> >> Actually, that code looks like weird way to implement sleep(), or at >> least it has such (side) effect. >> >> 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); >> ------------------------------------------------------------------------- > > 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. > > 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: > > mmcsd0: 8GB at mmc0 > 50.0MHz/4bit/65535-block > > That's from a wandboard, but a BBB eMMC should always be 8 bits. > > -- Ian > > > _______________________________________________ > 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" Yes, I have the same problem with a BBB. The above patch appears to workaround it. ...keith -- Keith White, genie.uottawa.ca engineering.uottawa.ca kwhite@uottawa.ca [+1 613 562 5800 x6681]