Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Oct 2008 13:19:32 +0100
From:      "Bruce M. Simpson" <bms@incunabulum.net>
To:        freebsd-embedded@FreeBSD.org
Subject:   HOWTO: Build NSLU2 U-Boot on FreeBSD
Message-ID:  <48F099D4.2050302@incunabulum.net>

next in thread | raw e-mail | index | archive | help
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 <Winsock2.h>
 
+#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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48F099D4.2050302>