Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 Fix MINITRONICS v1 support #27150

Merged
merged 3 commits into from
Aug 22, 2024

Conversation

lkundrak
Copy link
Contributor

@lkundrak lkundrak commented Jun 4, 2024

Description

This restores support for bitrotten MINITRONICS (v1.0 and v1.1) support.

This is my first contribution to Marlin -- please be patient with me if I messed up something in the PR.

Requirements

The MINITRONICS v1 board.

Benefits

Everybody with a MINITRONICS board (which I imagine is millions of people) can upgrade to the best and latest Marlin firmware and impress everybody.

Configurations

With the most basic functionality, to build and run this one just needs to set MOTHERBOARD:

-  #define MOTHERBOARD BOARD_RAMPS_14_EFB
+  #define MOTHERBOARD BOARD_MINITRONICS

@lkundrak
Copy link
Contributor Author

lkundrak commented Jun 4, 2024

I've tried attaching REPRAP_DISCOUNT_SMART_CONTROLLER and that seems to work perfectly, except that it literally eats up every single available pin, including ICSP and external extruder connector, with no pins left for card detect or buzzer anyway. It seems to work okay, patches forthcoming.

I'm going to actually use the board with a 1602 (16x2) instead of the 2004 (20x4) display. MAKEBOARD_MINI_2_LINE_DISPLAY_1602 seems to work just fine, surprisingly usable for a 2-line display.

2024-06-02-01-31-01-147

@ellensp
Copy link
Contributor

ellensp commented Jun 4, 2024

You have changed Marlin/src/HAL/AVR/fastio/fastio_1281.h I am very concerned that this will break ever other board using it...

@lkundrak
Copy link
Contributor Author

lkundrak commented Jun 4, 2024

You have changed Marlin/src/HAL/AVR/fastio/fastio_1281.h I am very concerned that this will break ever other board using it...

It will affect every board. They're already all broken (since HAL numbering doesn't match MegaCore numbering), they'll just be broken differently.

More precisely speaking, "every" board appears to be MINITRONICS and SILVER_GATE. I'm fixing up MINITRONICS in this patch set. Silver Gate seem to be broken in another way too:

[lkundrak@bzdocha Marlin]$ grep SILVER_GATE Marlin/src/pins/pins.h
#elif MB(SILVER_GATE)
  #include "mega/pins_SILVER_GATE.h"                // ATmega2561                           env:mega2560
[lkundrak@bzdocha Marlin]$ 

Note the env:mega2560, which is incorrect. I don't think that will build (MINITRONICS was broken in the same way and tripped a build time check).

@InsanityAutomation
Copy link
Contributor

At present, I only see the 1 1281 board at least merged upstream.... But we definitely need to compare these changes to the MCU data sheet. It drastically changes the MCU port to dio numbering which should all coincide with the chip documentation.

@lkundrak
Copy link
Contributor Author

lkundrak commented Jun 4, 2024

Yeah, Silver Gate is not building:

[lkundrak@bzdocha Marlin]$ git diff
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 7effc47cf7..f7fb6da9c7 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -88,7 +88,7 @@
 
 // Choose the name from boards.h that matches your setup
 #ifndef MOTHERBOARD
