Skip to content

Commit 46eea66

Browse files
VSCP client bootloader code in "working" state
1 parent 57f501c commit 46eea66

File tree

10 files changed

+488
-242
lines changed

10 files changed

+488
-242
lines changed

src/common/crc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ crcInit(void)
161161
int dividend;
162162
unsigned char bit;
163163

164-
165164
/*
166165
* Compute the remainder of each possible dividend.
167166
*/

src/vscp/common/vscp-bootdevice-pic1.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
// #include <spdlog/sinks/stdout_color_sinks.h>
4141
#include <spdlog/spdlog.h>
4242

43-
#include <iomanip>
4443
#include <iostream>
45-
#include <sstream>
44+
#include <iomanip>
45+
#include <sstream>
4646

4747
///////////////////////////////////////////////////////////////////////////////
4848
// Constructor
@@ -228,16 +228,13 @@ CBootDevice_PIC1::deviceInfo(void)
228228
//
229229

230230
int
231-
CBootDevice_PIC1::deviceInit(cguid &ourguid, uint16_t devicecode, bool bAbortOnFirmwareCodeFail)
231+
CBootDevice_PIC1::deviceInit(cguid& ourguid, uint16_t devicecode, bool bAbortOnFirmwareCodeFail)
232232
{
233233
int rv;
234234

235235
// Save our local GUID
236236
m_ourguid = ourguid;
237237

238-
// Save Firmware device code
239-
m_firmwaredeviceCode = devicecode;
240-
241238
/*
242239
First do a test to see if the device is already in boot mode
243240
if it is 0x14nn/0x15nn should be returned (nn == nodeid).
@@ -359,7 +356,7 @@ CBootDevice_PIC1::deviceInit(cguid &ourguid, uint16_t devicecode, bool bAbortOnF
359356
// Set device in boot mode
360357
cguid guid;
361358
m_stdRegs.getGUID(guid);
362-
msg.data[0] = (uint8_t) m_nodeid; // Nickname to read register from
359+
msg.data[0] = (uint8_t)m_nodeid; // Nickname to read register from
363360
msg.data[1] = VSCP_BOOTLOADER_PIC1; // VSCP PIC1 bootloader algorithm
364361
msg.data[2] = guid.getAt(0);
365362
msg.data[3] = guid.getAt(3);
@@ -566,7 +563,7 @@ int
566563
CBootDevice_PIC1::writeDeviceControlRegs(uint32_t addr, uint8_t flags, uint8_t cmd, uint8_t cmdData0, uint8_t cmdData1)
567564
{
568565
int rv;
569-
// vscpEventEx event;
566+
//vscpEventEx event;
570567
canalMsg msg;
571568

572569
// Save the internal addresss
@@ -640,7 +637,7 @@ CBootDevice_PIC1::checkResponseLevel1(uint32_t response_id)
640637
// Response received from all - return success
641638
spdlog::debug("checkResponseLevel1: RECEIVE OK");
642639
if (nullptr != m_statusCallback) {
643-
// m_statusCallback(-1, "checkResponseLevel1: Response received OK.");
640+
//m_statusCallback(-1, "checkResponseLevel1: Response received OK.");
644641
}
645642
return VSCP_ERROR_SUCCESS;
646643
}
@@ -688,7 +685,7 @@ CBootDevice_PIC1::checkResponseLevel2(uint32_t id)
688685
// Response received - return success
689686
spdlog::debug("checkResponseLevel2: RECEIVE OK");
690687
if (nullptr != m_statusCallback) {
691-
// m_statusCallback(-1, "checkResponseLevel2: Response received OK.");
688+
//m_statusCallback(-1, "checkResponseLevel2: Response received OK.");
692689
}
693690
return VSCP_ERROR_SUCCESS;
694691
}
@@ -831,7 +828,7 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end)
831828
}
832829

833830
// Init the block
834-
if (VSCP_ERROR_SUCCESS != (rv = fillMemoryBuffer(pbuf, size, start))) {
831+
if (VSCP_ERROR_SUCCESS != (rv = fillMemoryBuffer(pbuf, size, start, end))) {
835832
spdlog::error("writeFirmwareBlock: Failed to fill code block with data.");
836833
if (nullptr != m_statusCallback) {
837834
m_statusCallback(-1,
@@ -855,7 +852,7 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end)
855852
}
856853

857854
// Start at beginning
858-
paddr += minAddr - start;
855+
paddr += minAddr-start;
859856

860857
for (uint32_t blk = 0; blk < nPackets; blk++) {
861858
spdlog::debug("Loading flash on remote device... block={0} {1:X}", blk, blk * 8);
@@ -865,11 +862,11 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end)
865862
}
866863
paddr += 8;
867864
if (nullptr != m_statusCallback) {
868-
m_statusCallback((100 * blk) / nPackets, "" /*vscp_str_format("blk %d.", blk).c_str()*/);
865+
m_statusCallback((100 * blk) / nPackets, ""/*vscp_str_format("blk %d.", blk).c_str()*/);
869866
}
870867

871868
} // for
872-
} // code
869+
} // code
873870

874871
delete[] pbuf;
875872
return VSCP_ERROR_SUCCESS;
@@ -882,18 +879,18 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end)
882879
int
883880
CBootDevice_PIC1::deviceLoad(std::function<void(int, const char *)> statusCallback, bool bAbortOnFirmwareCodeFail)
884881
{
885-
// bool bRun = true;
882+
//bool bRun = true;
886883
int rv;
887884

888-
m_checksum = 0;
889-
// uint32_t progress = 0;
885+
m_checksum = 0;
886+
//uint32_t progress = 0;
890887
uint32_t addr = 0;
891888
std::string strStatus;
892889

893-
// uint8_t pbuf[BUFFER_SIZE_CODE];
894-
// uint32_t nPackets;
895-
// uint32_t minAddr;
896-
// uint32_t maxAddr;
890+
//uint8_t pbuf[BUFFER_SIZE_CODE];
891+
//uint32_t nPackets;
892+
// uint32_t minAddr;
893+
// uint32_t maxAddr;
897894

898895
if (nullptr != m_statusCallback) {
899896
m_statusCallback(0, "Starting firmware download");

0 commit comments

Comments
 (0)