summaryrefslogtreecommitdiffstats
path: root/src/progs/tbl_bootloader
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
commitf508189682b6fba62e08feeb1596f682bad5fff9 (patch)
tree28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/progs/tbl_bootloader
downloadpiklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz
piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/progs/tbl_bootloader')
-rw-r--r--src/progs/tbl_bootloader/Makefile.am3
-rw-r--r--src/progs/tbl_bootloader/base/Makefile.am11
-rw-r--r--src/progs/tbl_bootloader/base/base.pro6
-rw-r--r--src/progs/tbl_bootloader/base/tbl_bootloader.cpp327
-rw-r--r--src/progs/tbl_bootloader/base/tbl_bootloader.h74
-rw-r--r--src/progs/tbl_bootloader/base/tbl_bootloader.xml70
-rw-r--r--src/progs/tbl_bootloader/base/tbl_bootloader_data.h21
-rw-r--r--src/progs/tbl_bootloader/base/tbl_bootloader_prog.cpp14
-rw-r--r--src/progs/tbl_bootloader/base/tbl_bootloader_prog.h46
-rw-r--r--src/progs/tbl_bootloader/gui/Makefile.am6
-rw-r--r--src/progs/tbl_bootloader/gui/tbl_bootloader_ui.cpp80
-rw-r--r--src/progs/tbl_bootloader/gui/tbl_bootloader_ui.h42
-rw-r--r--src/progs/tbl_bootloader/tbl_bootloader.pro2
-rw-r--r--src/progs/tbl_bootloader/xml/Makefile.am14
-rw-r--r--src/progs/tbl_bootloader/xml/xml.pro17
-rw-r--r--src/progs/tbl_bootloader/xml/xml_tbl_bootloader_parser.cpp48
16 files changed, 781 insertions, 0 deletions
diff --git a/src/progs/tbl_bootloader/Makefile.am b/src/progs/tbl_bootloader/Makefile.am
new file mode 100644
index 0000000..fccf96d
--- /dev/null
+++ b/src/progs/tbl_bootloader/Makefile.am
@@ -0,0 +1,3 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+SUBDIRS = xml base gui
diff --git a/src/progs/tbl_bootloader/base/Makefile.am b/src/progs/tbl_bootloader/base/Makefile.am
new file mode 100644
index 0000000..60b11bc
--- /dev/null
+++ b/src/progs/tbl_bootloader/base/Makefile.am
@@ -0,0 +1,11 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libtblbootloader.la
+libtblbootloader_la_SOURCES = tbl_bootloader_data.cpp tbl_bootloader.cpp tbl_bootloader_prog.cpp
+libtblbootloader_la_DEPENDENCIES = tbl_bootloader_data.cpp
+
+noinst_DATA = tbl_bootloader.xml
+tbl_bootloader_data.cpp: ../xml/xml_tbl_bootloader_parser tbl_bootloader.xml
+ ../xml/xml_tbl_bootloader_parser
+CLEANFILES = tbl_bootloader_data.cpp
diff --git a/src/progs/tbl_bootloader/base/base.pro b/src/progs/tbl_bootloader/base/base.pro
new file mode 100644
index 0000000..1ccb8e9
--- /dev/null
+++ b/src/progs/tbl_bootloader/base/base.pro
@@ -0,0 +1,6 @@
+STOPDIR = ../../../..
+include($${STOPDIR}/lib.pro)
+
+TARGET = tbl_bootloader
+HEADERS += tbl_bootloader_data.h tbl_bootloader.h tbl_bootloader_prog.h
+SOURCES += tbl_bootloader_data.cpp tbl_bootloader.cpp tbl_bootloader_prog.cpp
diff --git a/src/progs/tbl_bootloader/base/tbl_bootloader.cpp b/src/progs/tbl_bootloader/base/tbl_bootloader.cpp
new file mode 100644
index 0000000..419ad86
--- /dev/null
+++ b/src/progs/tbl_bootloader/base/tbl_bootloader.cpp
@@ -0,0 +1,327 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "tbl_bootloader.h"
+
+#include "tbl_bootloader_data.h"
+#include "progs/base/prog_config.h"
+
+//-----------------------------------------------------------------------------
+Port::Serial::Speed TinyBootloader::Config::readSpeed()
+{
+ uint speed = readUIntEntry("port_speed", 19200);
+ for (uint i=0; i<Port::Serial::Nb_Speeds; i++)
+ if ( speed==Port::Serial::SPEED_VALUES[i] ) return Port::Serial::Speed(i);
+ return Port::Serial::S19200;
+}
+void TinyBootloader::Config::writeSpeed(Port::Serial::Speed speed)
+{
+ writeEntry("port_speed", Port::Serial::SPEED_VALUES[speed]);
+}
+
+uint TinyBootloader::Config::readTimeout()
+{
+ return readUIntEntry("timeout", 300);
+}
+void TinyBootloader::Config::writeTimeout(uint timeout)
+{
+ writeEntry("timeout", timeout);
+}
+
+uint TinyBootloader::Config::readRetries()
+{
+ return readUIntEntry("nb_retries", 5);
+}
+void TinyBootloader::Config::writeRetries(uint nb)
+{
+ writeEntry("nb_retries", nb);
+}
+
+//-----------------------------------------------------------------------------
+TinyBootloader::Hardware::Hardware(::Programmer::Base &base, const QString &portDevice)
+ : ::Bootloader::Hardware(base, new Port::Serial(portDevice, Port::Serial::NoProperty, base))
+{
+ Config config;
+ _timeout = config.readTimeout();
+ _retries = config.readRetries();
+}
+
+bool TinyBootloader::Hardware::openPort()
+{
+ if ( !port()->open() ) return false;
+ Config config;
+ if ( !port()->setMode(Port::Serial::IgnoreBreak | Port::Serial::IgnoreParity,
+ Port::Serial::ByteSize8 | Port::Serial::IgnoreControlLines,
+ config.readSpeed(), _timeout) )
+ return false;
+ return true;
+}
+
+bool TinyBootloader::Hardware::internalConnectHardware()
+{
+ if ( !openPort() ) return false;
+ // #### possibly do hard (RTS) or soft reset (codes)
+ uchar uc = 0xC1;
+ if ( !port()->sendChar(uc, _timeout) ) return false;
+ if ( !port()->receiveChar((char &)_id, _timeout) ) return false;
+ if ( !waitReady(0) ) return false;
+ return true;
+}
+
+bool TinyBootloader::Hardware::verifyDeviceId()
+{
+ uchar id = data(device().name()).id;
+ QValueVector<QString> list = _base.group().supportedDevices();
+ QStringList devices;
+ for (uint i=0; i<uint(list.count()); i++)
+ if ( _id==data(list[i]).id ) devices.append(list[i]);
+ if ( _id!=id ) {
+ if ( devices.count()==0 ) log(Log::LineType::Error, i18n("Unknown id returned by bootloader (%1 read and %2 expected).").arg(toHexLabel(_id, 2)).arg(toHexLabel(id, 2)));
+ else log(Log::LineType::Error, i18n("Id returned by bootloader corresponds to other devices: %1 (%2 read and %3 expected).").arg(devices.join(" ")).arg(toHexLabel(_id, 2)).arg(toHexLabel(id, 2)));
+ // we can't ask for "continue anyway?" because bootloader can timeout...
+ return false;
+ }
+ log(Log::LineType::Information, " " + i18n("Bootloader identified device as: %1").arg(devices.join(" ")));
+ return true;
+}
+
+bool TinyBootloader::Hardware::waitReady(bool *checkCRC)
+{
+ char c;
+ if ( !port()->receiveChar(c, _timeout) ) return false;
+ if ( c=='K' ) {
+ if (checkCRC) *checkCRC = true;
+ return true;
+ }
+ if (checkCRC) {
+ *checkCRC = false;
+ if ( c=='N' ) return true;
+ log(Log::LineType::Error, i18n("Received unexpected character ('%1' received; 'K' or 'N' expected).").arg(toPrintable(c, PrintAlphaNum)));
+ return true;
+ }
+ log(Log::LineType::Error, i18n("Received unexpected character ('%1' received; 'K' expected).").arg(toPrintable(c, PrintAlphaNum)));
+ return false;
+}
+
+bool TinyBootloader::Hardware::sendChar(char c, uchar *crc)
+{
+ if (crc) *crc += c;
+ return port()->sendChar(c, 10*_timeout);
+}
+
+bool TinyBootloader::Hardware::sendCodeAddress(uint address, uchar &crc)
+{
+ switch (device().architecture().type()) {
+ case Pic::Architecture::P16X:
+ if ( !sendChar(address >> 8, &crc) ) return false; // address high
+ if ( !sendChar(address & 0xFF, &crc) ) return false; // address low
+ break;
+ case Pic::Architecture::P18F:
+ if ( !sendChar(address >> 16, &crc) ) return false; // address upper
+ if ( !sendChar((address >> 8) & 0xFF, &crc) ) return false; // address high
+ if ( !sendChar(address & 0xFF, &crc) ) return false; // address low
+ break;
+ case Pic::Architecture::P30F:
+ if ( !sendChar(address & 0xFF, &crc) ) return false; // address low
+ if ( !sendChar((address >> 8) & 0xFF, &crc) ) return false; // address high
+ if ( !sendChar(address >> 16, &crc) ) return false; // address upper
+ break;
+ default: Q_ASSERT(false); return false;
+ }
+ return true;
+}
+
+bool TinyBootloader::Hardware::endWrite(uchar crc, uint &retries, bool &ok)
+{
+ if ( !sendChar(-crc & 0xFF, 0) ) return false;
+ if ( !waitReady(&ok) ) return false;
+ if ( !ok ) {
+ if ( retries==0 ) {
+ log(Log::LineType::Error, i18n("Too many failures: bailing out."));
+ return false;
+ }
+ retries--;
+ log(Log::LineType::Warning, i18n("CRC error from bootloader: retrying..."));
+ }
+ return true;
+}
+
+bool TinyBootloader::Hardware::writeCode(const Device::Array &data, bool erase)
+{
+ uint nb = data.count() - 100;
+ Device::Array wdata(nb+4);
+
+ // check that there is nothing on top of bootloader
+ for (uint i=nb; i<data.size(); i++) {
+ if ( data[i]==device().mask(Pic::MemoryRangeType::Code) ) continue;
+ uint address = device().addressIncrement(Pic::MemoryRangeType::Code) * i;
+ log(Log::LineType::Warning, " " + i18n("Code is present in bootloader reserved area (at address %1). It will be ignored.").arg(toHexLabel(address, device().nbCharsAddress())));
+ break;
+ }
+
+ // check first 4 instructions for "goto" and copy them
+ if (erase) {
+ for (uint i=0; i<4; i++) wdata[nb+i] = device().nopInstruction();
+ } else {
+ bool ok = false;
+ for (uint i=0; i<4; i++) {
+ wdata[nb+i] = data[i];
+ if ( !ok && device().isGotoInstruction(data[i]) ) {
+ ok = true;
+ if ( i==3 && device().gotoInstruction(0x0, false).count()==2 )
+ log(Log::LineType::Warning, " " + i18n("Only the first word of the \"goto\" instruction is into the first four instructions."));
+ }
+ }
+ if ( !ok ) log(Log::LineType::Warning, " " + i18n("No \"goto\" instruction in the first four instructions."));
+ }
+
+ // place "goto size-100" at reset vector
+ wdata[0] = device().nopInstruction(); // for icd2
+ uint address = device().addressIncrement(Pic::MemoryRangeType::Code) * (nb+4);
+ Device::Array a = device().gotoInstruction(address, true);
+ for (uint i=0; i<a.size(); i++) wdata[1+i] = a[i];
+ // copy the rest
+ for (uint i=4; i<nb; i++) wdata[i] = data[i];
+
+ uint retries = _retries, nbWords = 0x20; // 16F: 64 bytes (80 bytes reserved) ; 18F: 64 bytes ; 30F: 96 bytes
+ Q_ASSERT( (data.count()%nbWords)==0 );
+ for (uint i=0; i<wdata.count(); i+=nbWords) {
+ if ( !erase ) {
+ bool write = false;
+ for (uint k=0; k<nbWords; k++) {
+ if ( wdata[i+k]==device().mask(Pic::MemoryRangeType::Code) ) continue;
+ write = true;
+ break;
+ }
+ if ( !write ) continue; // skip
+ }
+ for (;;) {
+ uchar crc = 0;
+ uint address = device().addressIncrement(Pic::MemoryRangeType::Code) * i;
+ if ( !sendCodeAddress(address, crc) ) return false;
+ uint nbw = device().nbBytesWord(Pic::MemoryRangeType::Code);
+ if ( !sendChar(nbw*nbWords, &crc) ) return false;
+ log(Log::DebugLevel::Normal, QString("write code memory at %1: %2 bytes").arg(toHexLabel(address, 4)).arg(2*nbWords));
+ for(uint k=0; k<nbWords; k++) {
+ if ( !sendChar(wdata[i+k].byte(0), &crc) ) return false; // data low
+ if ( !sendChar(wdata[i+k].byte(1), &crc) ) return false; // data high
+ if ( nbw==3 && !sendChar(wdata[i+k].byte(2), &crc) ) return false; // upper byte
+ }
+ bool ok;
+ if ( !endWrite(crc, retries, ok) ) return false;
+ if (ok) break;
+ }
+ }
+ return true;
+}
+
+bool TinyBootloader::Hardware::writeConfig(const Device::Array &data)
+{
+ if ( device().architecture()==Pic::Architecture::P16X ) return false;
+ uint retries = _retries;
+ for (uint i=0; i<data.count(); i++) {
+ for (;;) {
+ uchar crc = 0;
+ Address address = device().range(Pic::MemoryRangeType::Config).start + i;
+ switch (device().architecture().type()) {
+ case Pic::Architecture::P18F:
+ if ( !sendChar(0x80 | address.byte(2), &crc) ) return false; // address upper | flag
+ if ( !sendChar(address.byte(1), &crc) ) return false; // address high
+ if ( !sendChar(address.byte(0), &crc) ) return false; // address low
+ if ( !sendChar(1, &crc) ) return false; // nb bytes
+ if ( !sendChar(data[i].byte(0), &crc) ) return false; // data
+ break;
+ case Pic::Architecture::P30F:
+ if ( !sendChar(address.byte(0), &crc) ) return false; // address low
+ if ( !sendChar(address.byte(1), &crc) ) return false; // address high
+ if ( !sendChar(address.byte(2), &crc) ) return false; // address upper
+ if ( !sendChar(2, &crc) ) return false; // nb bytes
+ if ( !sendChar(data[i].byte(0), &crc) ) return false; // data low
+ if ( !sendChar(data[i].byte(1), &crc) ) return false; // data high
+ break;
+ default: Q_ASSERT(false); return false;
+ }
+ bool ok;
+ if ( !endWrite(crc, retries, ok) ) return false;
+ if (ok) break;
+ }
+ }
+ return true;
+}
+
+bool TinyBootloader::Hardware::writeEeprom(const Device::Array &data)
+{
+ uint retries = _retries;
+ for (uint i=0; i<data.count(); i++) {
+ for (;;) {
+ uchar crc = 0;
+ Address address = device().range(Pic::MemoryRangeType::Config).start + i;
+ switch (device().architecture().type()) {
+ case Pic::Architecture::P16X:
+ if ( !sendChar(0x40, &crc) ) return false; // flag
+ if ( !sendChar(address.byte(0), &crc) ) return false; // address
+ if ( !sendChar(1, &crc) ) return false; // nb bytes
+ if ( !sendChar(data[i].byte(0), &crc) ) return false; // data
+ break;
+ case Pic::Architecture::P18F:
+ if ( !sendChar(0x40, &crc) ) return false; // flag
+ if ( !sendChar(address.byte(0), &crc) ) return false; // address
+ if ( !sendChar(data[i].byte(0), &crc) ) return false; // data
+ if ( !sendChar(0x00, &crc) ) return false; // dummy
+ break;
+ case Pic::Architecture::P30F:
+ if ( !sendChar(address.byte(0), &crc) ) return false; // address low
+ if ( !sendChar(address.byte(1), &crc) ) return false; // address high
+ if ( !sendChar(address.byte(2), &crc) ) return false; // address upper
+ if ( !sendChar(2, &crc) ) return false; // nb bytes
+ if ( !sendChar(data[i].byte(0), &crc) ) return false; // data low
+ if ( !sendChar(data[i].byte(1), &crc) ) return false; // data high
+ break;
+ default: Q_ASSERT(false); return false;
+ }
+ bool ok;
+ if ( !endWrite(crc, retries, ok) ) return false;
+ if (ok) break;
+ }
+ }
+ return true;
+}
+
+bool TinyBootloader::Hardware::write(Pic::MemoryRangeType type, const Device::Array &data)
+{
+ Q_ASSERT( data.count()==device().nbWords(type) );
+ if ( type==Pic::MemoryRangeType::Code ) return writeCode(data, false);
+ if ( type==Pic::MemoryRangeType::Config ) return writeConfig(data);
+ if ( type==Pic::MemoryRangeType::Eeprom ) return writeEeprom(data);
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+bool TinyBootloader::DeviceSpecific::canWriteRange(Pic::MemoryRangeType type) const
+{
+ if ( type==Pic::MemoryRangeType::Eeprom || type==Pic::MemoryRangeType::Code ) return true;
+ if ( device().architecture()==Pic::Architecture::P18F && type==Pic::MemoryRangeType::Config ) return true;
+ return false;
+}
+
+bool TinyBootloader::DeviceSpecific::doErase(bool)
+{
+ bool eeprom = readConfigEntry(::Programmer::Config::ProgramEeprom).toBool();
+ if (eeprom) log(Log::LineType::Warning, " " + i18n("Only code and EEPROM will be erased."));
+ else log(Log::LineType::Warning, " " + i18n("Only code will be erased."));
+ if ( doEraseRange(Pic::MemoryRangeType::Code)==false ) return false;
+ if ( eeprom && doEraseRange(Pic::MemoryRangeType::Eeprom)==false ) return false;
+ return true;
+}
+
+bool TinyBootloader::DeviceSpecific::doEraseRange(Pic::MemoryRangeType type)
+{
+ Pic::Memory memory(device());
+ if ( type==Pic::MemoryRangeType::Code ) return static_cast<Hardware &>(hardware()).writeCode(memory.arrayForWriting(type), true);
+ return hardware().write(type, memory.arrayForWriting(type));
+}
diff --git a/src/progs/tbl_bootloader/base/tbl_bootloader.h b/src/progs/tbl_bootloader/base/tbl_bootloader.h
new file mode 100644
index 0000000..b6e759f
--- /dev/null
+++ b/src/progs/tbl_bootloader/base/tbl_bootloader.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef TBL_BOOTLOADER_H
+#define TBL_BOOTLOADER_H
+
+#include "progs/bootloader/base/bootloader.h"
+#include "progs/bootloader/base/bootloader_prog.h"
+#include "common/port/serial.h"
+#include "common/global/generic_config.h"
+
+namespace TinyBootloader
+{
+//-----------------------------------------------------------------------------
+class Config : public GenericConfig
+{
+public:
+ Config() : GenericConfig("tiny_bootloader") {}
+ Port::Serial::Speed readSpeed();
+ void writeSpeed(Port::Serial::Speed speed);
+ uint readTimeout(); // ms
+ void writeTimeout(uint timeout); // ms
+ uint readRetries();
+ void writeRetries(uint nb);
+};
+
+//-----------------------------------------------------------------------------
+class Hardware : public ::Bootloader::Hardware
+{
+public:
+ Hardware(::Programmer::Base &base, const QString &portDevice);
+ Port::Serial *port() { return static_cast<Port::Serial *>(_port); }
+ bool verifyDeviceId();
+ virtual bool write(Pic::MemoryRangeType type, const Device::Array &data);
+ virtual bool read(Pic::MemoryRangeType, Device::Array &, const ::Programmer::VerifyData *) { return false; }
+ bool writeCode(const Device::Array &data, bool erase);
+ bool writeConfig(const Device::Array &data);
+ bool writeEeprom(const Device::Array &data);
+ virtual bool internalConnectHardware();
+ virtual bool openPort();
+
+private:
+ uchar _id;
+ uint _timeout; // ms
+ uint _retries;
+
+ bool waitReady(bool *checkCRC);
+ bool sendChar(char c, uchar *crc);
+ bool sendCodeAddress(uint address, uchar &crc);
+ bool endWrite(uchar crc, uint &retries, bool &ok);
+};
+
+//-----------------------------------------------------------------------------
+class DeviceSpecific : public ::Bootloader::DeviceSpecific
+{
+public:
+ DeviceSpecific(::Programmer::Base &base) : ::Bootloader::DeviceSpecific(base) {}
+ virtual bool canEraseAll() const { return true; }
+ virtual bool canEraseRange(Pic::MemoryRangeType type) const { return canWriteRange(type); }
+ virtual bool emulatedErase() const { return true; }
+ virtual bool canReadRange(Pic::MemoryRangeType) const { return false; }
+ virtual bool canWriteRange(Pic::MemoryRangeType type) const;
+ virtual bool doEraseRange(Pic::MemoryRangeType type);
+ virtual bool doErase(bool);
+};
+
+} // namespace
+
+#endif
diff --git a/src/progs/tbl_bootloader/base/tbl_bootloader.xml b/src/progs/tbl_bootloader/base/tbl_bootloader.xml
new file mode 100644
index 0000000..bbad6dd
--- /dev/null
+++ b/src/progs/tbl_bootloader/base/tbl_bootloader.xml
@@ -0,0 +1,70 @@
+<!-- ************************************************************************* -->
+<!-- * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> * -->
+<!-- * * -->
+<!-- * This program is free software; you can redistribute it and/or modify * -->
+<!-- * it under the terms of the GNU General Public License as published by * -->
+<!-- * the Free Software Foundation; either version 2 of the License, or * -->
+<!-- * (at your option) any later version. * -->
+<!-- *************************************************************************/-->
+<!DOCTYPE piklab>
+
+<type name="tbl_bootloader">
+ <device name="16F873A" family="generic" id="0x32" />
+ <device name="16F874A" family="generic" id="0x32" />
+ <device name="16F876A" family="generic" id="0x31" />
+ <device name="16F877A" family="generic" id="0x31" />
+ <device name="16F87" family="generic" id="0x33" />
+ <device name="16F88" family="generic" id="0x33" />
+
+ <device name="18F1220" family="generic" id="0x46" />
+ <device name="18F1320" family="generic" id="0x45" />
+ <device name="18F2220" family="generic" id="0x46" />
+ <device name="18F2320" family="generic" id="0x45" />
+ <device name="18F4220" family="generic" id="0x48" />
+ <device name="18F4320" family="generic" id="0x47" />
+ <device name="18F6720" family="generic" id="0x4A" />
+ <device name="18F8720" family="generic" id="0x4A" />
+ <device name="18F6620" family="generic" id="0x4B" />
+ <device name="18F8620" family="generic" id="0x4B" />
+ <device name="18F6520" family="generic" id="0x4C" />
+ <device name="18F8520" family="generic" id="0x4C" />
+ <device name="18F8680" family="generic" id="0x4D" />
+ <device name="18F2525" family="generic" id="0x4E" />
+ <device name="18F4525" family="generic" id="0x4E" />
+ <device name="18F2620" family="generic" id="0x4F" />
+ <device name="18F4620" family="generic" id="0x4F" />
+ <device name="18F242" family="generic" id="0x42" />
+ <device name="18F252" family="generic" id="0x41" />
+ <device name="18F442" family="generic" id="0x42" />
+ <device name="18F452" family="generic" id="0x41" />
+ <device name="18F2420" family="generic" id="0x42" />
+ <device name="18F2520" family="generic" id="0x41" />
+ <device name="18F4420" family="generic" id="0x42" />
+ <device name="18F4520" family="generic" id="0x41" />
+ <device name="18F248" family="generic" id="0x44" />
+ <device name="18F258" family="generic" id="0x43" />
+ <device name="18F448" family="generic" id="0x44" />
+ <device name="18F458" family="generic" id="0x43" />
+ <device name="18F2480" family="generic" id="0x44" />
+ <device name="18F2580" family="generic" id="0x43" />
+ <device name="18F4480" family="generic" id="0x44" />
+ <device name="18F4580" family="generic" id="0x43" />
+ <device name="18F2455" family="generic" id="0x56" />
+ <device name="18F2550" family="generic" id="0x55" />
+ <device name="18F4455" family="generic" id="0x56" />
+ <device name="18F4550" family="generic" id="0x55" />
+
+ <device name="30F2010" family="generic" id="0x70" />
+ <device name="30F6014" family="generic" id="0x71" />
+ <device name="30F6012" family="generic" id="0x71" />
+ <device name="30F6013" family="generic" id="0x72" />
+ <device name="30F6011" family="generic" id="0x72" />
+ <device name="30F3013" family="generic" id="0x73" />
+ <device name="30F3012" family="generic" id="0x73" />
+ <device name="30F2012" family="generic" id="0x74" />
+ <device name="30F2011" family="generic" id="0x74" />
+ <device name="30F4011" family="generic" id="0x75" />
+ <device name="30F4012" family="generic" id="0x75" />
+ <device name="30F3010" family="generic" id="0x76" />
+ <device name="30F3011" family="generic" id="0x76" />
+</type>
diff --git a/src/progs/tbl_bootloader/base/tbl_bootloader_data.h b/src/progs/tbl_bootloader/base/tbl_bootloader_data.h
new file mode 100644
index 0000000..51be528
--- /dev/null
+++ b/src/progs/tbl_bootloader/base/tbl_bootloader_data.h
@@ -0,0 +1,21 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef TBL_BOOTLOADER_DATA_H
+#define TBL_BOOTLOADER_DATA_H
+
+namespace TinyBootloader
+{
+ struct Data {
+ uchar id;
+ };
+ extern bool isSupported(const QString &device);
+ extern const Data &data(const QString &device);
+} // namespace
+
+#endif
diff --git a/src/progs/tbl_bootloader/base/tbl_bootloader_prog.cpp b/src/progs/tbl_bootloader/base/tbl_bootloader_prog.cpp
new file mode 100644
index 0000000..22c831e
--- /dev/null
+++ b/src/progs/tbl_bootloader/base/tbl_bootloader_prog.cpp
@@ -0,0 +1,14 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "tbl_bootloader_prog.h"
+
+//-----------------------------------------------------------------------------
+TinyBootloader::ProgrammerBase::ProgrammerBase(const Programmer::Group &group, const Pic::Data *data)
+ : Bootloader::ProgrammerBase(group, data, "tiny_bootloader_programmer_base")
+{}
diff --git a/src/progs/tbl_bootloader/base/tbl_bootloader_prog.h b/src/progs/tbl_bootloader/base/tbl_bootloader_prog.h
new file mode 100644
index 0000000..75b986d
--- /dev/null
+++ b/src/progs/tbl_bootloader/base/tbl_bootloader_prog.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef TBL_BOOTLOADER_PROG_H
+#define TBL_BOOTLOADER_PROG_H
+
+#include "tbl_bootloader.h"
+
+namespace TinyBootloader
+{
+
+//-----------------------------------------------------------------------------
+class ProgrammerBase : public ::Bootloader::ProgrammerBase
+{
+Q_OBJECT
+public:
+ ProgrammerBase(const Programmer::Group &group, const Pic::Data *data);
+ virtual bool verifyDeviceId() { return static_cast<Hardware &>(hardware()).verifyDeviceId(); }
+};
+
+//-----------------------------------------------------------------------------
+class Group : public ::Bootloader::Group
+{
+public:
+ virtual QString name() const { return "tbl_bootloader"; }
+ virtual QString label() const { return i18n("Tiny Bootloader"); }
+ virtual ::Programmer::Properties properties() const { return ::Programmer::Programmer; }
+ virtual ::Programmer::TargetPowerMode targetPowerMode() const { return ::Programmer::TargetSelfPowered; }
+ virtual bool isPortSupported(PortType type) const { return type==PortType::Serial; }
+ virtual bool canReadVoltage(Pic::VoltageType) const { return false; }
+
+protected:
+ virtual void initSupported();
+ virtual ::Programmer::Base *createBase(const Device::Data *data) const { return new ProgrammerBase(*this, static_cast<const Pic::Data *>(data)); }
+ virtual ::Programmer::Hardware *createHardware(::Programmer::Base &base, const ::Programmer::HardwareDescription &hd) const { return new Hardware(base, hd.port.device); }
+ virtual ::Programmer::DeviceSpecific *createDeviceSpecific(::Programmer::Base &base) const { return new DeviceSpecific(base); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/progs/tbl_bootloader/gui/Makefile.am b/src/progs/tbl_bootloader/gui/Makefile.am
new file mode 100644
index 0000000..d10b944
--- /dev/null
+++ b/src/progs/tbl_bootloader/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libtblbootloaderui.la
+libtblbootloaderui_la_LDFLAGS = $(all_libraries)
+libtblbootloaderui_la_SOURCES = tbl_bootloader_ui.cpp
diff --git a/src/progs/tbl_bootloader/gui/tbl_bootloader_ui.cpp b/src/progs/tbl_bootloader/gui/tbl_bootloader_ui.cpp
new file mode 100644
index 0000000..5b576b9
--- /dev/null
+++ b/src/progs/tbl_bootloader/gui/tbl_bootloader_ui.cpp
@@ -0,0 +1,80 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "tbl_bootloader_ui.h"
+
+#include "progs/tbl_bootloader/base/tbl_bootloader.h"
+#include "common/port/serial.h"
+
+//-----------------------------------------------------------------------------
+TinyBootloader::ConfigWidget::ConfigWidget(const::Programmer::Group &group, QWidget *parent)
+ : ::Programmer::ConfigWidget(group, parent)
+{
+ uint row = numRows();
+
+ QLabel *label = new QLabel(i18n("Port Speed:"), this);
+ addWidget(label, row,row, 0,0);
+ _speed = new KComboBox(this);
+ for (uint i=0; i<Port::Serial::Nb_Speeds; i++) {
+ if ( Port::Serial::SPEED_VALUES[i]==0 || !Port::Serial::SPEED_DATA[i].supported ) continue;
+ _speed->insertItem(QString::number(Port::Serial::SPEED_VALUES[i]));
+ }
+ addWidget(_speed, row,row, 1,1);
+ row++;
+
+ label = new QLabel(i18n("Timeout (ms):"), this);
+ addWidget(label, row,row, 0,0);
+ _timeout = new KIntNumInput(this);
+ _timeout->setMinValue(0);
+ addWidget(_timeout, row,row, 1,1);
+ row++;
+
+ label = new QLabel(i18n("No of Retries:"), this);
+ addWidget(label, row,row, 0,0);
+ _retries = new KIntNumInput(this);
+ _retries->setMinValue(0);
+ addWidget(_retries, row,row, 1,1);
+ row++;
+}
+
+void TinyBootloader::ConfigWidget::saveConfig()
+{
+ Config config;
+ uint k = 0;
+ for (uint i=0; i<Port::Serial::Nb_Speeds; i++) {
+ if ( Port::Serial::SPEED_VALUES[i]==0 || !Port::Serial::SPEED_DATA[i].supported ) continue;
+ if ( uint(_speed->currentItem())==k ) {
+ config.writeSpeed(Port::Serial::Speed(i));
+ break;
+ }
+ k++;
+ }
+ config.writeTimeout(_timeout->value());
+ config.writeRetries(_retries->value());
+}
+
+void TinyBootloader::ConfigWidget::loadConfig()
+{
+ Config config;
+ Port::Serial::Speed speed = config.readSpeed();
+ uint k = 0;
+ for (uint i=0; i<Port::Serial::Nb_Speeds; i++) {
+ if ( Port::Serial::SPEED_VALUES[i]==0 || !Port::Serial::SPEED_DATA[i].supported ) continue;
+ if ( i==uint(speed) ) break;
+ k++;
+ }
+ _speed->setCurrentItem(k);
+ _timeout->setValue(config.readTimeout());
+ _retries->setValue(config.readRetries());
+}
+
+//-----------------------------------------------------------------------------
+::Programmer::ConfigWidget *TinyBootloader::GroupUI::createConfigWidget(QWidget *parent) const
+{
+ return new ConfigWidget(static_cast<const ::Programmer::Group &>(group()), parent);
+}
diff --git a/src/progs/tbl_bootloader/gui/tbl_bootloader_ui.h b/src/progs/tbl_bootloader/gui/tbl_bootloader_ui.h
new file mode 100644
index 0000000..d0285af
--- /dev/null
+++ b/src/progs/tbl_bootloader/gui/tbl_bootloader_ui.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef TBL_BOOTLOADER_UI_H
+#define TBL8BOOTLOADER_UI_H
+
+#include <kcombobox.h>
+#include <knuminput.h>
+
+#include "progs/bootloader/gui/bootloader_ui.h"
+
+//-----------------------------------------------------------------------------
+namespace TinyBootloader
+{
+class ConfigWidget: public ::Programmer::ConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(const ::Programmer::Group &group, QWidget *parent);
+ virtual void loadConfig();
+ virtual void saveConfig();
+
+private:
+ KIntNumInput *_timeout, *_retries;
+ KComboBox *_type, *_speed;
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public ::Bootloader::GroupUI
+{
+public:
+ virtual ::Programmer::ConfigWidget *createConfigWidget(QWidget *parent) const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/progs/tbl_bootloader/tbl_bootloader.pro b/src/progs/tbl_bootloader/tbl_bootloader.pro
new file mode 100644
index 0000000..60ac0f5
--- /dev/null
+++ b/src/progs/tbl_bootloader/tbl_bootloader.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS = xml base
diff --git a/src/progs/tbl_bootloader/xml/Makefile.am b/src/progs/tbl_bootloader/xml/Makefile.am
new file mode 100644
index 0000000..609ca90
--- /dev/null
+++ b/src/progs/tbl_bootloader/xml/Makefile.am
@@ -0,0 +1,14 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_PROGRAMS = xml_tbl_bootloader_parser
+xml_tbl_bootloader_parser_SOURCES = xml_tbl_bootloader_parser.cpp
+OBJECTS = $(top_builddir)/src/devices/list/libdevicelistnoui.la \
+ $(top_builddir)/src/devices/pic/pic/libpic.la $(top_builddir)/src/devices/pic/base/libpicbase.la \
+ $(top_builddir)/src/devices/pic/xml_data/libpicxml.la \
+ $(top_builddir)/src/devices/mem24/mem24/libmem24.la $(top_builddir)/src/devices/mem24/base/libmem24base.la \
+ $(top_builddir)/src/devices/mem24/xml_data/libmem24xml.la \
+ $(top_builddir)/src/xml_to_data/libxmltodata.la $(top_builddir)/src/devices/base/libdevicebase.la \
+ $(top_builddir)/src/common/common/libcommon.la
+xml_tbl_bootloader_parser_DEPENDENCIES = $(OBJECTS)
+xml_tbl_bootloader_parser_LDADD = $(OBJECTS) $(LIB_KDECORE)
diff --git a/src/progs/tbl_bootloader/xml/xml.pro b/src/progs/tbl_bootloader/xml/xml.pro
new file mode 100644
index 0000000..a7d488a
--- /dev/null
+++ b/src/progs/tbl_bootloader/xml/xml.pro
@@ -0,0 +1,17 @@
+STOPDIR = ../../../..
+include($${STOPDIR}/app.pro)
+
+TARGET = xml_tbl_bootloader_parser
+SOURCES += xml_tbl_bootloader_parser.cpp
+LIBS += ../../../devices/list/libdevicelist.a \
+ ../../../devices/mem24/mem24/libmem24.a ../../../devices/mem24/xml_data/libmem24xml.a \
+ ../../../devices/mem24/base/libmem24base.a \
+ ../../../devices/pic/pic/libpic.a ../../../devices/pic/xml_data/libpicxml.a \
+ ../../../devices/pic/base/libpicbase.a ../../../xml_to_data/libxmltodata.a \
+ ../../../devices/base/libdevicebase.a ../../../common/global/libglobal.a \
+ ../../../common/nokde/libnokde.a ../../../common/common/libcommon.a
+
+unix:QMAKE_POST_LINK = cd ../base && ../xml/xml_tbl_bootloader_parser
+unix:QMAKE_CLEAN += ../base/tbl_bootloader_data.cpp
+win32:QMAKE_POST_LINK = cd ..\base && ..\xml\xml_tbl_bootloader_parser.exe
+win32:QMAKE_CLEAN += ..\base\tbl_bootloader_data.cpp
diff --git a/src/progs/tbl_bootloader/xml/xml_tbl_bootloader_parser.cpp b/src/progs/tbl_bootloader/xml/xml_tbl_bootloader_parser.cpp
new file mode 100644
index 0000000..62ed806
--- /dev/null
+++ b/src/progs/tbl_bootloader/xml/xml_tbl_bootloader_parser.cpp
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "xml_to_data/prog_xml_to_data.h"
+
+#include "progs/tbl_bootloader/base/tbl_bootloader_data.h"
+#include "devices/base/device_group.h"
+#include "devices/pic/base/pic.h"
+
+//-----------------------------------------------------------------------------
+namespace TinyBootloader
+{
+
+class XmlToData : public Programmer::XmlToData<Data>
+{
+public:
+ XmlToData() : Programmer::XmlToData<Data>("tbl_bootloader", "TinyBootloader") {}
+
+private:
+ virtual void parseData(QDomElement element, Data &data);
+ virtual void outputData(const Data &data, QTextStream &s) const;
+};
+
+void TinyBootloader::XmlToData::parseData(QDomElement element, Data &data)
+{
+ const Device::Data *ddata = Device::lister().data(currentDevice());
+ if ( ddata->group().name()!="pic" ) qFatal("non-pic device not supported");
+ const Pic::Data *pdata = static_cast<const Pic::Data *>(ddata);
+ if ( !pdata->hasFeature(Pic::Feature::USART) ) qFatal("device does not have USART");
+ bool ok;
+ data.id = fromHexLabel(element.attribute("id"), 2, &ok);
+ if ( !ok ) qFatal("Invalid \"id\" tag");
+}
+
+void TinyBootloader::XmlToData::outputData(const Data &data, QTextStream &s) const
+{
+ s << data.id;
+}
+
+} // namespace
+
+//-----------------------------------------------------------------------------
+XML_MAIN(TinyBootloader::XmlToData)