A GRBL ported to Zephyr RTOS with some additional features like software CDC ACM serial port and SD card support. Developed for my CoreXY pen ploter, so some features of GRBL are commented out. Please create an issue or propose a pull request if you are interested in more functionality (list of unsupported bits is below). The greatest benefit of having the GRBL ported to Zephyr is the ability of running it on variety of platforms with way more powerful CPUs than the original Arduino. As of now this project is targeting the STM32F405RG (earlier tests were performed on the STM32F446RE) and with minor modifications in the boards directory or overlay file (or adding either of those to be precise) it should work on different STM32-s as well.
The only non standard driver this project uses is the modules/hw_timer
and this is the only obstacle for running this on MCUs different than STM32-s. modules/hw_timer
is derived from the pwm
driver and its only purpose is to fire a callback(s) on a timer update event (and possibly on output compare event in the future). Other parts are implemented in stock Zephyr.
The project was written to power my CoreXY pen plotter, and as such has some parts not implemented (probing) and others not tested (Z-axis with stepper motor, see below). It should be a good starting point to develop something more complete that would run the variety of CNC machines. Pull requests are welcome.
- TODO list of things to do.
- My notes on problems I've had.
- Hackaday.io project page
Tested with Zephyr RTOS 2.6.99. Familiarize yourself with the Zephyr RTOS build process first. :
?
That is when CONFIG_BOOTLOADER_MCUBOOT=n
in the prj.conf
.
rm -Rf build
cmake -B build -GNinja -DBOARD=plotter_f405rg -DBOARD_ROOT=. .
ninja -C build
west flash # Or use IDE, or use openocd directly
- Added a new macro for my machine named DEFAULTS_ZEPHYR_GRBL_PLOTTER in the
config.h
and globally in theCMakeLists.txt
. Used mostly in thedefaults.h
- Coolant control, spindle comented out.
- Added
extern "C" {
to most of the*.h
files to enable C++ interoperability. - Added definitions for my machine in the
defaults.h
. - Eeprom support ported.
- Zephyr PWM module was modified to accept a timer output compare ISR callback.
- AVR GPIO registers code ported to zephyr
- Homing and limiters ported.
- Probe implementation commented out.
- Control switches support commented out. I'll have an OLED display and I can add those features there.
- Spindle control commented out.
-
Gpio inverting functionality stripped down as from now the Zephyr's device tree configuration is used for this. Logging ported to Zephyr.Rolled back.- Port uart code to zephyr.
-
Make use of new async uart functionality merged recently to zephyr.Analogous to this.-
Modify the overlay. -
Turn DMA on in Kconfig. - Interrupt UART API and Zephyr ring buffers.
-
-
- GRBL seems to lack any call to a
delay
function in the main loop. This prevents scheduler from switching to other lower-priority threads which in my case were :idle
,logging
andshell_uart
. I've lowered the main thread priority to 14 (from 0) and added k_yeld, so other low priority threads have a chance to run now. This include logging, shell and others.
- Software
- Out of tree driver for timer callback.
- TMC driver?
- GRBL obviously.
Derived from PWM driver. Changes:
Header:
- Names (file names & all the names in the code). PWM -> HW_TIMER.
- A
typedef
for the callback. - Few macro / defines.
Source file:
- Names
- Callback setter
- Datadield for the callback.
- TODO remove unused code.