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

LDO Nitehawk 36 #67

Open
wants to merge 9 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configuration/boards/btt-sb-2209-10-rp2040/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ then
mkdir /home/pi/printer_data/config/firmware_binaries
chown pi:pi /home/pi/printer_data/config/firmware_binaries
fi
cp -f /home/pi/klipper/out/klipper.bin /home/pi/printer_data/config/firmware_binaries/firmware-btt-sb-2209-10-rp.uf2
cp -f /home/pi/klipper/out/klipper.uf2 /home/pi/printer_data/config/firmware_binaries/firmware-btt-sb-2209-10-rp.uf2
chown pi:pi /home/pi/printer_data/config/firmware_binaries/firmware-btt-sb-2209-10-rp.uf2
popd || exit
4 changes: 4 additions & 0 deletions configuration/boards/ldo-nitehawk-36/98-ldo-nitehawk-36.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# LDO Nitehawk 36
SUBSYSTEMS=="usb", ATTRS{idProduct}=="614e", ATTRS{idVendor}=="1d50", ATTRS{serial}=="ldo-nitehawk-36", ACTION=="add", SYMLINK+="ldo-nitehawk-36", RUN+="/home/pi/printer_data/config/RatOS/scripts/klipper-mcu-added.sh"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify the hardcoded script path.

The script path /home/pi/printer_data/config/RatOS/scripts/klipper-mcu-added.sh assumes a specific directory structure. Consider making this path configurable or using environment variables.


🏁 Script executed:

#!/bin/bash
# Check if the script exists at the hardcoded path
if [ ! -f "/home/pi/printer_data/config/RatOS/scripts/klipper-mcu-added.sh" ]; then
  echo "Warning: klipper-mcu-added.sh not found at expected path"
fi

Length of output: 203


Hardcoded Script Path Issue – Action Required

The verification revealed that the file /home/pi/printer_data/config/RatOS/scripts/klipper-mcu-added.sh does not exist at the hardcoded location. To ensure reliability across different setups, please consider one of the following:

  • Make the script path configurable (e.g., via a configuration file or environment variable)
  • Ensure the script is correctly deployed at the expected location if retaining the hardcoded path


ACTION=="remove", ENV{DEVLINKS}=="/dev/ldo-nitehawk-36", RUN+="/home/pi/printer_data/config/RatOS/scripts/klipper-mcu-removed.sh"
39 changes: 39 additions & 0 deletions configuration/boards/ldo-nitehawk-36/board-definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "../board-definition.schema.json",
"manualFileName": "manual.pdf",
"wireDiagramFileName": "wiring.drawio.svg",
"isToolboard": true,
"name": "Nitehawk 36",
"manufacturer": "LDO",
"id": "ldo-nitehawk-36",
"firmwareBinaryName": "firmware-ldo-nitehawk-36.bin",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure firmware binary name consistency across files.

The firmwareBinaryName uses .bin extension which matches the source in compile.sh but not the destination. Please maintain consistency across all files.

Also applies to: 17-17

"boardImageFileName": "board.webp",
"compileScript": "compile.sh",
"flashScript": "flash.sh",
"documentationLink": "https://os.ratrig.com/docs/boards/ldo/nitehawk-36",
"driverCount": 1,
"integratedDrivers": {
"extruder": "LDO-NITEHAWK-TMC2209"
},
"dfu": {
"flashDevice": "1d50:614e",
"dfuBootImage": "dfubooting.png",
"instructions": [
"Connect the USB cable to the Raspberry Pi",
"Make sure the board is powered (you need both cables connected to the USB adapter and power on)",
"Press and hold the BOOT button on the board.",
"Press and release the RESET button on the board.",
"Release the BOOT button."
],
"hasBoot0Jumper": false
},
"thermistorPullup": 2200,
"ADXL345SPI": {
"cs_pin": "gpio27",
"software": {
"sclk": "gpio18",
"mosi": "gpio20",
"miso": "gpio19"
}
}
}
Binary file added configuration/boards/ldo-nitehawk-36/board.webp
Binary file not shown.
19 changes: 19 additions & 0 deletions configuration/boards/ldo-nitehawk-36/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "ERROR: Please run as root"
exit
fi
cp -f /home/pi/printer_data/config/RatOS/boards/ldo-nitehawk-36/firmware.config /home/pi/klipper/.config
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for configuration file copy.

The file copy operation should verify the existence of source files and handle errors.

Apply this diff to improve error handling:

