Skip to content
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
75 changes: 75 additions & 0 deletions README_MACOS.md
Original file line number Diff line number Diff line change
@@ -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 <sector> <count> <file>
rkdeveloptool read-partition <partition> <file>
rkdeveloptool write <sector> <file>
rkdeveloptool write-partition <partition> <file>

# Device management
rkdeveloptool boot <loader>
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)
72 changes: 72 additions & 0 deletions install_macos.sh
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 2 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
18 changes: 10 additions & 8 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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')

Expand All @@ -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'))
Expand Down