grblHAL / core

grblHAL core code and master Wiki
Other
304 stars 73 forks source link

Custom board with STM32F446RET6 and my issues with configuration #457

Open PecaJosef opened 4 months ago

PecaJosef commented 4 months ago

I have made a custom board with STM32F446RET6 (Image for reference - https://imgur.com/a/bE8EdQD) and since I have worked only with grbl on ATmega328p I am getting lost in this configuration.

Unfortunately, I didn't think of an external EEPROM, so my first problem is configuring grblHAL to work without the EEPROM and using Flash for user settings instead. I really hope it is possible because the board costs me a lot of time and money. If I try to build it I get this error -> flash.c:41: undefined reference to `_EEPROM_Emul_Start' I also need to have Y axis ganged with possible auto-square.

Here is my pinout configuration:

// Define step pulse output pins.
#define X_STEP_PORT             GPIOC
#define X_STEP_PIN              9
#define Y_STEP_PORT             GPIOC
#define Y_STEP_PIN              7
#define Z_STEP_PORT             GPIOB
#define Z_STEP_PIN              13
#define STEP_OUTMODE            GPIO_BITBAND
//#define STEP_PINMODE            PINMODE_OD // Uncomment for open drain outputs

// Define step direction output pins.
#define X_DIRECTION_PORT        GPIOC
#define X_DIRECTION_PIN         8
#define Y_DIRECTION_PORT        GPIOC
#define Y_DIRECTION_PIN         6
#define Z_DIRECTION_PORT        GPIOB
#define Z_DIRECTION_PIN         13
#define DIRECTION_OUTMODE       GPIO_BITBAND
//#define DIRECTION_PINMODE       PINMODE_OD // Uncomment for open drain outputs

// Define stepper driver enable/disable output pin.
#define X_ENABLE_PORT               GPIOA
#define X_ENABLE_PIN                8
#define Y_ENABLE_PORT               GPIOA
#define Y_ENABLE_PIN                8
#define Z_ENABLE_PORT               GPIOA
#define Z_ENABLE_PIN                8
//#define STEPPERS_ENABLE_PORT       GPIOA
//#define STEPPERS_ENABLE_PIN        8
#define STEPPERS_ENABLE_OUTMODE    GPIO_BITBAND

// Define homing/hard limit switch input pins.
#define X_LIMIT_PORT            GPIOB
#define X_LIMIT_PIN             2
#define Y_LIMIT_PORT            GPIOB
#define Y_LIMIT_PIN             1
#define Z_LIMIT_PORT            GPIOC
#define Z_LIMIT_PIN             5
#define LIMIT_INMODE            GPIO_BITBAND

// Define ganged axis or A axis step pulse and step direction output pins.
#if N_ABC_MOTORS > 0
#define M3_AVAILABLE
#define M3_STEP_PORT            GPIOB
#define M3_STEP_PIN             15
#define M3_DIRECTION_PORT       GPIOB
#define M3_DIRECTION_PIN        14
#define M3_LIMIT_PORT           GPIOB
#define M3_LIMIT_PIN            0
#define M3_ENABLE_PORT          GPIOA
#define M3_ENABLE_PIN           8
#endif

// Define ganged axis or A axis step pulse and step direction output pins.
#if N_ABC_MOTORS == 2
#define M4_AVAILABLE
#define M4_STEP_PORT            GPIOA
#define M4_STEP_PIN             10
#define M4_DIRECTION_PORT       GPIOA
#define M4_DIRECTION_PIN        13
#define M4_LIMIT_PORT           GPIOB
#define M4_LIMIT_PIN            10
#define M4_ENABLE_PORT          GPIOA
#define M4_ENABLE_PIN           9
#endif

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_PORT     GPIOC
#define SPINDLE_ENABLE_PIN      2
#define SPINDLE_DIRECTION_PORT  GPIOC
#define SPINDLE_DIRECTION_PIN   3
#define SPINDLE_OUTMODE         GPIO_BITBAND

// Define spindle PWM output pin.
#define SPINDLE_PWM_PORT_BASE   GPIOA_BASE
#define SPINDLE_PWM_PIN         5

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PORT      GPIOA
#define COOLANT_FLOOD_PIN       1
#define COOLANT_MIST_PORT       GPIOA
#define COOLANT_MIST_PIN        0
#define COOLANT_OUTMODE         GPIO_BITBAND

#define AUXOUTPUT0_PORT         GPIOA
#define AUXOUTPUT0_PIN          2
//#define AUXOUTPUT1_PORT         GPIOB
//#define AUXOUTPUT1_PIN          0
//#define AUXOUTPUT2_PORT         GPIOA
//#define AUXOUTPUT2_PIN          4
//#define AUXOUTPUT3_PORT         GPIOA
//#define AUXOUTPUT3_PIN          6
#define AUXOUTPUT_OUTMODE       GPIO_BITBAND

//#define AUXINPUT0_PORT          GPIOA
//#define AUXINPUT0_PIN           0
//#define AUXINPUT1_PORT          GPIOA
//#define AUXINPUT1_PIN           1
//#define AUXINPUT2_PORT          GPIOA
//#define AUXINPUT2_PIN           2

// Define user-control controls (cycle start, reset, feed hold) input pins.
#define RESET_PORT              GPIOA
#define RESET_PIN               15
#define FEED_HOLD_PORT          GPIOB
#define FEED_HOLD_PIN           8
#define CYCLE_START_PORT        GPIOB
#define CYCLE_START_PIN         9
#if SAFETY_DOOR_ENABLE
#define SAFETY_DOOR_PORT        GPIOC
#define SAFETY_DOOR_PIN         4
#endif
#define CONTROL_INMODE          GPIO_BITBAND

// Define probe switch input pin.
#define PROBE_PORT              GPIOC
#define PROBE_PIN               4

#if I2C_STROBE_ENABLE
#define I2C_STROBE_PORT         GPIOB
#define I2C_STROBE_PIN          10
#endif

#if SDCARD_ENABLE
#define SD_CS_PORT              GPIOA
#define SD_CS_PIN               3
#define SPI_PORT                12 // GPIOB, SCK = 3, MISO = 4, MOSI = 5
#endif
PecaJosef commented 4 months ago

I have found the problem. I do not know why but when selected Release STM32F446 it built it with the STM32F446RETX_BL64K_NONVS_FLASH.ld file which does not have Emulated EEPROM. I do not know how to fix it elegantly so I have copied the STM32F446RETX_FLASH.ld content to the STM32F446RETX_BL64K_NONVS_FLASH.ld and it worked.

The only problem I have right now is that I am unable to turn on the spindle and set its speed :D.

samitray commented 2 months ago

It depends on the value of _EEPROM_Emul_Sector supplied in the linker file. So depending on which part of flash was used for emulation, the value of _EEPROM_Emul_Sector has to be changed as per sector numbers in the data sheet see Discussion -> General #503