Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
madmonkey1907 committed Jan 3, 2017
0 parents commit de29903
Show file tree
Hide file tree
Showing 47 changed files with 3,244 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
@@ -0,0 +1,12 @@
*.pro.user
*.img
bin/mkbootimg
bin/sntool
bin/sunxi-fel
bin/unpackbootimg
build*/
kernel*/
data/
dump/
mod/bin/busybox
mod/hakchi/transfer/
6 changes: 6 additions & 0 deletions .gitmodules
@@ -0,0 +1,6 @@
[submodule "3rdparty/mkbootimg"]
path = 3rdparty/mkbootimg
url = git@github.com:osm0sis/mkbootimg.git
[submodule "3rdparty/sunxi-tools"]
path = 3rdparty/sunxi-tools
url = git@github.com:linux-sunxi/sunxi-tools.git
1 change: 1 addition & 0 deletions 3rdparty/busybox.url
@@ -0,0 +1 @@
https://busybox.net/downloads/binaries/latest/busybox-armv7l
1 change: 1 addition & 0 deletions 3rdparty/mkbootimg
Submodule mkbootimg added at f74725
1 change: 1 addition & 0 deletions 3rdparty/sunxi-tools
Submodule sunxi-tools added at 1e219c
28 changes: 28 additions & 0 deletions 3rdparty/sunxi-tools.diff
@@ -0,0 +1,28 @@
diff --git a/fel_lib.c b/fel_lib.c
index a484b4c..8d4d651 100644
--- a/fel_lib.c
+++ b/fel_lib.c
@@ -42,8 +42,14 @@ struct _felusb_handle {
bool iface_detached;
};

+void no_exit(int ec)
+{
+ (void)ec;
+}
+#define exit(x) {no_exit(x);return 0;}
+
/* a helper function to report libusb errors */
-void usb_error(int rc, const char *caption, int exitcode)
+void no_usb_error(int rc, const char *caption, int exitcode)
{
if (caption)
fprintf(stderr, "%s ", caption);
@@ -58,6 +64,7 @@ void usb_error(int rc, const char *caption, int exitcode)
if (exitcode != 0)
exit(exitcode);
}
+#define usb_error(x,y,z) {no_usb_error(x,y,z);if(z!=0)return 0;}

