- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am using Particle Photon as an embedded host to bootload CYBLE 012011 module. I took the files in folder UART Bootloader Host from AN68272 and modified them. Now my project folder contains the following files
1. communication_api.cpp
2. communication_api.h
3. cybtldr_api.h
4. cybtldr_api.cpp
5. cybtldr_parse.h
6. cybtldr_parse.cpp
7. cybtldr_utils.h
8. cybtldr_command.h
9. cybtldr_command.cpp
10. OTA.cpp - Particle Photon program.
I changed the .c extension to .cpp, replacedPSoC UART code in communication_api.cpp with Particle UART code.
Connections between BLE and Particle Photon:
BLE pins | Particle Photon |
VDD | 3.3V |
GND | GND |
3.5 | Rx |
3.4 | Tx |
Data on the Serial:
After keeping the BLE in bootloader mode, I am calling the API BootloadStringImage(myImageFromCYACDFile, lineCount); to update the firmware. I printed the data going in and out on the UART channel and this is what I get.
In HEX:
Data going to BLE module(TX): 1 38 0 0 C7 FF 17
This matches the packed data from the API CyBtldr_CreateEnterBootloaderCmd(...).
Data from BLE module(RX): 1 4 0 0 FB FF 17
I am not sure what this is. The expected byteCnt is 15 but it's only receiving 7 bytes and it waits forever due to the while(byteCnt > 0) loop.
Sometimes I only get 1 byte and sometimes I get 7 bytes before it starts to wait forever. Seems like a timing issue. Here is my modified communication_api.c file.
#include "communication_api.h"
//Serial1 is UART and Serial is USB COM for debugging
int OpenConnection(void)
{
Serial1.begin(115200); //initializes the UART on baud 115200
return CYRET_SUCCESS;
}
int CloseConnection(void)
{
Serial1.end();
return CYRET_SUCCESS;
}
int WriteData(uint8_t* wrData, int byteCnt)
{
uint16_t timeOut =1;
/* Clears TX and RX FIFOs and the status registers */
/* Send the data */
Serial1.write((uint8_t*)wrData, byteCnt);
Serial.print("Sending : ");
for(int a=0; a<byteCnt; a++){
Serial.print(wrData, HEX);
Serial.print(",");
}
Serial.println("");
Serial1.flush(); //waits ...
return(CYRET_SUCCESS);
}
int ReadData(uint8_t* rdData, int byteCnt)
{
uint16_t timeOut =1;
uint8_t dataIndexCntr = 0;
/* Wait till there is data available */
while(!Serial1.available());
/* Read the data bytes */
Serial.print("Received data: ");
while (byteCnt > 0)
{
if(Serial1.available() > 0){
rdData[dataIndexCntr]=(uint8_t)(Serial1.read());
Serial.print(rdData[dataIndexCntr], HEX);
Serial.print(", ");
dataIndexCntr++;
byteCnt--;
}
}
return(CYRET_SUCCESS);
}
Console output from Serial:
Sending: 1,38,0,0,C7,FF,17
Received data: 1,4,0,0,FB,FF,17
------------------------------------------------------------------------
The program gets stuck in the received data loop as the byteCnt is greater than 0. What's wrong with my ReadData()?
Thank you
Dheeraj
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Some thoughts looking at the output:
1. The err code from BootloadStringImage(myImageFromCYACDFile, lineCount) is 4.
2. The error code matches CYRET_ERR_DATA.
3. I have compared the output with the expected response in CyBtldr_ParseEnterBootLoaderCmdResult(...) API.
cmdBuf[0] is 1 which is CMD_START
cmdBuf[2] should be RESULT_DATA_SIZE which is 8 but it's 0
cmdBuf[3] should match RESULT_DATA_SIZE >> 8 but it's 0
cmdBuf[RESULT_SIZE - 1] should match CMD_STOP but I am missing the 15th byte.
My cmdBuf[2] is 0 which means data bytes are 0 so my return message will be 15 - 8 = 7 bytes long which is what I get!. Also my 7th byte is the expected 15th byte which is CMD_STOP.
Now why is the RESULT_DATA_SIZE field zero ?