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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
doc/
_build/
output/
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build
on: [push]
jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git fetch --prune --unshallow
- name: Install latest Docker
run: curl -fsSL https://get.docker.com | sudo sh
- name: Build Docker image
run: docker build -t openfang .
- name: Build openfang
run: docker run -v $(pwd)/output:/output openfang
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: openfang-${{ github.sha }}
path: output/
40 changes: 23 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
FROM ubuntu:16.04
# TODO: 18.04

RUN \
apt update && apt upgrade -y && \
apt install -y \
build-essential \
git \
autoconf \
cmake \
python \
unzip \
cpio \
wget \
vim \
locales \
lzop \
bc \
libncurses5-dev
RUN apt-get update && apt-get install -y \
autoconf \
bc \
build-essential \
cmake \
cpio \
git \
libncurses5-dev \
locales \
lzop \
python \
unzip \
vim \
wget
# Can't remove apt lists -- oss configure script libgtk fails without them and
# installing libgtk takes up way more space than the lists do.

RUN locale-gen --no-purge en_US.UTF-8
RUN git clone https://github.com/anmaped/openfang/ /root/openfang
COPY . /root/openfang
WORKDIR /root/openfang
ENV OPENFANG_OUTPUT_DIR /output

# TODO: non-root user

CMD ["/root/openfang/buildopenfang.sh"]
53 changes: 24 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,52 @@
# openfang
The openfang is a bootloader, kernel and toolchain for devices using Ingenic T10 and T20 SOC.
Openfang is a bootloader, kernel and toolchain for devices using Ingenic T10 and T20 SOC.

## Overview

At the present time, this repository only contains kernel and rootfs for cameras using Inegnic T20 SOC. To ease identifying these cameras please use the pictures below. A more detailed technical description can be found [here](doc/overview.md).
## Overview
At the present time, this repository only contains kernel and rootfs for cameras using Ingenic T20 SOC. To ease identifying these cameras please use the pictures below. A more detailed technical description can be found [here](doc/overview.md).