-cp -f /home/pi/printer_data/config/RatOS/boards/ldo-nitehawk-36/firmware.config /home/pi/klipper/.config
+if [ ! -f "/home/pi/printer_data/config/RatOS/boards/ldo-nitehawk-36/firmware.config" ]; then
+  echo "ERROR: firmware.config not found"
+  exit 1
+fi
+cp -f /home/pi/printer_data/config/RatOS/boards/ldo-nitehawk-36/firmware.config /home/pi/klipper/.config || {
+  echo "ERROR: Failed to copy firmware.config"
+  exit 1
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cp -f /home/pi/printer_data/config/RatOS/boards/ldo-nitehawk-36/firmware.config /home/pi/klipper/.config
if [ ! -f "/home/pi/printer_data/config/RatOS/boards/ldo-nitehawk-36/firmware.config" ]; then
echo "ERROR: firmware.config not found"
exit 1
fi
cp -f /home/pi/printer_data/config/RatOS/boards/ldo-nitehawk-36/firmware.config /home/pi/klipper/.config || {
echo "ERROR: Failed to copy firmware.config"
exit 1
}

pushd /home/pi/klipper || exit
make olddefconfig || exit 1
make clean || exit 1
make || exit 1

if [ ! -d "/home/pi/printer_data/config/firmware_binaries" ]
then
mkdir /home/pi/printer_data/config/firmware_binaries
chown pi:pi /home/pi/printer_data/config/firmware_binaries
fi
cp -f /home/pi/klipper/out/klipper.bin /home/pi/printer_data/config/firmware_binaries/firmware-ldo-nitehawk-36.bin
chown pi:pi /home/pi/printer_data/config/firmware_binaries/firmware-ldo-nitehawk-36.bin
popd || exit
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions configuration/boards/ldo-nitehawk-36/firmware.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
CONFIG_LOW_LEVEL_OPTIONS=y
# CONFIG_MACH_AVR is not set
# CONFIG_MACH_ATSAM is not set
# CONFIG_MACH_ATSAMD is not set
# CONFIG_MACH_LPC176X is not set
# CONFIG_MACH_STM32 is not set
# CONFIG_MACH_HC32F460 is not set
CONFIG_MACH_RPXXXX=y
# CONFIG_MACH_PRU is not set
# CONFIG_MACH_AR100 is not set
# CONFIG_MACH_LINUX is not set
# CONFIG_MACH_SIMU is not set
CONFIG_BOARD_DIRECTORY="rp2040"
CONFIG_MCU="rp2040"
CONFIG_CLOCK_FREQ=12000000
CONFIG_USBSERIAL=y
CONFIG_FLASH_SIZE=0x200000
CONFIG_FLASH_BOOT_ADDRESS=0x10000100
CONFIG_RAM_START=0x20000000
CONFIG_RAM_SIZE=0x42000
CONFIG_STACK_SIZE=512
CONFIG_FLASH_APPLICATION_ADDRESS=0x10004000
CONFIG_RPXXXX_SELECT=y
CONFIG_MACH_RP2040=y
# CONFIG_MACH_RP2350 is not set
CONFIG_RPXXXX_HAVE_BOOTLOADER=y
# CONFIG_RPXXXX_FLASH_START_0100 is not set
CONFIG_RPXXXX_FLASH_START_4000=y
CONFIG_RP2040_STAGE2_FILE="boot2_w25q080.S"
CONFIG_RP2040_STAGE2_CLKDIV=2
CONFIG_RPXXXX_USB=y
# CONFIG_RPXXXX_SERIAL_UART0_PINS_0_1 is not set
# CONFIG_RPXXXX_SERIAL_UART0_PINS_12_13 is not set
# CONFIG_RPXXXX_SERIAL_UART0_PINS_16_17 is not set
# CONFIG_RPXXXX_SERIAL_UART0_PINS_28_29 is not set
# CONFIG_RPXXXX_SERIAL_UART1_PINS_4_5 is not set
# CONFIG_RPXXXX_SERIAL_UART1_PINS_8_9 is not set
# CONFIG_RPXXXX_SERIAL_UART1_PINS_20_21 is not set
# CONFIG_RPXXXX_SERIAL_UART1_PINS_24_25 is not set
# CONFIG_RPXXXX_CANBUS is not set
# CONFIG_RPXXXX_USBCANBUS is not set
# CONFIG_RPXXXX_CANBUS_GPIO_RX=4
# CONFIG_RPXXXX_CANBUS_GPIO_TX=5
CONFIG_USB=y
CONFIG_USB_VENDOR_ID=0x1d50
CONFIG_USB_DEVICE_ID=0x614e
# CONFIG_USB_SERIAL_NUMBER_CHIPID is not set
CONFIG_USB_SERIAL_NUMBER="ldo-nitehawk-36"

#
# USB ids
#
# end of USB ids

CONFIG_WANT_GPIO_BITBANGING=y
CONFIG_WANT_DISPLAYS=y
CONFIG_WANT_THERMOCOUPLE=y
CONFIG_WANT_ADXL345=y
CONFIG_WANT_LIS2DW=y
CONFIG_WANT_MPU9250=y
CONFIG_WANT_HX71X=y
CONFIG_WANT_ADS1220=y
CONFIG_WANT_LDC1612=y
CONFIG_WANT_SENSOR_ANGLE=y
CONFIG_WANT_SOFTWARE_I2C=y
CONFIG_WANT_SOFTWARE_SPI=y
CONFIG_NEED_SENSOR_BULK=y
CONFIG_CANBUS_FREQUENCY=1000000
CONFIG_INITIAL_PINS="!gpio8"
CONFIG_HAVE_GPIO=y
CONFIG_HAVE_GPIO_ADC=y
CONFIG_HAVE_GPIO_SPI=y
CONFIG_HAVE_GPIO_I2C=y
CONFIG_HAVE_GPIO_HARD_PWM=y
CONFIG_HAVE_STRICT_TIMING=y
CONFIG_HAVE_CHIPID=y
CONFIG_HAVE_STEPPER_BOTH_EDGE=y
CONFIG_HAVE_BOOTLOADER_REQUEST=y
CONFIG_INLINE_STEPPER_HACK=y
17 changes: 17 additions & 0 deletions configuration/boards/ldo-nitehawk-36/flash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
MCU=/dev/ldo-nitehawk-36
if [ "$EUID" -ne 0 ]
then echo "ERROR: Please run as root"
exit
fi
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
FLASH_SCRIPT=$(realpath "$SCRIPT_DIR/../../scripts/flash-path.sh")
if [ ! -f "$FLASH_SCRIPT" ]; then
echo "ERROR: Flash script not found at $FLASH_SCRIPT"
exit 1
fi
if [ ! -e "$MCU" ]; then
echo "ERROR: Device $MCU not found"
exit 1
fi
$FLASH_SCRIPT $MCU
Binary file not shown.
28 changes: 28 additions & 0 deletions configuration/boards/ldo-nitehawk-36/make-and-flash-mcu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

if [ "$EUID" -ne 0 ]
then echo "ERROR: Please run as root"
exit
fi

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

"$SCRIPT_DIR"/compile.sh
if [ $? -ne 0 ]; then
echo "ERROR: Compilation failed"
exit 1
fi

"$SCRIPT_DIR"/compile.sh
if [ $? -ne 0 ]; then
echo "ERROR: Compilation failed"
exit 1
fi

"$SCRIPT_DIR"/flash.sh
if [ $? -ne 0 ]; then
echo "ERROR: Flashing failed"
exit 1
fi

echo "Successfully compiled and flashed firmware"
Binary file added configuration/boards/ldo-nitehawk-36/manual.pdf
Binary file not shown.
36 changes: 36 additions & 0 deletions configuration/boards/ldo-nitehawk-36/toolboard-config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# WARNING. DO NOT EDIT THIS FILE.
# To override settings from this file, you can copy and paste the relevant
# sections into your printer.cfg and change it there.
# WARNING: it is NOT recommended to override board_pins aliases,
# use the boards pin names directly in your printer.cfg instead.
# Look up the pins you need in the boards pinout diagram.

[board_pins ldo-nitehawk-36]
mcu: toolboard
aliases:
x_endstop_pin=gpio13,
e_step_pin=gpio23, e_dir_pin=gpio24, e_enable_pin=gpio25, e_uart_pin=gpio0, e_diag_pin=gpio3, e_heater_pin=gpio9, e_sensor_pin=gpio29,
# accel
adxl345_cs_pin=gpio27, adxl345_miso=gpio19, adxl345_mosi=gpio20, adxl345_clk=gpio18,
# leveling
# BLTouch is not supported on this board
bltouch_sensor_pin=null, bltouch_control_pin=null,
probe_pin=gpio10,
# fans
fan_part_cooling_pin=gpio6,
fan_toolhead_cooling_pin=gpio5,
# 4 pin fans
4p_fan_toolhead_cooling_tach_pin=gpio16

[mcu toolboard]
serial: /dev/ldo-nitehawk-36

[adxl345 toolboard]
cs_pin: toolboard:adxl345_cs_pin
spi_software_sclk_pin: toolboard:gpio18
spi_software_mosi_pin: toolboard:gpio20
spi_software_miso_pin: toolboard:gpio19

[temperature_sensor toolboard]
sensor_type: temperature_mcu
sensor_mcu: toolboard
4 changes: 4 additions & 0 deletions configuration/boards/ldo-nitehawk-36/wiring.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading