I'm working on wireless uploader for Arduino from iOS devices. I'm using HM-10 BLE module which seems to work ok. PIO 2 is used as DTR for resetting (see
A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 1 [0x31]
and
A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 0 [0x30]
below)- using 0.1uF capacitor and 10K resistor wired to MCU reset pin)(microcontroller - What is the cap for in Arduino reset circuit? - Electrical Engineering Stack Exchange). Reset seems to be done correctly as i'm getting ready
output (in 'setup()' body in uploaded sketch).
For some reason i'm getting 0x14 0x10
for 0x30 0x20
request (to ping bootloader) but not getting response for A [0x41] . [0x81] [0x20]
within almost 1 second.
Uploading over BLE:
2015-07-04 19:24:10.955 xctest[54864:5122867] [TRACE ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 1 [0x31]
2015-07-04 19:24:10.955 xctest[54864:5122867] [TRACE ] [OUT]: BLE sending bytes range from 0 length 8
2015-07-04 19:24:11.106 xctest[54864:5122867] [DEBUG ] [OUT]: Sending 8 bytes
2015-07-04 19:24:11.106 xctest[54864:5122867] [TRACE ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 0 [0x30]
2015-07-04 19:24:11.106 xctest[54864:5122867] [TRACE ] [OUT]: BLE sending bytes range from 0 length 8
2015-07-04 19:24:11.148 xctest[54864:5122867] [DEBUG ] [ ]: Draining for 230 ms ...
2015-07-04 19:24:11.148 xctest[54864:5122867] [TRACE ] [IN ]: Start reading
2015-07-04 19:24:11.323 xctest[54864:5122903] [TRACE ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 1 [0x31]
2015-07-04 19:24:11.323 xctest[54864:5122903] [TRACE ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 0 [0x30]
2015-07-04 19:24:11.381 xctest[54864:5122867] [TRACE ] [IN ]: Finish reading
2015-07-04 19:24:11.381 xctest[54864:5122867] [TRACE ] [IN ]: Ble clear buffer
2015-07-04 19:24:11.381 xctest[54864:5122867] [DEBUG ] [IN ]: Drained 18 bytes
2015-07-04 19:24:11.381 xctest[54864:5122867] [DEBUG ] [OUT]: Sending 2 bytes
2015-07-04 19:24:11.381 xctest[54864:5122867] [TRACE ] [OUT]: Send: 0 [0x30] [0x20]
2015-07-04 19:24:11.382 xctest[54864:5122867] [TRACE ] [OUT]: BLE sending bytes range from 0 length 2
2015-07-04 19:24:11.382 xctest[54864:5122867] [DEBUG ] [IN ]: Reading 1 bytes ...
2015-07-04 19:24:11.382 xctest[54864:5122867] [TRACE ] [IN ]: Start reading
2015-07-04 19:24:11.746 xctest[54864:5122914] [TRACE ] [IN ]: Rx value received 1 bytes: . [0x00]
2015-07-04 19:24:11.747 xctest[54864:5122914] [TRACE ] [IN ]: Ignoring single 0x00 char
2015-07-04 19:24:11.747 xctest[54864:5122914] [TRACE ] [IN ]: Rx value received 2 bytes: . [0x14] . [0x10]
2015-07-04 19:24:11.748 xctest[54864:5122867] [TRACE ] [IN ]: Finish reading
2015-07-04 19:24:11.748 xctest[54864:5122867] [TRACE ] [IN ]: Receive: . [0x14]
2015-07-04 19:24:11.749 xctest[54864:5122867] [DEBUG ] [IN ]: Read 1 bytes, actually received 2 bytes
2015-07-04 19:24:11.749 xctest[54864:5122867] [TRACE ] [IN ]: 1 bytes in incoming buffer remaining for next receive
2015-07-04 19:24:11.749 xctest[54864:5122867] [DEBUG ] [IN ]: Reading 1 bytes ...
2015-07-04 19:24:11.750 xctest[54864:5122867] [TRACE ] [IN ]: Having current receive buffer: . [0x10]
2015-07-04 19:24:11.750 xctest[54864:5122867] [TRACE ] [IN ]: Start reading
2015-07-04 19:24:11.750 xctest[54864:5122867] [TRACE ] [IN ]: Finish reading
2015-07-04 19:24:11.751 xctest[54864:5122867] [TRACE ] [IN ]: Receive: . [0x10]
2015-07-04 19:24:11.751 xctest[54864:5122867] [DEBUG ] [IN ]: Read 1 bytes, actually received 1 bytes
2015-07-04 19:24:11.751 xctest[54864:5122867] [TRACE ] [IN ]: Ble clear buffer
2015-07-04 19:24:11.752 xctest[54864:5122867] [DEBUG ] [OUT]: Sending 3 bytes
2015-07-04 19:24:11.752 xctest[54864:5122867] [TRACE ] [OUT]: Send: A [0x41] . [0x81] [0x20]
2015-07-04 19:24:11.752 xctest[54864:5122867] [TRACE ] [OUT]: BLE sending bytes range from 0 length 3
2015-07-04 19:24:11.752 xctest[54864:5122867] [DEBUG ] [IN ]: Reading 1 bytes ...
2015-07-04 19:24:11.753 xctest[54864:5122867] [TRACE ] [IN ]: Start reading
2015-07-04 19:24:11.821 xctest[54864:5122914] [TRACE ] [IN ]: Rx value received 1 bytes: . [0x00]
2015-07-04 19:24:11.821 xctest[54864:5122914] [TRACE ] [IN ]: Ignoring single 0x00 char
2015-07-04 19:24:12.721 xctest[54864:5122903] [TRACE ] [IN ]: Rx value received 5 bytes: r [0x72] e [0x65] a [0x61] d [0x64] y [0x79]
2015-07-04 19:24:12.722 xctest[54864:5122867] [TRACE ] [IN ]: Finish reading
2015-07-04 19:24:12.722 xctest[54864:5122867] [TRACE ] [IN ]: Receive: r [0x72]
2015-07-04 19:24:12.723 xctest[54864:5122867] [DEBUG ] [IN ]: Read 1 bytes, actually received 5 bytes
2015-07-04 19:24:12.723 xctest[54864:5122867] [TRACE ] [IN ]: 4 bytes in incoming buffer remaining for next receive
2015-07-04 19:24:12.723 xctest[54864:5122867] [ERROR ] [ ]: STK500:getParameter: protocol error #1, expected [0x14], received [0x72]
When uploading over usb it's ok:
2015-06-29 16:34:10.829 xctest[36585:3703900] [TRACE ] [ ]: DTR/RTS supported by Serial, resetting
2015-06-29 16:34:11.140 xctest[36585:3703900] [DEBUG ] [IN ]: Draining ...
2015-06-29 16:34:11.392 xctest[36585:3703900] [DEBUG ] [IN ]: Drain done
2015-06-29 16:34:11.392 xctest[36585:3703900] [DEBUG ] [OUT]: Sending 2 bytes
2015-06-29 16:34:11.392 xctest[36585:3703900] [TRACE ] [OUT]: Send: 0 [0x30] [0x20]
2015-06-29 16:34:11.393 xctest[36585:3703900] [DEBUG ] [IN ]: Receiving 1 bytes
2015-06-29 16:34:11.531 xctest[36585:3703900] [TRACE ] [IN ]: Received: . [0x14]
2015-06-29 16:34:11.531 xctest[36585:3703900] [DEBUG ] [IN ]: Receiving 1 bytes
2015-06-29 16:34:11.532 xctest[36585:3703900] [TRACE ] [IN ]: Received: . [0x10]
2015-06-29 16:34:11.532 xctest[36585:3703900] [DEBUG ] [OUT]: Sending 3 bytes
2015-06-29 16:34:11.532 xctest[36585:3703900] [TRACE ] [OUT]: Send: A [0x41] . [0x81] [0x20]
2015-06-29 16:34:11.533 xctest[36585:3703900] [DEBUG ] [IN ]: Receiving 1 bytes
2015-06-29 16:34:11.535 xctest[36585:3703900] [TRACE ] [IN ]: Received: . [0x14]
2015-06-29 16:34:11.536 xctest[36585:3703900] [DEBUG ] [IN ]: Receiving 1 bytes
2015-06-29 16:34:11.536 xctest[36585:3703900] [TRACE ] [IN ]: Received: . [0x04]
2015-06-29 16:34:11.536 xctest[36585:3703900] [DEBUG ] [IN ]: Receiving 1 bytes
2015-06-29 16:34:11.536 xctest[36585:3703900] [TRACE ] [IN ]: Received: . [0x10]
2015-06-29 16:34:11.537 xctest[36585:3703900] [DEBUG ] [OUT]: Sending 3 bytes
2015-06-29 16:34:11.537 xctest[36585:3703900] [TRACE ] [OUT]: Send: A [0x41] . [0x82] [0x20]
2015-06-29 16:34:11.537 xctest[36585:3703900] [DEBUG ] [IN ]: Receiving 1 bytes
2015-06-29 16:34:11.540 xctest[36585:3703900] [TRACE ] [IN ]: Received: . [0x14]
So when uploading over USB DTR/RTS and similar schematic is used.
I think the problem is in resetting approach - wiring to reset does not work when trying to upload. Am i right? Is it bootloader issue?
PS. Arduino sketch uploaded:
void setup() {
Serial.begin(115200);
Serial.print("ready");
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
}
HM-10 is in mode 1 which allows to send 'AT' commands after pairing (see it performs PIO set to 1 and then to 0 to reset MCU). I'm not sure is HM-10 does transmit
A [0x41] . [0x81] [0x20]
to the MCU actually
if i send
0x30 0x20
twice just to check connection with bootloader after reset it responds twice as expected.
2015-07-04 19:55:19.302 xctest[54929:5148304] [TRACE ] [IN ]: Start reading
2015-07-04 19:55:19.486 xctest[54929:5148356] [TRACE ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 1 [0x31]
2015-07-04 19:55:19.524 xctest[54929:5148356] [TRACE ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 0 [0x30]
2015-07-04 19:55:19.536 xctest[54929:5148304] [TRACE ] [IN ]: Finish reading
2015-07-04 19:55:19.537 xctest[54929:5148304] [TRACE ] [IN ]: Ble clear buffer
2015-07-04 19:55:19.537 xctest[54929:5148304] [DEBUG ] [IN ]: Drained 18 bytes
2015-07-04 19:55:19.537 xctest[54929:5148304] [DEBUG ] [OUT]: Sending 2 bytes
2015-07-04 19:55:19.538 xctest[54929:5148304] [TRACE ] [OUT]: Send: 0 [0x30] [0x20] // check #1
2015-07-04 19:55:19.538 xctest[54929:5148304] [TRACE ] [OUT]: BLE sending bytes range from 0 length 2
2015-07-04 19:55:19.538 xctest[54929:5148304] [DEBUG ] [IN ]: Reading 1 bytes ...
2015-07-04 19:55:19.539 xctest[54929:5148304] [TRACE ] [IN ]: Start reading
2015-07-04 19:55:19.599 xctest[54929:5148343] [TRACE ] [IN ]: Rx value received 1 bytes: . [0x00]
2015-07-04 19:55:19.599 xctest[54929:5148343] [TRACE ] [IN ]: Ignoring single 0x00 char
2015-07-04 19:55:19.974 xctest[54929:5148356] [TRACE ] [IN ]: Rx value received 2 bytes: . [0x14] . [0x10]
2015-07-04 19:55:19.974 xctest[54929:5148304] [TRACE ] [IN ]: Finish reading
2015-07-04 19:55:19.975 xctest[54929:5148304] [TRACE ] [IN ]: Receive: . [0x14]
2015-07-04 19:55:19.975 xctest[54929:5148304] [DEBUG ] [IN ]: Read 1 bytes, actually received 2 bytes
2015-07-04 19:55:19.975 xctest[54929:5148304] [TRACE ] [IN ]: 1 bytes in incoming buffer remaining for next receive
2015-07-04 19:55:19.975 xctest[54929:5148304] [DEBUG ] [IN ]: Reading 1 bytes ...
2015-07-04 19:55:19.976 xctest[54929:5148304] [TRACE ] [IN ]: Having current receive buffer: . [0x10]
2015-07-04 19:55:19.976 xctest[54929:5148304] [TRACE ] [IN ]: Start reading
2015-07-04 19:55:19.976 xctest[54929:5148304] [TRACE ] [IN ]: Finish reading
2015-07-04 19:55:19.977 xctest[54929:5148304] [TRACE ] [IN ]: Receive: . [0x10]
2015-07-04 19:55:19.977 xctest[54929:5148304] [DEBUG ] [IN ]: Read 1 bytes, actually received 1 bytes
2015-07-04 19:55:19.977 xctest[54929:5148304] [TRACE ] [IN ]: Ble clear buffer
2015-07-04 19:55:19.978 xctest[54929:5148304] [DEBUG ] [OUT]: Sending 2 bytes
2015-07-04 19:55:19.978 xctest[54929:5148304] [TRACE ] [OUT]: Send: 0 [0x30] [0x20] // check #2
2015-07-04 19:55:19.978 xctest[54929:5148304] [TRACE ] [OUT]: BLE sending bytes range from 0 length 2
2015-07-04 19:55:19.979 xctest[54929:5148304] [DEBUG ] [IN ]: Reading 1 bytes ...
2015-07-04 19:55:19.979 xctest[54929:5148304] [TRACE ] [IN ]: Start reading
2015-07-04 19:55:20.049 xctest[54929:5148343] [TRACE ] [IN ]: Rx value received 1 bytes: . [0x00]
2015-07-04 19:55:20.049 xctest[54929:5148343] [TRACE ] [IN ]: Ignoring single 0x00 char
2015-07-04 19:55:20.049 xctest[54929:5148343] [TRACE ] [IN ]: Rx value received 2 bytes: . [0x14] . [0x10]
2015-07-04 19:55:20.050 xctest[54929:5148304] [TRACE ] [IN ]: Finish reading
2015-07-04 19:55:20.050 xctest[54929:5148304] [TRACE ] [IN ]: Receive: . [0x14]
2015-07-04 19:55:20.050 xctest[54929:5148304] [DEBUG ] [IN ]: Read 1 bytes, actually received 2 bytes
2015-07-04 19:55:20.050 xctest[54929:5148304] [TRACE ] [IN ]: 1 bytes in incoming buffer remaining for next receive
2015-07-04 19:55:20.051 xctest[54929:5148304] [DEBUG ] [IN ]: Reading 1 bytes ...
2015-07-04 19:55:20.051 xctest[54929:5148304] [TRACE ] [IN ]: Having current receive buffer: . [0x10]
2015-07-04 19:55:20.051 xctest[54929:5148304] [TRACE ] [IN ]: Start reading
2015-07-04 19:55:20.052 xctest[54929:5148304] [TRACE ] [IN ]: Finish reading
2015-07-04 19:55:20.052 xctest[54929:5148304] [TRACE ] [IN ]: Receive: . [0x10]
2015-07-04 19:55:20.052 xctest[54929:5148304] [DEBUG ] [IN ]: Read 1 bytes, actually received 1 bytes
2015-07-04 19:55:20.055 xctest[54929:5148304] [TRACE ] [IN ]: Ble clear buffer
2015-07-04 19:55:20.055 xctest[54929:5148304] [DEBUG ] [OUT]: Sending 3 bytes
2015-07-04 19:55:20.055 xctest[54929:5148304] [TRACE ] [OUT]: Send: A [0x41] . [0x81] [0x20]
2015-07-04 19:55:20.056 xctest[54929:5148304] [TRACE ] [OUT]: BLE sending bytes range from 0 length 3
2015-07-04 19:55:20.056 xctest[54929:5148304] [DEBUG ] [IN ]: Reading 1 bytes ...
2015-07-04 19:55:20.056 xctest[54929:5148304] [TRACE ] [IN ]: Start reading
2015-07-04 19:55:20.123 xctest[54929:5148356] [TRACE ] [IN ]: Rx value received 1 bytes: . [0x00]
2015-07-04 19:55:20.124 xctest[54929:5148356] [TRACE ] [IN ]: Ignoring single 0x00 char
2015-07-04 19:55:21.174 xctest[54929:5148343] [TRACE ] [IN ]: Rx value received 5 bytes: r [0x72] e [0x65] a [0x61] d [0x64] y [0x79]
I forgot to say i've tested with Arduino Uno r3. i've just tested uploading to Arduino Mega2560 and it works - Mega's bootloader replies as expected and uploading succeed. What's wrong with Uno?