Getting grblHAL to work on the Scylla 1.0 board

Firmware Source

The Scylla-capable STM32H7xx driver is from:

cd ~/git/grblHAL
git clone https://github.com/dresco/STM32H7xx.git

Initialize submodules from inside the driver repo:

git submodule update --init --recursive

Required submodules include:

Build Tools

Install PlatformIO CLI. The working installation used pipx:

pipx install platformio

Check it is available:

pio --version

Firmware Configuration

The custom PlatformIO environments are in:

~/git/grblHAL/STM32H7xx/platformio.ini

The currently relevant environment is:

btt_scylla_h723_tmc5160_dualy_pwm_bl128

It is linked for the Scylla 128K bootloader offset and includes:

-D BOARD_BTT_SCYLLA
-D HSE_VALUE=25000000
-D TRINAMIC_ENABLE=5160
-D Y_AUTO_SQUARE=1
-D SPINDLE0_ENABLE=SPINDLE_PWM0
-D ESTOP_ENABLE=1
-D CONTROL_ENABLE=CONTROL_ESTOP
-D TOOLSETTER_ENABLE=1

The E-stop flags are required so the Scylla X-MAX input is handled as a blocking grblHAL E-stop, not only reported in Pn:E status output. Confirm after flashing:

$pins

Expected E-stop pin assignment:

[PIN:PC6,Emergency stop]

The toolsetter flag is required for the Scylla Tool-IN input to be exposed as the dedicated grblHAL toolsetter input. The Scylla board map uses PE7 for Tool-IN. Confirm after flashing with:

$pins

Expected toolsetter pin assignment:

[PIN:PE7,Toolsetter]

Scylla E-stop Driver Patch

The Scylla X-MAX E-stop input is on PC6, which uses the STM32 EXTI9_5 interrupt range. If status shows Pn:E but motion continues, for example Run|...|Pn:E, the input is visible but the runtime interrupt path is not aborting motion.

Patch ~/git/grblHAL/STM32H7xx/Src/driver.c so claimed aux control inputs are initialized with their selected IRQ edge before HAL_GPIO_Init().

Inside settings_changed(), before the existing aux input EXTICR mapping block, add:

if(input->group == PinGroup_AuxInput) {
    aux_ctrl_t *aux_in = aux_ctrl_in_get(input->user_port);

    if(aux_in && aux_in->irq_mode != IRQ_Mode_None && !(xbar_is_probe_in(aux_in->function) || xbar_is_encoder_in(aux_in->function))) {
        input->mode.irq_mode = aux_in->irq_mode;
        if(input->mode.irq_mode & IRQ_Mode_RisingFalling)
            input->mode.irq_mode = (settings->control_invert.mask & aux_in->signal.mask) ? IRQ_Mode_Falling : IRQ_Mode_Rising;
    }

The following existing aux input block should then continue immediately after that code:

if(input->cap.irq_mode != IRQ_Mode_None) {
    // Map interrupt to pin
    uint32_t extireg = SYSCFG->EXTICR[input->pin >> 2] & ~(0b1111 << ((input->pin & 0b11) << 2));
    extireg |= ((uint32_t)(GPIO_GET_INDEX(input->port)) << ((input->pin & 0b11) << 2));
    SYSCFG->EXTICR[input->pin >> 2] = extireg;
}

}

Also patch EXTI9_5_IRQHandler() so aux inputs in the 5..9 interrupt range are dispatched correctly:

#if AUXINPUT_MASK & 0x03E0
        if(ifg & aux_irq)
            aux_pin_irq(ifg & aux_irq);
#endif

This replaces the incorrect aux block that checked SPINDLE_INDEX_BIT and called spindle_encoder_index_event().

Build Firmware

From inside ~/git/grblHAL/STM32H7xx:

pio run -e btt_scylla_h723_tmc5160_dualy_pwm_bl128

The SD-card/bootloader firmware output is:

.pio/build/btt_scylla_h723_tmc5160_dualy_pwm_bl128/firmware.bin

Flash Firmware By SD Card

Use the *_bl128 build for SD-card flashing:

.pio/build/btt_scylla_h723_tmc5160_dualy_pwm_bl128/firmware.bin

General process:

  1. Copy firmware.bin to the root of a FAT32-formatted SD card.
  2. Power off the Scylla.
  3. Insert the SD card.
  4. Power on the Scylla.
  5. Wait for the bootloader to flash the firmware.
  6. Reconnect USB/gSender.

After flashing, confirm the board reports correctly:

$I

Expected key lines:

[FIRMWARE:grblHAL]
[DRIVER:STM32H723@480MHz]
[BOARD:BTT Scylla]
[PLUGIN:Trinamic v0.33]
[PLUGIN:SDCARD v1.27]