diff --git a/README_MACOS.md b/README_MACOS.md new file mode 100644 index 0000000..3bf8610 --- /dev/null +++ b/README_MACOS.md @@ -0,0 +1,75 @@ +# rkdeveloptool for macOS + +This is a macOS-compatible fork of [DorianRudolph/rkdeveloptool](https://github.com/DorianRudolph/rkdeveloptool) with modifications to compile and run on macOS (Intel & Apple Silicon). + +## Changes for macOS Compatibility + +### Build System Fixes +- Added C++11 standard requirement in `meson.build` +- Made udev dependency Linux-only (not available on macOS) +- Fixed C++11 syntax compatibility in `main.cpp` + +### Installation on macOS + +#### Prerequisites +```bash +# Install dependencies via Homebrew +brew install libusb meson +``` + +#### Build and Install +```bash +# Clone this repository +git clone https://github.com/YOUR_USERNAME/rkdeveloptool.git +cd rkdeveloptool + +# Build with Meson +meson setup build +meson compile -C build + +# Install (optional) +sudo meson install -C build +# Or copy to local bin +cp build/rkdeveloptool ~/bin/ +``` + +## Usage + +This version includes both short and long command names: + +```bash +# List devices +rkdeveloptool list +rkdeveloptool ld + +# List partitions +rkdeveloptool list-partitions +rkdeveloptool lp + +# Device information +rkdeveloptool read-flash-info +rkdeveloptool read-chip-info +rkdeveloptool read-capability + +# Read/Write operations +rkdeveloptool read +rkdeveloptool read-partition +rkdeveloptool write +rkdeveloptool write-partition + +# Device management +rkdeveloptool boot +rkdeveloptool reset +rkdeveloptool reboot +rkdeveloptool erase-flash +``` + +## Tested On +- macOS Sonoma (Apple Silicon M1/M2/M3/M4) +- macOS Ventura (Intel & Apple Silicon) + +## Original Project +This fork is based on [DorianRudolph/rkdeveloptool](https://github.com/DorianRudolph/rkdeveloptool), which is actively maintained to support PineNote, Quartz64, and other Pine64 RK devices. + +## License +GPL-2.0 (same as original project) diff --git a/install_macos.sh b/install_macos.sh new file mode 100755 index 0000000..e2518f6 --- /dev/null +++ b/install_macos.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# rkdeveloptool macOS Installation Script +# This script installs rkdeveloptool on macOS (Intel & Apple Silicon) + +set -e + +echo "🚀 Installing rkdeveloptool for macOS..." + +# Check if we're on macOS +if [[ "$OSTYPE" != "darwin"* ]]; then + echo "❌ This script is for macOS only" + exit 1 +fi + +# Check if Homebrew is installed +if ! command -v brew &> /dev/null; then + echo "❌ Homebrew is required but not installed" + echo "📥 Install Homebrew from: https://brew.sh" + exit 1 +fi + +echo "📦 Installing dependencies..." +brew install libusb meson + +echo "🔨 Building rkdeveloptool..." +if [ -d "build" ]; then + rm -rf build +fi + +meson setup build +meson compile -C build + +echo "📋 Installation options:" +echo "1) Install system-wide (requires sudo)" +echo "2) Install to ~/bin (user only)" +echo "3) Just build (no installation)" + +read -p "Choose option (1-3): " choice + +case $choice in + 1) + echo "🔐 Installing system-wide..." + sudo meson install -C build + echo "✅ Installed to system PATH" + ;; + 2) + echo "📁 Installing to ~/bin..." + mkdir -p ~/bin + cp build/rkdeveloptool ~/bin/ + echo "✅ Installed to ~/bin/rkdeveloptool" + echo "💡 Add ~/bin to your PATH if not already done:" + echo " echo 'export PATH=\"\$HOME/bin:\$PATH\"' >> ~/.zshrc" + ;; + 3) + echo "✅ Build complete. Binary is at: build/rkdeveloptool" + ;; + *) + echo "❌ Invalid option" + exit 1 + ;; +esac + +echo "" +echo "🎉 Installation complete!" +echo "" +echo "📖 Usage examples:" +echo " rkdeveloptool list # List devices" +echo " rkdeveloptool list-partitions # Show partitions" +echo " rkdeveloptool read-flash-info # Device info" +echo "" +echo "📚 For more commands: rkdeveloptool --help" diff --git a/main.cpp b/main.cpp index ddaa04d..5bf915f 100644 --- a/main.cpp +++ b/main.cpp @@ -3316,7 +3316,8 @@ int main(int argc, char *argv[]) { char szProgramProcPath[100]; char szProgramDir[256]; string strLogDir, strConfigFile; - struct stat statBuf {}; + struct stat statBuf; + memset(&statBuf, 0, sizeof(statBuf)); g_ConfigItemVec.clear(); sprintf(szProgramProcPath, "/proc/%d/exe", getpid()); diff --git a/meson.build b/meson.build index 808ce1f..df075a9 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('rkdeveloptool', 'cpp', version: '1.0.0') +project('rkdeveloptool', 'cpp', version: '1.0.0', default_options: ['cpp_std=c++11']) libusb = dependency('libusb-1.0') @@ -22,13 +22,15 @@ executable('rkdeveloptool', install: true) -# Install udev rules for the usb part -udev = dependency('udev') -udev_rules_dir = udev.get_pkgconfig_variable('udevdir') + '/rules.d' -install_data( - ['99-rk-rockusb.rules'], - install_dir: udev_rules_dir, -) +# Install udev rules for the usb part (Linux only) +if host_machine.system() == 'linux' + udev = dependency('udev') + udev_rules_dir = udev.get_pkgconfig_variable('udevdir') + '/rules.d' + install_data( + ['99-rk-rockusb.rules'], + install_dir: udev_rules_dir, + ) +endif # Build and install the man pages scdoc = dependency('scdoc', native: true, required: get_option('man-pages'))