Ingenic T20L (64Mb DDR) |  
:-- | --:
![Xiaomi Mijia](doc/SXJ02ZM/img/xiaomi_mijia_2018.jpg) Xiaomi Mijia 2018 | ![Xiaomi Xiaofang 1S](doc/xiaomi_xiaofang1s/img/xiaofang1s.jpg) Xiaomi Xiaofang 1S
:--: | :--:
[![Xiaomi Mijia](doc/SXJ02ZM/img/xiaomi_mijia_2018.jpg)](https://github.com/mje-nz/openfang/blob/master/doc/SXJ02ZM/SXJ02ZM_instructions.md) <br/> Xiaomi Mijia 2018 | ![Xiaomi Xiaofang 1S](doc/xiaomi_xiaofang1s/img/xiaofang1s.jpg) <br/> Xiaomi Xiaofang 1S

Ingenic T20N (64Mb DDR + SIMD128)
:-- |
![DIGOO DG W30](doc/dg-w30/img/dg-w30.jpg) DIGOO DG W30
:--: |
![DIGOO DG W30](doc/dg-w30/img/dg-w30.jpg) <br/> DIGOO DG W30

Ingenic T20X (128Mb DDR) | &nbsp;
:-- | --:
![Wyze Cam v2](doc/wyzecam_v2/img/wyzecam_v2.jpg) Wyze Cam V2 |
![Xiaomi Dafang](doc/xiaomi_dafang/img/xiaomi_dafang.jpg) Xiaomi Dafang | ![Wyze Cam Pan](doc/WYZECP1/img/wyzecam_pan.jpg) Wyze Cam Pan
Ingenic T20X (128Mb DDR) | &nbsp; | &nbsp;
:--: | :--: | :--:
![Wyze Cam v2](doc/wyzecam_v2/img/wyzecam_v2.jpg) <br/> Wyze Cam V2 | ![Xiaomi Dafang](doc/xiaomi_dafang/img/xiaomi_dafang.jpg) <br/> Xiaomi Dafang | [![Wyze Cam Pan](doc/WYZECP1/img/wyzecam_pan.jpg)](https://github.com/mje-nz/openfang/blob/master/doc/WYZECP1/wyzecp1_instructions.md) <br/> Wyze Cam Pan

If you have a device with a Ingenic T10 SOC, consider using for now https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks
If you have a device with a Ingenic T10 SOC, consider using [EliasKotlyar/Xiaomi-Dafang-Hacks](https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks) for now.

If you have a classic XiaoFang with a ARM-Processor, consider using https://github.com/samtap/fang-hacks
If you have a classic Xiaofang with a ARM processor, consider using [samtap/fang-hacks](https://github.com/samtap/fang-hacks).


## How to install openfang

Before installing openfang, we suggest you carefully read the [FAQ](/doc/faq.md).

After that, continue to the [Installation](/doc/install.md) procedure. More details on [troubleshooting](doc/troubleshooting.md).

## How to compile openfang

## How to compile openfang
Openfang is actively developed and releases are only provided when the openfang distribution is stable. If you want to test the development version you can easily compile it using [docker](https://www.docker.com/). More details on how to do it [here](doc/docker.md).

### Issues and support ###

If you encounter an issue which you think is a bug in the openfang or the associated libraries, you are welcome to submit it here on Github: https://github.com/anmaped/openfang/issues.
### Issues and support
If you encounter an issue which you think is a bug in openfang or the associated libraries, you are welcome to submit it [here on Github](https://github.com/anmaped/openfang/issues).

Please provide as much context as possible:

- buildroot core version which you are using;
- kernel version and modules you have enable;
- build root packages you are trying to integrate;
- when encountering an issue which happens at run time, attach serial output. Wrap it into a code block, just like the code;
- for issues which happen at compile time, enable verbose compiler output in the buildroot preferences, and attach that output (also inside a code block);
- development board model and brand;
- other settings (board choice, flash size, etc.).
- buildroot core version which you are using
- kernel version and modules you have enable
- build root packages you are trying to integrate
- when encountering an issue which happens at run time, attach serial output (wrap it into a code block)
- for issues which happen at compile time, enable verbose compiler output in the buildroot preferences, and attach that output (also inside a code block)
- development board model and brand
- other settings (board choice, flash size, etc.)

Or ask in our [Gitter channel](https://gitter.im/openfang_project) for help.

### Contributing

For minor fixes of code and documentation, please go ahead and submit a pull request.

Check out the list of issues which are easy to fix — [easy issues for openfang 01](https://github.com/anmaped/openfang/issues). Working on them is a great way to move the project forward.
Expand All @@ -59,6 +55,5 @@ Larger changes (rewriting parts of existing libraries from scratch, adding new f

Feature branches with lots of small commits (especially titled "oops", "fix typo", "forgot to add file", etc.) should be squashed before opening a pull request. At the same time, please refrain from putting multiple unrelated changes into a single pull request.

### License and credits ###

Buildroot is developed and maintained by The Buildroot developers.
### License and credits
Buildroot is developed and maintained by the Buildroot developers.
144 changes: 85 additions & 59 deletions buildopenfang.sh
Original file line number Diff line number Diff line change
@@ -1,101 +1,127 @@
#!/bin/sh

TAG=rc05_01

set -e

CPW=$(pwd)
info() {
# Don't bother checking for an ANSI-capable terminal
# https://github.com/actions/runner/issues/241
echo "\033[0;32m> $*\033[0m"
}

DIR=_build
[ -d $DIR ] || { printf '%s does not exist!\n' "$DIR"; mkdir $DIR; }

date=$(date +"%Y-%m-%d %H:%M")
#ID="($(git rev-parse HEAD)) $date"
# Set up directories
info "Setting up directories"
OPENFANG_ROOT_DIR=$(pwd)
echo "Project directory: $OPENFANG_ROOT_DIR"
OPENFANG_OUTPUT_DIR="${OPENFANG_OUTPUT_DIR:-$OPENFANG_ROOT_DIR/output}"
if ! [ -d "$OPENFANG_OUTPUT_DIR" ]; then
echo "Creating output directory: $OPENFANG_OUTPUT_DIR"
mkdir "$OPENFANG_OUTPUT_DIR"
else
echo "Output directory: $OPENFANG_OUTPUT_DIR"
fi
OPENFANG_BUILD_DIR="$OPENFANG_ROOT_DIR/_build"
if [ ! -d "$OPENFANG_BUILD_DIR" ]; then
echo "Creating build directory: $OPENFANG_BUILD_DIR"
mkdir "$OPENFANG_BUILD_DIR"
else
echo "Build directory: $OPENFANG_BUILD_DIR"
fi


# Update version info
info "Updating version info"
TAG=rc05_01
DATE=$(date +"%Y-%m-%d %H:%M")
#ID="($(git rev-parse HEAD)) $DATE"
ID="$(git describe --tags)"
SHORTID=$(git rev-parse --short HEAD)

echo "$ID" > fs/opt/version

cp fs $DIR/ -r;
cp -r fs/ "$OPENFANG_BUILD_DIR/"

sed -i "s/VERSION=.*/VERSION=\"$date\"/g" $DIR/fs/opt/autoupdate.sh
sed -i "s/TAG=.*/TAG=\"$TAG\"/g" $DIR/fs/opt/autoupdate.sh
sed -i "s/ID=.*/ID=\"$SHORTID\"/g" $DIR/fs/opt/autoupdate.sh
sed -i "s/VERSION=.*/VERSION=\"$DATE\"/g" "$OPENFANG_BUILD_DIR/fs/opt/autoupdate.sh"
sed -i "s/TAG=.*/TAG=\"$TAG\"/g" "$OPENFANG_BUILD_DIR/fs/opt/autoupdate.sh"
sed -i "s/ID=.*/ID=\"$SHORTID\"/g" "$OPENFANG_BUILD_DIR/fs/opt/autoupdate.sh"

[ "$1" = "stamp" ] && { exit 0; }
echo "VERSION: $DATE"
echo "TAG: $TAG"
echo "ID: $ID"
echo "SHORTID: $SHORTID"
[ "$1" = "stamp" ] && exit 0

cd $DIR

BUILDROOT_VERSION=2016.02

[ -d "buildroot-$BUILDROOT_VERSION" ] || {
wget https://buildroot.org/downloads/buildroot-$BUILDROOT_VERSION.tar.gz;
tar xvf buildroot-$BUILDROOT_VERSION.tar.gz;
rm buildroot-$BUILDROOT_VERSION.tar.gz;
cd buildroot-$BUILDROOT_VERSION
patch -p1 < "$CPW"/patches/add_fp_no_fused_madd.patch
cd ..
}
cd "$OPENFANG_BUILD_DIR"
info "Setting up buildroot"

# Download buildroot
BUILDROOT_VERSION=2016.02
if [ ! -d "buildroot-$BUILDROOT_VERSION" ]; then
info "Downloading and patching buildroot $BUILDROOT_VERSION"
wget -q https://buildroot.org/downloads/buildroot-$BUILDROOT_VERSION.tar.gz
tar -xf buildroot-$BUILDROOT_VERSION.tar.gz
rm buildroot-$BUILDROOT_VERSION.tar.gz
cd buildroot-$BUILDROOT_VERSION
patch -p1 < "$OPENFANG_ROOT_DIR/patches/add_fp_no_fused_madd.patch"
cd ..
fi
cd buildroot-$BUILDROOT_VERSION

# update config files
cp "$CPW"/config/buildroot.config ./.config
cp "$CPW"/config/busybox.config ./package/busybox
cp "$CPW"/config/uClibc-ng.config ./package/uclibc

[ -d "dl" ] || { mkdir dl; }
# Update config files
cp "$OPENFANG_ROOT_DIR/config/buildroot.config" .config
cp "$OPENFANG_ROOT_DIR/config/busybox.config" package/busybox/
cp "$OPENFANG_ROOT_DIR/config/uClibc-ng.config" package/uclibc/

cp ../../kernel-3.10.14.tar.xz dl/
cp ../../uboot-v2013.07.tar.xz dl/
[ -d "dl" ] || mkdir dl

WDIR=$CPW/$DIR/buildroot-$BUILDROOT_VERSION
cp "$OPENFANG_ROOT_DIR/kernel-3.10.14.tar.xz" dl/
cp "$OPENFANG_ROOT_DIR/uboot-v2013.07.tar.xz" dl/

# Patch buildroot if gcc >= 5
#
echo "GCC version: $(gcc -dumpversion)"
GCCVER=$(gcc -dumpversion | cut -d'.' -f1)
echo "GCC version: $GCCVER"
if [ "$GCCVER" -ge "5" ]; then
cp "$CPW"/patches/automake.in.patch "$WDIR"/package/automake
cp "$CPW"/patches/python/python2.7_gcc8__fix.patch "$WDIR"/package/python
cp "$CPW"/patches/lzop-gcc6.patch "$WDIR"/package/lzop
cp "$OPENFANG_ROOT_DIR/patches/automake.in.patch" package/automake/
cp "$OPENFANG_ROOT_DIR/patches/python/python2.7_gcc8__fix.patch" package/python/
cp "$OPENFANG_ROOT_DIR/patches/lzop-gcc6.patch" package/lzop/
fi

# copy python patches to address host-python build failing
# when host has openssl 1.1.0 headers installed
cp -f "$CPW"/patches/python/111-optional-ssl.patch "$WDIR"/package/python
cp "$CPW"/patches/python/019-force-internal-hash-if-ssl-disabled.patch "$WDIR"/package/python
# Copy Python patches to address host-python build failing when host has
# openssl 1.1.0 headers installed
cp -f "$OPENFANG_ROOT_DIR/patches/python/111-optional-ssl.patch" package/python/
cp "$OPENFANG_ROOT_DIR/patches/python/019-force-internal-hash-if-ssl-disabled.patch" package/python/

# copy custom openfang packages to buildroot directory
rm -r "$WDIR"/package/ffmpeg # use updated package version instead
rm -r "$WDIR"/package/libtirpc # use updated package version instead
#rm -r "$WDIR"/package/python # use updated package version instead
#rm -r "$WDIR"/package/uclibc # use updated package version instead
cp "$CPW"/buildroot/* . -rf
# Copy custom openfang packages to buildroot directory
rm -r package/ffmpeg # use updated package version instead
rm -r package/libtirpc # use updated package version instead
#rm -r package/python # use updated package version instead
#rm -r package/uclibc # use updated package version instead
cp -rf "$OPENFANG_ROOT_DIR/buildroot"/* .


info "Building"
make

#
# compile different versions of uboot
#
# Compile different versions of uboot
[ -f "output/images/u-boot-lzo-with-spl.bin" ] && mv output/images/u-boot-lzo-with-spl.bin output/images/u-boot-lzo-with-spl_t20_128M.bin

# change uboot configuration
# Change uboot configuration
sed -i "s/BR2_TARGET_UBOOT_BOARDNAME=.*/BR2_TARGET_UBOOT_BOARDNAME=\"isvp_t20_sfcnor\"/g" .config

make uboot-dirclean
make uboot

[ -f "output/images/u-boot-lzo-with-spl.bin" ] && mv output/images/u-boot-lzo-with-spl.bin output/images/u-boot-lzo-with-spl_t20_64M.bin

# end uboot compilation


# constructs release with git hash label
echo "Compressing toolchain..."
tar -c -C "$WDIR"/output/host --transform s/./mipsel-ingenic-linux-uclibc/ --checkpoint=.1000 . | xz --best > "$CPW"/toolchain-$SHORTID.tar.xz
echo "Compressing rootfs images..."
tar -c -C "$WDIR"/output/images --transform s/./openfang-images/ --checkpoint=.1000 . | xz --best > "$CPW"/images-$SHORTID.tar.xz
echo "Build completed successfully."
# Copy images to output dir
cp output/images/* "$OPENFANG_OUTPUT_DIR"


# Construct release with git hash label
info "Compressing toolchain..."
tar -c -C output/host/ --transform s/./mipsel-ingenic-linux-uclibc/ --checkpoint=.1000 . | xz --best > "$OPENFANG_OUTPUT_DIR/toolchain-$SHORTID.tar.xz"
info "Compressing rootfs images..."
tar -c -C output/images/ --transform s/./openfang-images/ --checkpoint=.1000 . | xz --best > "$OPENFANG_OUTPUT_DIR/images-$SHORTID.tar.xz"
info "Build completed successfully."
Loading