diff options
author | root <root@no.no.james.local> | 2015-09-01 15:47:35 +0100 |
---|---|---|
committer | root <root@no.no.james.local> | 2015-09-01 15:47:35 +0100 |
commit | 88d098d6b3f85f70c9cde405a0d2ff70997fe706 (patch) | |
tree | c43b84caed6f8f8dfede544976ec715122700cbc | |
parent | b86d2b80040c0ac6810a49f593934d651a257128 (diff) | |
download | nrfdfu-88d098d6b3f85f70c9cde405a0d2ff70997fe706.tar.gz nrfdfu-88d098d6b3f85f70c9cde405a0d2ff70997fe706.tar.bz2 nrfdfu-88d098d6b3f85f70c9cde405a0d2ff70997fe706.zip |
bootloader support
-rw-r--r-- | dfu.c | 27 |
1 files changed, 19 insertions, 8 deletions
@@ -103,10 +103,24 @@ dfu (const char *bdaddr, const char *type, const char *version, uint8_t * dat, uint32_t u32; uint16_t u16; - if (strcmp (type, "application")) + uint32_t start_data[3]; + uint8_t dfu_type; + + if (!strcmp (type, "application")) { - fprintf (stderr, "only know how to flash applications\n"); - exit (EXIT_FAILURE); + dfu_type=DFU_UPDATE_APP; /*bit field */ + start_data[0]=0; + start_data[1]=0; + start_data[2]=bin_sz; + + }else if (!strcmp (type, "bootloader")) { + dfu_type=DFU_UPDATE_BL; /*bit field */ + start_data[0]=0; + start_data[1]=bin_sz; + start_data[2]=0; + } else { + fprintf("No idea how to upload %s\n",type); + exit(EXIT_FAILURE); } ble_init (); @@ -124,7 +138,7 @@ dfu (const char *bdaddr, const char *type, const char *version, uint8_t * dat, break; buf[0] = OP_CODE_START_DFU; - buf[1] = DFU_UPDATE_APP; /*bit field */ + buf[1] = dfu_type; /*bit field */ ble_wait_setup (b, OP_CODE_START_DFU); @@ -133,11 +147,8 @@ dfu (const char *bdaddr, const char *type, const char *version, uint8_t * dat, /*4 bytes sd size, 4 bytes bl size, 4 bytes app size */ - memset (buf, 0, 12); - u32 = bin_sz; - memcpy (&buf[8], &u32, 4); - if (ble_send_data (b, buf, 12)) + if (ble_send_data (b, start_data, sizeof(start_data))) break; if (ble_wait_run (b) != BLE_DFU_RESP_VAL_SUCCESS) |