[PATCH 2/2] setser: new command to set serial number on ARM

Baruch Siach baruch at tkos.co.il
Thu Aug 5 07:23:18 EDT 2010


Signed-off-by: Baruch Siach <baruch at tkos.co.il>
---
 commands/Kconfig  |    8 ++++++++
 commands/Makefile |    1 +
 commands/setser.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 0 deletions(-)
 create mode 100644 commands/setser.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 1ffc826..9d11a8b 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -231,6 +231,14 @@ config CMD_BOOTU
 	   compile in the 'bootu' command to start raw (uncompressed)
 	   Linux images
 
+config CMD_SETSER
+	tristate
+	depends on ARM
+	prompt "setser"
+	help
+	  compile in the 'setser' command to set the 64bit serial number to be 
+	  passed to the Linux kernel upon boot
+
 config CMD_LINUX16
 	tristate
 	default y if X86
diff --git a/commands/Makefile b/commands/Makefile
index b99f042..276af85 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
+obj-$(CONFIG_CMD_SETSER)	+= setser.o
 obj-$(CONFIG_CMD_LINUX16)	+= linux16.o
 obj-$(CONFIG_CMD_LOADB)		+= loadb.o xyzModem.o
 obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o
diff --git a/commands/setser.c b/commands/setser.c
new file mode 100644
index 0000000..ef4fb0a
--- /dev/null
+++ b/commands/setser.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010 Baruch Siach <baruch at tkos.co.il>,
+ *	Orex Computed Radiography
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <common.h>
+#include <command.h>
+#include <asm/armlinux.h>
+#include <asm/byteorder.h>
+
+static int do_setser(struct command *cmdtp, int argc, char *argv[])
+{
+	int ret;
+	u8 buf[8];
+
+	if (argc != 2)
+		return COMMAND_ERROR_USAGE;
+
+	ret = string_to_bin(argv[1], buf, 8);
+	if (ret < 0)
+		return COMMAND_ERROR_USAGE;
+
+	armlinux_set_serial(be64_to_cpup((u64 *)buf));
+
+	return 0;
+}
+
+static const __maybe_unused char cmd_setser_help[] =
+"Usage: setser xx:xx:xx:xx:xx:xx:xx:xx\n"
+"Set 64bit serial number to pass to the Linux kernel\n";
+
+BAREBOX_CMD_START(setser)
+	.cmd	= do_setser,
+	.usage	= "set serial number",
+	BAREBOX_CMD_HELP(cmd_setser_help)
+BAREBOX_CMD_END
-- 
1.7.1




More information about the barebox mailing list