-  #define MOTHERBOARD BOARD_RAMPS_14_EFB
+  #define MOTHERBOARD BOARD_SILVER_GATE
 #endif
 /**
[lkundrak@bzdocha Marlin]$ make marlin
...
In file included from Marlin/src/HAL/AVR/../../inc/../pins/pins.h:302:0,
                 from Marlin/src/HAL/AVR/../../inc/MarlinConfig.h:36,
                 from Marlin/src/HAL/AVR/HAL_SPI.cpp:34:
Marlin/src/HAL/AVR/../../inc/../pins/mega/pins_SILVER_GATE.h:27:4: error: #error "Oops! Select 'Silvergate' in 'Tools > Board.'"
   #error "Oops! Select 'Silvergate' in 'Tools > Board.'"
    ^~~~~

I guess I could fix it up blindly, but I have no way to test.

@ellensp
Copy link
Contributor

ellensp commented Jun 4, 2024

It also disagree with changes, there is a provided Fastio.h information in https://reprap.org/wiki/Minitronics_10 File:Fastio.h.zip upload by The board developer themselves Brupje

@lkundrak
Copy link
Contributor Author

lkundrak commented Jun 4, 2024

It also disagree with changes, there is a provided Fastio.h information in https://reprap.org/wiki/Minitronics_10 File:Fastio.h.zip upload by The board developer themselves Brupje

Yeah, as mentioned in the commit message: I have no idea where those numbers come from. They most certainly don't work with 2.1.x. They are not what megacore uses. Here's what it does use: https://github.com/MCUdude/MegaCore?tab=readme-ov-file#pinout

@thisiskeithb
Copy link
Member

You will need to target this PR to the bugfix-2.1.x branch.

@lkundrak lkundrak changed the base branch from 2.1.x to bugfix-2.1.x June 4, 2024 12:08
@lkundrak lkundrak changed the base branch from bugfix-2.1.x to 2.1.x June 4, 2024 12:10
@ellensp
Copy link
Contributor

ellensp commented Jun 4, 2024

I think thats the issue, you have presumed megacore
when they infact used their own board https://reprap.org/wiki/File:MinitronicsArduinoAddon.zip

"mega1281.build.core=arduino" not megacore (MCUdude_corefiles)

@lkundrak lkundrak changed the base branch from 2.1.x to bugfix-2.1.x June 4, 2024 12:24
@lkundrak
Copy link
Contributor Author

lkundrak commented Jun 4, 2024

You will need to target this PR to the bugfix-2.1.x branch.

Retargeted it now.

I think thats the issue, you have presumed megacore when they infact used their own board https://reprap.org/wiki/File:MinitronicsArduinoAddon.zip

"mega1281.build.core=arduino" not megacore (MCUdude_corefiles)

Sorry, I'm not familiar with Arduino enough to comprehend this. I've presumed megacore, because that's what ended up being used, but I don't really understand why. What would be the most reasonable course of action here? Hope it doesn't involve relying on some ancient Arduino fork?

@ellensp
Copy link
Contributor

ellensp commented Jun 4, 2024

use stock code

apply this diff and build. I suspect it works fine

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index f88f5b9dbd..187b85f6b0 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -68,7 +68,7 @@
 
 // Choose the name from boards.h that matches your setup
 #ifndef MOTHERBOARD
-  #define MOTHERBOARD BOARD_RAMPS_14_EFB
+  #define MOTHERBOARD BOARD_MINITRONICS
 #endif
 
 /**
diff --git a/Marlin/src/pins/mega/pins_MINITRONICS.h b/Marlin/src/pins/mega/pins_MINITRONICS.h
index e6e24f8886..383ea212c2 100644
--- a/Marlin/src/pins/mega/pins_MINITRONICS.h
+++ b/Marlin/src/pins/mega/pins_MINITRONICS.h
@@ -34,7 +34,7 @@
  *  Added pin definitions for M3, M4 & M5 spindle control commands
  */
 
-#if NOT_TARGET(__AVR_ATmega1281__)
+#if NOT_TARGET(__AVR_ATmega1280__)
   #error "Oops! Select 'Minitronics' in 'Tools > Board.'"
 #elif HOTENDS > 2 || E_STEPPERS > 2
   #error "Minitronics supports up to 2 hotends / E steppers."
diff --git a/platformio.ini b/platformio.ini
index 76200cbbd5..10c822c908 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -13,7 +13,7 @@
 [platformio]
 src_dir      = Marlin
 boards_dir   = buildroot/share/PlatformIO/boards
-default_envs = mega2560
+default_envs = mega1280
 include_dir  = Marlin
 extra_configs =
     Marlin/config.ini

