From c17adb3710c187f1deb34f23043c707e3aeded3b Mon Sep 17 00:00:00 2001 From: Franklyn Tackitt Date: Sun, 22 Dec 2024 13:50:09 -0700 Subject: [PATCH] Fix spi_flash --- scripts/spi_flash/fatfs_lib.py | 10 +++++----- scripts/spi_flash/spi_flash.py | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/spi_flash/fatfs_lib.py b/scripts/spi_flash/fatfs_lib.py index 87c3f841a..fff4448b8 100644 --- a/scripts/spi_flash/fatfs_lib.py +++ b/scripts/spi_flash/fatfs_lib.py @@ -5,14 +5,14 @@ # This file may be distributed under the terms of the GNU GPLv3 license. import os import sys +import pathlib -KLIPPER_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")) -sys.path.append(os.path.join(KLIPPER_DIR, "klippy")) - -import chelper # noqa: E402 +KLIPPER_DIR = pathlib.Path(__file__).parent.parent.parent +sys.path.insert(0, str(KLIPPER_DIR)) +from klippy import chelper # noqa: E402 DEST_LIB = "fatfs.so" -FATFS_DIR = os.path.join(KLIPPER_DIR, "lib/fatfs") +FATFS_DIR = str(KLIPPER_DIR / "lib" / "fatfs") FATFS_SRC = ["ff.c", "ffsystem.c", "ffunicode.c"] SPI_FLASH_SRC = ["fatfs_api.c"] FATFS_HEADERS = ["diskio.h", "ff.h", "ffconf.h"] diff --git a/scripts/spi_flash/spi_flash.py b/scripts/spi_flash/spi_flash.py index 5266e4363..a31eb4a75 100644 --- a/scripts/spi_flash/spi_flash.py +++ b/scripts/spi_flash/spi_flash.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # Module supporting uploads Klipper firmware to an SD Card via SPI and SDIO # # Copyright (C) 2021 Eric Callahan @@ -17,6 +17,9 @@ import json import board_defs import fatfs_lib +import pathlib + +sys.path.insert(0, str(pathlib.Path(__file__).parent.parent.parent)) from klippy import reactor, serialhdl, clocksync, mcu ###########################################################