Is it possible to write and read the flash without entering into the DFU mode?

0

WIN 7

visual studio 2017

I have writen a C program to open a serial port.

I have writen a C program to write and read from flash in a Bluetooth chip(tailor-made).

However, I have to enter into the DFU mode to read and write from flash.

Is it possible to read and write from flash without entering into the DFU mode?

I have to press the button to entering into the DFU mode, which is time consuming for mass production.

In what kind of bluetooth chip, the DFU mode is necessary to read and write flash?

int test_read_cmd(void)
{
    int ret;
    int i;
    static const unsigned int addr[] = { 0x00000010, 0x00000020, 0x00000030, };
    static const unsigned char rlen[sizeof(addr) / sizeof(addr[0])] = { 1, 4, 16, };
    unsigned char b[16];

    for (i = 0; i < sizeof(rlen); i++) {
        ret = read_cmd(addr[i], rlen[i], b);
        if (ret) {
            return ret;
        }
    }

    return 0;
}

int read_cmd(unsigned int addr, unsigned int len, unsigned char *data)
{
    int ret;
    unsigned char b[17];
    size_t reply_len;

    //TRACE("--- Send READ msg addr=0x%08x len=%d ---", addr, len);

    if (len > 16) {
        TRACE("READ msg length too long: %d", len);
        return 1;
    }

    comm_state = COMM_READ;

    memcpy(&b[0], &addr, 4);
    b[4] = len;

    ret = send_packet(b, 5, TYPE_READ, send_seq++);
    if (ret) {
        TRACE("Sending READ %d failed", len);
        return ret;
    }

    //TRACE("--- Recv READ %d reply msg ---", len);

    ret = recv_reply(b, 1 + len, &reply_len);
    if (ret) {
        TRACE("Receiving READ %d reply failed", len);
        return ret;
    }

    if (b[0] != ERR_NONE) {
        TRACE("READ %d reply error 0x%x", len, b[0]);
        return 1;
    }

    memcpy(data, &b[1], len);

    //dump_buffer(data, len);

    return 0;
}
c
asked on Stack Overflow Sep 20, 2018 by CreateFile • edited Sep 20, 2018 by Mathieu

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0