classycodeoss / nrf52-dfu Goto Github PK
View Code? Open in Web Editor NEWNordic nRF52 firmware update example
License: BSD 3-Clause "New" or "Revised" License
Nordic nRF52 firmware update example
License: BSD 3-Clause "New" or "Revised" License
Thanks a lot for sharing, that helped me a lot!
One topic I stumbled on:
There is no SLIP escaping when sending commands to the nRF bootloader. This can create problems when a command parameter contains the EOM character (0xC0). The bootloader on the nRF side then prematurely cuts the commad block, leaving possibly invalid parameters for its upper levels.
I had that problem with a specific payload length of a block to download. The last CREATE OBJECT command will use the remaining size of the block instead of the maximum block size. If that remainig blocksize generates a 0xC0 in the length parameter of the CREATE OBJECT command, the command will fail. I had that with a remaining block size of 2240 bytes, which results in a length encoding of 0xC0, 0x08, 0x00, 0x00.
Correction is easy:
Just add SLIP escaping in fwuPrepareSendBuffer(). I did it this way:
static void fwuPrepareSendBuffer(TFwu *fwu, uint8_t *data, uint8_t len)
{
// TODO assert privateCommandState == FWU_CS_IDLE | _DONE | _FAIL
// TODO assert len <= FWU_REQUEST_BUF_SIZE
uint8_t i;
uint8_t *p = &fwu->privateRequestBuf[0];
fwu->privateRequestIx = 0;
fwu->privateRequestLen = len + 1;
fwu->privateResponseLen = 0;
// Copy the data into our internal buffer.
// Handle SLIP escaping.
for (i = 0; i < len; i++) {
// SLIP escape characters: C0->DBDC, DB->DBDD
if ((*data == 0xC0) || (*data == 0xDB)) {
*p++ = 0xDB;
*p++ = (*data++ == 0xC0) ? 0xDC : 0xDD;
fwu->privateRequestLen++;
} else {
*p++ = *data++;
}
}
// Add the end-of-message marker.
*p = FWU_EOM;
// Ready to send!
fwu->privateCommandRequest = FWU_CR_SEND;
}
Regards and many thanks for sharing!
Michael
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.