/*
* AW_USB_MAX_BULK_SEND and the timeout constant USB_TIMEOUT are related.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions Makefile
@@ -0,0 +1,31 @@
all: bin/sunxi-fel bin/mkbootimg bin/unpackbootimg mod/bin/busybox build/hakchi-gui bin/sntool

bin/sunxi-fel: 3rdparty/sunxi-tools/sunxi-fel
@cp 3rdparty/sunxi-tools/sunxi-fel bin/

3rdparty/sunxi-tools/sunxi-fel: 3rdparty/sunxi-tools/fel.c
@make -C 3rdparty/sunxi-tools sunxi-fel

bin/mkbootimg: 3rdparty/mkbootimg/mkbootimg
@cp 3rdparty/mkbootimg/mkbootimg bin/

3rdparty/mkbootimg/mkbootimg: 3rdparty/mkbootimg/mkbootimg.c
@make -C 3rdparty/mkbootimg

bin/unpackbootimg: 3rdparty/mkbootimg/unpackbootimg
@cp 3rdparty/mkbootimg/unpackbootimg bin/

3rdparty/mkbootimg/unpackbootimg: 3rdparty/mkbootimg/unpackbootimg.c
@make -C 3rdparty/mkbootimg

mod/bin/busybox: 3rdparty/busybox.url
wget --no-use-server-timestamps $(shell cat $<) -O $@ && chmod +x $@ && upx -qq --best $@

build/hakchi-gui: build/Makefile hakchi-gui/src/*
@make -C build

build/Makefile: hakchi-gui/hakchi-gui.pro
@mkdir -p build && (cd build; qmake ../$< CONFIG+=release)

bin/sntool: sntool/sntool.cpp
@g++ -std=gnu++11 -Wall -Wextra $< -o $@
17 changes: 17 additions & 0 deletions bin/extractimg
@@ -0,0 +1,17 @@
#!/bin/bash
set -e

img=$1
if [ -z "$img" ]; then
img=./dump/kernel.img
fi

infile=$(basename "$img")
inpath=./$(basename "$infile" .img)

rm -rf "$inpath"
mkdir "$inpath"
unpackbootimg -i "$img" -o "$inpath"
lzop -d "$inpath/$infile-ramdisk.gz" -o "$inpath/initramfs.cpio"
mkdir "$inpath/initramfs"
(cd "$inpath/initramfs";cpio -imd --no-preserve-owner --quiet -I "../initramfs.cpio")
35 changes: 35 additions & 0 deletions bin/extractimg.bat
@@ -0,0 +1,35 @@
@echo off

set img=%~f1
if "%img%"=="" goto error

set infile=%~nx1
set inpath=.\%~n1

if exist "%inpath%" rd /s /q "%inpath%"
if %errorlevel% neq 0 goto error

md "%inpath%"
if %errorlevel% neq 0 goto error

unpackbootimg -i "%img%" -o "%inpath%"
if %errorlevel% neq 0 goto error

lzop -d "%inpath%\%infile%-ramdisk.gz" -o "%inpath%\initramfs.cpio"
if %errorlevel% neq 0 goto error

md "%inpath%\initramfs"
if %errorlevel% neq 0 goto error

cd "%inpath%\initramfs"
if %errorlevel% neq 0 goto error

cpio -imd --no-preserve-owner --quiet -I "..\initramfs.cpio"
if %errorlevel% neq 0 goto error

exit /b %errorlevel%

:error
if %errorlevel% equ 0 set errorlevel=7
echo %0 %1 -^> exit %errorlevel% ?!?
exit /b %errorlevel%
11 changes: 11 additions & 0 deletions bin/felboot
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

sunxi-fel version

sunxi-fel write 0x2000 data/fes1.bin
sunxi-fel exe 0x2000

sunxi-fel -p write 0x43800000 kernel.img
sunxi-fel -p write 0x47000000 data/uboot.bin
sunxi-fel exe 0x47000000
31 changes: 31 additions & 0 deletions bin/makeimg
@@ -0,0 +1,31 @@
#!/bin/bash
set -e

inpath=$1
if [ -z "$inpath" ]; then
inpath=./kernel
fi

infile=$(basename "$inpath").img
img=./$infile

rm -rf "$inpath/initramfs/hakchi/transfer"
(cd "$inpath/../mod";cp -a * "../$inpath/initramfs/")
if [ "$2" == "notx" ]; then
rm -rf "$inpath/initramfs/hakchi/transfer"
fi
upx -qq --best "$inpath/initramfs/sbin/cryptsetup" || true
(cd "$inpath/initramfs";find . -print0 | sort -z | cpio -0o -H newc -R root:root --quiet > ../initramfs.cpio)
lzop --best -f -o "$inpath/$infile-ramdisk.gz" "$inpath/initramfs.cpio"

mkbootimg \
--kernel "$inpath/$infile-zImage" \
--ramdisk "$inpath/$infile-ramdisk.gz" \
--cmdline "$(cat $inpath/$infile-cmdline)" \
--board "$(cat $inpath/$infile-board)" \
--base "$(cat $inpath/$infile-base)" \
--pagesize "$(cat $inpath/$infile-pagesize)" \
--kernel_offset "$(cat $inpath/$infile-kerneloff)" \
--ramdisk_offset "$(cat $inpath/$infile-ramdiskoff)" \
--tags_offset "$(cat $inpath/$infile-tagsoff)" \
-o "$img"
38 changes: 38 additions & 0 deletions bin/makeimg.bat
@@ -0,0 +1,38 @@
@echo off

set inpath=%~f1
if "%inpath%"=="" goto error

set infile=%~nx1.img
set img=.\%~nx1.img

if exist "%inpath%\initramfs\hakchi\transfer" rd /s /q "%inpath%\initramfs\hakchi\transfer"
xcopy "%inpath%\..\mod" "%inpath%\initramfs" /h /y /c /r /s /q || cd >nul
if "%2"=="notx" if exist "%inpath%\initramfs\hakchi\transfer" rd /s /q "%inpath%\initramfs\hakchi\transfer"
if %errorlevel% neq 0 goto error

upx -qq --best "%inpath%\initramfs\sbin\cryptsetup" || cd >nul

mkbootfs "%inpath%\initramfs" > "%inpath%\initramfs.cpio"
if %errorlevel% neq 0 goto error

lzop --best -f -o "%inpath%\%infile%-ramdisk.gz" "%inpath%\initramfs.cpio"
if %errorlevel% neq 0 goto error

set /p cmdline=<"%inpath%\%infile%-cmdline"
set /p board=<"%inpath%\%infile%-board"
set /p base=<"%inpath%\%infile%-base"
set /p pagesize=<"%inpath%\%infile%-pagesize"
set /p kerneloff=<"%inpath%\%infile%-kerneloff"
set /p ramdiskoff=<"%inpath%\%infile%-ramdiskoff"
set /p tagsoff=<"%inpath%\%infile%-tagsoff"

mkbootimg --kernel "%inpath%\%infile%-zImage" --ramdisk "%inpath%\%infile%-ramdisk.gz" --cmdline "%cmdline%" --board "%board%" --base "%base%" --pagesize "%pagesize%" --kernel_offset "%kerneloff%" --ramdisk_offset "%ramdiskoff%" --tags_offset "%tagsoff%" -o "%img%"
if %errorlevel% neq 0 goto error

exit /b %errorlevel%

:error
if %errorlevel% equ 0 set errorlevel=7
echo %0 %1 %2 -^> exit %errorlevel% ?!?
exit /b %errorlevel%
17 changes: 17 additions & 0 deletions hakchi-gui/hakchi-gui.pro
@@ -0,0 +1,17 @@
QT+=core gui
greaterThan(QT_MAJOR_VERSION,4):QT+=widgets
TARGET=hakchi-gui
TEMPLATE=app

INCLUDEPATH+=$${PWD}/../3rdparty/sunxi-tools $${PWD}/../3rdparty/sunxi-tools/include $${PWD}/../3rdparty/mkbootimg
DEPENDPATH+=$${PWD}/src $${PWD}/../3rdparty/sunxi-tools $${PWD}/../3rdparty/sunxi-tools/include
LIBS += $$system(pkg-config --libs \"libusb-1.0 >= 1.0.0\" --static)
QMAKE_CFLAGS += $$system(pkg-config --cflags \"libusb-1.0 >= 1.0.0\") -std=gnu99 -DNDEBUG -Wall -Wextra
QMAKE_CXXFLAGS += $$system(pkg-config --cflags \"libusb-1.0 >= 1.0.0\") -Wall -Wextra

SOURCES += fel_lib.c soc_info.c progress.c

SOURCES += $${PWD}/src/*.cpp
SOURCES += $${PWD}/src/*.c
HEADERS += $${PWD}/src/*.h
FORMS += $${PWD}/src/*.ui

0 comments on commit de29903

Please sign in to comment.