Skip to content

Commit

Permalink
Updated for core change (settings structure).
Browse files Browse the repository at this point in the history
Switched to SDK v2.0.0 and added initial support for RP2350 (Pico 2).
  • Loading branch information
terjeio committed Nov 29, 2024
1 parent ec81aaa commit 643952d
Show file tree
Hide file tree
Showing 17 changed files with 480 additions and 118 deletions.
5 changes: 2 additions & 3 deletions .vscode/cmake-kits.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
{
"name": "Pico",
"compilers": {
"C": "${userHome}/.pico-sdk/toolchain/13_2_Rel1/bin/arm-none-eabi-gcc.exe",
"CXX": "${userHome}/.pico-sdk/toolchain/13_2_Rel1/bin/arm-none-eabi-gcc.exe"
"C": "${command:raspberry-pi-pico.getCompilerPath}",
"CXX": "${command:raspberry-pi-pico.getCxxCompilerPath}"
},
"toolchainFile": "${env:USERPROFILE}/.pico-sdk/sdk/2.0.0/cmake/preload/toolchains/pico_arm_cortex_m0plus_gcc.cmake",
"environmentVariables": {
"PATH": "${command:raspberry-pi-pico.getEnvPath};${env:PATH}"
},
Expand Down
101 changes: 101 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,103 @@
<<<<<<< .mine
{
"version": "0.2.0",
"configurations": [
{
"name": "Pico Debug (Cortex-Debug)",
"cwd": "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts",
"executable": "${command:raspberry-pi-pico.launchTargetPath}",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"serverpath": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
"gdbPath": "${command:raspberry-pi-pico.getGDBPath}",
"device": "${command:raspberry-pi-pico.getChipUppercase}",
"configFiles": [
"interface/cmsis-dap.cfg",
"target/${command:raspberry-pi-pico.getTarget}.cfg"
],
"svdFile": "${userHome}/.pico-sdk/sdk/2.0.0/src/${command:raspberry-pi-pico.getChip}/hardware_regs/${command:raspberry-pi-pico.getChipUppercase}.svd",
"runToEntryPoint": "main",
// Fix for no_flash binaries, where monitor reset halt doesn't do what is expected
// Also works fine for flash binaries
"overrideLaunchCommands": [
"monitor reset init",
"load \"${command:raspberry-pi-pico.launchTargetPath}\""
],
"openOCDLaunchCommands": [
"adapter speed 5000"
]
},
{
"name": "Pico Debug (Cortex-Debug with external OpenOCD)",
"cwd": "${workspaceRoot}",
"executable": "${command:raspberry-pi-pico.launchTargetPath}",
"request": "launch",
"type": "cortex-debug",
"servertype": "external",
"gdbTarget": "localhost:3333",
"gdbPath": "${command:raspberry-pi-pico.getGDBPath}",
"device": "${command:raspberry-pi-pico.getChipUppercase}",
"svdFile": "${userHome}/.pico-sdk/sdk/2.0.0/src/${command:raspberry-pi-pico.getChip}/hardware_regs/${command:raspberry-pi-pico.getChipUppercase}.svd",
"runToEntryPoint": "main",
// Fix for no_flash binaries, where monitor reset halt doesn't do what is expected
// Also works fine for flash binaries
"overrideLaunchCommands": [
"monitor reset init",
"load \"${command:raspberry-pi-pico.launchTargetPath}\""
]
},
{
"name": "Pico Debug (C++ Debugger)",
"type": "cppdbg",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${command:raspberry-pi-pico.launchTargetPath}",
"MIMode": "gdb",
"miDebuggerPath": "${command:raspberry-pi-pico.getGDBPath}",
"miDebuggerServerAddress": "localhost:3333",
"debugServerPath": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe",
"debugServerArgs": "-f interface/cmsis-dap.cfg -f target/${command:raspberry-pi-pico.getTarget}.cfg -c \"adapter speed 5000\"",
"serverStarted": "Listening on port .* for gdb connections",
"filterStderr": true,
"hardwareBreakpoints": {
"require": true,
"limit": 4
},
"preLaunchTask": "Flash",
"svdPath": "${userHome}/.pico-sdk/sdk/2.0.0/src/${command:raspberry-pi-pico.getChip}/hardware_regs/${command:raspberry-pi-pico.getChipUppercase}.svd"
},
]
}
||||||| .r10465
{
"version": "0.2.0",
"configurations": [
{
"name": "Pico Debug",
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
// This may need to be arm-none-eabi-gdb depending on your system
"gdbPath" : "gdb-multiarch",
"device": "RP2040",
"configFiles": [
"interface/raspberrypi-swd.cfg",
"target/rp2040.cfg"
],
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
"runToMain": true,
// Work around for stopping at main on restart
"postRestartCommands": [
"break main",
"continue"
]
}
]
}
=======
{
"version": "0.2.0",
"configurations": [
Expand Down Expand Up @@ -67,3 +167,4 @@
},
]
}
>>>>>>> .r10955
38 changes: 38 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if(ADD_WIFI OR ADD_BLUETOOTH)
set(PICO_BOARD pico_w)
endif()

