HOWTO: Build NSLU2 U-Boot on FreeBSD
Bruce M. Simpson
bms at incunabulum.net
Sat Oct 11 12:19:34 UTC 2008
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.
Recommend getting one like the Olimex OCD as it has heaps more useful
functionality than just rewriting the flash, and should also work with
OpenOCD.
Toolchain setup
cd /usr/ports/devel/cross-binutils
env TGTARCH=arm TGTABI=rtems make install
cd /usr/ports/devel/cross-gcc
env TGTARCH=arm TGTABI=rtems make install
Get stas at 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·
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=arm-rtems- gmake distclean
env CROSS_COMPILE=arm-rtems- gmake nslu2_config
env CROSS_COMPILE=arm-rtems- gmake
Voila, you should have u-boot firmware images, which you can now use to
reflash an NSLU2.
-------------- next part --------------
--- ./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
-------------- next part --------------
--- ./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)
More information about the freebsd-embedded
mailing list