@thisiskeithb thisiskeithb added Needs: More Data We need more data in order to proceed C: Boards/Pins Needs: Discussion Discussion is needed labels Jun 6, 2024
@lkundrak
Copy link
Contributor Author

lkundrak commented Jun 7, 2024

Thanks for the response. With the patch, it builds, but the pin mapping is still entirely messed up:

M43
echo:M43
PIN:   0   Port: E0        RXD0                                   protected 
PIN:   1   Port: E1        TXD0                                   protected 
PIN:   2   Port: E4        Y_MIN_PIN                              protected 
.                          Y_STOP_PIN                             protected 
PIN:   3   Port: E5        HEATER_BED_PIN                         protected 
PIN:   4   Port: G5        <unused/unknown>                       Input  LOW                           TIMER0B   PWM:     0    WGM: 3    COM0B: 3    CS: 3    TCCR0A: 3    TCCR0B: 3    TIMSK0: 3   overflow interrupt enabled  
PIN:   5   Port: E3        X_MIN_PIN                              protected 
.                          X_STOP_PIN                             protected 
PIN:   6   Port: H3        Z_MIN_PIN                              protected 
.                          Z_STOP_PIN                             protected 
PIN:   7   Port: H4        HEATER_0_PIN                           protected 
PIN:   8   Port: H5        HEATER_1_PIN                           Input  LOW    TIMER4C   PWM:     0    WGM: 1    COM4C: 0    CS: 3    TCCR4A: 1    TCCR4B: 3    TIMSK4: 0  
PIN:   9   Port: H6        FAN0_PIN                               protected 
PIN:  10   Port: B4        <unused/unknown>                       Input  LOW                           TIMER2A   PWM:     0    WGM: 1    COM2A: 1    CS: 4    TCCR2A: 1    TCCR2B: 4    TIMSK2: 0  
PIN:  11   Port: B5        <unused/unknown>                       Input  LOW                           TIMER1A   PWM:  2000    WGM: 4    COM1A: 0    CS: 2    TCCR1A: 0    TCCR1B: 10    TIMSK1: 2   non-standard PWM mode   compare interrupt enabled  
PIN:  12   Port: B6        <unused/unknown>                       Input  LOW                           TIMER1B   PWM:     0    WGM: 4    COM1B: 0    CS: 2    TCCR1A: 0    TCCR1B: 10    TIMSK1: 2   non-standard PWM mode  
PIN:  13   Port: B7        <unused/unknown>                       Input  LOW                           TIMER0A   PWM:   128    WGM: 3    COM0A: 3    CS: 3    TCCR0A: 3    TCCR0B: 3    TIMSK0: 3   compare interrupt enabled   overflow interrupt enabled  
 .                  TIMER1C is also tied to this pin                  TIMER1C   PWM:     0    WGM: 4    COM1C: 0    CS: 2    TCCR1A: 0    TCCR1B: 10    TIMSK1: 2   non-standard PWM mode
PIN:  14   Port: J1        <unused/unknown>                       Input  LOW                         
PIN:  15   Port: J0        <unused/unknown>                       Input  LOW                         
PIN:  16   Port: H1        SDSS                                   Input  LOW  
PIN:  17   Port: H0        <unused/unknown>                       Input  LOW                         
PIN:  18   Port: D3        <unused/unknown>                       Input  LOW                         
PIN:  19   Port: D2        <unused/unknown>                       Input  HIGH                         
PIN:  20   Port: D1        <unused/unknown>                       Input  HIGH                         
PIN:  21   Port: D0        <unused/unknown>                       Input  LOW                         
PIN:  22   Port: A0        <unused/unknown>                       Input  HIGH                         
PIN:  23   Port: A1        <unused/unknown>                       Input  LOW                         
PIN:  24   Port: A2        <unused/unknown>                       Input  LOW                         
PIN:  25   Port: A3        <unused/unknown>                       Input  HIGH                         
PIN:  26   Port: A4        <unused/unknown>                       Input  LOW                         
PIN:  27   Port: A5        E0_ENABLE_PIN                          protected 
PIN:  28   Port: A6        <unused/unknown>                       Input  LOW                         
PIN:  29   Port: A7        <unused/unknown>                       Input  LOW                         
PIN:  30   Port: C7        <unused/unknown>                       Input  LOW                         
PIN:  31   Port: C6        <unused/unknown>                       Input  LOW                         
PIN:  32   Port: C5        <unused/unknown>                       Input  LOW                         
PIN:  33   Port: C4        <unused/unknown>                       Input  LOW                         
PIN:  34   Port: C3        <unused/unknown>                       Input  LOW                         
PIN:  35   Port: C2        E1_DIR_PIN                             Input  LOW  
PIN:  36   Port: C1        E1_STEP_PIN                            Input  LOW  
PIN:  37   Port: C0        E1_ENABLE_PIN                          Input  HIGH  
PIN:  38   Port: D7        Y_ENABLE_PIN                           protected 
PIN:  39   Port: G2        Y_STEP_PIN                             protected 
PIN:  40   Port: G1        Y_DIR_PIN                              protected 
PIN:  41   Port: G0        Z_ENABLE_PIN                           protected 
PIN:  42   Port: L7        Z_STEP_PIN                             protected 
PIN:  43   Port: L6        Z_DIR_PIN                              protected 
PIN:  44   Port: L5        E0_DIR_PIN                             protected 
PIN:  45   Port: L4        E0_STEP_PIN                            protected 
PIN:  46   Port: L3        LED_PIN                                Input  LOW    TIMER5A   PWM:     0    WGM: 1    COM5A: 1    CS: 3    TCCR5A: 1    TCCR5B: 3    TIMSK5: 0  
PIN:  47   Port: L2        X_DIR_PIN                              protected 
PIN:  48   Port: L1        X_STEP_PIN                             protected 
PIN:  49   Port: L0        X_ENABLE_PIN                           protected 
PIN:  50   Port: B3        AVR_MISO_PIN                           Input  LOW  
.                          SD_MISO_PIN                            Input  LOW  
PIN:  51   Port: B2        AVR_MOSI_PIN                           Output HIGH  
.                          SD_MOSI_PIN                            Output HIGH  
PIN:  52   Port: B1        AVR_SCK_PIN                            Output LOW  
.                          SD_SCK_PIN                             Output LOW  
PIN:  53   Port: B0        AVR_SS_PIN                             Output HIGH  
.                          SD_SS_PIN                              Output HIGH  
PIN:  54   Port: F0 (A 0)  <unused/unknown>                       Output LOW                         
PIN:  55   Port: F1 (A 1)  <unused/unknown>   Analog in =     2   Input  LOW                         
PIN:  56   Port: F2 (A 2)  <unused/unknown>   Analog in =     0   Input  LOW                         
PIN:  57   Port: F3 (A 3)  <unused/unknown>   Analog in =  1023   Input  HIGH                         
PIN:  58   Port: F4 (A 4)  <unused/unknown>   Analog in =   830   Input  HIGH                         
PIN:  59   Port: F5 (A 5)  <unused/unknown>   Analog in =     4   Input  LOW                         
PIN:  60   Port: F6 (A 6)  TEMP_1_PIN                             protected 
.                          TEMP_BED_PIN                           protected 
PIN:  61   Port: F7 (A 7)  TEMP_0_PIN                             protected 
PIN:  62   Port: K0 (A 8)  <unused/unknown>   Analog in =  1020   Input  LOW                         
PIN:  63   Port: K1 (A 9)  <unused/unknown>   Analog in =  1019   Input  LOW                         
PIN:  64   Port: K2 (A10)  <unused/unknown>   Analog in =  1019   Input  LOW                         
PIN:  65   Port: K3 (A11)  <unused/unknown>   Analog in =  1020   Input  LOW                         
PIN:  66   Port: K4 (A12)  <unused/unknown>   Analog in =  1020   Input  LOW                         
PIN:  67   Port: K5 (A13)  <unused/unknown>   Analog in =  1021   Input  LOW                         
PIN:  68   Port: K6 (A14)  <unused/unknown>   Analog in =  1021   Input  LOW                         
PIN:  69   Port: K7 (A15)  <unused/unknown>   Analog in =  1021   Input  LOW                         
ok

This is the full diff:

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 7effc47cf7..f427455bbb 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -88,7 +88,7 @@
 
 // Choose the name from boards.h that matches your setup
 #ifndef MOTHERBOARD
-  #define MOTHERBOARD BOARD_RAMPS_14_EFB
+  #define MOTHERBOARD BOARD_MINITRONICS
 #endif
 
 /**
@@ -2488,7 +2488,7 @@
  * SD Card support is disabled by default. If your controller has an SD slot,
  * you must uncomment the following option or it won't work.
  */
-//#define SDSUPPORT
+#define SDSUPPORT
 
 /**
  * SD CARD: ENABLE CRC
diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index 82fd1be67b..b1776638d6 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -4228,18 +4228,18 @@
 //
 // M42 - Set pin states
 //
-//#define DIRECT_PIN_CONTROL
+#define DIRECT_PIN_CONTROL
 
 //
 // M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe
 //
-//#define PINS_DEBUGGING
+#define PINS_DEBUGGING
 
 // Enable Tests that will run at startup and produce a report
 //#define MARLIN_TEST_BUILD
 
 // Enable Marlin dev mode which adds some special commands
-//#define MARLIN_DEV_MODE
+#define MARLIN_DEV_MODE
 
 #if ENABLED(MARLIN_DEV_MODE)
   /**
diff --git a/Marlin/src/pins/mega/pins_MINITRONICS.h b/Marlin/src/pins/mega/pins_MINITRONICS.h
index c8828faea7..21fcac601f 100644
--- a/Marlin/src/pins/mega/pins_MINITRONICS.h
+++ b/Marlin/src/pins/mega/pins_MINITRONICS.h
@@ -36,7 +36,7 @@
  *  Added pin definitions for M3, M4 & M5 spindle control commands
  */
 
-#if NOT_TARGET(__AVR_ATmega1281__)
+#if NOT_TARGET(__AVR_ATmega1280__)
   #error "Oops! Select 'Minitronics' in 'Tools > Board.'"
 #elif HOTENDS > 2 || E_STEPPERS > 2
   #error "Minitronics supports up to 2 hotends / E steppers."
diff --git a/platformio.ini b/platformio.ini
index e3bdb6f586..70038dae38 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -13,7 +13,7 @@
 [platformio]
 src_dir      = Marlin
 boards_dir   = buildroot/share/PlatformIO/boards
-default_envs = mega2560
+default_envs = mega1280
 include_dir  = Marlin
 extra_configs =
     Marlin/config.ini

@ellensp
Copy link
Contributor

ellensp commented Jun 7, 2024

Whats messed up?
from the test https://reprap.org/wiki/File:MinitronicsTest.zip

 #define X_STEP_PIN 48
 #define X_DIR_PIN 47
 #define X_ENABLE_PIN 49
 #define X_MIN_PIN 5
 #define X_MAX_PIN -1 //2 //Max endstops default to disabled "-1", set to commented value to enable.

From M43

✅PIN:  48   Port: L1        X_STEP_PIN                             protected 
✅PIN:  47   Port: L2        X_DIR_PIN                              protected 
✅PIN:  49   Port: L0        X_ENABLE_PIN                           protected 
✅PIN:   5   Port: E3        X_MIN_PIN                              protected 

and

 #define Y_STEP_PIN 39 // A6
 #define Y_DIR_PIN 40 // A0
 #define Y_ENABLE_PIN 38
 #define Y_MIN_PIN 2
 #define Y_MAX_PIN -1 //15
