...
 
Commits (19)
fexc
bin2fex
fex2bin
Makefile
Makefile.in
*.m4
compile
config.guess
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
.deps/
.libs/
bootinfo
fel
pio
fexc
nand-part
phoenix_info
pio
boot_head_sun4i.bin
boot_head_sun4i.elf
boot_head_sun5i.bin
boot_head_sun5i.elf
fel-pio.bin
fel-pio.elf
fel-sdboot.bin
fel-sdboot.elf
jtag-loop.bin
jtag-loop.elf
*.a
*.o
*.la
*.so*
*.swp
*~
autom4te.cache/
Alejandro Mery <amery@geeks.cl>
Henrik Nordstrom <henrik@henriknordstrom.net>
Patrick Wood <patrickhwood@gmail.com>
Pat Wood <Pat.Wood@efi.com>
2014-07-29 Andrey V.Kosteltsev <kosteltsev@gmail.com>
* Tag 1.3 created.
* Sources have been reorganized.
* Build system moved to Autotools.
This diff is collapsed.
# Copyright (C) 2012 Alejandro Mery <amery@geeks.cl>
# Copyright (C) 2012,2013 Henrik Nordstrom <henrik@henriknordstrom.net>
# Copyright (C) 2013 Patrick Wood <patrickhwood@gmail.com>
# Copyright (C) 2013 Pat Wood <Pat.Wood@efi.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
CC = gcc
CFLAGS = -g -O0 -Wall -Wextra
CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200112L
CFLAGS += -Iinclude/
TOOLS = fexc bin2fex fex2bin bootinfo fel pio
TOOLS += nand-part
MISC_TOOLS = phoenix_info
CROSS_COMPILE ?= arm-none-eabi-
.PHONY: all clean
all: $(TOOLS)
misc: $(MISC_TOOLS)
clean:
@rm -vf $(TOOLS) $(MISC_TOOLS) *.o *.elf *.sunxi *.bin *.nm *.orig
$(TOOLS): Makefile common.h
fex2bin bin2fex: fexc
ln -s $< $@
fexc: fexc.h script.h script.c \
script_uboot.h script_uboot.c \
script_bin.h script_bin.c \
script_fex.h script_fex.c
LIBUSB = libusb-1.0
LIBUSB_CFLAGS = `pkg-config --cflags $(LIBUSB)`
LIBUSB_LIBS = `pkg-config --libs $(LIBUSB)`
fel: fel.c
$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS)
nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h
$(CC) $(CFLAGS) -c -o nand-part-main.o nand-part-main.c
$(CC) $(CFLAGS) -c -o nand-part-a10.o nand-part.c -D A10
$(CC) $(CFLAGS) -c -o nand-part-a20.o nand-part.c -D A20
$(CC) $(LDFLAGS) -o $@ nand-part-main.o nand-part-a10.o nand-part-a20.o $(LIBS)
%: %.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS)
fel-pio.bin: fel-pio.elf fel-pio.nm
$(CROSS_COMPILE)objcopy -O binary fel-pio.elf fel-pio.bin
fel-pio.elf: fel-pio.c fel-pio.lds
$(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder fel-pio.c -nostdlib -o fel-pio.elf -T fel-pio.lds
fel-pio.nm: fel-pio.elf
$(CROSS_COMPILE)nm fel-pio.elf | grep -v " _" >fel-pio.nm
jtag-loop.elf: jtag-loop.c jtag-loop.lds
$(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder jtag-loop.c -nostdlib -o jtag-loop.elf -T jtag-loop.lds -Wl,-N
jtag-loop.bin: jtag-loop.elf
$(CROSS_COMPILE)objcopy -O binary jtag-loop.elf jtag-loop.bin
jtag-loop.sunxi: jtag-loop.bin
mksunxiboot jtag-loop.bin jtag-loop.sunxi
fel-sdboot.elf: fel-sdboot.c fel-sdboot.lds
$(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder fel-sdboot.c -nostdlib -o fel-sdboot.elf -T fel-sdboot.lds -Wl,-N
fel-sdboot.bin: fel-sdboot.elf
$(CROSS_COMPILE)objcopy -O binary fel-sdboot.elf fel-sdboot.bin
fel-sdboot.sunxi: fel-sdboot.bin
mksunxiboot fel-sdboot.bin fel-sdboot.sunxi
boot_head_sun3i.elf: boot_head_sun3i.S boot_head_sun3i.lds
$(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder boot_head.S -nostdlib -o boot_head_sun3i.elf -T boot_head.lds -Wl,-N -DMACHID=0x1094
boot_head_sun3i.bin: boot_head_sun3i.elf
$(CROSS_COMPILE)objcopy -O binary boot_head_sun3i.elf boot_head_sun3i.bin
boot_head_sun4i.elf: boot_head.S boot_head.lds
$(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder boot_head.S -nostdlib -o boot_head_sun4i.elf -T boot_head.lds -Wl,-N -DMACHID=0x1008
boot_head_sun4i.bin: boot_head_sun4i.elf
$(CROSS_COMPILE)objcopy -O binary boot_head_sun4i.elf boot_head_sun4i.bin
boot_head_sun5i.elf: boot_head.S boot_head.lds
$(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder boot_head.S -nostdlib -o boot_head_sun5i.elf -T boot_head.lds -Wl,-N -DMACHID=0x102A
boot_head_sun5i.bin: boot_head_sun5i.elf
$(CROSS_COMPILE)objcopy -O binary boot_head_sun5i.elf boot_head_sun5i.bin
bootinfo: bootinfo.c
.gitignore: Makefile
@for x in $(TOOLS) '*.o' '*.swp'; do \
echo "$$x"; \
done > $@
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = m4 autogen.sh include/common.h include/endian_compat.h include/types.h
if HOST_CPU_ARM
MAYBE_SRC = src
endif
SUBDIRS = libfex tools binaries scripts man $(MAYBE_SRC)
dist_doc_DATA = COPYING README
docdir = $(datadir)/doc/@PACKAGE@-@VERSION@
Sources tree has been reorganized and moved to using autotools.
NOTE:
If your target CPU is not arm then binaries in 'src' directory will not be built.
Skipping 'src' directory in this case made for building tools without cross compiler
for development PC.
$ tar xzvf sunxi-tools-1.3.tar.gz
$ mkdir build
$ cd ./build
configure with cross:
--------------------
CC="<toolchain path>/bin/arm-a1x-linux-gnueabihf-gcc --sysroot=<path to sysroot where libusb is installed>" \
OBJCOPY=<toolchain path>/bin/arm-a1x-linux-gnueabihf-objcopy \
NM=<toolchain path>/bin/arm-a1x-linux-gnueabihf-nm \
CFLAGS=-I<path to sysroot>/usr/include \
LDFLAGS="-L<path to sysroot>/lib -L<path to sysroot>/usr/lib" \
../sunxi-tools-1.3/configure \
--prefix=/usr \
--build=x86_64-slackware-linux \
--host=arm-a1x-linux-gnueabihf \
--target=arm-a1x-linux-gnueabihf \
--prefix=/usr --mandir=/usr/share/man \
--program-prefix=
configure on and for developers machine:
---------------------------------------
../sunxi-tools-1.3/configure --prefix=/usr
$ make
$ make install DESTDIR=<path to sysroot>
Enjoy.
#!/bin/sh
libtoolize --force --copy
aclocal --install -I m4 --force
autoheader
automake --gnu --add-missing --copy --force-missing
autoconf --force
EXTRA_DIST = fel-pio.bin \
fel-pio.nm \
fel-sdboot.sunxi \
jtag-loop.sunxi \
ramboot.scr \
ramboot.uboot-sh
binariesdir = $(datadir)/doc/@PACKAGE@-@VERSION@/binaries
binaries_SCRIPTS = fel-pio.bin \
ramboot.uboot-sh
extradir = $(datadir)/doc/@PACKAGE@-@VERSION@/binaries
extra_DATA = fel-pio.nm \
fel-sdboot.sunxi \
jtag-loop.sunxi \
ramboot.scr
/*
* Copyright (C) 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
SECTIONS
{
. = 0x40007000;
.text : { *(.text) }
}
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.68])
AC_INIT([sunxi-tools], [1.3], [https://github.com/linux-sunxi/sunxi-tools])
AC_CONFIG_SRCDIR([tools/fexc.c])
AC_CANONICAL_SYSTEM
# automake initialisation and check for minimal automake API version 1.9
AM_INIT_AUTOMAKE([1.9])
LT_INIT
AC_CANONICAL_HOST
# Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AM_PROG_AS
AM_PROG_CC_C_O
AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
AC_CHECK_PROGS(CXX_FOR_BUILD, g++)
AC_CHECK_PROGS(OBJCOPY, objcopy)
AC_CHECK_PROGS(OBJDUMP, objdump)
AC_CHECK_PROGS(AR, ar)
AC_CHECK_PROGS(NM, nm)
AC_SUBST([CCC_FOR_BUILD])
AC_SUBST([CXX_FOR_BUILD])
AC_SUBST([OBJCOPY])
AC_SUBST([OBJDUMP])
AC_SUBST([AR])
AC_SUBST([NM])
AM_CONDITIONAL([HOST_CPU_ARM], [test "$host_cpu" = "arm"])
case "$host_cpu" in
arm*)
THUMB_CFLAGS="$THUMB_CFLAGS -mno-thumb-interwork"
;;
esac
AC_SUBST([THUMB_CFLAGS])
AC_PROG_LN_S
AC_PROG_MKDIR_P
# Checks for libraries.
PKG_CHECK_MODULES([LIBUSB], libusb-1.0 >= 1.0.0,, AC_MSG_ERROR([*** Required libusb-1.0 >= 1.0.0 not installed ***]))
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/mount.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_INT32_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
dnl Following macro generates '#define malloc rpl_malloc' it's lead to link stage error:
dnl AC_FUNC_MALLOC
dnl AC_FUNC_REALLOC
# Checks for library functions.
AC_FUNC_MMAP
AC_CHECK_FUNCS([memset munmap strchr strerror strtol strtoul])
AC_CONFIG_FILES([Makefile libfex/Makefile tools/Makefile src/Makefile binaries/Makefile scripts/Makefile man/Makefile])
AC_OUTPUT
/*
* Copyright (C) 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
SECTIONS
{
. = 0x2000;
.text : { *(.text) }
}
/*
* Copyright (C) 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
SECTIONS
{
. = 0x0030;
.text : { *(.text) }
}
/*
* Copyright (C) 2012 Eric Molitor <eric@molitor.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef SUNXI_ENDIAN_COMPAT_H_
#define SUNXI_ENDIAN_COMPAT_H_
#ifdef __APPLE__
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#define htole32(x) CFSwapInt32HostToLittle(x)
#define le32toh(x) CFSwapInt32LittleToHost(x)
......
/*
* (C) Copyright 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
* (C) Copyright 2012 Alejandro Mery <amery@geeks.cl>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef SUNXI_TYPES_H
#define SUNXI_TYPES_H
......
/*
* Copyright (C) 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
SECTIONS
{
. = 0x0030;
.text : { *(.text) }
}
AM_CFLAGS = -g -O0 -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -I$(top_srcdir) -I$(top_srcdir)/include
AM_LDFLAGS =
lib_LTLIBRARIES = libfex.la
libfex_la_SOURCES = $(top_srcdir)/include/libfex/script.h script.c \
$(top_srcdir)/include/libfex/script_uboot.h script_uboot.c \
$(top_srcdir)/include/libfex/script_bin.h script_bin.c \
$(top_srcdir)/include/libfex/script_fex.h script_fex.c
libfex_la_includedir = $(includedir)/libfex
libfex_la_include_HEADERS = $(top_srcdir)/include/libfex/script.h \
$(top_srcdir)/include/libfex/script_uboot.h \
$(top_srcdir)/include/libfex/script_bin.h \
$(top_srcdir)/include/libfex/script_fex.h
libfex_la_CFLAGS = $(CFLAGS) $(AM_CFLAGS)
libfex_la_LDFLAGS = $(LDFLAGS) $(AM_LDFLAGS)
......@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include "script.h"
#include "libfex/script.h"
/*
*/
......
......@@ -23,8 +23,8 @@
#include <stdio.h>
#include <string.h>
#include "script.h"
#include "script_bin.h"
#include "libfex/script.h"
#include "libfex/script_bin.h"
#define pr_info(...) errf("fexc-bin: " __VA_ARGS__)
#define pr_err(...) errf("E: fexc-bin: " __VA_ARGS__)
......
......@@ -22,8 +22,8 @@
#include <stdlib.h>
#include <string.h>
#include "script.h"
#include "script_fex.h"
#include "libfex/script.h"
#include "libfex/script_fex.h"
#define MAX_LINE 255
......
......@@ -20,8 +20,8 @@
#include <stdio.h>
#include <string.h>
#include "script.h"
#include "script_uboot.h"
#include "libfex/script.h"
#include "libfex/script_uboot.h"
#define pr_info(...) errf("fexc-uboot: " __VA_ARGS__)
#define pr_err(...) errf("E: fexc-uboot: " __VA_ARGS__)
......
#!/bin/bash
WRKDIR="`pwd`"
ISOK=1
while [ "$ISOK" -eq "1" ]; do
while [ -z "${DEBFULLNAME}" ]; do
DEBFULLNAME=$(whiptail --title "Package configuration" --inputbox "\nYour Name" 9 40 3>&1 1>&2 2>&3)
done
while [ -z "${DEBEMAIL}" ] ; do
DEBEMAIL=$(whiptail --title "Package configuration" --inputbox "\nYour Email" 9 40 3>&1 1>&2 2>&3)
done
while [ -z "${RELEASETAG}" ] ; do
RELEASETAG=$(whiptail --title "Package configuration" --inputbox "\nRelease Tag (UNRELEASED/MAIN/CONTRIB/etc...)" 9 40 3>&1 1>&2 2>&3)
done
whiptail --title "Package configuration summary" --yesno " Maintainer Name : ${DEBFULLNAME}\nMaintainer Email : ${DEBEMAIL}\n Release Tag : ${RELEASETAG}\n\nIs this ok?" 11 60
ISOK="$?"
if [ "$ISOK" -gt "1" ] || [ "$ISOK" -lt "0" ]; then
exit
fi
if [ "$ISOK" -eq "1" ]; then
unset RELEASETAG
unset DEBFULLNAME
unset DEBEMAIL
fi
done
rm -rf dpkg
mkdir -p dpkg
make dist-gzip
mv sunxi-tools-1.0.tar.gz dpkg/sunxi-tools_1.0.orig.tar.gz
cd dpkg
tar -xzvf sunxi-tools_1.0.orig.tar.gz
cd sunxi-tools-1.0
mkdir debian
echo "sunxi-tools (1.0-1) ${RELEASETAG}; urgency=low" > debian/changelog
git log -1 --pretty=format:'%n * %s%n%n -- %cn <%ce> %cD%n' >> debian/changelog
echo "9" > debian/compat
cat > debian/control <<EOF
Source: sunxi-tools
Maintainer: ${DEBFULLNAME} <${DEBEMAIL}>
Section: misc
Priority: optional
Standards-Version: 3.9.4
Build-Depends: debhelper (>= 8)
Package: sunxi-tools
Architecture: any
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: Tools to help hacking Allwinner A10/A20 based devices
Tools to help hacking Allwinner A10 (aka sun4i) based devices and possibly
it's successors, that's why the 'x' in the package name.
EOF
cat > debian/copyright <<EOF
sunxi-tools Copyright (C) 2012 Alejandro Mery <amery@geeks.cl>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301, USA.
On Debian GNU/Linux systems, the complete text of the GNU General
Public License can be found in /usr/share/common-licenses/GPL-2.
EOF
cat > debian/rules <<EOF
#!/usr/bin/make -f
%:
dh \$@
EOF
chmod 755 debian/rules
mkdir -p debian/source
echo "3.0 (quilt)" > debian/source/format
debuild -us -uc
cd ${WRKDIR}
mv dpkg/*.deb .
rm -rf dpkg
man_MANS = sunxi-tools.7
EXTRA_DIST = sunxi-tools.7
install-data-hook:
@cd $(DESTDIR)$(mandir)/man7 ; \
for file in *.7 ; do \
gzip -9 $$file ; \
done
.TH SUNXI-TOOLS "7" "August 2013" "For allWinner's A10/A20"
.SH NAME
sunxi-tools \- Tools to help hacking Allwinner A10 (aka sun4i) based devices
and possibly it's successors, that's why the 'x' in the package name.
.SH SYNOPSIS
.B fexc
[\fI-vq\fR] [\fI-I <fex|bin>\fR] [\fI-O <bin|fex>\fR] [\fI<input> \fR[\fI<output>\fR]]
.PP
(de)compiler for `.fex` configuration file.
.PP
.B fex2bin
[\fI-vq\fR] [\fI<input> \fR[\fI<output>\fR]]
.PP
Compatibility shortcut to call `fexc` to decompile an script.bin
blob back into `.fex` format used by allwinner's SDK to configure
the boards
.PP
.B bin2fex
[\fI-vq\fR] [\fI<input> \fR[\fI<output>\fR]]
.PP
Compatiblity shortcut to call `fexc` to compile a `.fex` file into
the binary form used by the sun4i kernel.
.PP
.B fel
\fIcommand arguments\fR [\fIcommand arguments\fR ...]
.PP
Script interface for talking to the FEL USB handler built in to
the CPU. You activate FEL mode by pushing the usboot/recovery
button at poweron.
.PP
.B pio
[\fI-m\fR|\fI-i input\fR] [\fI-o output\fR] \fIpin\fR ...
.PP
Manipulate PIO register dumps
.PP
.B nand-part
\fInand-device '\fIname2\fR \fIlen2\fR [\fIusertype2\fR]' ['\fIname3 len3\fR [\fIusertype3\fR]'] ...
.br
.B nand-part
\fInand-device [\fI-f\fR] \fIstart1\fR '\fIname1 len1\fR [\fIusertype1\fR]' ['\fIname2 len2\fR [\fIusertype2\fR]'] ...
.PP
Tool for manipulating Allwinner A10 NAND partition tables.
.PP
.B nand-part-a20
\fInand-device '\fIname2\fR \fIlen2\fR [\fIusertype2\fR]' ['\fIname3 len3\fR [\fIusertype3\fR]'] ...
.br
.B nand-part-a20
\fInand-device [\fI-f\fR] \fIstart1\fR '\fIname1 len1\fR [\fIusertype1\fR]' ['\fIname2 len2\fR [\fIusertype2\fR]'] ...
.PP
Tool for manipulating Allwinner A20 NAND partition tables
.PP
.B bootinfo
[\fI--type=<sd|nand>\fR] \FIfilename\FR
.PP
Dump information from Allwinner boot files (boot0/boot1)
.PP
.B phoenix_info
[\FI-v\FR] [\FI-q\FR] [\FI-p N\FR] [\FI-o X\FR] [\FI-s\FR] [\FIphoenix_image\FR]
.PP
Gives information about a phoenix image created by the
phoenixcard utility and optionally extracts the embedded boot
code & firmware file from their hidden partitions.
.PP
.SH DESCRIPTION
.\" Add any additional description here
See the help of each tool for more information about its usage (\FI-?\FR).
.SH AUTHOR
Written by Alejandro Mery <amery@geeks.cl>
.SH "REPORTING BUGS"
Report bugs at https://github.com/linux-sunxi/sunxi-tools
.SH COPYRIGHT
Copyright \(co 2012 Alejandro Mery
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
.br
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
EXTRA_DIST = usb-boot
scriptsdir = $(datadir)/doc/@PACKAGE@-@VERSION@/scripts
scripts_SCRIPTS = usb-boot
#!/bin/sh -e
top=`dirname $0`
if [ $# -lt 2 ]; then
echo "Usage: $0 u-boot-spl.bin u-boot.bin [boot.scr] [kernel script.bin [initramfs]]"
exit 1
fi
board=$1; shift || (echo "ERROR: u-boot-spl.bin must be specified"; exit 1;)
uboot=$1; shift || (echo "ERROR: u-boot.bin must be specified"; exit 1;)
bootscr=$top/felboot/ramboot.scr
if [ ! -f $bootscr ]; then
bootscr=$top/bin/ramboot.scr
fi
case "$1" in
*.scr) bootscr="$1"; shift
;;
esac
if [ $# -ge 1 ]; then
kernel=$1; shift || true
fi
if [ $# -ge 1 ]; then
scriptbin=$1; shift || true
fi
if [ $# -ge 1 ]; then
initramfs=$1; shift || true
fi
fel() {
echo fel "$@"
$top/fel $@
}
case $board in
*/*) felboot=$board
;;
*)
felboot=$top/felboot/fel-boot-${board}.bin
if [ ! -f $felboot ]; then
felboot=$top/bin/fel-boot-${board}.bin
fi
;;
esac
if [ ! -f $felboot ]; then
echo "ERROR: Can't find SPL FEL binary ${board}"
exit 1
fi
if [ `wc -c $felboot | cut '-d ' -f1` -gt 15616 ]; then
echo "ERROR: SPL FEL binary too large. Must be the FEL version of SPL"
exit 1
fi
if [ ! -f $bootscr ]; then
echo "ERROR: Can't fint boot script '${bootscr}'"
exit 1
fi
fel write 0x2000 $felboot
fel exe 0x2000
sleep 1 # Wait for DRAM initialization to complete
if [ -n "$uboot" ]; then
fel write 0x4a000000 $uboot
fi
if [ -n "$bootscr" ]; then
fel write 0x41000000 $bootscr
fi
if [ -n "$kernel" ]; then
if [ -n "$scriptbin" ]; then
fel write 0x43000000 $scriptbin
fi
fel write 0x44000000 $kernel
if [ -n "$initramfs" ]; then
fel write 0x4c000000 $initramfs
fi
fi
fel exe 0x4a000000
AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = adb-devprobe.sh \
boot_head.S \
boot_head.lds \
fel-gpio \
fel-pio.c \
fel-pio.lds \
fel-sdboot.c \
fel-sdboot.lds \
jtag-loop.c \
jtag-loop.lds \
\
jtag-loop.S \
fel-copy.c
AM_CFLAGS = -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc \
-Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral \
-Wno-format-security -fno-toplevel-reorder -nostdlib
BINARIES = fel-pio.bin \
jtag-loop.bin \
fel-sdboot.bin \
boot_head_sun4i.bin \
boot_head_sun5i.bin
scriptsdir = $(datadir)/doc/@PACKAGE@-@VERSION@/scripts
scripts_SCRIPTS = adb-devprobe.sh fel-gpio
clean-local:
rm -f boot_head_sun4i.elf boot_head_sun5i.elf fel-sdboot.elf fel-pio.elf fel-pio.nm jtag-loop.elf boot_head_sun4i.bin boot_head_sun5i.bin fel-sdboot.bin fel-pio.bin jtag-loop.bin *~
all: $(BINARIES)
fel-pio.bin: fel-pio.elf fel-pio.nm
$(OBJCOPY) -O binary fel-pio.elf fel-pio.bin
fel-pio.elf: fel-pio.c fel-pio.lds
$(CC) $(CFLAGS) $(AM_CFLAGS) $(THUMB_CFLAGS) $(top_srcdir)/src/fel-pio.c \
-nostdlib -o fel-pio.elf -T $(top_srcdir)/src/fel-pio.lds
fel-pio.nm: fel-pio.elf
$(NM) $(CURDIR)/fel-pio.elf | grep -v " _" >fel-pio.nm
jtag-loop.elf: jtag-loop.c jtag-loop.lds
$(CC) $(CFLAGS) $(AM_CFLAGS) $(THUMB_CFLAGS) $(top_srcdir)/src/jtag-loop.c \
-o jtag-loop.elf -T $(top_srcdir)/src/jtag-loop.lds -Wl,-N
jtag-loop.bin: jtag-loop.elf
$(OBJCOPY) -O binary jtag-loop.elf jtag-loop.bin
#jtag-loop.sunxi: jtag-loop.bin
# mksunxiboot jtag-loop.bin jtag-loop.sunxi
fel-sdboot.elf: fel-sdboot.c fel-sdboot.lds
$(CC) $(CFLAGS) $(AM_CFLAGS) $(THUMB_CFLAGS) $(top_srcdir)/src/fel-sdboot.c \
-o fel-sdboot.elf -T $(top_srcdir)/src/fel-sdboot.lds -Wl,-N
fel-sdboot.bin: fel-sdboot.elf
$(OBJCOPY) -O binary fel-sdboot.elf fel-sdboot.bin
#fel-sdboot.sunxi: fel-sdboot.bin
# mksunxiboot fel-sdboot.bin fel-sdboot.sunxi
boot_head_sun3i.elf: boot_head_sun3i.S boot_head_sun3i.lds
$(CC) $(CFLAGS) $(AM_CFLAGS) $(THUMB_CFLAGS) $(top_srcdir)/src/boot_head.S \
-o boot_head_sun3i.elf -T $(top_srcdir)/src/boot_head.lds -Wl,-N -DMACHID=0x1094
boot_head_sun3i.bin: boot_head_sun3i.elf
$(OBJCOPY) -O binary boot_head_sun3i.elf boot_head_sun3i.bin
boot_head_sun4i.elf: boot_head.S boot_head.lds
$(CC) $(CFLAGS) $(AM_CFLAGS) $(THUMB_CFLAGS) $(top_srcdir)/src/boot_head.S \
-o boot_head_sun4i.elf -T $(top_srcdir)/src/boot_head.lds -Wl,-N -DMACHID=0x1008
boot_head_sun4i.bin: boot_head_sun4i.elf
$(OBJCOPY) -O binary boot_head_sun4i.elf boot_head_sun4i.bin
boot_head_sun5i.elf: boot_head.S boot_head.lds
$(CC) $(CFLAGS) $(AM_CFLAGS) $(THUMB_CFLAGS) $(top_srcdir)/src/boot_head.S \
-o boot_head_sun5i.elf -T $(top_srcdir)/src/boot_head.lds -Wl,-N -DMACHID=0x102A
boot_head_sun5i.bin: boot_head_sun5i.elf
$(OBJCOPY) -O binary boot_head_sun5i.elf boot_head_sun5i.bin
#!/bin/bash
# Copyright (C) 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
adb shell insmod /vendor/modules/sunxi-dbgreg.ko >/dev/null
dump_io()
......
SECTIONS
{
. = 0x40007000;
.text : { *(.text) }
}
#!/bin/sh -e
# Copyright (C) 2012,2013 Henrik Nordstrom <henrik@henriknordstrom.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
pio_to_sram=0x2000
sram_to_pio=0x2004
......
SECTIONS
{
. = 0x2000;
.text : { *(.text) }
}
SECTIONS
{
. = 0x0030;
.text : { *(.text) }
}
SECTIONS
{
. = 0x0030;
.text : { *(.text) }
}
AM_CFLAGS = -g -O0 -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -I$(top_srcdir) -I$(top_srcdir)/include
AM_LDFLAGS = -L$(top_srcdir)/libfex
bin_PROGRAMS = fexc fel bootinfo pio nand-part phoenix_info
fexc_SOURCES = fexc.c
fexc_CFLAGS = $(CFLAGS) $(AM_CFLAGS)
fexc_LDFLAGS = $(LDFLAGS) $(AM_LDFLAGS)
fexc_LDADD = $(top_builddir)/libfex/.libs/libfex.a
fel_SOURCES = fel.c
fel_CFLAGS = $(CFLAGS) $(AM_CFLAGS) $(LIBUSB_CFLAGS)
fel_LDFLAGS = $(LDFLAGS) $(AM_LDFLAGS) $(LIBUSB_LIBS)
bootinfo_SOURCES = bootinfo.c
bootinfo_CFLAGS = $(CFLAGS) $(AM_CFLAGS)
bootinfo_LDFLAGS = $(LDFLAGS) $(AM_LDFLAGS)
pio_SOURCES = pio.c
pio_CFLAGS = $(CFLAGS) $(AM_CFLAGS)
pio_LDFLAGS = $(LDFLAGS) $(AM_LDFLAGS)
nand_part_SOURCES = nand-part-main.c
nand_part_CFLAGS = $(CFLAGS) $(AM_CFLAGS)
nand_part_LDFLAGS = $(LDFLAGS) $(AM_LDFLAGS)
nand_part_LDADD = liba10.a liba20.a
noinst_LIBRARIES = liba10.a liba20.a
liba10_a_SOURCES = nand-part.c
liba10_a_CFLAGS = $(CFLAGS) $(AM_CFLAGS) -DA10
liba20_a_SOURCES = nand-part.c
liba20_a_CFLAGS = $(CFLAGS) $(AM_CFLAGS) -DA20
phoenix_info_SOURCES = phoenix_info.c
phoenix_info_CFLAGS = $(CFLAGS) $(AM_CFLAGS)
phoenix_info_LDFLAGS = $(LDFLAGS) $(AM_LDFLAGS)
noinst_HEADERS = fexc.h \
nand-common.h \
nand-part-a10.h \
nand-part-a20.h
install-exec-hook:
@( cd $(DESTDIR)$(bindir) ; \
$(LN_S) -f *fexc$(EXEEXT) fex2bin$(EXEEXT) ; \
$(LN_S) -f *fexc$(EXEEXT) bin2fex$(EXEEXT) ; \
)
......@@ -273,6 +273,7 @@ void print_boot0_private_head(boot0_private_head_t *hdr, loader_type type)
void print_script(void *script)
{
script = script;
}
void print_core_para(boot_core_para_t *core)
......
......@@ -68,8 +68,7 @@ static inline char *read_all(int fd, const char *filename, size_t *size)
p = buf + count;
}
}
} else if (errno != EAGAIN ||
errno != EINTR) {
} else if (errno != EAGAIN && errno != EINTR) {
pr_err("%s: %s: %s\n", filename,
"read", strerror(errno));
free(buf);
......
......@@ -22,9 +22,9 @@
#include <stdint.h>
#include <stdio.h>
#include "script.h"
#include "script_bin.h"
#include "script_fex.h"
#include "script_uboot.h"
#include "libfex/script.h"
#include "libfex/script_bin.h"
#include "libfex/script_fex.h"
#include "libfex/script_uboot.h"
#endif
......@@ -43,7 +43,7 @@ static int save_part(struct phoenix_ptable *ptable, int part, const char *dest,
{
int l = strlen(dest) + 16;
char outname[l];
FILE *out;
FILE *out = NULL;
char *buf = NULL;
int ret = 0;
snprintf(outname, l, dest, part);
......
......@@ -315,6 +315,7 @@ static void cmd_clean(char *buf)
static int do_command(char *buf, const char **args, int argc)
{
argc = argc;
const char *command = args[0];
if (*command == 'P') {
if (strchr(command, '<'))
......
#!/bin/sh -e
# Copyright (C) 2013 Henrik Nordstrom <henrik@henriknordstrom.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
top=`dirname $0`
if [ $# -lt 2 ]; then
echo "Usage: $0 u-boot-spl.bin u-boot.bin [boot.scr] [kernel script.bin [initramfs]]"
exit 1
fi
board=$1; shift || (echo "ERROR: u-boot-spl.bin must be specified"; exit 1;)
uboot=$1; shift || (echo "ERROR: u-boot.bin must be specified"; exit 1;)
bootscr=$top/felboot/ramboot.scr
if [ ! -f $bootscr ]; then
bootscr=$top/bin/ramboot.scr
fi
case "$1" in
*.scr) bootscr="$1"; shift
;;
esac
if [ $# -ge 1 ]; then
kernel=$1; shift || true
fi
if [ $# -ge 1 ]; then
scriptbin=$1; shift || true
fi
if [ $# -ge 1 ]; then
initramfs=$1; shift || true
fi
fel() {
echo fel "$@"
$top/fel $@
}
case $board in
*/*) felboot=$board
;;
*)
felboot=$top/felboot/fel-boot-${board}.bin
if [ ! -f $felboot ]; then
felboot=$top/bin/fel-boot-${board}.bin
fi
;;
esac
if [ ! -f $felboot ]; then
echo "ERROR: Can't find SPL FEL binary ${board}"
exit 1
fi
if [ `wc -c $felboot | cut '-d ' -f1` -gt 15616 ]; then
echo "ERROR: SPL FEL binary too large. Must be the FEL version of SPL"
exit 1
fi
if [ ! -f $bootscr ]; then
echo "ERROR: Can't find boot script '${bootscr}'"
exit 1
fi
fel write 0x2000 $felboot
fel exe 0x2000
sleep 1 # Wait for DRAM initialization to complete
if [ -n "$uboot" ]; then
fel write 0x4a000000 $uboot
fi
if [ -n "$bootscr" ]; then
fel write 0x41000000 $bootscr
fi
if [ -n "$kernel" ]; then
if [ -n "$scriptbin" ]; then
fel write 0x43000000 $scriptbin
fi
fel write 0x44000000 $kernel
if [ -n "$initramfs" ]; then
fel write 0x4c000000 $initramfs
fi
fi
fel exe 0x4a000000