aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/flashing/flash.sh
blob: 8841c3568464932c88da8ddd3890f1395690ad72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
#
# tftp flash script for wireless routers 
#
# Copyright (C) 2004 by Oleg I. Vdovikin <oleg@cs.msu.su>
# Copyright (C) 2005 by Waldemar Brodkorb <wbx@openwrt.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

if [ -z "$1" ] || [ ! -f $1 ] || [ -z $2 ]; then
    echo Usage: $0 firmware vendor
cat << EOF
IMPORTANT:
Notes for Linksys / Asus WL500gx router: 
   be sure you have set boot_wait to yes. Power on your router
   after executing this script.
 
Notes for Asus WL500g router:
   be sure POWER led is flashing (If this is not the case
   poweroff the device, push the reset button & power on
   it again, then release button)

1) connect your pc to the LAN port
2) be sure your link is up and has an address in the
   192.168.1.0/24 address range (and not the 192.168.1.1)

Notes for Toshiba router:
   boot_wait is enabled by default on these units.

1) connect your pc to any of the four LAN ports
2) be sure your link is up and has an address in the
   192.168.10.1/24 address range (and not the 192.168.10.1)
3) run this script (unit will only accept .trx images)
4) Turn unit power on.

EOF
    exit 0
fi
if [ "$2" == "asus" ]; then
echo Confirming IP address setting...
echo -en "get ASUSSPACELINK\x01\x01\xa8\xc0 /dev/null\nquit\n" | tftp 192.168.1.1
echo Flashing 192.168.1.1 using $1...
echo -en "binary\nput $1 ASUSSPACELINK\nquit\n" | tftp 192.168.1.1
echo Please wait until leds stops flashing. 
elif [ "$2" == "linksys" ]; then
echo Flashing 192.168.1.1 using $1...
echo -en "rexmt 1\ntrace\nbinary\nput $1\nquit\n" | tftp 192.168.1.1
echo Please wait until power led stops flashing. Do not poweroff! Then you can login via telnet 192.168.1.1.
elif [ "$2" == "toshiba" ]; then
echo Flashing 192.168.10.1 using $1...
echo -en "rexmt 1\ntrace\nbinary\nput $1\nquit\n" | tftp 192.168.10.1
echo Unit will automatically reboot within 5 minutes.  Do not power off.  Then you can login via telnet 192.168.10.1.
fi
5 files changed, 43 insertions(+), 9 deletions(-) --- a/include/linux/module.h +++ b/include/linux/module.h @@ -158,6 +158,7 @@ extern void cleanup_module(void); /* Generic info of form tag = "info" */ #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info) +#define MODULE_INFO_STRIP(tag, info) __MODULE_INFO_STRIP(tag, tag, info) /* For userspace: you can also call me... */ #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias) @@ -201,12 +202,12 @@ extern void cleanup_module(void); * Author(s), use "Name <email>" or just "Name", for multiple * authors use multiple MODULE_AUTHOR() statements/lines. */ -#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author) +#define MODULE_AUTHOR(_author) MODULE_INFO_STRIP(author, _author) /* What your module does. */ -#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) +#define MODULE_DESCRIPTION(_description) MODULE_INFO_STRIP(description, _description) -#ifdef MODULE +#if defined(MODULE) && !defined(CONFIG_MODULE_STRIPPED) /* Creates an alias so file2alias.c can find device table. */ #define MODULE_DEVICE_TABLE(type, name) \ extern typeof(name) __mod_##type##__##name##_device_table \ @@ -233,7 +234,9 @@ extern typeof(name) __mod_##type##__##na */ #if defined(MODULE) || !defined(CONFIG_SYSFS) -#define MODULE_VERSION(_version) MODULE_INFO(version, _version) +#define MODULE_VERSION(_version) MODULE_INFO_STRIP(version, _version) +#elif defined(CONFIG_MODULE_STRIPPED) +#define MODULE_VERSION(_version) __MODULE_INFO_DISABLED(version) #else #define MODULE_VERSION(_version) \ static struct module_version_attribute ___modver_attr = { \ @@ -255,7 +258,7 @@ extern typeof(name) __mod_##type##__##na /* Optional firmware file (or files) needed by the module * format is simply firmware file name. Multiple firmware * files require multiple MODULE_FIRMWARE() specifiers */ -#define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware) +#define MODULE_FIRMWARE(_firmware) MODULE_INFO_STRIP(firmware, _firmware) struct notifier_block; --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -17,6 +17,16 @@ /* Chosen so that structs with an unsigned long line up. */ #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long)) +/* This struct is here for syntactic coherency, it is not used */ +#define __MODULE_INFO_DISABLED(name) \ + struct __UNIQUE_ID(name) {} + +#ifdef CONFIG_MODULE_STRIPPED +#define __MODULE_INFO_STRIP(tag, name, info) __MODULE_INFO_DISABLED(name) +#else +#define __MODULE_INFO_STRIP(tag, name, info) __MODULE_INFO(tag, name, info) +#endif + #ifdef MODULE #define __MODULE_INFO(tag, name, info) \ static const char __UNIQUE_ID(name)[] \ @@ -24,8 +34,7 @@ static const char __UNIQUE_ID(name)[] = __stringify(tag) "=" info #else /* !MODULE */ /* This struct is here for syntactic coherency, it is not used */ -#define __MODULE_INFO(tag, name, info) \ - struct __UNIQUE_ID(name) {} +#define __MODULE_INFO(tag, name, info) __MODULE_INFO_DISABLED(name) #endif #define __MODULE_PARM_TYPE(name, _type) \ __MODULE_INFO(parmtype, name##type, #name ":" _type) @@ -33,7 +42,7 @@ static const char __UNIQUE_ID(name)[] /* One for each parameter, describing how to use it. Some files do multiple of these per line, so can't just use MODULE_INFO. */ #define MODULE_PARM_DESC(_parm, desc) \ - __MODULE_INFO(parm, _parm, #_parm ":" desc) + __MODULE_INFO_STRIP(parm, _parm, #_parm ":" desc) struct kernel_param; --- a/init/Kconfig +++ b/init/Kconfig @@ -1903,6 +1903,13 @@ config TRIM_UNUSED_KSYMS If unsure, or if you need to build out-of-tree modules, say N. +config MODULE_STRIPPED + bool "Reduce module size" + depends on MODULES + help + Remove module parameter descriptions, author info, version, aliases, + device tables, etc. + endif # MODULES config MODULES_TREE_LOOKUP --- a/kernel/module.c +++ b/kernel/module.c @@ -3022,9 +3022,11 @@ static struct module *setup_load_info(st static int check_modinfo(struct module *mod, struct load_info *info, int flags) { - const char *modmagic = get_modinfo(info, "vermagic"); int err; +#ifndef CONFIG_MODULE_STRIPPED + const char *modmagic = get_modinfo(info, "vermagic"); + if (flags & MODULE_INIT_IGNORE_VERMAGIC) modmagic = NULL; @@ -3045,6 +3047,7 @@ static int check_modinfo(struct module * mod->name); add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK); } +#endif check_modinfo_retpoline(mod, info); --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1996,7 +1996,9 @@ static void read_symbols(char *modname) symname = remove_dot(info.strtab + sym->st_name); handle_modversions(mod, &info, sym, symname); +#ifndef CONFIG_MODULE_STRIPPED handle_moddevtable(mod, &info, sym, symname); +#endif } if (!is_vmlinux(modname) || (is_vmlinux(modname) && vmlinux_section_warnings)) @@ -2157,8 +2159,10 @@ static void add_header(struct buffer *b, buf_printf(b, "#include <linux/vermagic.h>\n"); buf_printf(b, "#include <linux/compiler.h>\n"); buf_printf(b, "\n"); +#ifndef CONFIG_MODULE_STRIPPED buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n"); buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n"); +#endif buf_printf(b, "\n"); buf_printf(b, "__visible struct module __this_module\n"); buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n"); @@ -2175,8 +2179,10 @@ static void add_header(struct buffer *b, static void add_intree_flag(struct buffer *b, int is_intree) { +#ifndef CONFIG_MODULE_STRIPPED if (is_intree) buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n"); +#endif } /* Cannot check for assembler */ @@ -2189,10 +2195,12 @@ static void add_retpoline(struct buffer static void add_staging_flag(struct buffer *b, const char *name) { +#ifndef CONFIG_MODULE_STRIPPED static const char *staging_dir = "drivers/staging"; if (strncmp(staging_dir, name, strlen(staging_dir)) == 0) buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); +#endif } /** @@ -2291,11 +2299,13 @@ static void add_depends(struct buffer *b static void add_srcversion(struct buffer *b, struct module *mod) { +#ifndef CONFIG_MODULE_STRIPPED if (mod->srcversion[0]) { buf_printf(b, "\n"); buf_printf(b, "MODULE_INFO(srcversion, \"%s\");\n", mod->srcversion); } +#endif } static void write_if_changed(struct buffer *b, const char *fname) @@ -2532,7 +2542,9 @@ int main(int argc, char **argv) add_staging_flag(&buf, mod->name); err |= add_versions(&buf, mod); add_depends(&buf, mod, modules); +#ifndef CONFIG_MODULE_STRIPPED add_moddevtable(&buf, mod); +#endif add_srcversion(&buf, mod); sprintf(fname, "%s.mod.c", mod->name);