✅PIN:  39   Port: G2        Y_STEP_PIN                             protected 
✅PIN:  40   Port: G1        Y_DIR_PIN                              protected 
✅PIN:  38   Port: D7        Y_ENABLE_PIN                           protected 
✅PIN:   2   Port: E4        Y_MIN_PIN                              protected 

and

 #define Z_STEP_PIN 42 // A2
 #define Z_DIR_PIN 43 // A6
 #define Z_ENABLE_PIN 41 // A1
 #define Z_MIN_PIN 6
 #define Z_MAX_PIN -1
✅PIN:  42   Port: L7        Z_STEP_PIN                             protected 
✅PIN:  43   Port: L6        Z_DIR_PIN                              protected 
✅PIN:  41   Port: G0        Z_ENABLE_PIN                           protected 
✅PIN:   6   Port: H3        Z_MIN_PIN                              protected 

and

#define E_STEP_PIN         45
#define E_DIR_PIN          44
#define E_ENABLE_PIN       27
✅PIN:  45   Port: L4        E0_STEP_PIN                            protected 
✅PIN:  44   Port: L5        E0_DIR_PIN                             protected 
✅PIN:  27   Port: A5        E0_ENABLE_PIN                          protected 

and

#define HEATER_0_PIN       9            //❓<= FAN0_PIN Marlin/src/pins/mega/pins_MINITRONICS.h
#define HEATER_1_PIN       8
#define HEATER_2_PIN       7            //❓<=   HEATER_0_PIN in Marlin/src/pins/mega/pins_MINITRONICS.h
#define HEATER_3_PIN       3
#define TEMP_0_PIN         7  // ANALOG NUMBERING
#define TEMP_1_PIN         6   // ANALOG NUMBERING
✅PIN:   7   Port: H4        HEATER_0_PIN                           protected 
✅PIN:   8   Port: H5        HEATER_1_PIN                           Input  LOW    TIMER4C   PWM:     0    WGM: 1    COM4C: 0    CS:0  
✅PIN:   9   Port: H6        FAN0_PIN                               protected 
✅PIN:   3   Port: E5        HEATER_BED_PIN                         protected 
✅PIN:  61   Port: F7 (A 7)  TEMP_0_PIN                             protected 
✅PIN:  60   Port: F6 (A 6)  TEMP_1_PIN                             protected 

Pins debugging doesnt know about 1280/1, and is using incorrect mega2560 port names

@ellensp
Copy link
Contributor

ellensp commented Jun 7, 2024

schematic
minitronics_-_Project.pdf
PCB
minitronics_-_PCB.pdf

@thinkyhead
Copy link
Member

Let's start this one over from the beginning. The pins mapping in Marlin is based on the GPIO indexed pin mapping of Arduino, and the pin numbering is generally meant to make all the AVR boards map in a similar way to the 2560, and as long as our AVR pin numbering is internally consistent within Marlin, it doesn't need to correspond to anything else.

As mentioned, our pin numbering is based on the fastio.h provided by RepRapWorld / Brupje. It works perfecly fine, as long as the pins files are correctly using its numbering. If you're going to change Marlin's internal pin numbering for the 1281 to something new, you'll need to explain why it is less arbitrary than the numbering scheme we currently have.

There are some other "Fast I/O" solutions out there that we might look at adopting in future, but in the meantime we ought to document our FastIO headers with a little extra explanation as to why the logical (i.e., "GPIO") pin numbers are in the order that they appear, and not in some other order, and then make sure that ordering is simply internally consistent and adheres to our set rules..

@thinkyhead
Copy link
Member

Pins debugging doesnt know about 1280/1, and is using incorrect mega2560 port names

Marlin pins debugging (and other things) use Arduino digitalPinToPort to get the port for a given logical pin number. Thus, our pin numbers do need to correspond to whatever Arduino has in a digital_pin_to_port_PGM table for the 1281….

@thinkyhead
Copy link
Member

thinkyhead commented Jun 7, 2024

