Send commitlog mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r1312 - trunk/src/target/u-boot/patches ([EMAIL PROTECTED])
   2. r1313 - trunk/src/target/gsm/src/gsmd ([EMAIL PROTECTED])
   3. r1314 - in trunk/src/target/gsm: include/gsmd include/libgsmd
      src/gsmd src/libgsmd src/util ([EMAIL PROTECTED])
--- Begin Message ---
Author: werner
Date: 2007-03-10 02:42:26 +0100 (Sat, 10 Mar 2007)
New Revision: 1312

Modified:
   trunk/src/target/u-boot/patches/uboot-dfu.patch
Log:
drivers/usbdfu.c (handle_dnload): "nand erase clear" the end of the rootfs
  partition



Modified: trunk/src/target/u-boot/patches/uboot-dfu.patch
===================================================================
--- trunk/src/target/u-boot/patches/uboot-dfu.patch     2007-03-09 20:21:08 UTC 
(rev 1311)
+++ trunk/src/target/u-boot/patches/uboot-dfu.patch     2007-03-10 01:42:26 UTC 
(rev 1312)
@@ -99,7 +99,7 @@
 ===================================================================
 --- /dev/null
 +++ u-boot/drivers/usbdfu.c
-@@ -0,0 +1,1014 @@
+@@ -0,0 +1,1042 @@
 +/*
 + * (C) 2007 by OpenMoko, Inc.
 + * Author: Harald Welte <[EMAIL PROTECTED]>
@@ -317,6 +317,29 @@
 +      return RET_NOTHING;
 +}
 +
++static int erase_tail_clean_nand(struct urb *urb, struct dnload_state *ds)
++{
++      struct usb_device_instance *dev = urb->device;
++      int rc;
++
++      ds->erase_opts.offset = ds->off;
++      ds->erase_opts.length = ds->part->size-ds->off;
++      debug("Erasing 0x%x bytes @ offset 0x%x (jffs=%u)\n",
++              ds->erase_opts.length, ds->erase_opts.offset,
++              ds->erase_opts.jffs2);
++      rc = nand_erase_opts(ds->nand, &ds->erase_opts);
++      if (rc) {
++              debug("Error erasing\n");
++              dev->dfu_state = DFU_STATE_dfuERROR;
++              dev->dfu_status = DFU_STATUS_errERASE;
++              return RET_STALL;
++      }
++
++      ds->off += ds->part->size; /* for consistency */
++
++      return RET_NOTHING;
++}
++
 +/* Read the next erase blcok from NAND into buffer */
 +static int read_next_nand(struct urb *urb, struct dnload_state *ds)
 +{
@@ -396,10 +419,15 @@
 +                      ds->ptr = ds->buf = ds->_buf;
 +                      break;
 +              default:
++                      rc = 0;
 +                      if (ds->ptr > ds->buf)
 +                              rc = erase_flash_verify_nand(urb, ds,
 +                                                      ds->nand->erasesize,
 +                                                      ds->nand->erasesize);
++                      /* rootfs partition */
++                      if (!rc && dev->alternate == 5)
++                              rc = erase_tail_clean_nand(urb, ds);
++
 +                      ds->nand = NULL;
 +                      break;
 +              }




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-03-10 03:21:28 +0100 (Sat, 10 Mar 2007)
New Revision: 1313

Modified:
   trunk/src/target/gsm/src/gsmd/atcmd.c
Log:
* deal correctly with 'gsm power cycling'
* consider % as prefix for extended response, even though non-standard


Modified: trunk/src/target/gsm/src/gsmd/atcmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/atcmd.c       2007-03-10 01:42:26 UTC (rev 
1312)
+++ trunk/src/target/gsm/src/gsmd/atcmd.c       2007-03-10 02:21:28 UTC (rev 
1313)
@@ -176,8 +176,11 @@
        int rc = 0, final = 0;
 
        DEBUGP("buf=`%s'(%d)\n", buf, len);
