summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/agptek_rocker/Dockerfile50
-rw-r--r--tools/agptek_rocker/README46
-rw-r--r--tools/agptek_rocker/bootloader_install.sh129
-rw-r--r--tools/agptek_rocker/hiby_player.sh10
-rw-r--r--tools/agptek_rocker/update_update.py81
5 files changed, 316 insertions, 0 deletions
diff --git a/tools/agptek_rocker/Dockerfile b/tools/agptek_rocker/Dockerfile
new file mode 100644
index 0000000000..de6a234474
--- /dev/null
+++ b/tools/agptek_rocker/Dockerfile
@@ -0,0 +1,50 @@
1FROM debian:9
2
3WORKDIR /home/rb
4ENV HOME /home/rb
5
6# Install tools needed
7RUN apt-get update && \
8 DEBIAN_FRONTEND=noninteractive apt-get install -y \
9 build-essential \
10 git \
11 perl \
12 curl \
13 texinfo \
14 flex \
15 bison \
16 bzip2 \
17 gzip \
18 zip \
19 patch \
20 automake \
21 libtool \
22 libtool-bin \
23 autoconf \
24 libmpc-dev \
25 gawk \
26 python \
27 python-lzo \
28 python-setuptools \
29 mtd-utils \
30 xorriso && \
31 rm -rf /var/lib/apt/lists/*
32
33# Clone rockbox repository
34RUN cd /home/rb && \
35 git clone https://github.com/wodz/rockbox-wodz.git
36
37# Build cross toolchain (It takes quite long)
38RUN cd /home/rb/rockbox-wodz && \
39 git checkout agptek-rocker && \
40 ./tools/rockboxdev.sh --target=y
41
42# Install tools for unpacking ubifs
43RUN cd /home/rb && \
44 git clone https://github.com/jrspruitt/ubi_reader.git && \
45 cd /home/rb/ubi_reader && \
46 python setup.py install
47
48# Copy build script
49RUN cp /home/rb/rockbox-wodz/tools/agptek_rocker/bootloader_install.sh /usr/local/bin && \
50 chmod 755 /usr/local/bin/bootloader_install.sh
diff --git a/tools/agptek_rocker/README b/tools/agptek_rocker/README
new file mode 100644
index 0000000000..6b627698e5
--- /dev/null
+++ b/tools/agptek_rocker/README
@@ -0,0 +1,46 @@
1Steps needed to patch update.upt with rockbox bootloader are explained in
2bootloader_install.sh shell script. Process is quite involved and some
3custom tools are needed.
4
5
6For convenience Dockerfile is provided which prepares custom image based
7on debian 9 which has all the tools needed to work with Agptek Rocker update
8images.
9
10Basically image extends standard debian image by:
111) Installing developer packages from stock debian
122) Cloning https://github.com/wodz/rockbox-wodz.git
133) Building custom cross toolchain
144) Cloning and installing tools to work with UBIFS
15
16You first need to build image with:
17docker build . -t "agptek-dev"
18
19Then you can start container and work with update.upt.
20If you want to generate patched update image in automatic way:
21docker run --rm -it -v /path/to/dir/with/update.upt:/upt \
22-e UPT_DIR=/upt agptek-dev bootloader_install.sh
23
24Patched update.upt with rockbox bootloader and rockbox.zip should end up in
25specified directory.
26
27If you want to play around, hack something etc. you can run container in
28interactive mode:
29docker run -it -v /path/to/dir/with/update.upt:/upt \
30-e UPT_DIR=/upt agptek-dev bash
31
32
33Files in this directory:
34README - this file
35bootloader_install.sh - shell script documenting process of patching
36 agptek rocker update images
37
38update_update.py - little helper utility to patch update.txt
39 controll file
40
41hiby_player.sh - shell script called on player boot which
42 originally started music player application
43 and now it starts bootloader
44
45Dockerfile - file to build docker image with all needed
46 tools to play with agptek rocker files
diff --git a/tools/agptek_rocker/bootloader_install.sh b/tools/agptek_rocker/bootloader_install.sh
new file mode 100644
index 0000000000..487b8870ea
--- /dev/null
+++ b/tools/agptek_rocker/bootloader_install.sh
@@ -0,0 +1,129 @@
1#!/bin/sh
2
3[ -z "$UPT_DIR" ] && UPT_DIR=`pwd`
4cd $HOME
5
6# get sources
7echo
8echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!"
9echo "!!! STEP 0: Get sources !!!"
10echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!"
11echo
12[ -d "$HOME/rockbox-wodz" ] || git clone https://github.com/wodz/rockbox-wodz.git
13
14cd $HOME/rockbox-wodz
15
16# build bootloader
17echo
18echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
19echo "!!! STEP 1: Build bootloader !!!"
20echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
21echo
22
23[ -d "$HOME/rockbox-wodz/build" ] && rm -rf $HOME/rockbox-wodz/build
24git checkout agptek-rocker && \
25git pull && \
26mkdir $HOME/rockbox-wodz/build && cd $HOME/rockbox-wodz/build && \
27../tools/configure --target=240 --type=b && \
28make clean && \
29make && \
30cd $HOME
31
32# Extract update file (ISO9660 image) content
33# NOTE: Update process on device loop mount ISO image. Default behavior of mount
34# is to map all names to lowercase. Because of this forcing lowercase
35# mapping is needed when extracting
36echo
37echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
38echo "!!! STEP 2: Extract upt file !!!"
39echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
40echo
41[ -d "$HOME/iso" ] && rm -rf $HOME/iso
42mkdir $HOME/iso && \
43xorriso -osirrox on -ecma119_map lowercase -indev $UPT_DIR/update.upt -extract / $HOME/iso
44
45# Extract rootfs files. Preserve permissions (although this are wrong!)
46echo
47echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
48echo "!!! STEP 3: Extract system.ubi !!!"
49echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
50echo
51ubireader_extract_files -k -o $HOME/rootfs $HOME/iso/system.ubi
52
53# Copy rockbox bootloader
54echo
55echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
56echo "!!! STEP 4: Copy bootloader !!!"
57echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
58echo
59cp $HOME/rockbox-wodz/build/bootloader.elf $HOME/rootfs/usr/bin/rb_bootloader && \
60mipsel-rockbox-linux-gnu-strip --strip-unneeded $HOME/rootfs/usr/bin/rb_bootloader
61
62# Overwrite default player starting script with one running our bootloader
63echo
64echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
65echo "!!! STEP 5: Modify startup script !!!"
66echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
67echo
68cp $HOME/rockbox-wodz/tools/agptek_rocker//hiby_player.sh $HOME/rootfs/usr/bin/hiby_player.sh && \
69chmod 755 $HOME/rootfs/usr/bin/hiby_player.sh
70
71# Rebuild ubifs
72echo
73echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
74echo "!!! STEP 6: Rebuild system.ubi !!!"
75echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
76echo
77mkfs.ubifs --min-io-size=2048 --leb-size=126976 --max-leb-cnt=1024 -o $HOME/system_rb.ubi -r $HOME/rootfs && \
78mv $HOME/system_rb.ubi $HOME/iso/system.ubi
79
80# Fixup update.txt file with correct md5
81echo
82echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
83echo "!!! STEP 7: Fixup update.txt !!!"
84echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
85echo
86python $HOME/rockbox-wodz/tools/agptek_rocker/update_update.py $HOME/iso/update.txt
87
88# Rebuild .upt file
89echo
90echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
91echo "!!! STEP 8: Rebuild upt file !!!"
92echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
93echo
94xorriso -as mkisofs -volid 'CDROM' --norock -output $UPT_DIR/update_rb.upt $HOME/iso
95
96# Build rockbox.zip
97echo
98echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
99echo "!!! STEP 9: Build rockbox application !!!"
100echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
101echo
102cd $HOME/rockbox-wodz/build && \
103../tools/configure --target=240 --type=n && \
104make clean && \
105make && \
106make zip && \
107cp rockbox.zip $UPT_DIR/
108
109# Cleanup
110echo
111echo "!!!!!!!!!!!!!!!!!!!!!!!!"
112echo "!!! STEP 10: Cleanup !!!"
113echo "!!!!!!!!!!!!!!!!!!!!!!!!"
114echo
115rm -rf $HOME/rockbox-wodz/build
116rm -rf $HOME/iso
117rm -rf $HOME/rootfs
118
119echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
120echo "! Building finished !"
121echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
122echo
123echo "You should find update_rb.upt and rockbox.zip in output directory"
124echo
125echo "1) Unzip rockbox.zip file in the root directory of SD card"
126echo "2) Copy update_rb.upt to the root directory of SD card"
127echo "3) Rename update_rb.upt to update.upt in SD card"
128echo "4) Select update firmware on device"
129echo
diff --git a/tools/agptek_rocker/hiby_player.sh b/tools/agptek_rocker/hiby_player.sh
new file mode 100644
index 0000000000..e40e84c987
--- /dev/null
+++ b/tools/agptek_rocker/hiby_player.sh
@@ -0,0 +1,10 @@
1#!/bin/sh
2
3mount /dev/mmcblk0 /mnt/sd_0 &>/dev/null || \
4mount /dev/mmcblk0p1 /mnt/sd_0 &>/dev/null
5
6killall rb_bootloader &>/dev/null
7killall -9 rb_bootloader &>/dev/null
8
9/usr/bin/rb_bootloader
10sleep 1
diff --git a/tools/agptek_rocker/update_update.py b/tools/agptek_rocker/update_update.py
new file mode 100644
index 0000000000..4fb7056d19
--- /dev/null
+++ b/tools/agptek_rocker/update_update.py
@@ -0,0 +1,81 @@
1#!/usr/bin/env python
2import os
3import sys
4import hashlib
5import argparse
6from collections import OrderedDict
7
8EQ = '='
9BLK_START = '{'
10BLK_END = '}'
11
12#name: {key: value, key: value}
13def parse(filename):
14 blocks = OrderedDict()
15 blk = None
16 key = None
17 value = None
18
19 with open(filename) as f:
20 # read all lines
21 for line in f:
22 # if line has '=' sign treat it
23 # as split symbol
24 if EQ in line:
25 key, value = line.split(EQ, 1)
26 key = key.strip()
27 value = value.strip()
28
29 if value == BLK_START:
30 # value on the right of '=' is '{'
31 # so this opens new block
32 blk = key
33 blocks[key] = OrderedDict()
34
35 elif value == BLK_END:
36 # value on the right of '=' is '}'
37 # this terminates block
38 blk = None
39
40 else:
41 # key = value inside block
42 blocks[blk][key] = value
43
44 # return parsed structure as dictionary
45 return blocks
46
47# write back internal representation into file
48def dump(tree, filename=None):
49 with open(filename, 'w') as f:
50 for blk in tree.keys():
51 f.write('\n%s={\n' % blk)
52 for key,value in tree[blk].items():
53 f.write('\t%s=%s\n' % (key,value))
54 f.write('}\n')
55
56if __name__=='__main__':
57 description = 'Update information in update.txt control file.'
58 usage = 'update_update.py filepath'
59
60 argp = argparse.ArgumentParser(usage=usage, description=description)
61 argp.add_argument('filepath', help='update.txt filepath to update contents of.')
62
63 if len(sys.argv) == 1:
64 argp.print_help()
65 sys.exit(1)
66
67 args = argp.parse_args()
68
69 # build config file representation
70 tree = parse(args.filepath)
71
72 dir = os.path.dirname(args.filepath)
73
74 # update all md5 sums
75 for blk in tree.keys():
76 filename = os.path.join(dir, os.path.basename(tree[blk]['file_path']))
77 with open(filename) as f:
78 tree[blk]['md5'] = hashlib.md5(f.read()).hexdigest()
79
80 # write back result
81 dump(tree, args.filepath)