diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/agptek_rocker/Dockerfile | 50 | ||||
-rw-r--r-- | tools/agptek_rocker/README | 46 | ||||
-rw-r--r-- | tools/agptek_rocker/bootloader_install.sh | 129 | ||||
-rw-r--r-- | tools/agptek_rocker/hiby_player.sh | 10 | ||||
-rw-r--r-- | tools/agptek_rocker/update_update.py | 81 |
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 @@ | |||
1 | FROM debian:9 | ||
2 | |||
3 | WORKDIR /home/rb | ||
4 | ENV HOME /home/rb | ||
5 | |||
6 | # Install tools needed | ||
7 | RUN 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 | ||
34 | RUN cd /home/rb && \ | ||
35 | git clone https://github.com/wodz/rockbox-wodz.git | ||
36 | |||
37 | # Build cross toolchain (It takes quite long) | ||
38 | RUN cd /home/rb/rockbox-wodz && \ | ||
39 | git checkout agptek-rocker && \ | ||
40 | ./tools/rockboxdev.sh --target=y | ||
41 | |||
42 | # Install tools for unpacking ubifs | ||
43 | RUN 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 | ||
49 | RUN 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 @@ | |||
1 | Steps needed to patch update.upt with rockbox bootloader are explained in | ||
2 | bootloader_install.sh shell script. Process is quite involved and some | ||
3 | custom tools are needed. | ||
4 | |||
5 | |||
6 | For convenience Dockerfile is provided which prepares custom image based | ||
7 | on debian 9 which has all the tools needed to work with Agptek Rocker update | ||
8 | images. | ||
9 | |||
10 | Basically image extends standard debian image by: | ||
11 | 1) Installing developer packages from stock debian | ||
12 | 2) Cloning https://github.com/wodz/rockbox-wodz.git | ||
13 | 3) Building custom cross toolchain | ||
14 | 4) Cloning and installing tools to work with UBIFS | ||
15 | |||
16 | You first need to build image with: | ||
17 | docker build . -t "agptek-dev" | ||
18 | |||
19 | Then you can start container and work with update.upt. | ||
20 | If you want to generate patched update image in automatic way: | ||
21 | docker run --rm -it -v /path/to/dir/with/update.upt:/upt \ | ||
22 | -e UPT_DIR=/upt agptek-dev bootloader_install.sh | ||
23 | |||
24 | Patched update.upt with rockbox bootloader and rockbox.zip should end up in | ||
25 | specified directory. | ||
26 | |||
27 | If you want to play around, hack something etc. you can run container in | ||
28 | interactive mode: | ||
29 | docker run -it -v /path/to/dir/with/update.upt:/upt \ | ||
30 | -e UPT_DIR=/upt agptek-dev bash | ||
31 | |||
32 | |||
33 | Files in this directory: | ||
34 | README - this file | ||
35 | bootloader_install.sh - shell script documenting process of patching | ||
36 | agptek rocker update images | ||
37 | |||
38 | update_update.py - little helper utility to patch update.txt | ||
39 | controll file | ||
40 | |||
41 | hiby_player.sh - shell script called on player boot which | ||
42 | originally started music player application | ||
43 | and now it starts bootloader | ||
44 | |||
45 | Dockerfile - 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` | ||
4 | cd $HOME | ||
5 | |||
6 | # get sources | ||
7 | echo | ||
8 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
9 | echo "!!! STEP 0: Get sources !!!" | ||
10 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
11 | echo | ||
12 | [ -d "$HOME/rockbox-wodz" ] || git clone https://github.com/wodz/rockbox-wodz.git | ||
13 | |||
14 | cd $HOME/rockbox-wodz | ||
15 | |||
16 | # build bootloader | ||
17 | echo | ||
18 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
19 | echo "!!! STEP 1: Build bootloader !!!" | ||
20 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
21 | echo | ||
22 | |||
23 | [ -d "$HOME/rockbox-wodz/build" ] && rm -rf $HOME/rockbox-wodz/build | ||
24 | git checkout agptek-rocker && \ | ||
25 | git pull && \ | ||
26 | mkdir $HOME/rockbox-wodz/build && cd $HOME/rockbox-wodz/build && \ | ||
27 | ../tools/configure --target=240 --type=b && \ | ||
28 | make clean && \ | ||
29 | make && \ | ||
30 | cd $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 | ||
36 | echo | ||
37 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
38 | echo "!!! STEP 2: Extract upt file !!!" | ||
39 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
40 | echo | ||
41 | [ -d "$HOME/iso" ] && rm -rf $HOME/iso | ||
42 | mkdir $HOME/iso && \ | ||
43 | xorriso -osirrox on -ecma119_map lowercase -indev $UPT_DIR/update.upt -extract / $HOME/iso | ||
44 | |||
45 | # Extract rootfs files. Preserve permissions (although this are wrong!) | ||
46 | echo | ||
47 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
48 | echo "!!! STEP 3: Extract system.ubi !!!" | ||
49 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
50 | echo | ||
51 | ubireader_extract_files -k -o $HOME/rootfs $HOME/iso/system.ubi | ||
52 | |||
53 | # Copy rockbox bootloader | ||
54 | echo | ||
55 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
56 | echo "!!! STEP 4: Copy bootloader !!!" | ||
57 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
58 | echo | ||
59 | cp $HOME/rockbox-wodz/build/bootloader.elf $HOME/rootfs/usr/bin/rb_bootloader && \ | ||
60 | mipsel-rockbox-linux-gnu-strip --strip-unneeded $HOME/rootfs/usr/bin/rb_bootloader | ||
61 | |||
62 | # Overwrite default player starting script with one running our bootloader | ||
63 | echo | ||
64 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
65 | echo "!!! STEP 5: Modify startup script !!!" | ||
66 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
67 | echo | ||
68 | cp $HOME/rockbox-wodz/tools/agptek_rocker//hiby_player.sh $HOME/rootfs/usr/bin/hiby_player.sh && \ | ||
69 | chmod 755 $HOME/rootfs/usr/bin/hiby_player.sh | ||
70 | |||
71 | # Rebuild ubifs | ||
72 | echo | ||
73 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
74 | echo "!!! STEP 6: Rebuild system.ubi !!!" | ||
75 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
76 | echo | ||
77 | mkfs.ubifs --min-io-size=2048 --leb-size=126976 --max-leb-cnt=1024 -o $HOME/system_rb.ubi -r $HOME/rootfs && \ | ||
78 | mv $HOME/system_rb.ubi $HOME/iso/system.ubi | ||
79 | |||
80 | # Fixup update.txt file with correct md5 | ||
81 | echo | ||
82 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
83 | echo "!!! STEP 7: Fixup update.txt !!!" | ||
84 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
85 | echo | ||
86 | python $HOME/rockbox-wodz/tools/agptek_rocker/update_update.py $HOME/iso/update.txt | ||
87 | |||
88 | # Rebuild .upt file | ||
89 | echo | ||
90 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
91 | echo "!!! STEP 8: Rebuild upt file !!!" | ||
92 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
93 | echo | ||
94 | xorriso -as mkisofs -volid 'CDROM' --norock -output $UPT_DIR/update_rb.upt $HOME/iso | ||
95 | |||
96 | # Build rockbox.zip | ||
97 | echo | ||
98 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
99 | echo "!!! STEP 9: Build rockbox application !!!" | ||
100 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
101 | echo | ||
102 | cd $HOME/rockbox-wodz/build && \ | ||
103 | ../tools/configure --target=240 --type=n && \ | ||
104 | make clean && \ | ||
105 | make && \ | ||
106 | make zip && \ | ||
107 | cp rockbox.zip $UPT_DIR/ | ||
108 | |||
109 | # Cleanup | ||
110 | echo | ||
111 | echo "!!!!!!!!!!!!!!!!!!!!!!!!" | ||
112 | echo "!!! STEP 10: Cleanup !!!" | ||
113 | echo "!!!!!!!!!!!!!!!!!!!!!!!!" | ||
114 | echo | ||
115 | rm -rf $HOME/rockbox-wodz/build | ||
116 | rm -rf $HOME/iso | ||
117 | rm -rf $HOME/rootfs | ||
118 | |||
119 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
120 | echo "! Building finished !" | ||
121 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | ||
122 | echo | ||
123 | echo "You should find update_rb.upt and rockbox.zip in output directory" | ||
124 | echo | ||
125 | echo "1) Unzip rockbox.zip file in the root directory of SD card" | ||
126 | echo "2) Copy update_rb.upt to the root directory of SD card" | ||
127 | echo "3) Rename update_rb.upt to update.upt in SD card" | ||
128 | echo "4) Select update firmware on device" | ||
129 | echo | ||
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 | |||
3 | mount /dev/mmcblk0 /mnt/sd_0 &>/dev/null || \ | ||
4 | mount /dev/mmcblk0p1 /mnt/sd_0 &>/dev/null | ||
5 | |||
6 | killall rb_bootloader &>/dev/null | ||
7 | killall -9 rb_bootloader &>/dev/null | ||
8 | |||
9 | /usr/bin/rb_bootloader | ||
10 | sleep 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 | ||
2 | import os | ||
3 | import sys | ||
4 | import hashlib | ||
5 | import argparse | ||
6 | from collections import OrderedDict | ||
7 | |||
8 | EQ = '=' | ||
9 | BLK_START = '{' | ||
10 | BLK_END = '}' | ||
11 | |||
12 | #name: {key: value, key: value} | ||
13 | def 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 | ||
48 | def 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 | |||
56 | if __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) | ||