summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHamish Guthrie <hcg@openwrt.org>2007-04-05 13:23:15 +0000
committerHamish Guthrie <hcg@openwrt.org>2007-04-05 13:23:15 +0000
commit9a8ff3b05d3e35ba34e6e6b5cd17c9134a1cc8db (patch)
treec0d7d521399f4958b7aa2ecead7eeeb2c44033b7
parenta726e63349ad149f9529cd7d91e4d44097f79451 (diff)
downloadmtk-20170518-9a8ff3b05d3e35ba34e6e6b5cd17c9134a1cc8db.zip
mtk-20170518-9a8ff3b05d3e35ba34e6e6b5cd17c9134a1cc8db.tar.gz
mtk-20170518-9a8ff3b05d3e35ba34e6e6b5cd17c9134a1cc8db.tar.bz2
Added module to generate u-boot config file. Added platform overrides for base files.
SVN-Revision: 6870
-rw-r--r--target/linux/at91-2.6/base-files/default/etc/inittab5
-rwxr-xr-xtarget/linux/at91-2.6/base-files/default/sbin/ubpar0
-rw-r--r--target/linux/at91-2.6/image/u-boot/Makefile9
-rw-r--r--target/linux/at91-2.6/image/u-boot/ubclient/Makefile15
-rw-r--r--target/linux/at91-2.6/image/u-boot/ubclient/ubpar.c125
5 files changed, 153 insertions, 1 deletions
diff --git a/target/linux/at91-2.6/base-files/default/etc/inittab b/target/linux/at91-2.6/base-files/default/etc/inittab
new file mode 100644
index 0000000..c1b9cd7
--- /dev/null
+++ b/target/linux/at91-2.6/base-files/default/etc/inittab
@@ -0,0 +1,5 @@
+::sysinit:/etc/init.d/rcS
+tts/0::askfirst:/bin/ash --login
+ttyS0::askfirst:/bin/ash --login
+
+ttyS2::respawn:/sbin/getty -L ttyS2 115200 vt100
diff --git a/target/linux/at91-2.6/base-files/default/sbin/ubpar b/target/linux/at91-2.6/base-files/default/sbin/ubpar
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/target/linux/at91-2.6/base-files/default/sbin/ubpar
diff --git a/target/linux/at91-2.6/image/u-boot/Makefile b/target/linux/at91-2.6/image/u-boot/Makefile
index 4584f20..35b1e9b 100644
--- a/target/linux/at91-2.6/image/u-boot/Makefile
+++ b/target/linux/at91-2.6/image/u-boot/Makefile
@@ -27,11 +27,18 @@ define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) $(UBOOT_CONFIG)_config
export CROSS_COMPILE=$(TARGET_CROSS); \
$(MAKE) -C $(PKG_BUILD_DIR)
+ mkdir -p $(PKG_BUILD_DIR)/ubclient
+ $(CP) ./ubclient/* $(PKG_BUILD_DIR)/ubclient
+ $(MAKE) -C $(PKG_BUILD_DIR)/ubclient \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS) -Dtarget_$(BOARD)=1"
endef
define Build/InstallDev
dd if=$(PKG_BUILD_DIR)/u-boot.bin of=$(PKG_BUILD_DIR)/u-boot.block bs=232k count=1 conv=sync
-# mv $(PKG_BUILD_DIR) $(KERNEL_BUILD_DIR)/$(PKG_NAME)
+# $(INSTALL_DIR) $(STAGING_DIR)/ubclient/sbin
+# $(INSTALL_BIN) $(PKG_BUILD_DIR)/ubclient/ubpar $(STAGING_DIR)/ubclient/sbin/
+ $(CP) $(PKG_BUILD_DIR)/ubclient/ubpar ../../base-files/default/sbin
endef
$(eval $(call Build/DefaultTargets))
diff --git a/target/linux/at91-2.6/image/u-boot/ubclient/Makefile b/target/linux/at91-2.6/image/u-boot/ubclient/Makefile
new file mode 100644
index 0000000..c79260e
--- /dev/null
+++ b/target/linux/at91-2.6/image/u-boot/ubclient/Makefile
@@ -0,0 +1,15 @@
+#
+
+all: ubpar
+
+crc32.c:
+ ln -s ../lib_generic/crc32.c ./
+
+%.o: %.c
+ $(CC) -I ../include $(CFLAGS) $(EXTRA_FLAGS) -c -o $@ $^
+
+ubpar: ubpar.o crc32.o
+ $(CC) -o $@ $^
+
+clean:
+ rm -f *.o ubpar
diff --git a/target/linux/at91-2.6/image/u-boot/ubclient/ubpar.c b/target/linux/at91-2.6/image/u-boot/ubclient/ubpar.c
new file mode 100644
index 0000000..e1e9e37
--- /dev/null
+++ b/target/linux/at91-2.6/image/u-boot/ubclient/ubpar.c
@@ -0,0 +1,125 @@
+/*
+ * ubparams.c
+ *
+ * Generate a u-boot parameter block with correct crc
+ *
+ * (C) 1007 Guthrie Consulting
+ * hamish@prodigi.ch
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef __ASSEMBLY__
+#define __ASSEMBLY__
+#endif
+#define __ASM_STUB_PROCESSOR_H__
+#include <config.h>
+#undef __ASSEMBLY__
+#include <environment.h>
+
+#define XMK_STR(x) #x
+#define MK_STR(x) XMK_STR(x)
+
+extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned int);
+
+#if !defined(ENV_CRC)
+#define ENV_CRC ~0
+#endif
+
+static char *environment[] = {
+ "bootdelay=3\0"
+ "baudrate=115200\0"
+ "stdin=serial\0"
+ "stdout=serial\0"
+ "stderr=serial\0"
+ "partitions=mtdparts=AT45DB642.spi0:132k(bootloader),33k(ubparams),99k(spare),1056k(linux),1056k(rootfs),33k(nvram),-(rootfs_data)\0"
+ "fbargs=setenv bootargs mtdparts=AT45DB642.spi0:132k(bootloader),33k(ubparams),99k(spare),1056k(linux),1056k(rootfs),33k(nvram),-(rootfs_data) root=/dev/mtdblock4 ro init=/etc/preinit console=/dev/ttyS0,115200,mem=32M\0"
+ "rdba=setenv bootargs mtdparts=AT45DB642.spi0:132k(bootloader),33k(ubparams),99k(spare),1056k(linux),1056k(rootfs),33k(nvram),-(rootfs_data) root=/dev/ram rw initrd=0x21200000,6000000 ramdisk_size=20000 init=/etc/preinit console=/dev/ttyS0,115200,mem=32M\0"
+ "rdram=run rdba; tftp 21000000 vImage; tftp 21200000 root.squashfs; bootm 21000000\0"
+ "flash=run fbargs; bootm 0xc0042000\0"
+ "bootargs=setenv bootargs mtdparts=AT45DB642.spi0:132k(bootloader),33k(ubparams),99k(spare),1056k(linux),1056k(rootfs),33k(nvram),-(rootfs_data) root=/dev/mtdblock4 ro init=/etc/preinit console=/dev/ttyS0,115200,mem=32M\0"
+ "bootcmd=bootm 0xc0042000\0"
+ "ipaddr=10.0.1.73\0"
+ "serverip=10.0.1.210\0"
+ "\0"
+ };
+
+int main(int argc, char *argv[]) {
+ env_t *envptr;
+ char *src, *srcptr;
+ char *dataptr;
+ FILE *params;
+ int argfail = 1;
+ char newmac[30];
+ char newser[30];
+ int paramlen = 0;
+ int progmac = 0;
+ int progser = 0;
+
+ if (argc < 3) {
+ printf ("Invalid arguments\n");
+ return 1;
+ }
+
+ switch (argc) {
+ case 5:
+ if (strcmp(argv[3], "--serial") == 0) {
+ argfail = 0;
+ sprintf(newser, "serial#=%s", argv[4]);
+ progser = 1;
+ }
+ case 3:
+ if (strcmp(argv[1], "--mac") == 0) {
+ argfail = 0;
+ sprintf(newmac, "ethaddr=%s", argv[2]);
+ progmac = 1;
+ }
+ else
+ argfail = 1;
+ }
+
+ if (argfail) {
+ printf("Invalid arguments\n");
+ return 1;
+ }
+
+
+ src = srcptr = *environment;
+ envptr = (env_t *)malloc(CFG_ENV_SIZE);
+ dataptr = (char *)envptr + ENV_HEADER_SIZE;
+
+ while(*srcptr) {
+ //printf("%d, %s\n", strlen(srcptr), srcptr);
+ paramlen += strlen(srcptr) + 1;
+ srcptr += strlen(srcptr) + 1;
+ }
+
+ printf("Make u-boot params\n");
+ printf("Params size is %d\n", CFG_ENV_SIZE);
+
+ memset(envptr, 0, CFG_ENV_SIZE);
+ memcpy(dataptr, src, paramlen);
+ dataptr += paramlen;
+
+ if (progmac) {
+ memcpy(dataptr, newmac, strlen(newmac));
+ dataptr += strlen(newmac) + 1;
+ }
+
+ if (progser) {
+ memcpy(dataptr, newser, strlen(newser));
+ dataptr += strlen(newser) + 1;
+ }
+
+ envptr->crc = crc32(0, envptr->data, ENV_SIZE);
+
+ params = fopen("params", "w");
+ fwrite(envptr, CFG_ENV_SIZE, 1, params);
+ fclose(params);
+
+ free(envptr);
+ return 0;
+}