aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/ipaccess
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2009-12-28 03:11:33 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2009-12-28 09:05:15 +0100
commitf413a0811a608d4f7eaabdf343683422940ccc44 (patch)
treeacd8f65b88b65361778dbf31b7c6817d4096999f /openbsc/src/ipaccess
parent30b9ecda334693a3ae1157254bf90d7347f7900c (diff)
[ipaccess] Add firmware download option to ipaccess-config
This will mostly work like the downloading in bs11_config and is based on the bs11_config state machine as well. Once it is working we can see how to unite both implementations.
Diffstat (limited to 'openbsc/src/ipaccess')
-rw-r--r--openbsc/src/ipaccess/ipaccess-config.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/openbsc/src/ipaccess/ipaccess-config.c b/openbsc/src/ipaccess/ipaccess-config.c
index 7df4cefeb..c0fc2c469 100644
--- a/openbsc/src/ipaccess/ipaccess-config.c
+++ b/openbsc/src/ipaccess/ipaccess-config.c
@@ -1,6 +1,8 @@
/* ip.access nanoBTS configuration tool */
/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2009 by Holger Hans Peter Freyther
+ * (C) 2009 by On Waves
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@@ -48,6 +50,7 @@ static char *prim_oml_ip;
static char *unit_id;
static u_int16_t nv_flags;
static u_int16_t nv_mask;
+static char *software = NULL;
/*
static u_int8_t prim_oml_attr[] = { 0x95, 0x00, 7, 0x88, 192, 168, 100, 11, 0x00, 0x00 };
@@ -164,6 +167,58 @@ static int nm_sig_cb(unsigned int subsys, unsigned int signal,
return 0;
}
+/* callback function passed to the ABIS OML code */
+static int percent;
+static int percent_old;
+static int swload_cbfn(unsigned int hook, unsigned int event, struct msgb *msg,
+ void *data, void *param)
+{
+ struct gsm_bts *bts;
+
+ if (hook != GSM_HOOK_NM_SWLOAD)
+ return 0;
+
+ bts = (struct gsm_bts *) data;
+
+ switch (event) {
+ case NM_MT_LOAD_INIT_ACK:
+ fprintf(stdout, "Software Load Initiate ACK\n");
+ break;
+ case NM_MT_LOAD_INIT_NACK:
+ fprintf(stderr, "ERROR: Software Load Initiate NACK\n");
+ exit(5);
+ break;
+ case NM_MT_LOAD_END_ACK:
+ fprintf(stderr, "LOAD END ACK...");
+#if 0
+ if (data) {
+ /* we did a safety load and must activate it */
+ abis_nm_software_activate(g_bts, fname_safety,
+ swload_cbfn, bts);
+ sleep(5);
+ }
+#endif
+ break;
+ case NM_MT_LOAD_END_NACK:
+ fprintf(stderr, "ERROR: Software Load End NACK\n");
+ exit(3);
+ break;
+ case NM_MT_ACTIVATE_SW_NACK:
+ fprintf(stderr, "ERROR: Activate Software NACK\n");
+ exit(4);
+ break;
+ case NM_MT_ACTIVATE_SW_ACK:
+ break;
+ case NM_MT_LOAD_SEG_ACK:
+ percent = abis_nm_software_load_status(bts);
+ if (percent > percent_old)
+ printf("Software Download Progress: %d%%\n", percent);
+ percent_old = percent;
+ break;
+ }
+ return 0;
+}
+
static void bootstrap_om(struct gsm_bts *bts)
{
int len;
@@ -226,6 +281,16 @@ static void bootstrap_om(struct gsm_bts *bts)
printf("restarting BTS\n");
abis_nm_ipaccess_restart(bts);
}
+
+ if (software) {
+ int rc;
+ printf("Attempting software upload with '%s'\n", software);
+ rc = abis_nm_software_load(bts, software, 19, 0, swload_cbfn, bts);
+ if (rc < 0) {
+ fprintf(stderr, "Failed to start software load\n");
+ exit(-3);
+ }
+ }
}
void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx)
@@ -310,9 +375,10 @@ int main(int argc, char **argv)
{ "help", 0, 0, 'h' },
{ "listen", 1, 0, 'l' },
{ "stream-id", 1, 0, 's' },
+ { "software", 1, 0, 'd' },
};
- c = getopt_long(argc, argv, "u:o:rn:l:hs:", long_options,
+ c = getopt_long(argc, argv, "u:o:rn:l:hs:d:", long_options,
&option_index);
if (c == -1)
@@ -343,6 +409,9 @@ int main(int argc, char **argv)
case 's':
stream_id = atoi(optarg);
break;
+ case 'd':
+ software = strdup(optarg);
+ break;
case 'h':
print_usage();
print_help();