From 1ba1b5a2f3a3b56e24fe7b5b4d81174e797f37dc Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Thu, 25 Feb 2021 19:00:07 -0500 Subject: [PATCH 1/4] Indicate if axis is stalled --- parts/components/TMC2130.cpp | 7 ++++++- parts/components/TMC2130.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/parts/components/TMC2130.cpp b/parts/components/TMC2130.cpp index 1ef1c48c..1cd8453a 100644 --- a/parts/components/TMC2130.cpp +++ b/parts/components/TMC2130.cpp @@ -57,7 +57,11 @@ void TMC2130::_Draw(bool bIsSimple) } // Copy atomic to local float fPos = m_fCurPos; - glColor3f(0,0,0); + if (m_bDrawStall) { + glColor3f(0.7,0,0); + } else { + glColor3f(0,0,0); + } glBegin(GL_QUADS); glVertex3f(0,0,0); glVertex3f(350,0,0); @@ -191,6 +195,7 @@ void TMC2130::RaiseDiag(uint8_t value) if (bDiag) { //printf("Raised: %d\n", value == m_regs.defs.GCONF.diag0_int_pushpull); + m_bDrawStall = value>0; RaiseIRQ(DIAG_OUT, value == m_regs.defs.GCONF.diag0_int_pushpull); } } diff --git a/parts/components/TMC2130.h b/parts/components/TMC2130.h index aad0374e..ad8d0466 100644 --- a/parts/components/TMC2130.h +++ b/parts/components/TMC2130.h @@ -218,6 +218,8 @@ class TMC2130: public SPIPeripheral, public Scriptable bool m_bStall = false; uint32_t m_uiStepIncrement = 1; + std::atomic_bool m_bDrawStall {false}; + // Position helpers float StepToPos(int32_t step); int32_t PosToStep(float step); From bac794f92187ff5dbdac653db87eb17f87978d82 Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Thu, 25 Feb 2021 19:26:00 -0500 Subject: [PATCH 2/4] Update test images --- scripts/tests/snaps/parts/TMC02.png | Bin 920 -> 1014 bytes scripts/tests/snaps/parts/TMC03.png | Bin 843 -> 951 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/scripts/tests/snaps/parts/TMC02.png b/scripts/tests/snaps/parts/TMC02.png index 3a6919816be6230480a126b900eb8d3dab5be2f8..573323d9fecd972d629d4ba3b7ee79049133ebc4 100644 GIT binary patch delta 992 zcmbQi{*8TtO8s6>7srr_IdAVe7R`1LU=5gf>g$}tx7byh$Y>NF4vQ|BqDL<7S2m_PN#$PKRU_ z7T$jy&wJS5-I;VQf5tmG^Hk*hI+rUmx1XHKdN@2HzCiiT{Er{&-yaOmxqJNac?&za z{z8ekK$#ckjCi?E?(jK0p<}(ih5c{CzIJV!8s*nbPt7+8zI$wuSN7so*#bfPMY-p0 z`hK4H^zf^zA~EX* zP@DTMU{CKk*%vqF=2pi`KWVkTuzC&i%n9GOO20duzjW3ahRiQpWB(e>wZ5>_Ou4>P z%r4(Dy1@F*b@9m;_b}hBygsGo{W6*9=iS7)UfpT@7sGezu)R&SQN<_uj;}YBUfE9) z{vL35x3lnpxywxMct0#PYI|Oq`Z@0ZuIpUW#4T&))if5xeh*-+n4YR3eVRc9;zkC} z+SxmqFX$VWH#}*9M33S_z6lcw>e)R!b}++Lfua*CzcAnYb;ZA`cMMw`o`Y1fd%QSe z8*d-D93Cl0&}NIm#Lv~9m&LvKO-;-|Hl+!MFgXsJkQbL%DlO_t#Xf(fMJ@bGe@Ja`Peg3lCWtUwt(%j{knz zKP~AuE91FaeBVny*A?Hk%hVG7-exd8Tp~^&;adFjds99L?wn~YkOYdf-@LO^TBIBn zEVKT8sBDV79)H2B_(!plE4wSb75t^&CT!6bf;gJ0l72md0g_`&i3@y zBI}xk2|u_PljiPde|2Tg{uedAuZW;*H$)8T&I`2env%&6Vj#ZiR?lWBP-MJo#G+yUZ+|0U4Tf}7#KT%fe=KvT{{ zXKRz0i|E_|+J6$VS_pUG4Z_FkH=N?qYtG&0KA*V3PaFVwH^hC*bnZa+zC6d1ggd|s z33s4x+V-SexEFqd0YHP=yhHIeI(MLBcXpqB-5@XAfnL3Jt`PFNHp6|nq`dVV1inyT zx2spvxdUB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s%l9$nrd zJ41~D1QZVK`JWm&jr;wa=kLRr9`M%RyT{1zh_k$bQT33malT;}tmkIABUQ5dw;fhUcY_!+OVL4dCym~ey%@v z|H<#`xiZt##hLb`_U=5i;q>jKy-Oa{o%Knv4=^zHH7sWTHTnEj^}BDX?Eg<#VP+-! z?&~)8fWvcpy!IJJZuqbyD9)gU-`uKvfwAeWZy&klwf#=qw>X#GBg+`~T|cdav2+9ZGAymAqqM7J}kat-s3_H@p24=238tc>D4WV^>Rk zLiAVRgok_=rcLmkaJk_A{GgaO40AF;#yX^D`4}J5p27G1eDd{YD>)NN)fZ37_Yu>v zSwBUb=l}8BuItUP zXRoPzdugIqyxJOl-P0k7ZJXcD`6%EpZzIovh8AlO2FCyjQKImp?j6IH1F?#XY$|sc z*-9QtuKGEBQO?)J$LyZ6UN_|q=hn|S!^+~-^1FN6jN5Xdb;h6gSkJF|yM5}-cXrpZ z>qTs$c^^!By8rL_bnfh&zqeJVa>-2-U-vD=vBCSyo#p4*{yh7lxkuqZ=*xn7yLpq2 zzRxkSH0IQ|xcg%3VQ!`zsaJQZWz5^(7x%L>W?abJ@&310Fl)m;lPf#-D}C;r?#9LR z=RiLHcjJfR+Ux2X)SvEqzRz@F5a$AYD`1KNrkZ*X!T9vh-`mzJ7%r&It)8{sgDLj+ z+lTM8`wvX;J6tOtw95}{-uD|H+91{hSlzKt=iWN|`{v)u|0))r{OD0}@a3_!`wl_e zv%ae;&Ev<+H$Q`w4;*YwU$KreG(Yddf%MrkTXgSy>1Jg-Rogkq`=(YK!>p?xbtBjs kj1S2sI2@8i4%Zd0FVdQ&MBb@03yGDGynhq From db010297254545a940cd447d8ae4fc1634e608e5 Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Fri, 26 Feb 2021 08:51:23 -0500 Subject: [PATCH 3/4] Support loading languages from hex file to xflash --- parts/Board.cpp | 24 ++++++++++++++++-------- parts/Board.h | 3 +++ parts/boards/EinsyRambo.cpp | 5 +++++ parts/boards/EinsyRambo.h | 2 ++ parts/components/w25x20cl.cpp | 7 +++++++ parts/components/w25x20cl.h | 3 +++ 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/parts/Board.cpp b/parts/Board.cpp index a4a1079c..6c92482c 100644 --- a/parts/Board.cpp +++ b/parts/Board.cpp @@ -321,22 +321,30 @@ namespace Boards { avr_flashaddr_t Board::LoadFirmware(const string &strFW) { - uint32_t uiFWSize = 0, uiFWStart = 0; if (strFW.size()>4) { if (0==strFW.compare(strFW.size()-4, 4, ".hex")) { - gsl::unique_ptr puiBytes {read_ihex_file(strFW.c_str(),&uiFWSize, &uiFWStart) }; - if (!puiBytes) + ihex_chunk_p pChunks = nullptr; + int iCount = read_ihex_chunks(strFW.c_str(), &pChunks); + if (iCount==0) + { + std::cerr << "No chunks found in .hex file. Firmware NOT loaded!\n"; + return 0; + } else if (pChunks[0].data == nullptr) { std::cout << "WARN: Could not load " << strFW << ". MCU will execute existing flash." << '\n'; + return 0; } - else - { - std::cout << "Loaded " << uiFWSize << " bytes from HEX file: " << strFW << '\n'; - gsl::span flash {m_pAVR->flash, m_pAVR->flashend}; - memcpy(flash.begin() + uiFWStart, puiBytes.get(), uiFWSize); + gsl::span chunk0 {pChunks[0].data, pChunks[0].size}; + uint32_t uiFWStart = pChunks[0].baseaddr; + if (iCount > 1) { + OnExtraHexChunk({pChunks[1].data,pChunks[1].size}); } + std::cout << "Loaded " << chunk0.size_bytes() << " bytes from HEX file: " << strFW << '\n'; + gsl::span flash {m_pAVR->flash, m_pAVR->flashend}; + memcpy(flash.data() + uiFWStart, chunk0.begin(), chunk0.size_bytes()); + free_ihex_chunks(pChunks); m_pAVR->codeend = m_pAVR->flashend; return uiFWStart; } diff --git a/parts/Board.h b/parts/Board.h index 56af9eba..b945a45c 100644 --- a/parts/Board.h +++ b/parts/Board.h @@ -111,6 +111,9 @@ namespace Boards // within the context of the AVR run thread. virtual void OnAVRCycle(){}; + // For boards that can handle extra chunks in the hex (language) + virtual void OnExtraHexChunk(gsl::span chunk){}; + void OnKeyPress(const Key& key) override; LineStatus ProcessAction(unsigned int ID, const std::vector &vArgs) override; diff --git a/parts/boards/EinsyRambo.cpp b/parts/boards/EinsyRambo.cpp index a3ca6296..de6f8993 100644 --- a/parts/boards/EinsyRambo.cpp +++ b/parts/boards/EinsyRambo.cpp @@ -240,6 +240,11 @@ namespace Boards sd_card.Unmount(); } + void EinsyRambo::OnExtraHexChunk(gsl::span chunk) + { + spiFlash.Load(chunk); + } + void EinsyRambo::OnAVRReset() { std::cout << "RESET\n"; diff --git a/parts/boards/EinsyRambo.h b/parts/boards/EinsyRambo.h index 1524db94..534b3b48 100644 --- a/parts/boards/EinsyRambo.h +++ b/parts/boards/EinsyRambo.h @@ -66,6 +66,8 @@ namespace Boards void OnKeyPress(const Key& key) override; + void OnExtraHexChunk(gsl::span chunk) override; + static constexpr float fScale24v = 1.0f/26.097f; // Based on rSense voltage divider outputting 5v bool m_bFactoryReset = false; diff --git a/parts/components/w25x20cl.cpp b/parts/components/w25x20cl.cpp index f105fe86..4d18b47b 100644 --- a/parts/components/w25x20cl.cpp +++ b/parts/components/w25x20cl.cpp @@ -358,6 +358,13 @@ void w25x20cl::Load(const std::string &path) Load(); } +void w25x20cl::Load(const gsl::span data) +{ + size_t bytes = std::min(m_flash.size_bytes(), data.size_bytes()); + memcpy(m_flash.begin(), data.begin(), bytes); + std::cout << "Loaded " << std::to_string(bytes) << " from hex file to xflash\n"; +} + void w25x20cl::Load() { auto *path = m_filepath.c_str(); diff --git a/parts/components/w25x20cl.h b/parts/components/w25x20cl.h index d3fd628b..874751ac 100644 --- a/parts/components/w25x20cl.h +++ b/parts/components/w25x20cl.h @@ -58,6 +58,9 @@ class w25x20cl:public SPIPeripheral, public Scriptable // Loads the flash contents from file. (creates "path" if it does not exit) void Load(const std::string &path); + // Loads from an array + void Load(const gsl::span data); + // Reloads the current file. void Load(); From 5f57d12168b8d2d2c03a6eb227127af8208d4135 Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Fri, 26 Feb 2021 17:33:09 -0500 Subject: [PATCH 4/4] lint --- parts/Board.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parts/Board.h b/parts/Board.h index b945a45c..01d35683 100644 --- a/parts/Board.h +++ b/parts/Board.h @@ -112,7 +112,7 @@ namespace Boards virtual void OnAVRCycle(){}; // For boards that can handle extra chunks in the hex (language) - virtual void OnExtraHexChunk(gsl::span chunk){}; + virtual void OnExtraHexChunk(gsl::span /*chunk*/){}; void OnKeyPress(const Key& key) override;