To use mappings for MCUs under PlatformIO we create a variant and then implement our own digital_pin_to_port_PGM table. For example see buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h. We can't use this technique for Arduino IDE, so our most direct solution is to find the appropriate Arduino package for 1281 that has some digital_pin_to_port_PGM values defined for us, or we may just be able to rework our internal mapping so it corresponds perfectly to a 1280 and treat it otherwise just like a 1280.

@thinkyhead
Copy link
Member

We're unable to make any changes or add commits to this PR, maybe due to a glitch in GitHub. Sometimes if a Marlin fork isn't named "Marlin" we encounter this problem. Anyway, if you see a checkbox on this page labeled "Allow edits by maintainers," then please make sure it is checked. If we still can't make any edits, then we can still submit changes to your branch using a PR targeted at your fork, but then you have to approve them. The other option is to add me and/or other Marlin maintainers to your fork as team members with edit permissions.

Anyway, thanks for the contribution and we appreciate your patience with our review process! We would love to get that pins debugging output fixed as a part of this one.

@lkundrak
Copy link
Contributor Author

@thinkyhead @ellensp than you very much for your patience and an exhaustive explanation. I suspect there's more than just the pin debugging that's broken, because when I carried over my configuration to the original pin numbering, it no longer works -- display does not show anything. I wasn't able to debug further without knowing what's up with the pin debugging. I'm unable to look into what's wrong until the weekend, but I suspect your explanation will be of great help.

@thinkyhead
Copy link
Member

thinkyhead commented Jun 14, 2024

Drop a comment when you're getting started on your research to get these pins consistent. I'd be interested to compare notes, and we can do our best to base the pin mapping on existing platforms and datasheets. I vaguely recall a long ago conversation where we decided to just map 1281/2561 to 1280/2560 for simplicity, but in the long run it would be nice to have a good canonical mapping for this MCU sub-family.

@lkundrak
Copy link
Contributor Author

lkundrak commented Jul 7, 2024

I've looked some more and I don't think the pin numbers in Marlin/src/pins/mega/pins_MINITRONICS.h are in 1280 pin numbers either. I don't know what they are.

Save other things that are very obviously wrong: The comments generally all totally off (possibly copy'n'paste from elsewhere without correction), X_MAX_PIN and Y_MAX_PIN are just bogus numbers. The board has no provision for max endstops. Ditto FAN0_PIN -- there fan header is uncontrolled. I'm not sure how much this matters, but I'm not sure how much I can trust the rest to make any sense.

In general, all [XYZ]_{STEP,DIR,ENABLE}_PINs look wrong:

Take for instance Y_STEP_PIN. That's connected to PA1. Note the comment says it's "A6".

It's defined to be 39. That matches both "MINITRONICS v1.0 DATASHEET" and "MINITRONICS v1.1 DATASHEET" -- they both call the pin "D39". But where do these numbers come from?

According to fastio_1280.h, PA1 would be pin "23". That seems to agree with the schematics, which calls this "D23_YSTEP".

Add env:mega1281 board, based on env:mega1280. Uses slightly different
pin mapping, originally based on and used by the Mintronics v1 board.
Needs -mcu=atmega1281 so that fastio picks the right pin mapping.
The 1281 support was bitrotten for some time. No more!
The MAX endstops are not there, the comments are wrong.
@lkundrak
Copy link
Contributor Author

lkundrak commented Jul 15, 2024

Hey, how does it look now? Now the original Minitronics pin numbers work for me, and pin debugging looks okay too.

Here's a couple of partial drawings I did along the way, may or may not be more legible that the original schematics:
minitronics.pdf
lcd-cabling-harness.pdf

@lkundrak
Copy link
Contributor Author

@thinkyhead @ellensp any chance this could get another look? I think I figured out how to make it work while remaining compatible with the original Minitronics support, using the same pin mapping. Thanks!

@thinkyhead thinkyhead merged commit 98a33d3 into MarlinFirmware:bugfix-2.1.x Aug 22, 2024
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Boards/Pins Needs: Discussion Discussion is needed Needs: More Data We need more data in order to proceed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants