Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: installboot(8) changes for installing u-boot directly to SPI flash (or other raw flash devices)



On Mon, Sep 16, 2019 at 12:39:43PM -0700, Jason Thorpe wrote:
> 
> 
> > On Sep 16, 2019, at 7:10 AM, Jason Thorpe <thorpej%me.com@localhost> wrote:
> > 
> > Ah, I had only been building as a host tool so far.  I?ll fix it up today.
> 
> This should be fixed now.  You'll need both evboards.c and evboards.h

Thanks.
I tested this on a A20-OLinuXino-LIME2-e16Gs16M with the attached
installboot.plist

Running
installboot -o media=spi /dev/spiflash0
failed because it tries to use /dev/rspiflash0 but spiflash doens't have a
character device.

We could special-case spiflash in installboot but, after thinking about it,
it seems better to fix getdiskrawname() to return NULL if the character
device doesn't exists. The attached patch does this.

With the patched libutil.so, 
installboot -o media=spi /dev/spiflash0
did make the spi flash bootable.

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--
<!-- $NetBSD: installboot.plist,v 1.1 2019/07/12 05:08:38 thorpej Exp $ -->
<!--
  Copyright (c) 2019 The NetBSD Foundation, Inc.
  All rights reserved.
 
  This code is derived from software contributed to The NetBSD Foundation
  by Jason R. Thorpe.
 
  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:
  1. Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     documentation and/or other materials provided with the distribution.
 
  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  POSSIBILITY OF SUCH DAMAGE.
-->
<plist>
<dict>
	<key>olimex,a20-olinuxino-lime2-emmc</key>
	<dict>
		<key>description</key>
		<string>Olimex A20-OLinuXino-LIME2-eMMC</string>
		<key>u-boot-install-sdmmc</key>
		<array>
			<dict>
				<key>file-name</key>
				<string>u-boot-sunxi-with-spl.bin</string>
				<key>image-offset</key>
				<integer>8192</integer>
			</dict>
		</array>
                <key>u-boot-install-emmc</key>
                <string>u-boot-install-sdmmc</string>
                <key>u-boot-install-spi</key>
                <array>
                        <dict>
                                <key>file-name</key>
                                <string>u-boot-sunxi-with-spl.bin</string>
                                <key>output-size</key>
                                <integer>2097152</integer>
                                <key>output-block-size</key>
                                <integer>65536</integer>
                        </dict>
                </array>
	</dict>
</dict>
</plist>
Index: getdiskrawname.c
===================================================================
RCS file: /cvsroot/src/lib/libutil/getdiskrawname.c,v
retrieving revision 1.6
diff -u -p -u -r1.6 getdiskrawname.c
--- getdiskrawname.c	22 Aug 2019 20:23:43 -0000	1.6
+++ getdiskrawname.c	17 Sep 2019 11:49:44 -0000
@@ -157,6 +157,14 @@ getdiskrawname(char *buf, size_t bufsiz,
 	if (calc_name(buf, bufsiz, name, "r") == -1)
 		return NULL;
 
+	if (stat(buf, &st) == -1)
+		return NULL;
+
+	if (!S_ISCHR(st.st_mode)) {
+		errno = EFTYPE;
+		return NULL;
+	}
+
 	return buf;
 }
 


Home | Main Index | Thread Index | Old Index