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
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build

on:
push:
branches: ['master']
pull_request:
branches: ['master']

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install dependencies
run: |
sudo apt-get install -y --no-install-recommends \
libusb-1.0-0-dev pkg-config ninja-build

- name: Configure
run: cmake -B build -S . -G Ninja

- name: Build
run: cmake --build build
108 changes: 52 additions & 56 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,56 +1,52 @@
# Project name
set (PROJECT_NAME "rkDevelopTool_Mac")

# The version number.
set (RKDevelopTool_Mac_PACKAGE_VERSION "1.3")

file (GLOB LOCAL_CPP_FILES *.cpp)
set (SOURCE_FILES ${SOURCE_FILES} ${LOCAL_CPP_FILES})

file (GLOB LOCAL_H_FILES *.h)
set (HEADER_FILES ${HEADER_FILES} ${LOCAL_H_FILES})

# Set your libusb path
set (libusb_INCLUDE_DIR "/usr/local/Cellar/libusb/1.0.22/include/libusb-1.0/")
set (libusb_STATIC "/usr/local/Cellar/libusb/1.0.22/lib/")

# Set your libiconv path
set (libiconv_INCLUDE_DIR "/usr/local/opt/libiconv/include/")
set (libiconv_STATIC "/usr/local/opt/libiconv/lib/")

cmake_minimum_required (VERSION 2.6)
project (${PROJECT_NAME})


# Turn off build log
# set (CMAKE_VERBOSE_MAKEFILE ON)

# Configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)

# add the binary tree to the search path for include files
# so that we will find config.h
include_directories (
"${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}"
"${libusb_INCLUDE_DIR}"
"${libiconv_INCLUDE_DIR}"
)

link_directories (
${libusb_STATIC}
${libiconv_STATIC}
)

add_executable (${PROJECT_NAME} ${SOURCE_FILES})

target_link_libraries (
"${PROJECT_NAME}"
"${libusb_STATIC}/libusb-1.0.dylib"
"${libiconv_STATIC}/libiconv.dylib"
)

cmake_minimum_required(VERSION 3.19)

project(rkdeveloptool VERSION 1.32 LANGUAGES CXX)

set(UDEV_RULES_DIR "lib/udev/rules.d"
CACHE PATH "Directory to install udev rules.")

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(GNUInstallDirs)

find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBUSB1 REQUIRED libusb-1.0)

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/config.h"
)

add_executable(rkdeveloptool
main.cpp
crc.cpp
RKBoot.cpp
RKComm.cpp
RKDevice.cpp
RKImage.cpp
RKLog.cpp
RKScan.cpp
)

target_compile_options(rkdeveloptool PRIVATE
-Wall -Werror -Wextra -Wreturn-type
-fno-strict-aliasing
-D_FILE_OFFSET_BITS=64 -D_LARGE_FILE
)

target_include_directories(rkdeveloptool PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${LIBUSB1_INCLUDE_DIRS}"
)

target_link_libraries(rkdeveloptool PRIVATE ${LIBUSB1_LIBRARIES})

install(TARGETS rkdeveloptool RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
install(FILES 99-rk-rockusb.rules DESTINATION "${UDEV_RULES_DIR}")
endif()
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# rkdeveloptool

A command-line tool for reading and writing Rockchip devices over USB in
MASKROM or ROCKUSB mode.

## Build

CMake is the recommended way to build. Install the required library and build
tools (a C++11-compatible compiler, CMake, and Ninja) first:

```shell
apt-get install cmake ninja-build libusb-1.0-0-dev pkg-config
```

### CMake

```bash
cmake -B build -S . -G Ninja
cmake --build build
```

The binary is placed at `build/rkdeveloptool`.

### Autotools

Install required dependencies.

```bash
apt-get install dh-autoreconf make
```

Generate `Makefile` and build.

```bash
./autogen.sh
./configure
make
```

## Usage

Most commands require the device to be connected in MASKROM or ROCKUSB mode.

```bash
./rkdeveloptool -h
```

### Example: Flash a Kernel Image

1. Load the bootloader into RAM (device must be in MASKROM mode).
```bash
./rkdeveloptool db RKXXLoader.bin
```
2. Write the kernel to its partition (0x8000 is the sector offset).
```bash
./rkdeveloptool wl 0x8000 kernel.img
```
3. Reset the device.
```bash
./rkdeveloptool rd
```

## Troubleshooting

### USB Device Permissions

To use the tool without `sudo`, install the bundled udev rules.

```bash
cp 99-rk-rockusb.rules /etc/udev/rules.d/
udevadm control --reload-rules
```
25 changes: 0 additions & 25 deletions Readme.txt

This file was deleted.

4 changes: 2 additions & 2 deletions config.h.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// the configured options and settings for RKDevelopTool_Mac
#define PACKAGE_VERSION "@RKDevelopTool_Mac_PACKAGE_VERSION@"
// The configured options and settings for rkdeveloptool.
#define PACKAGE_VERSION "@PROJECT_VERSION@"