From owner-freebsd-mips@FreeBSD.ORG Sun Feb 13 19:02:47 2011 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A505E106564A; Sun, 13 Feb 2011 19:02:47 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 4635A8FC0A; Sun, 13 Feb 2011 19:02:46 +0000 (UTC) Received: by vws9 with SMTP id 9so2560718vws.13 for ; Sun, 13 Feb 2011 11:02:46 -0800 (PST) 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:cc :content-type; bh=nhFdfdIMMYFRqtTVjFtX1Jitip45TlhRBkFxJ07PmIk=; b=lGXKJwCHNzUV1//LmkD4i04Q+3sFKP5AVMahmLfgl/PH+3y08JLDXLar3jWysoJuqi B04ELOPjcWfnZp9V1/Q/74Q85rCFcqzHsIBEAO2xQ6xReq3dxdYtxhWr8sWSFb+IlePI hhmhDEEmGK/EOQUsuZ5IePC7a5I5a9dtQePdY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=s40zZAdmJn5UW9RpMb6ly7q69zRY8MwBAjHjMrevkKy49P+7TzVRdyfROo7zfla3WH D5Tg67u6x0AM81W79Gi/3iDPmei/mMuRDG/XGLoHLEfU73pGRu9rdFbcJf9oHao0hTZv c5TPt5KqrgE70MjaHUIfsXPooWfwTv0BpLX4A= MIME-Version: 1.0 Received: by 10.220.201.70 with SMTP id ez6mr3764939vcb.229.1297623766439; Sun, 13 Feb 2011 11:02:46 -0800 (PST) Received: by 10.220.186.133 with HTTP; Sun, 13 Feb 2011 11:02:46 -0800 (PST) Date: Mon, 14 Feb 2011 03:02:46 +0800 Message-ID: From: Adrian Chadd To: freebsd-embedded@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-mips@freebsd.org Subject: patch to sys/dev/flash/ to allow smaller read IO sizes X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Feb 2011 19:02:47 -0000 I've been running a few of my ubiquiti boards out of flash recently and the default sector size just makes it impossible. This patch introduces a couple of important changes: * the GEOM sector size is changed to 512 bytes; * non-aligned size/offset for read/write is now an IO error, rather than a KASSERT(); This means that read IO will work fine with smaller IO sizes and the wrong-sized IO will simply return EIO rather than panicing the kernel. Writing should still work for IO size+offset as a multiple of the sector size. Thanks, Adrian ==== [root@pcbsd-1294 /data/1/adrian/head/src]# cat /tmp/flash_read_size.diff Index: sys/dev/flash/mx25l.c =================================================================== --- sys/dev/flash/mx25l.c (revision 218440) +++ sys/dev/flash/mx25l.c (working copy) @@ -49,6 +49,13 @@ #define FL_ERASE_4K 0x01 #define FL_ERASE_32K 0x02 +/* + * Define the sectorsize to be a smaller size rather than the flash + * sector size. Trying to run FFS off of a 64k flash sector size + * results in a completely un-usable system. + */ +#define MX25L_SECTORSIZE 512 + struct mx25l_flash_ident { const char *name; @@ -230,17 +237,10 @@ bytes_writen = 0; write_offset = offset; - /* - * Sanity checks - */ - KASSERT(count % sc->sc_sectorsize == 0, - ("count for BIO_WRITE is not sector size (%d bytes) aligned", - sc->sc_sectorsize)); + /* Use the erase sectorsize here; since blocks are erased first before writing */ + if (count % sc->sc_sectorsize != 0 || offset % sc->sc_sectorsize != 0) + return (EIO); - KASSERT(offset % sc->sc_sectorsize == 0, - ("offset for BIO_WRITE is not sector size (%d bytes) aligned", - sc->sc_sectorsize)); - /* * Assume here that we write per-sector only * and sector size should be 256 bytes aligned @@ -307,17 +307,10 @@ pdev = device_get_parent(dev); sc = device_get_softc(dev); - /* - * Sanity checks - */ - KASSERT(count % sc->sc_sectorsize == 0, - ("count for BIO_READ is not sector size (%d bytes) aligned", - sc->sc_sectorsize)); + /* Enforce the disk read sectorsize; not the erase sectorsize */ + if (count % sc->sc_disk->d_sectorsize != 0 || offset % sc->sc_disk->d_sectorsize != 0) + return (EIO); - KASSERT(offset % sc->sc_sectorsize == 0, - ("offset for BIO_READ is not sector size (%d bytes) aligned", - sc->sc_sectorsize)); - txBuf[0] = CMD_FAST_READ; cmd.tx_cmd_sz = 5; cmd.rx_cmd_sz = 5; @@ -371,7 +364,7 @@ sc->sc_disk->d_name = "flash/spi"; sc->sc_disk->d_drv1 = sc; sc->sc_disk->d_maxsize = DFLTPHYS; - sc->sc_disk->d_sectorsize = ident->sectorsize; + sc->sc_disk->d_sectorsize = MX25L_SECTORSIZE; sc->sc_disk->d_mediasize = ident->sectorsize * ident->sectorcount; sc->sc_disk->d_unit = device_get_unit(sc->sc_dev); sc->sc_disk->d_dump = NULL; /* NB: no dumps */ From owner-freebsd-mips@FreeBSD.ORG Fri Feb 18 19:15:48 2011 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9FF56106566B for ; Fri, 18 Feb 2011 19:15:48 +0000 (UTC) (envelope-from aduane@juniper.net) Received: from exprod7og125.obsmtp.com (exprod7og125.obsmtp.com [64.18.2.28]) by mx1.freebsd.org (Postfix) with ESMTP id 257168FC0C for ; Fri, 18 Feb 2011 19:15:47 +0000 (UTC) Received: from source ([66.129.224.36]) (using TLSv1) by exprod7ob125.postini.com ([64.18.6.12]) with SMTP ID DSNKTV7FY5mmfZEqy1lW4aTH29XgPbLqFrlJ@postini.com; Fri, 18 Feb 2011 11:15:48 PST Received: from p-emfe02-wf.jnpr.net (172.28.145.25) by P-EMHUB02-HQ.jnpr.net (172.24.192.36) with Microsoft SMTP Server (TLS) id 8.2.254.0; Fri, 18 Feb 2011 11:10:25 -0800 Received: from EMBX01-WF.jnpr.net ([fe80::1914:3299:33d9:e43b]) by p-emfe02-wf.jnpr.net ([fe80::c126:c633:d2dc:8090%11]) with mapi; Fri, 18 Feb 2011 14:10:51 -0500 From: Andrew Duane To: "mips@freebsd.org" Date: Fri, 18 Feb 2011 14:08:49 -0500 Thread-Topic: Bootstraps for Mips/OCTEON platforms Thread-Index: AQHLz5+ONwy9jXT8HUeAmQ+uzM+W2w== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: Subject: Bootstraps for Mips/OCTEON platforms X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Feb 2011 19:15:48 -0000 I'm starting at ground zero (almost) with an Octeon based platform related = to the OCTEON1 config in the -CURRENT. The board uses an existing MIPS boot= strap and loader, but that does not seem to be compatible with what the ker= nel expects. What bootstrap is used normally? u-boot?=20 -- Andrew Duane Juniper Networks 978-589-0551 10 Technology Park Dr aduane@juniper.net Westford, MA 01886-3418 From owner-freebsd-mips@FreeBSD.ORG Fri Feb 18 19:47:35 2011 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 95087106567A for ; Fri, 18 Feb 2011 19:47:35 +0000 (UTC) (envelope-from mahan@mahan.org) Received: from ns.mahan.org (ns.mahan.org [67.116.10.138]) by mx1.freebsd.org (Postfix) with ESMTP id 6B8B78FC0A for ; Fri, 18 Feb 2011 19:47:35 +0000 (UTC) Received: from Patrick-Mahans-MacBook-Pro.local (crowTrobot [67.116.10.140]) by ns.mahan.org (8.13.6/8.13.6) with ESMTP id p1IJa6NA037649; Fri, 18 Feb 2011 11:36:07 -0800 (PST) (envelope-from mahan@mahan.org) Message-ID: <4D5EC92B.1040803@mahan.org> Date: Fri, 18 Feb 2011 11:31:55 -0800 From: Patrick Mahan User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: Andrew Duane References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "mips@freebsd.org" Subject: Re: Bootstraps for Mips/OCTEON platforms X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Feb 2011 19:47:35 -0000 Andrew, Most of the Cavium hardware I have played with all use u-boot or a modified version of u-boot. However, I have seen a few vendors platforms that have their own bootloader (Cisco, Motorola to name a few). If it is not u-boot, then I guess you need to determine where the hardware expects the bootloader to load the start of the kernel. If it boots linux and you have the sources for the linux it will boot, you look at the link map for linux which should have some clues. But overall, it has always (to the best of my knowledge) been u-boot. Hope this points you in the right direction, Patrick On 2/18/11 11:08 AM, Andrew Duane wrote: > > I'm starting at ground zero (almost) with an Octeon based platform related to the OCTEON1 config in the -CURRENT. The board uses an existing MIPS bootstrap and loader, but that does not seem to be compatible with what the kernel expects. What bootstrap is used normally? u-boot? > > > -- > Andrew Duane Juniper Networks > 978-589-0551 10 Technology Park Dr > aduane@juniper.net Westford, MA 01886-3418 > _______________________________________________ > freebsd-mips@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-mips > To unsubscribe, send any mail to "freebsd-mips-unsubscribe@freebsd.org" > > From owner-freebsd-mips@FreeBSD.ORG Fri Feb 18 22:58:04 2011 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6EB43106566B for ; Fri, 18 Feb 2011 22:58:04 +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 31E208FC12 for ; Fri, 18 Feb 2011 22:58:04 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id p1IMt6uE068007 for ; Fri, 18 Feb 2011 15:55:06 -0700 (MST) (envelope-from imp@bsdimp.com) Message-ID: <4D5EF8CA.5010008@bsdimp.com> Date: Fri, 18 Feb 2011 15:55:06 -0700 From: Warner Losh User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.13) Gecko/20101211 Thunderbird/3.1.7 MIME-Version: 1.0 To: freebsd-mips@freebsd.org References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Bootstraps for Mips/OCTEON platforms X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Feb 2011 22:58:04 -0000 On 02/18/2011 12:08, Andrew Duane wrote: > I'm starting at ground zero (almost) with an Octeon based platform related to the OCTEON1 config in the -CURRENT. The board uses an existing MIPS bootstrap and loader, but that does not seem to be compatible with what the kernel expects. What bootstrap is used normally? u-boot? u-boot is what we support. There's no other support in the codebase right now. uboot gives us: in a3 is passed in the cavium hardware descriptor. All other registers are ignored on boot. We only support version 6 and newer of the boot descriptor. You can see the details of the structure in sys/mips/cavium/octeon_machdep.c starting with platform_start(). Warner From owner-freebsd-mips@FreeBSD.ORG Fri Feb 18 23:02:25 2011 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 582D21065672 for ; Fri, 18 Feb 2011 23:02:25 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id 1A9EF8FC19 for ; Fri, 18 Feb 2011 23:02:24 +0000 (UTC) Received: by qyk36 with SMTP id 36so743263qyk.13 for ; Fri, 18 Feb 2011 15:02:24 -0800 (PST) Received: by 10.229.95.19 with SMTP id b19mr1007549qcn.179.1298070144202; Fri, 18 Feb 2011 15:02:24 -0800 (PST) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.229.74.70 with HTTP; Fri, 18 Feb 2011 15:02:04 -0800 (PST) In-Reply-To: <4D5EF8CA.5010008@bsdimp.com> References: <4D5EF8CA.5010008@bsdimp.com> From: Juli Mallett Date: Fri, 18 Feb 2011 15:02:04 -0800 X-Google-Sender-Auth: snfAohGrMBZFEO-jVHFAKOIBNrM Message-ID: To: Warner Losh Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-mips@freebsd.org Subject: Re: Bootstraps for Mips/OCTEON platforms X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Feb 2011 23:02:25 -0000 On Fri, Feb 18, 2011 at 14:55, Warner Losh wrote: > On 02/18/2011 12:08, Andrew Duane wrote: >> >> I'm starting at ground zero (almost) with an Octeon based platform relat= ed >> to the OCTEON1 config in the -CURRENT. The board uses an existing MIPS >> bootstrap and loader, but that does not seem to be compatible with what = the >> kernel expects. What bootstrap is used normally? u-boot? > > u-boot is what we support. =A0There's no other support in the codebase ri= ght > now. =A0uboot gives us: > > in a3 is passed in the cavium hardware descriptor. =A0All other registers= are > ignored on boot. =A0We only support version 6 and newer of the boot > descriptor. =A0You can see the details of the structure in > sys/mips/cavium/octeon_machdep.c starting with platform_start(). It's worth noting that we don't use the Simple Executive ELF Application calling convention but the Octeon Linux one, so 'bootoctlinux' should be used instead of 'bootoctelf'. Juli.