Skip to content

Commit

Permalink
Add "debugcore" option for more flash space on 2560 (#304)
Browse files Browse the repository at this point in the history
* Add debugchip option for more flash space on 2560
  • Loading branch information
vintagepc authored Apr 20, 2021
1 parent f971410 commit 7b5d679
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
16 changes: 15 additions & 1 deletion MK404.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,10 @@ int main(int argc, char *argv[])
std::vector<string> vstrExts = PrintVisualType::GetOpts();
ValuesConstraint<string> vcPrintOpts(vstrExts);
ValueArg<string> argExtrusion("","extrusion","Set Print visual type. HR options create a LOT of triangles, do not use for large prints!",false, "Line", &vcPrintOpts, cmd);
SwitchArg argDebugCore("","debugcore","Uses a debug version of the chip with more flash space. Board-dependent.", cmd);
MultiSwitchArg argDebug("d","debug","Increases debugging output, where supported.", cmd);
SwitchArg argColourE("", "colour-extrusion", "Colours extrusion by width (for advanced step/extrusion debugging.", cmd, false);
ValueArg<string> argStrBoot("","bootloader-file", "Specifies a .hex file to load as the bootloader. If empty, ("") no bootloader is loaded, if unspecified the default is used.",false,"stk500boot_v2_mega2560.hex","string",cmd);
SwitchArg argBootloader("b","bootloader","Run bootloader on first start instead of going straight to the firmware.",cmd);
SwitchArg argMD("","markdown","Used to auto-generate the items in refs/ as markdown",cmd);

Expand All @@ -364,6 +366,8 @@ int main(int argc, char *argv[])
bool bArgHacks = argNoHacks.isSet() || argKlipper.isSet() || argMarlin.isSet();
bool bArgSkew = argSkew.isSet() || argKlipper.isSet();
Config::Get().SetSkewCorrect(bArgSkew);

Config::Get().SetDebugCore(argDebugCore.isSet());
// Make new image.
if (argImgSize.isSet())
{
Expand Down Expand Up @@ -402,8 +406,18 @@ int main(int argc, char *argv[])
strFW = argFW.getValue();
}

if (!argStrBoot.isSet())
{
std::cout << "No bootloader specified, using default: " << argStrBoot.getValue() << '\n';
} else if (argStrBoot.getValue().empty())
{
std::cout << "Empty bootloader filename provided. NOT loading a bootloader.\n";
} else {
std::cout << "Using Bootloader: " << argStrBoot.getValue() << '\n';
}

void *pRawPrinter = PrinterFactory::CreatePrinter(argModel.getValue(),pBoard,printer,argBootloader.isSet(),bArgHacks,argSerial.isSet(), argSD.getValue() ,
strFW,argSpam.getValue(), argGDB.isSet(), argVCDRate.getValue(),"stk500boot_v2_mega2560.hex"); // this line is the CreateBoard() args.
strFW,argSpam.getValue(), argGDB.isSet(), argVCDRate.getValue(),argStrBoot.getValue()); // this line is the CreateBoard() args.

pBoard->SetPrimary(true); // This is the primary board, responsible for scripting/dispatch. Blocks contention from sub-boards, e.g. MMU.

Expand Down
9 changes: 5 additions & 4 deletions parts/Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,13 @@ namespace Boards {
}
gsl::span<uint8_t> chunk0 {pChunks[0].data, pChunks[0].size};
uint32_t uiFWStart = pChunks[0].baseaddr;
if (iCount > 1) {
pChunks[1].baseaddr = 0; // Want to start at 0 in the flash chip, but after hex read this is end-of-firmware.
if (iCount > 1)
{
gsl::span<ihex_chunk_t> spanChunks {pChunks, gsl::narrow<uint32_t>(iCount)};
for (int i=1; i<iCount; i++)
OnExtraHexChunk({spanChunks.at(1).data,spanChunks.at(1).size},spanChunks.at(1).baseaddr);
if (iCount > 2)
{
OnExtraHexChunk({spanChunks.at(i).data,spanChunks.at(i).size},spanChunks.at(i).baseaddr);
std::cout << "Note: Hex file contains extra chunks, only 2 of " << std::to_string(iCount) << " were used.\n";
}
}
std::cout << "Loaded " << chunk0.size_bytes() << " bytes from HEX file: " << strFW << '\n';
Expand Down
4 changes: 2 additions & 2 deletions parts/PinSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PinSpec {
PinSpec(gsl::span<const unsigned char>pin2port, gsl::span<const unsigned char>pin2Mask, gsl::span<const unsigned char>pin2Timer,const std::string &strMCU):
m_pDPin2Port(pin2port),m_pDPin2Mask(pin2Mask),m_pDPin2Timer(pin2Timer),m_strMCU(strMCU)
{
std::cout << "Creating pinspec for" << strMCU << '\n';
std::cout << "Creating pinspec for " << strMCU << '\n';
};

// Returns a char representation of the port, e.g. 'A'
Expand All @@ -46,7 +46,7 @@ class PinSpec {

// Returns the MCU this spec is for. Used to designate the
// CPU in a board using this pinspec.
inline std::string GetMCUName() const { return m_strMCU; }
virtual inline std::string GetMCUName() const { return m_strMCU; }

protected:
// Set these in your derived class constructor args to pointer
Expand Down
3 changes: 3 additions & 0 deletions parts/pinspecs/PinSpec_2560.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma once

#include "PinSpec.h"
#include "Config.h"
#include "PinSpec_Helper.h"

class PinSpec_2560 : public PinSpec
Expand All @@ -33,6 +34,8 @@ class PinSpec_2560 : public PinSpec
public:
PinSpec_2560():PinSpec(DPin2Port,DPin2Mask,DPin2Timer,"atmega2560"){};

std::string GetMCUName() const { return Config::Get().GetDebugCore()?"atmega404":m_strMCU; };

private:

const unsigned char DPin2Timer[86] = {
Expand Down
5 changes: 5 additions & 0 deletions utility/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ class Config
inline void SetLCDScheme(uint8_t iVal){ m_iScheme = iVal;}
inline uint8_t GetLCDScheme(){ return m_iScheme;}

// Use a "debug" core? (board-specific)
inline void SetDebugCore(bool bVal){ m_bDebugCore = bVal;}
inline bool GetDebugCore(){ return m_bDebugCore;}

private:
unsigned int m_iExtrusion = false;
bool m_bColorExtrusion = false;
bool m_bSkew = false;
uint8_t m_iScheme = 0;
bool m_bDebugCore = false;

};

0 comments on commit 7b5d679

Please sign in to comment.