-       
-       if (!strcmp(buf, "AT-Command Interpreter ready")) {
+
+       /* FIXME: This needs to be part of the vendor plugin. If we receive
+        * an empty string or that 'ready' string, we need to init the modem */
+       if (strlen(buf) == 0 ||
+           !strcmp(buf, "AT-Command Interpreter ready")) {
                gsmd_initsettings(g);
                return 0;
        }
@@ -239,7 +242,7 @@
                }
 
                if (cmd) {
-                       if (cmd->buf[2] != '+') {
+                       if (cmd->buf[2] != '+' && cmd->buf[2] != '%') {
                                gsmd_log(GSMD_ERROR, "extd reply to non-extd 
command?\n");
                                return -EINVAL;
                        }




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-03-10 03:22:04 +0100 (Sat, 10 Mar 2007)
New Revision: 1314

Added:
   trunk/src/target/gsm/include/libgsmd/pin.h
   trunk/src/target/gsm/src/libgsmd/libgsmd_pin.c
Modified:
   trunk/src/target/gsm/include/gsmd/usock.h
   trunk/src/target/gsm/include/libgsmd/libgsmd.h
   trunk/src/target/gsm/src/gsmd/usock.c
   trunk/src/target/gsm/src/gsmd/vendor_ti.c
   trunk/src/target/gsm/src/libgsmd/Makefile.am
   trunk/src/target/gsm/src/libgsmd/libgsmd.c
   trunk/src/target/gsm/src/util/pin.c
Log:
* properly implement PIN/PUK handling throughout gsmd/libgsmd/util


Modified: trunk/src/target/gsm/include/gsmd/usock.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/usock.h   2007-03-10 02:21:28 UTC (rev 
1313)
+++ trunk/src/target/gsm/include/gsmd/usock.h   2007-03-10 02:22:04 UTC (rev 
1314)
@@ -86,6 +86,13 @@
        struct gsmd_addr addr;
 } __attribute__ ((packed));
 
+#define GSMD_PIN_MAXLEN                8
+struct gsmd_pin {
+       enum gsmd_pin_type type;
+       char pin[GSMD_PIN_MAXLEN+1];
+       char newpin[GSMD_PIN_MAXLEN+1];
+} __attribute__ ((packed));
+
 struct gsmd_evt_auxdata {
        union {
                struct {

Modified: trunk/src/target/gsm/include/libgsmd/libgsmd.h
===================================================================
--- trunk/src/target/gsm/include/libgsmd/libgsmd.h      2007-03-10 02:21:28 UTC 
(rev 1313)
+++ trunk/src/target/gsm/include/libgsmd/libgsmd.h      2007-03-10 02:22:04 UTC 
(rev 1314)
@@ -63,5 +63,7 @@
 extern int lgsm_passthrough(struct lgsm_handle *lh, const char *tx, char *rx, 
unsigned int *rx_len);
 extern int lgsm_subscriptions(struct lgsm_handle *lh, u_int32_t subscriptions);
 
-extern int lgsm_pin(struct lgsm_handle *lh, char *pin);
+extern struct gsmd_msg_hdr *lgsm_gmh_fill(int type, int subtype, int 
payload_len);
+extern int lgsm_send(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh);
+
 #endif

Added: trunk/src/target/gsm/include/libgsmd/pin.h
===================================================================
--- trunk/src/target/gsm/include/libgsmd/pin.h  2007-03-10 02:21:28 UTC (rev 
1313)
+++ trunk/src/target/gsm/include/libgsmd/pin.h  2007-03-10 02:22:04 UTC (rev 
1314)
@@ -0,0 +1,8 @@
+#ifndef _LGSM_PIN_H
+#define _LGSM_PIN_H
+
+extern const char *lgsm_pin_name(enum gsmd_pin_type ptype);
+
+extern int lgsm_pin(struct lgsm_handle *lh, unsigned int type, char *pin, char 
*newpin);
+
+#endif

Modified: trunk/src/target/gsm/src/gsmd/usock.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/usock.c       2007-03-10 02:21:28 UTC (rev 
1313)
+++ trunk/src/target/gsm/src/gsmd/usock.c       2007-03-10 02:22:04 UTC (rev 
1314)
@@ -38,6 +38,7 @@
 #include <gsmd/atcmd.h>
 #include <gsmd/usock.h>
 #include <gsmd/talloc.h>
+#include <gsmd/ts0707.h>
 
 static void *__ucmd_ctx, *__gu_ctx;
 
@@ -173,13 +174,37 @@
        return 0;
 }
 
+/* PIN command callback. Gets called for response to AT+CPIN cmcd */
+static int pin_cmd_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+       gsmd_log(GSMD_DEBUG, "pin cmd cb\n");
+
+       /* We need to verify if there is some error */
+       switch (cmd->ret) {
+       case 0:
+               break;
+       case GSM0707_CME_INCORRECT_PASSWORD:
+               /* prompt for pin again */
+               break;
+       default:        
+               /* something went wrong */
+               break;
+       }
+       return 0;
+}
+
 static int usock_rcv_pin(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, 
                         int len)
 {
-       u_int8_t *pin = (u_int8_t *)gph + sizeof(*gph);
-       int pin_len = len - sizeof(*gph);
+       struct gsmd_pin *gp = (struct gsmd_pin *) ((void *)gph + sizeof(*gph));
        struct gsmd_atcmd *cmd;
 
+       if (gph->len < sizeof(*gp) || len < sizeof(*gp)+sizeof(*gph))
+               return -EINVAL;
+
+       gsmd_log(GSMD_DEBUG, "pin type=%u, pin='%s', newpin='%s'\n",
+                gp->type, gp->pin, gp->newpin);
+
        switch (gph->msg_subtype) {
        case GSMD_PIN_INPUT:
                /* FIXME */
@@ -190,12 +215,23 @@
                return -EINVAL;
        }
 
-       cmd = atcmd_fill("AT+CPIN=\"", 9+1+1+strlen(pin),
-                        &null_cmd_cb, gu, 0);
+       cmd = atcmd_fill("AT+CPIN=\"", 9+GSMD_PIN_MAXLEN+3+GSMD_PIN_MAXLEN+2,
+                        &pin_cmd_cb, gu, 0);
        if (!cmd)
                return -ENOMEM;
 
-       strcat(cmd->buf, pin);
+       strcat(cmd->buf, gp->pin);
+
+       switch (gp->type) {
+       case GSMD_PIN_SIM_PUK:
+       case GSMD_PIN_SIM_PUK2:
+               strcat(cmd->buf, "\",\"");
+               strcat(cmd->buf, gp->newpin);
+               break;
+       default:
+               break;
+       }
+
        strcat(cmd->buf, "\"");
 
        return atcmd_submit(gu->gsmd, cmd);

Modified: trunk/src/target/gsm/src/gsmd/vendor_ti.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/vendor_ti.c   2007-03-10 02:21:28 UTC (rev 
1313)
+++ trunk/src/target/gsm/src/gsmd/vendor_ti.c   2007-03-10 02:22:04 UTC (rev 
1314)
@@ -235,6 +235,11 @@
        /* %CGEV: reports GPRS network events */
 };
 
+static int cpi_detect_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+       
+}
+
 static int ticalypso_detect(struct gsmd *g)
 {
        /* FIXME: do actual detection of vendor if we have multiple vendors */

Modified: trunk/src/target/gsm/src/libgsmd/Makefile.am
===================================================================
--- trunk/src/target/gsm/src/libgsmd/Makefile.am        2007-03-10 02:21:28 UTC 
(rev 1313)
+++ trunk/src/target/gsm/src/libgsmd/Makefile.am        2007-03-10 02:22:04 UTC 
(rev 1314)
@@ -5,6 +5,6 @@
 lib_LTLIBRARIES = libgsmd.la
 
 libgsmd_la_LDFLAGS = -Wc,-nostartfiles -version-info $(LIBVERSION)
-libgsmd_la_SOURCES = libgsmd.c libgsmd_input.c libgsmd_voicecall.c 
libgsmd_passthrough.c libgsmd_event.c libgsmd_phone.c libgsmd_network.c
+libgsmd_la_SOURCES = libgsmd.c libgsmd_input.c libgsmd_voicecall.c 
libgsmd_passthrough.c libgsmd_event.c libgsmd_phone.c libgsmd_network.c 
libgsmd_pin.c
 
 noinst_HEADERS = lgsm_internals.h

Modified: trunk/src/target/gsm/src/libgsmd/libgsmd.c
===================================================================
--- trunk/src/target/gsm/src/libgsmd/libgsmd.c  2007-03-10 02:21:28 UTC (rev 
1313)
+++ trunk/src/target/gsm/src/libgsmd/libgsmd.c  2007-03-10 02:22:04 UTC (rev 
1314)
@@ -197,7 +197,7 @@
        if (!gmh)
                return NULL;
 
-       memset(gmh, 0, sizeof(*gmh));
+       memset(gmh, 0, sizeof(*gmh)+payload_len);
 
        gmh->version = GSMD_PROTO_VERSION;
        gmh->msg_type = type;
@@ -207,21 +207,3 @@
        return gmh;
 }
 
-
-int lgsm_pin(struct lgsm_handle *lh, char *pin)
-{
-       int rc;
-       struct gsmd_msg_hdr *gmh;
-
-       gmh = lgsm_gmh_fill(GSMD_MSG_PIN, GSMD_PIN_INPUT, strlen(pin)+1);
-       if (!gmh)
-               return -ENOMEM;
-
-       gmh->data[0] = '\0';
-       strcat(gmh->data, pin);
-
-       rc = lgsm_send(lh, gmh);
-       free(gmh);
-
-       return rc;
-}

Added: trunk/src/target/gsm/src/libgsmd/libgsmd_pin.c
===================================================================
--- trunk/src/target/gsm/src/libgsmd/libgsmd_pin.c      2007-03-10 02:21:28 UTC 
(rev 1313)
+++ trunk/src/target/gsm/src/libgsmd/libgsmd_pin.c      2007-03-10 02:22:04 UTC 
(rev 1314)
@@ -0,0 +1,78 @@
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <sys/types.h>
+#include <gsmd/event.h>
+#include <libgsmd/libgsmd.h>
+
+static const char *pin_type_names[__NUM_GSMD_PIN] = {
+       [GSMD_PIN_NONE]         = "NONE",
+       [GSMD_PIN_SIM_PIN]      = "SIM PIN",
+       [GSMD_PIN_SIM_PUK]      = "SIM PUK",
+       [GSMD_PIN_PH_SIM_PIN]   = "Phone-to-SIM PIN",
+       [GSMD_PIN_PH_FSIM_PIN]  = "Phone-to-very-first SIM PIN",
+       [GSMD_PIN_PH_FSIM_PUK]  = "Phone-to-very-first SIM PUK",
+       [GSMD_PIN_SIM_PIN2]     = "SIM PIN2",
+       [GSMD_PIN_SIM_PUK2]     = "SIM PUK2",
+       [GSMD_PIN_PH_NET_PIN]   = "Network personalization PIN",
+       [GSMD_PIN_PH_NET_PUK]   = "Network personalizaiton PUK",
+       [GSMD_PIN_PH_NETSUB_PIN]= "Network subset personalisation PIN",
+       [GSMD_PIN_PH_NETSUB_PUK]= "Network subset personalisation PUK",
+       [GSMD_PIN_PH_SP_PIN]    = "Service provider personalisation PIN",
+       [GSMD_PIN_PH_SP_PUK]    = "Service provider personalisation PUK",
+       [GSMD_PIN_PH_CORP_PIN]  = "Corporate personalisation PIN",
+       [GSMD_PIN_PH_CORP_PUK]  = "Corporate personalisation PUK",
+};
+
+const char *lgsm_pin_name(enum gsmd_pin_type ptype)
+{
+       if (ptype >= __NUM_GSMD_PIN)
+               return "unknown";
+
+       return pin_type_names[ptype];
+}
+
+int lgsm_pin(struct lgsm_handle *lh, unsigned int type, char *pin, char 
*newpin)
+{
+       int rc;
+       struct {
+               struct gsmd_msg_hdr gmh;
+               struct gsmd_pin gp;
+       } __attribute__ ((packed)) *gm;
+
+       if (strlen(pin) > GSMD_PIN_MAXLEN || 
+           (newpin && strlen(newpin) > GSMD_PIN_MAXLEN) ||
+           type >= __NUM_GSMD_PIN)
+               return -EINVAL;
+
+       gm = (void *) lgsm_gmh_fill(GSMD_MSG_PIN, GSMD_PIN_INPUT,
+                                   sizeof(struct gsmd_pin));
+       if (!gm)
+               return -ENOMEM;
+
+       gm->gp.type = type;
+
+       gm->gp.pin[0] = '\0';
+       strcat(gm->gp.pin, pin);
+
+       switch (type) {
+       case GSMD_PIN_SIM_PUK:
+       case GSMD_PIN_SIM_PUK2:
+               /* GSM 07.07 explicitly states that only those two PUK types
+                * require a new pin to be specified! Don't know if this is a
+                * bug or a feature. */
+               if (!newpin)
+                       return -EINVAL;
+               gm->gp.newpin[0] = '\0';
+               strcat(gm->gp.newpin, newpin);
+               break;
+       default:
+               break;
+       }
+       printf("sending pin='%s', newpin='%s'\n", gm->gp.pin, gm->gp.newpin);
+       rc = lgsm_send(lh, &gm->gmh);
+       free(gm);
+
+       return rc;
+}

Modified: trunk/src/target/gsm/src/util/pin.c
===================================================================
--- trunk/src/target/gsm/src/util/pin.c 2007-03-10 02:21:28 UTC (rev 1313)
+++ trunk/src/target/gsm/src/util/pin.c 2007-03-10 02:22:04 UTC (rev 1314)
@@ -25,29 +25,46 @@
 
 #include <libgsmd/libgsmd.h>
 #include <libgsmd/event.h>
+#include <libgsmd/pin.h>
 
-#define PIN_SIZE 32
+#define PIN_SIZE 8
 
 static char *pin;
 static char pinbuf[PIN_SIZE+1];
+static char pinbuf2[PIN_SIZE+1];
 
 static int pin_handler(struct lgsm_handle *lh, int evt, struct 
gsmd_evt_auxdata *aux)
 {
        int rc;
+       int type = aux->u.pin.type;
+       char *newpin = NULL;
 
-       printf("EVENT: PIN request (type=%u) ", aux->u.pin.type);
+       printf("EVENT: PIN request (type='%s') ", 
lgsm_pin_name(aux->u.pin.type));
 
        /* FIXME: read pin from STDIN and send it back via lgsm_pin */
-       if (aux->u.pin.type == 1 && pin) {
+       if (type == 1 && pin) {
                printf("Auto-responding with pin `%s'\n", pin);
-               lgsm_pin(lh, pin);
+               lgsm_pin(lh, type, pin, NULL);
        } else {
                do {
-                       printf("Please enter PIN: ");
-                       rc = fscanf(stdin, "%32s", &pinbuf);
+                       printf("Please enter %s: ", lgsm_pin_name(type));
+                       rc = fscanf(stdin, "%8s", &pinbuf);
                } while (rc < 1);
 
-               return lgsm_pin(lh, pinbuf);
+               switch (type) {
+               case GSMD_PIN_SIM_PUK:
+               case GSMD_PIN_SIM_PUK2:
+                       do {
+                               printf("Please enter new PIN: ");
+                               rc = fscanf(stdin, "%8s", &pinbuf2);
+                               newpin = pinbuf2;
+                       } while (rc < 1);
+                       break;
+               default:
+                       break;
+               }
+
+               return lgsm_pin(lh, type, pinbuf, newpin);
        }
 
        return 0;




--- End Message ---
_______________________________________________
commitlog mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to