From owner-freebsd-embedded@FreeBSD.ORG Sat Oct 11 12:19:34 2008 Return-Path: Delivered-To: freebsd-embedded@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D4CE51065697 for ; Sat, 11 Oct 2008 12:19:34 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out3.smtp.messagingengine.com (out3.smtp.messagingengine.com [66.111.4.27]) by mx1.freebsd.org (Postfix) with ESMTP id 9756E8FC13 for ; Sat, 11 Oct 2008 12:19:34 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from compute2.internal (compute2.internal [10.202.2.42]) by out1.messagingengine.com (Postfix) with ESMTP id 2AB08179100 for ; Sat, 11 Oct 2008 08:19:34 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute2.internal (MEProxy); Sat, 11 Oct 2008 08:19:34 -0400 X-Sasl-enc: /3agDi35S489LNn5DLc4Hbu7CygLF2UDSAAXaBjwKfvf 1223727573 Received: from [192.168.123.18] (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTPSA id 8B7CC20797 for ; Sat, 11 Oct 2008 08:19:33 -0400 (EDT) Message-ID: <48F099D4.2050302@incunabulum.net> Date: Sat, 11 Oct 2008 13:19:32 +0100 From: "Bruce M. Simpson" User-Agent: Thunderbird 1.5.0.14 (Windows/20071210) MIME-Version: 1.0 To: freebsd-embedded@FreeBSD.org Content-Type: multipart/mixed; boundary="------------000708050906040207060303" Cc: Subject: HOWTO: Build NSLU2 U-Boot on FreeBSD X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Oct 2008 12:19:34 -0000 This is a multi-part message in MIME format. --------------000708050906040207060303 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Thanks to Rink Springer and Rafal Jaworowski. ---------------------- Building NSLU2 U-boot firmware on FreeBSD hosts Quick start Make sure you have a JTAG adapter as a get-out-of-jail-free card in case = you trash the flash, "portinstall devel/urjtag" to get a driver for it.=20 Recommend getting one like the Olimex OCD as it has heaps more useful=20 functionality than just rewriting the flash, and should also work with=20 OpenOCD. Toolchain setup cd /usr/ports/devel/cross-binutils env TGTARCH=3Darm TGTABI=3Drtems make install cd /usr/ports/devel/cross-gcc env TGTARCH=3Darm TGTABI=3Drtems make install Get stas@FreeBSD.org's updated u-boot tarball: uboot-atamantb.tar.bz2 Untar it Fetch NSLU2 patch set from NSLU2-Linux: http://trac.nslu2-linux.org/kernel/browser/trunk/patches/u-boot/0001-ixp-= Support-for-NSLU2.patch Apply (patch -p1) inside uboot-atamantb. Apply Ix*.diff (provided) inside cpu/ixp/npe. U-Boot doesn't grok being built for an RTEMS target, so it needs some sweet lovin'. Fetch encumbered NPE microcode from Intel: http://downloadcenter.intel.com/ Search for IPL_IXP400NPELIBRARY-2_1.ZIP (Yes yes, I know, we can't redistribute it, for now anyway...there will be a workaround) Unzip... Copy ./cpu/ixp/npe/IxNpeMicrocode.c.orig into uboot-atamantb/cpu/ixp/npe=B7= Remove mkimage from tools/Makefile (it needs rentokil to build on FreeBSD= ; and besides, you can use "portinstall devel/u-boot" to get mkimage) Now: env CROSS_COMPILE=3Darm-rtems- gmake distclean env CROSS_COMPILE=3Darm-rtems- gmake nslu2_config env CROSS_COMPILE=3Darm-rtems- gmake Voila, you should have u-boot firmware images, which you can now use to=20 reflash an NSLU2. --------------000708050906040207060303 Content-Type: text/plain; name="IxOsalEndianess.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="IxOsalEndianess.diff" --- ./cpu/ixp/npe/include/IxOsalEndianess.h.orig 2008-10-03 12:11:18.000000000 +0100 +++ ./cpu/ixp/npe/include/IxOsalEndianess.h 2008-10-03 13:11:48.000000000 +0100 @@ -59,6 +59,32 @@ /* get ntohl/ntohs/htohl/htons macros definitions for WinCE */ #include +#elif defined (__rtems__) + +# ifdef htonl +# undef htonl +# endif +# ifdef ntohl +# undef ntohl +# endif + +# if BYTE_ORDER == BIG_ENDIAN + +# define ntohl(a) (a) +# define htonl(a) (a) +# elif BYTE_ORDER == LITTLE_ENDIAN +# define SWAP_LONG(x) \ + ((__u32)( \ + (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ + (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ + (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ + (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) +# define ntohl(a) SWAP_LONG(a) +# define htonl(a) SWAP_LONG(a) +# else +# error meep +# endif + #else #error Unknown OS, please add a section with the include file for htonl/htons/ntohl/ntohs @@ -123,6 +149,14 @@ #define IX_OSAL_WINCE_LE +#elif defined (__rtems__) && defined (__BIG_ENDIAN) + +#define IX_OSAL_LINUX_BE /* XXX */ + +#elif defined (__rtems__) && defined (__BIG_ENDIAN) + +#define IX_OSAL_LINUX_LE /* XXX */ + #else #error Unknown OS/Endianess combination - only vxWorks BE LE, Linux BE LE, WinCE BE LE are supported --------------000708050906040207060303 Content-Type: text/plain; name="IxOsalMemAccess.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="IxOsalMemAccess.diff" --- ./cpu/ixp/npe/include/IxOsalMemAccess.h.orig 2008-10-03 13:24:52.000000000 +0100 +++ ./cpu/ixp/npe/include/IxOsalMemAccess.h 2008-10-03 13:26:07.000000000 +0100 @@ -324,7 +324,9 @@ #endif /* wince */ -#if defined (__vxworks) || (defined (__linux) && defined (IX_OSAL_STATIC_MEMORY_MAP)) || \ +#if defined (__vxworks) || \ + defined (__rtems__) || \ + (defined (__linux) && defined (IX_OSAL_STATIC_MEMORY_MAP)) || \ (defined (__wince) && defined (IX_OSAL_STATIC_MEMORY_MAP)) #define IX_OSAL_READ_LONG_IO(wAddr) IX_OSAL_READ_LONG_RAW(wAddr) --------------000708050906040207060303--