#set(PICO_BOARD pimoroni_pga2350 CACHE STRING "Board type")

include(pico_sdk_import.cmake)

if(ADD_WIFI OR ADD_ETHERNET)
Expand Down Expand Up @@ -107,6 +109,11 @@ endif()

pico_generate_pio_header(grblHAL ${CMAKE_CURRENT_LIST_DIR}/driverPIO.pio)

if(PICO_BOARD STREQUAL "pico" OR PICO_BOARD STREQUAL "pico_w")
target_compile_definitions(grblHAL PUBLIC RP_MCU=2040)
else()
target_compile_definitions(grblHAL PUBLIC RP_MCU=2350)
endif()
target_compile_definitions(grblHAL PUBLIC RP2040)
target_compile_definitions(grblHAL PUBLIC NEW_FATFS)
target_compile_definitions(grblHAL PUBLIC LITTLEFS_ENABLE=1)
Expand Down Expand Up @@ -198,6 +205,7 @@ if(ADD_HPGL)
endif()

target_include_directories(grblHAL PRIVATE ${CMAKE_CURRENT_LIST_DIR})
if(RP_MCU EQUAL 2040)
target_link_libraries(grblHAL PRIVATE
grbl
fatfs
Expand All @@ -222,13 +230,43 @@ target_link_libraries(grblHAL PRIVATE
hardware_spi
hardware_gpio
hardware_pwm
hardware_clocks
hardware_flash
hardware_rtc
)
else()
target_link_libraries(grblHAL PRIVATE
grbl
fatfs
sdcard
motors
trinamic
spindle
keypad
fans
laser
bluetooth
eeprom
misc_plugins
embroidery
tinyusb_device_unmarked
pico_stdlib
pico_unique_id
hardware_dma
hardware_uart
hardware_pio
hardware_i2c
hardware_spi
hardware_gpio
hardware_pwm
hardware_clocks
hardware_flash
)
endif()

pico_add_extra_outputs(grblHAL)

unset(PICO_BOARD CACHE)
unset(ADD_WIFI CACHE)
unset(ADD_ETHERNET CACHE)
unset(ADD_BLUETOOTH CACHE)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ A grblHAL driver for the Raspberry Pi Pico RP2040 processor on a [Pi Pico or Pi
This driver can be built with the [Web Builder](http://svn.io-engineering.com:8080/?driver=RP2040).

__Important__ download information can be found [here](https://github.com/grblHAL/core/wiki/Compiling-grblHAL).
The project has been updated to/now uses [SDK version 1.5.0](https://github.com/raspberrypi/pico-sdk/releases).
The project has been updated to/now uses [SDK version 2.0.0](https://github.com/raspberrypi/pico-sdk/releases).

The default build environment is Visual Studio Code, it is surprisingly easy to set up on Raspberry Pi - see the [Getting started](https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf) documentation for how to for this and other platforms.

---
2023-09-20
2024-11-28
180 changes: 180 additions & 0 deletions boards/RP2350B_5X_map.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*
RP2350B 5 Axis driver pin map
Part of grblHAL
Copyright (c) 2021-2024 Terje Io
Copyright (c) 2024 PL Barrett
grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
*/

#if TRINAMIC_ENABLE
#error Trinamic plugin not supported!
#endif

#if N_ABC_MOTORS > 2
#error "Axis configuration is not supported!"
#endif

#if PICO_PLATFORM != rp2350
#error "Board has a RP2350 processor!"
#endif

#define BOARD_NAME "RP23U5XBB"

#undef I2C_ENABLE
#define I2C_ENABLE 1
//#define SERIAL1_PORT 1

// Define step pulse output pins.
#define STEP_PORT GPIO_PIO // N_AXIS pin PIO SM
#define STEP_PINS_BASE 17 // N_AXIS number of consecutive pins are used by PIO

// Define step direction output pins.
#define DIRECTION_PORT GPIO_OUTPUT
#define X_DIRECTION_PIN 12
#define Y_DIRECTION_PIN 13
#define Z_DIRECTION_PIN 14
#define DIRECTION_OUTMODE GPIO_SHIFT12

// Define stepper driver enable/disable output pin.
#define ENABLE_PORT GPIO_OUTPUT
#define X_ENABLE_PIN 22
#define Y_ENABLE_PIN 23
#define Z_ENABLE_PIN 24

// Define homing/hard limit switch input pins.
#define X_LIMIT_PIN 5 // 1.0 -> 6
#define Y_LIMIT_PIN 6 // 1.0 -> 5
#define Z_LIMIT_PIN 3 // 1.0 -> 4
#define LIMIT_INMODE GPIO_MAP

// Define ganged axis or A axis step pulse and step direction output pins.
#if N_ABC_MOTORS > 0
#define M3_AVAILABLE
#define M3_DIRECTION_PIN 31
#define M3_LIMIT_PIN 4 // 1.0 -> 3
#define M3_ENABLE_PIN 41
#endif

#if N_ABC_MOTORS == 2
#define M4_AVAILABLE
#define M4_DIRECTION_PIN 32
#define M4_LIMIT_PIN 2
#define M4_ENABLE_PIN 42
#else
#define AUXINPUT6_PIN 2 // M4_LIMIT_PIN
#endif

#define AUXOUTPUT0_PORT GPIO_OUTPUT
#define AUXOUTPUT0_PIN 38
#define AUXOUTPUT1_PORT GPIO_OUTPUT
#define AUXOUTPUT1_PIN 37

//#define AUXOUTPUT3_PORT GPIO_OUTPUT
#define AUXOUTPUT3_PIN 33 // Spindle enable

//#define AUXOUTPUT4_PORT GPIO_OUTPUT
#define AUXOUTPUT4_PIN 35 // Spindle PWM

//#define AUXOUTPUT5_PORT GPIO_OUTPUT
#define AUXOUTPUT5_PIN 34 // Spindle direction
//#define AUXOUTPUT0_PWM_PIN 29 // Servo

#if DRIVER_SPINDLE_ENABLE

#define SPINDLE_PORT GPIO_OUTPUT
#define SPINDLE_ENABLE_PIN AUXOUTPUT3_PIN

#if DRIVER_SPINDLE_PWM_ENABLE
#define SPINDLE_PWM_PORT GPIO_OUTPUT
#define SPINDLE_PWM_PIN AUXOUTPUT4_PIN
#else
#define AUXOUTPUT4_PORT GPIO_OUTPUT
#endif

#if DRIVER_SPINDLE_DIR_ENABLE
#define SPINDLE_DIRECTION_PIN AUXOUTPUT5_PIN
#else
#define AUXOUTPUT5_PORT GPIO_OUTPUT
#endif

#else
#define AUXOUTPUT3_PORT GPIO_OUTPUT
#endif // DRIVER_SPINDLE_ENABLE

#define COOLANT_PORT GPIO_OUTPUT
#define COOLANT_FLOOD_PIN 39
#define COOLANT_MIST_PIN 40

//

#define AUXINPUT0_PIN 29
#define AUXINPUT1_PIN 28
#define AUXINPUT3_PIN 7 // Probe
#define AUXINPUT4_PIN 8 // Safety door or motor fault
#define AUXINPUT5_PIN 32 // I2C strobe pin

#define RESET_PIN 11
#define FEED_HOLD_PIN 10
#define CYCLE_START_PIN 9

#if PROBE_ENABLE
#define PROBE_PIN AUXINPUT3_PIN
#endif

#if SAFETY_DOOR_ENABLE
#define SAFETY_DOOR_PIN AUXINPUT4_PIN
#elif MOTOR_FAULT_ENABLE
#define MOTOR_FAULT_PIN AUXINPUT4_PIN // set Door as alternate Motor Fault input
#endif

#if I2C_STROBE_ENABLE
#define I2C_STROBE_PIN AUXINPUT5_PIN
#endif

#if SDCARD_ENABLE || ETHERNET_ENABLE

#define SPI_PORT 1
#define SPI_SCK_PIN 46
#define SPI_MOSI_PIN 43
#define SPI_MISO_PIN 44

#if SDCARD_ENABLE
#define SD_CS_PIN 45
#endif

#if ETHERNET_ENABLE
#define SPI_CS_PIN 41
#define SPI_IRQ_PIN 42
//#define SPI_RST_PORT 43
#endif

#endif // SDCARD_ENABLE || ETHERNET_ENABLE

#if I2C_ENABLE
#define I2C_PORT 1
#define I2C_SDA 30
#define I2C_SCL 31
#endif

#ifdef SERIAL1_PORT
#define UART_1_RX_PIN 27
#define UART_1_TX_PIN 36
#else
#define AUXINPUT2_PIN 27
#define AUXOUTPUT2_PORT GPIO_OUTPUT
#define AUXOUTPUT2_PIN 36
#endif
Loading

0 comments on commit 643952d

Please sign in to comment.