summaryrefslogtreecommitdiffstats
path: root/rbutil/mkamsboot
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/mkamsboot')
-rw-r--r--rbutil/mkamsboot/.gitignore2
-rw-r--r--rbutil/mkamsboot/Makefile31
-rw-r--r--rbutil/mkamsboot/README67
-rw-r--r--rbutil/mkamsboot/dualboot.c152
-rw-r--r--rbutil/mkamsboot/dualboot.h12
-rw-r--r--rbutil/mkamsboot/dualboot/.gitignore3
-rw-r--r--rbutil/mkamsboot/dualboot/Makefile61
-rw-r--r--rbutil/mkamsboot/dualboot/bin2c.c140
-rw-r--r--rbutil/mkamsboot/dualboot/dualboot.S307
-rw-r--r--rbutil/mkamsboot/dualboot/nrv2e_d8.S198
-rw-r--r--rbutil/mkamsboot/main.c174
-rw-r--r--rbutil/mkamsboot/md5.c246
-rw-r--r--rbutil/mkamsboot/md5.h25
-rw-r--r--rbutil/mkamsboot/mkamsboot.c595
-rw-r--r--rbutil/mkamsboot/mkamsboot.h195
15 files changed, 0 insertions, 2208 deletions
diff --git a/rbutil/mkamsboot/.gitignore b/rbutil/mkamsboot/.gitignore
deleted file mode 100644
index 568b1d5a87..0000000000
--- a/rbutil/mkamsboot/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-build/
-mkamsboot
diff --git a/rbutil/mkamsboot/Makefile b/rbutil/mkamsboot/Makefile
deleted file mode 100644
index 7100bd9512..0000000000
--- a/rbutil/mkamsboot/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# __________ __ ___.
-# Open \______ \ ____ ____ | | _\_ |__ _______ ___
-# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
-# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
-# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
-# \/ \/ \/ \/ \/
-
-# We use the UCL code available in the Rockbox tools/ directory
-CFLAGS += -I../../tools/ucl/include -Wall
-
-OUTPUT = mkamsboot
-LIBUCL = libucl.a
-
-# inputs
-LIBSOURCES := dualboot.c md5.c mkamsboot.c
-SOURCES := main.c
-# additional link dependencies for the standalone executable
-EXTRADEPS := $(LIBUCL)
-
-include ../libtools.make
-# explicit dependencies on dualboot.{c,h} and mkamsboot.h
-$(OBJDIR)mkamsboot.o: dualboot.h dualboot.c mkamsboot.c mkamsboot.h
-$(OBJDIR)main.o: dualboot.h dualboot.c main.c mkamsboot.h
-
-
-$(TARGET_DIR)$(OUTPUT).dll: EXTRALIBOBJS += $(TARGET_DIR)ucl.dll
-$(TARGET_DIR)$(OUTPUT).dll: $(TARGET_DIR)ucl.dll
-$(TARGET_DIR)ucl.dll:
- $(SILENT)$(MAKE) -C ../../tools/ucl/src/ \
- BUILD_DIR=$(BUILD_DIR) CC=$(CC) CROSS=$(CROSS) \
- TARGET_DIR=$(TARGET_DIR)/ ucl.dll
diff --git a/rbutil/mkamsboot/README b/rbutil/mkamsboot/README
deleted file mode 100644
index 8e3f202f38..0000000000
--- a/rbutil/mkamsboot/README
+++ /dev/null
@@ -1,67 +0,0 @@
-mkamsboot
----------
-
-A tool to inject a bootloader into a Sansa V2 (AMS) firmware file.
-
-
-Usage
------
-
-mkamsboot <firmware file> <boot file> <output file>
-
-<firmware file> is an original Sansa firmware file obtained from the Sansa
- forums for example : http://forums.sandisk.com/sansa/?category.id=devices
-
-<boot file> is the code you want to execute (a rockbox bootloader), previously
- scrambled with tools/scramble utility.
-
-<output file> is the resulting firmware file which you'll have to copy on your
- Sansa player. See "Firmware filenames".
-
-
-Supported models
-----------------
-
-Sansa Clip : firmware version starting with "01."
-Sansa Clip+ : firmware version starting with "01."
-Sansa Clipv2: firmware version starting with "02."
-Sansa ClipZip: firmware version starting with "01."
-Sansa Fuze : firmware version starting with "01."
-Sansa Fuzev2: firmware version starting with "02."
-Sansa E200v2: firmware version starting with "03."
-Sansa C200v2: firmware version starting with "03."
-Sansa M200v4: firmware version starting with "4."
-
-
-Firmware filenames
-------------------
-
-For the firmware upgrade to happen, the firmware has to be named specially:
-
-clip v2 : m30pa.bin
-clip : m300a.bin
-clip+ : clppa.bin
-clip zip: clpza.bin
-fuze : fuzea.bin
-fuzev2 : fuzpa.bin
-e200v2 : e200pa.bin
-c200v2 : c200pa.bin
-m200v4 : m200a.bin
-
-
-Dual-Boot
----------
-
- The purpose of this program is to provide dual-boot between the original
-firmware and the new (rockbox) firmware.
-
- By default the player will boot into the new firmware.
-
- To boot into the Original Firmware, you need to press the Left key.
- ***Note : on the Clip+ you can alternatively press the Home key.
- ***Note : on the Clip Zip you can alternatively press the Vol- key.
-
-Hacking
--------
-
-See comments in mkamsboot.c and dualboot/dualboot.S for more information.
diff --git a/rbutil/mkamsboot/dualboot.c b/rbutil/mkamsboot/dualboot.c
deleted file mode 100644
index d97ab0e95b..0000000000
--- a/rbutil/mkamsboot/dualboot.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/* Generated by bin2c */
-
-#include "dualboot.h"
-
-unsigned char nrv2e_d8[168] = {
- 0x0f, 0x18, 0x01, 0x24, 0x65, 0x42, 0xe4, 0x07, 0x05, 0x26, 0x36, 0x02, 0x0a, 0xe0, 0x00, 0x20,
- 0x00, 0x47, 0x04, 0x78, 0x64, 0x41, 0x01, 0x30, 0x24, 0x06, 0xf7, 0x46, 0x03, 0x78, 0x01, 0x30,
- 0x13, 0x70, 0x01, 0x32, 0x24, 0x19, 0xfe, 0x46, 0xf3, 0xd0, 0xf7, 0xd2, 0x01, 0x21, 0x04, 0xe0,
- 0x01, 0x39, 0x24, 0x19, 0xfe, 0x46, 0xec, 0xd0, 0x49, 0x41, 0x24, 0x19, 0xfe, 0x46, 0xe8, 0xd0,
- 0x49, 0x41, 0x24, 0x19, 0xfe, 0x46, 0xe4, 0xd0, 0xf2, 0xd3, 0xcb, 0x1e, 0x00, 0x21, 0x08, 0xd3,
- 0x1b, 0x02, 0x05, 0x78, 0x01, 0x30, 0x1d, 0x43, 0xed, 0x43, 0xd8, 0xd0, 0x6d, 0x10, 0x13, 0xd2,
- 0x03, 0xe0, 0x24, 0x19, 0xfe, 0x46, 0xd4, 0xd0, 0x0e, 0xd2, 0x01, 0x21, 0x24, 0x19, 0xfe, 0x46,
- 0xcf, 0xd0, 0x09, 0xd2, 0x24, 0x19, 0xfe, 0x46, 0xcb, 0xd0, 0x49, 0x41, 0x24, 0x19, 0xfe, 0x46,
- 0xc7, 0xd0, 0xf7, 0xd3, 0x04, 0x31, 0x04, 0xe0, 0x24, 0x19, 0xfe, 0x46, 0xc1, 0xd0, 0x49, 0x41,
- 0x02, 0x31, 0xee, 0x42, 0x00, 0xd2, 0x01, 0x31, 0x13, 0x78, 0x53, 0x5d, 0x13, 0x70, 0x01, 0x32,
- 0x01, 0x39, 0xfa, 0xd1, 0xbe, 0xe7, 0x00, 0x00
-};
-unsigned char dualboot_clip[196] = {
- 0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
- 0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x2c, 0x30, 0x0f, 0xe5, 0x6c, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x60, 0x00, 0x9f, 0xe5, 0x20, 0x10, 0xa0, 0xe3, 0x00, 0x14, 0x80, 0xe5,
- 0x80, 0x10, 0x80, 0xe5, 0x54, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0xa0, 0xe3, 0x00, 0x14, 0x80, 0xe5,
- 0x04, 0x10, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3, 0x02, 0x00, 0x00, 0x1a, 0x70, 0x00, 0x1f, 0xe5,
- 0x70, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x84, 0x00, 0x1f, 0xe5, 0x84, 0x10, 0x1f, 0xe5,
- 0x7c, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4,
- 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2,
- 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0d, 0xc8,
- 0x00, 0x00, 0x0c, 0xc8
-};
-unsigned char dualboot_e200v2[176] = {
- 0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
- 0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x2c, 0x30, 0x0f, 0xe5, 0x5c, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x50, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0xa0, 0xe3, 0x00, 0x14, 0x80, 0xe5,
- 0x20, 0x10, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3, 0x02, 0x00, 0x00, 0x0a, 0x60, 0x00, 0x1f, 0xe5,
- 0x60, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x74, 0x00, 0x1f, 0xe5, 0x74, 0x10, 0x1f, 0xe5,
- 0x6c, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4,
- 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2,
- 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0d, 0xc8
-};
-unsigned char dualboot_c200v2[272] = {
- 0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
- 0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x2c, 0x30, 0x0f, 0xe5, 0xa8, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x9c, 0x00, 0x9f, 0xe5, 0x08, 0x10, 0xa0, 0xe3, 0x00, 0x10, 0x80, 0xe5,
- 0x94, 0x20, 0x9f, 0xe5, 0x0c, 0x10, 0xa0, 0xe3, 0x20, 0x14, 0x82, 0xe5, 0x8c, 0x20, 0x9f, 0xe5,
- 0xff, 0x10, 0xa0, 0xe3, 0x20, 0x14, 0x82, 0xe5, 0x84, 0x00, 0x9f, 0xe5, 0x91, 0x1a, 0xa0, 0xe3,
- 0x08, 0x10, 0x80, 0xe5, 0x7c, 0x10, 0x9f, 0xe5, 0x10, 0x10, 0x80, 0xe5, 0x0c, 0x10, 0x90, 0xe5,
- 0x01, 0x1b, 0x11, 0xe2, 0xfc, 0xff, 0xff, 0x0a, 0x6c, 0x10, 0x9f, 0xe5, 0x08, 0x10, 0x80, 0xe5,
- 0x0c, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x11, 0xe2, 0xfc, 0xff, 0xff, 0x0a, 0xb4, 0x11, 0xd0, 0xe1,
- 0x04, 0x00, 0x11, 0xe3, 0x02, 0x00, 0x00, 0x0a, 0xac, 0x00, 0x1f, 0xe5, 0xac, 0x10, 0x1f, 0xe5,
- 0x01, 0x00, 0x00, 0xea, 0xc0, 0x00, 0x1f, 0xe5, 0xc0, 0x10, 0x1f, 0xe5, 0xb8, 0x30, 0x1f, 0xe5,
- 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4,
- 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3,
- 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8, 0x38, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0c, 0xc8,
- 0x00, 0x00, 0x0d, 0xc8, 0x00, 0x00, 0x12, 0xc8, 0xff, 0xf0, 0x00, 0x00, 0x1f, 0x90, 0x08, 0x00
-};
-unsigned char dualboot_m200v4[180] = {
- 0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
- 0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x2c, 0x30, 0x0f, 0xe5, 0x60, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x54, 0x00, 0x9f, 0xe5, 0x20, 0x10, 0xa0, 0xe3, 0x00, 0x14, 0x80, 0xe5,
- 0x80, 0x10, 0x80, 0xe5, 0x04, 0x20, 0x90, 0xe5, 0x00, 0x00, 0x52, 0xe3, 0x02, 0x00, 0x00, 0x1a,
- 0x64, 0x00, 0x1f, 0xe5, 0x64, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x78, 0x00, 0x1f, 0xe5,
- 0x78, 0x10, 0x1f, 0xe5, 0x70, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0,
- 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8,
- 0x00, 0x00, 0x0b, 0xc8
-};
-unsigned char dualboot_fuze[176] = {
- 0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
- 0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x2c, 0x30, 0x0f, 0xe5, 0x5c, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x50, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0xa0, 0xe3, 0x00, 0x14, 0x80, 0xe5,
- 0x20, 0x10, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3, 0x02, 0x00, 0x00, 0x0a, 0x60, 0x00, 0x1f, 0xe5,
- 0x60, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x74, 0x00, 0x1f, 0xe5, 0x74, 0x10, 0x1f, 0xe5,
- 0x6c, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4,
- 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2,
- 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0d, 0xc8
-};
-unsigned char dualboot_clipv2[240] = {
- 0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
- 0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x2c, 0x30, 0x0f, 0xe5, 0x98, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x8c, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x0c, 0x10, 0xc1, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x80, 0x00, 0x9f, 0xe5, 0x38, 0x10, 0xa0, 0xe3, 0x00, 0x14, 0x80, 0xe5,
- 0x08, 0x10, 0xa0, 0xe3, 0x20, 0x10, 0x80, 0xe5, 0x10, 0x10, 0xa0, 0xe3, 0x40, 0x10, 0x80, 0xe5,
- 0x20, 0x10, 0xa0, 0xe3, 0x80, 0x10, 0x80, 0xe5, 0x00, 0x10, 0xa0, 0xe3, 0x40, 0x10, 0x80, 0xe5,
- 0x05, 0x10, 0xa0, 0xe3, 0x01, 0x10, 0x51, 0xe2, 0xfd, 0xff, 0xff, 0x1a, 0x04, 0x10, 0x90, 0xe5,
- 0x00, 0x00, 0x51, 0xe3, 0x02, 0x00, 0x00, 0x0a, 0x9c, 0x00, 0x1f, 0xe5, 0x9c, 0x10, 0x1f, 0xe5,
- 0x01, 0x00, 0x00, 0xea, 0xb0, 0x00, 0x1f, 0xe5, 0xb0, 0x10, 0x1f, 0xe5, 0xa8, 0x30, 0x1f, 0xe5,
- 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4,
- 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3,
- 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8, 0x0c, 0x00, 0x10, 0xc8, 0x00, 0x00, 0x0e, 0xc8
-};
-unsigned char dualboot_clipplus[184] = {
- 0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
- 0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x2c, 0x30, 0x0f, 0xe5, 0x60, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x54, 0x00, 0x9f, 0xe5, 0x20, 0x10, 0x90, 0xe5, 0x50, 0x00, 0x9f, 0xe5,
- 0x08, 0x20, 0x90, 0xe5, 0x01, 0x20, 0x82, 0xe1, 0x00, 0x00, 0x52, 0xe3, 0x02, 0x00, 0x00, 0x1a,
- 0x64, 0x00, 0x1f, 0xe5, 0x64, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x78, 0x00, 0x1f, 0xe5,
- 0x78, 0x10, 0x1f, 0xe5, 0x70, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0,
- 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8,
- 0x00, 0x00, 0x0d, 0xc8, 0x00, 0x00, 0x0b, 0xc8
-};
-unsigned char dualboot_fuzev2[176] = {
- 0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
- 0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x2c, 0x30, 0x0f, 0xe5, 0x5c, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x50, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0xa0, 0xe3, 0x00, 0x14, 0x80, 0xe5,
- 0x20, 0x10, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3, 0x02, 0x00, 0x00, 0x1a, 0x60, 0x00, 0x1f, 0xe5,
- 0x60, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x74, 0x00, 0x1f, 0xe5, 0x74, 0x10, 0x1f, 0xe5,
- 0x6c, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4,
- 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2,
- 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0d, 0xc8
-};
-unsigned char dualboot_clipzip[232] = {
- 0x06, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5,
- 0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x2c, 0x30, 0x0f, 0xe5, 0x90, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3,
- 0x00, 0x10, 0x80, 0xe5, 0x84, 0x00, 0x9f, 0xe5, 0x00, 0x11, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3,
- 0x11, 0x00, 0x00, 0x1a, 0x78, 0x00, 0x9f, 0xe5, 0x00, 0x14, 0x90, 0xe5, 0x06, 0x10, 0x81, 0xe3,
- 0x20, 0x10, 0xc1, 0xe3, 0x00, 0x14, 0x80, 0xe5, 0x00, 0x10, 0xa0, 0xe3, 0x08, 0x10, 0x80, 0xe5,
- 0x04, 0x10, 0xa0, 0xe3, 0x10, 0x10, 0x80, 0xe5, 0x32, 0x10, 0xa0, 0xe3, 0x01, 0x10, 0x51, 0xe2,
- 0xfd, 0xff, 0xff, 0x1a, 0x80, 0x10, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3, 0x02, 0x00, 0x00, 0x1a,
- 0x94, 0x00, 0x1f, 0xe5, 0x94, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0xa8, 0x00, 0x1f, 0xe5,
- 0xa8, 0x10, 0x1f, 0xe5, 0xa0, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0,
- 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a,
- 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x14, 0x00, 0x0f, 0xc8,
- 0x00, 0x00, 0x0b, 0xc8, 0x00, 0x00, 0x0d, 0xc8
-};
diff --git a/rbutil/mkamsboot/dualboot.h b/rbutil/mkamsboot/dualboot.h
deleted file mode 100644
index 774c35c119..0000000000
--- a/rbutil/mkamsboot/dualboot.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Generated by bin2c */
-
-extern unsigned char nrv2e_d8[168];
-extern unsigned char dualboot_clip[196];
-extern unsigned char dualboot_e200v2[176];
-extern unsigned char dualboot_c200v2[272];
-extern unsigned char dualboot_m200v4[180];
-extern unsigned char dualboot_fuze[176];
-extern unsigned char dualboot_clipv2[240];
-extern unsigned char dualboot_clipplus[184];
-extern unsigned char dualboot_fuzev2[176];
-extern unsigned char dualboot_clipzip[232];
diff --git a/rbutil/mkamsboot/dualboot/.gitignore b/rbutil/mkamsboot/dualboot/.gitignore
deleted file mode 100644
index a0ed5f4ee1..0000000000
--- a/rbutil/mkamsboot/dualboot/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.arm-bin
-*.o
-bin2c
diff --git a/rbutil/mkamsboot/dualboot/Makefile b/rbutil/mkamsboot/dualboot/Makefile
deleted file mode 100644
index 0aa1e3f7d9..0000000000
--- a/rbutil/mkamsboot/dualboot/Makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-CC=gcc
-CROSS_PREFIX?=arm-elf-eabi
-# Edit the following variables (plus copy/paste another set of rules) when
-# adding a new target. mkamsboot.c also needs to be edited to refer to these
-# new images.
-
-BOOTOBJS = nrv2e_d8.o dualboot_clip.o dualboot_e200v2.o dualboot_c200v2.o dualboot_m200v4.o dualboot_fuze.o dualboot_clipv2.o dualboot_clipplus.o dualboot_fuzev2.o dualboot_clipzip.o
-BOOTBINS = nrv2e_d8.arm-bin dualboot_clip.arm-bin dualboot_e200v2.arm-bin dualboot_c200v2.arm-bin dualboot_m200v4.arm-bin dualboot_fuze.arm-bin dualboot_clipv2.arm-bin dualboot_clipplus.arm-bin dualboot_fuzev2.arm-bin dualboot_clipzip.arm-bin
-
-all: ../dualboot.h ../dualboot.c
-
-# Dualboot bootloaders
-
-dualboot_clip.o: dualboot.S
- $(CROSS_PREFIX)-$(CC) -DSANSA_CLIP -c -o dualboot_clip.o dualboot.S
-
-dualboot_fuze.o: dualboot.S
- $(CROSS_PREFIX)-$(CC) -DSANSA_FUZE -c -o dualboot_fuze.o dualboot.S
-
-dualboot_e200v2.o: dualboot.S
- $(CROSS_PREFIX)-$(CC) -DSANSA_E200V2 -c -o dualboot_e200v2.o dualboot.S
-
-dualboot_m200v4.o: dualboot.S
- $(CROSS_PREFIX)-$(CC) -DSANSA_M200V4 -c -o dualboot_m200v4.o dualboot.S
-
-dualboot_c200v2.o: dualboot.S
- $(CROSS_PREFIX)-$(CC) -DSANSA_C200V2 -c -o dualboot_c200v2.o dualboot.S
-
-dualboot_clipv2.o: dualboot.S
- $(CROSS_PREFIX)-$(CC) -DSANSA_CLIPV2 -c -o dualboot_clipv2.o dualboot.S
-
-dualboot_clipplus.o: dualboot.S
- $(CROSS_PREFIX)-$(CC) -DSANSA_CLIPPLUS -c -o dualboot_clipplus.o dualboot.S
-
-dualboot_fuzev2.o: dualboot.S
- $(CROSS_PREFIX)-$(CC) -DSANSA_FUZEV2 -c -o dualboot_fuzev2.o dualboot.S
-
-dualboot_clipzip.o: dualboot.S
- $(CROSS_PREFIX)-$(CC) -DSANSA_CLIPZIP -c -o dualboot_clipzip.o dualboot.S
-
-# Rules for the ucl unpack function
-nrv2e_d8.o: nrv2e_d8.S
- $(CROSS_PREFIX)-$(CC) -DPURE_THUMB -c -o nrv2e_d8.o nrv2e_d8.S
-
-# Rules for the ARM code embedded in mkamsboot - assemble, link, then extract
-# the binary code and finally convert to .h for building in mkamsboot
-
-%.arm-elf: %.o
- $(CROSS_PREFIX)-ld -e 0 -Ttext=0 -o $@ $<
-
-%.arm-bin: %.arm-elf
- $(CROSS_PREFIX)-objcopy -O binary $< $@
-
-../dualboot.c ../dualboot.h: $(BOOTBINS) bin2c
- ./bin2c ../dualboot $(BOOTBINS)
-
-bin2c: bin2c.c
- $(CC) -o bin2c bin2c.c
-
-clean:
- rm -f *~ bin2c $(BOOTBINS) $(BOOTOBJS)
diff --git a/rbutil/mkamsboot/dualboot/bin2c.c b/rbutil/mkamsboot/dualboot/bin2c.c
deleted file mode 100644
index b02af88a4d..0000000000
--- a/rbutil/mkamsboot/dualboot/bin2c.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 Dave Chapman
- *
- * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <libgen.h>
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-static off_t filesize(int fd)
-{
- struct stat buf;
-
- fstat(fd,&buf);
- return buf.st_size;
-}
-
-static void write_cfile(const unsigned char* buf, off_t len, FILE* fp, const char *name)
-{
- int i;
-
- fprintf(fp,"unsigned char %s[%ld] = {",name,len);
-
- for (i=0;i<len;i++) {
- if ((i % 16) == 0) {
- fprintf(fp,"\n ");
- }
- if (i == (len-1)) {
- fprintf(fp,"0x%02x",buf[i]);
- } else if ((i % 16) == 15) {
- fprintf(fp,"0x%02x,",buf[i]);
- } else {
- fprintf(fp,"0x%02x, ",buf[i]);
- }
- }
- fprintf(fp,"\n};\n");
-}
-
-int main (int argc, char* argv[])
-{
- char* cname;
- int i;
- FILE *cfile, *hfile;
- char cfilename[256], hfilename[256];
-
- if (argc < 3) {
- fprintf(stderr,"Usage: bin2c cname file1 [file2 [file3 ...]]\n");
- return 1;
- }
-
- cname=argv[1];
-
- snprintf(cfilename,256,"%s.c",cname);
- cfile = fopen(cfilename,"w+");
- if (cfile == NULL) {
- fprintf(stderr,"Couldn't open %s\n",cfilename);
- return 2;
- }
-
- snprintf(hfilename,256,"%s.h",cname);
- hfile = fopen(hfilename,"w+");
- if (hfile == NULL) {
- fprintf(stderr,"Couldn't open %s\n",hfilename);
- fclose(cfile);
- return 3;
- }
-
- fprintf(cfile,"/* Generated by bin2c */\n\n");
- fprintf(cfile,"#include \"%s\"\n\n", basename(hfilename));
- fprintf(hfile,"/* Generated by bin2c */\n\n");
-
- for(i=0; i < argc - 2; i++) {
- unsigned char* buf;
- off_t len;
- off_t orig_len;
- char *ext;
- char *array = argv[2+i];
-
- int fd = open(array,O_RDONLY|O_BINARY);
- if (fd < 0) {
- fprintf(stderr,"Can not open %s\n",argv[2+i]);
- fclose(cfile);
- fclose(hfile);
- return 4;
- }
-
- orig_len = filesize(fd);
- /* pad to 32bit */
- len = (orig_len + 3) & ~3;
-
- buf = malloc(len);
- if (read(fd,buf,orig_len) < orig_len) {
- fprintf(stderr,"Short read, aborting\n");
- return 5;
- }
-
- /* pad to 32bit with zeros */
- if (len > orig_len)
- memset(buf+orig_len, 0, len-orig_len);
-
- /* remove file extension */
- ext = strchr (array, '.');
- if (ext != NULL)
- *ext = '\0';
- write_cfile (buf, len, cfile, array);
- fprintf(hfile,"extern unsigned char %s[%ld];\n",array,len);
-
- close(fd);
- }
-
- fclose(cfile);
- fclose(hfile);
-
- return 0;
-}
diff --git a/rbutil/mkamsboot/dualboot/dualboot.S b/rbutil/mkamsboot/dualboot/dualboot.S
deleted file mode 100644
index 4e4dbe5505..0000000000
--- a/rbutil/mkamsboot/dualboot/dualboot.S
+++ /dev/null
@@ -1,307 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2008 Rafaël Carré
- *
- * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-.text
-
-/* AS3525 hardware registers */
-.set GPIOA, 0xC80B0000
-.set GPIOB, 0xC80C0000
-.set GPIOC, 0xC80D0000
-.set GPIOD, 0xC80E0000
-.set CGU_PROC, 0xC80F0010
-.set CGU_PERI, 0xC80F0014
-.set CGU_DBOP, 0xC80F0038
-.set CCU_IO, 0xC810000C
-.set DBOP, 0xC8120000
-.set I2C_BASE, 0xC8070000
-.set I2C_DATA, 0x00
-.set I2C_SLAD0, 0x04
-.set I2C_CNTRL, 0x0c
-.set I2C_DACNT, 0x10
-.set I2C_CPSR0, 0x1c
-.set I2C_CPSR1, 0x20
-.set I2C_IMR, 0x24
-.set I2C_SR, 0x30
-.set I2C_SADDR, 0x44
-.set AS3514_I2C_ADDR, 0x46
-.set AS3514_IRQ_ENRD0, 0x25
-.set PCLK, 24000000
-.set I2C_CLK, 400000
-.set I2C_PRESCALER, ((PCLK + I2C_CLK -1) / I2C_CLK)
-.set I2C_PRESCALER_LOW, (I2C_PRESCALER & 0xff)
-.set I2C_PRESCALER_HIGH, (I2C_PRESCALER >> 8)
-#if I2C_PRESCALER_HIGH > 3
-#error i2c prescaler too big!
-#endif
-
- b start @ skip our data
-
-/* These values are filled in by mkamsboot - don't move them from offset 0x4 */
-
-uclunpack_end: .word 0 /* End of the ucl_unpack function */
-uclunpack_size: .word 0 /* Size in bytes of the ucl_unpack function */
-
-ucl_of_end: .word 0 /* End of the ucl-compressed OF image */
-ucl_of_size: .word 0 /* Size in bytes of the compressed OF image */
-
-ucl_rb_end: .word 0 /* End of the ucl-compressed RB image */
-ucl_rb_size: .word 0 /* Size in bytes of the compressed RB image */
-
-ucl_dest: .word 0 /* End of our destination buffer (end of memory) */
-
-start:
- /* First copy the UCL unpack function to the end of RAM */
- ldr r0, uclunpack_end /* Source */
- ldr r1, uclunpack_size /* Source length */
- sub r2, r0, r1 /* Source start - 1*/
-
- ldr r3, ucl_dest /* Destination end */
-
-uclcopy:
- ldrb r4, [r0], #-1
- strb r4, [r3], #-1
- cmp r2, r0
- bne uclcopy
-
- /* store the new destination buffer */
- str r3, ucl_dest
-
- /* enable gpio clock */
- ldr r0, =CGU_PERI
- ldr r1, [r0]
- orr r1, r1, #(1<<16)
- str r1, [r0]
-
- /* Here are model specific tests for dual boot (test left button) */
-
-#ifdef SANSA_CLIP
-.set row, (1<<5) /* enable output on C5 */
-.set col, (1<<0) /* read keyscan column B0 */
-
- ldr r0, =GPIOC
- mov r1, #row
- str r1, [r0, #0x400]
- str r1, [r0, #(4*row)]
-
- ldr r0, =GPIOB
- mov r1, #0
- str r1, [r0, #0x400]
- ldr r1, [r0, #(4*col)]
-
- cmp r1, #0
- bne boot_of
-#elif defined(SANSA_CLIPV2)
-.set row, (1<<4) /* enable output on D4 */
-.set col, (1<<0) /* read keyscan column D0 */
-
- ldr r0, =CCU_IO
- ldr r1, [r0]
- bic r1, r1, #(3<<2) @ XPD works as general purpose IO
- str r1, [r0]
-
- ldr r0, =GPIOD
- mov r1, #((1<<5)|(1<<4)|(1<<3)) /* all rows as output */
- str r1, [r0, #0x400]
-
- /* all rows high */
- mov r1, #(1<<3)
- str r1, [r0, #(4*(1<<3))]
- mov r1, #(1<<4)
- str r1, [r0, #(4*(1<<4))]
- mov r1, #(1<<5)
- str r1, [r0, #(4*(1<<5))]
-
- mov r1, #0 /* button row low */
- str r1, [r0, #(4*row)]
-
- mov r1, #5 /* small delay */
-1: subs r1, r1, #1
- bne 1b
-
- ldr r1, [r0, #(4*col)]
-
- cmp r1, #0
- beq boot_of
-#elif defined(SANSA_E200V2) || defined(SANSA_FUZE)
- ldr r0, =GPIOC
- mov r1, #0
- str r1, [r0, #0x400]
- ldr r1, [r0, #0x20] /* read pin C3 */
-
- cmp r1, #0 /* C3 = #0 means button pressed */
- beq boot_of
-
-#elif defined(SANSA_FUZEV2)
- ldr r0, =GPIOC
- mov r1, #0
- str r1, [r0, #0x400]
- ldr r1, [r0, #0x20] /* read pin C3 */
-
- cmp r1, #0 /* C3 != #0 means button pressed */
- bne boot_of
-
-#elif defined(SANSA_CLIPPLUS)
- @ read pins
- ldr r0, =GPIOC
- ldr r1, [r0, #4*(1<<3)] @ read pin C3 "|<<"
-
- ldr r0, =GPIOA
- ldr r2, [r0, #4*(1<<1)] @ read pin A1 "Home"
-
- orr r2, r2, r1 @ c3 || A1
-
- cmp r2, #0 @ test input from pins
- bne boot_of @ branch directly to OF if either pin high
-
-#elif defined(SANSA_CLIPZIP)
- @ read pins
- ldr r0, =GPIOA
- ldr r1, [r0, #4*(1<<6)] @ read GPIO A6 "vol-"
-
- cmp r1, #0 @ test input from pins
- bne boot_of @ branch directly to OF if either pin high
-
- ldr r0, =GPIOC
-
- ldr r1, [r0, #0x400]
- orr r1, r1, #((1<<1)|(1<<2)) @ output
- bic r1, r1, #(1<<5) @ input
- str r1, [r0, #0x400]
-
- mov r1, #0
- str r1, [r0, #4*(1<<1)] @ zero C1
- mov r1, #(1<<2)
- str r1, [r0, #4*(1<<2)] @ set C2
-
- mov r1, #50 /* small delay */
-1: subs r1, r1, #1
- bne 1b
-
- ldr r1, [r0, #4*(1<<5)] @ read C5 = left
-
- cmp r1, #0
- bne boot_of
-
-#elif defined(SANSA_C200V2)
-.set BUTTON_LEFT, (1<< 2)
-.set BUTTON_DOWN, (1<< 3)
-.set BUTTON_SELECT, (1<< 4)
-.set BUTTON_UP, (1<< 5)
-.set BUTTON_RIGHT, (1<< 6)
-.set BUTTON_HOLD, (1<<12)
-
- ldr r0, =CGU_DBOP
- mov r1, #(1<<3) @ DBOP freq = PCLK, clock enabled
- str r1, [r0]
-
- @ AFSEL needs to be set for this to work
- ldr r2, =GPIOB
- mov r1, #0xc
- str r1, [r2, #0x420] @ GPIOB_AFSEL
- ldr r2, =GPIOC
- mov r1, #0xff
- str r1, [r2, #0x420] @ GPIOC_AFSEL
-
- ldr r0, =DBOP
- @ TIMPOL doesn't matter here since we don't need
- @ the control signals.
-
- @ 16 bit data width
- @ enable write
- @ tri-state output
- ldr r1, =0x00091000
- str r1, [r0, #8] @ DBOP_CTRL
-
- ldr r1, =0xf0ff @ precharge
- str r1, [r0, #0x10] @ DBOP_DOUT
-
-2: ldr r1, [r0, #0xc] @ DOBP_STAT
- ands r1, r1, #(1<<10)
- beq 2b @ make sure fifo is empty
-
- @ 16 bit data width
- @ start read
- @ tri-state output
- @ strobe time 31
- ldr r1, =0x0008901f
- str r1, [r0, #8] @ DBOP_CTRL
-
-3: ldr r1, [r0, #0xc] @ DOBP_STAT
- ands r1, r1, #(1<<16)
- beq 3b @ wait for valid data
-
- ldrh r1, [r0, #0x14] @ DBOP_DIN
-
- tst r1, #BUTTON_LEFT @ boot of?
- beq boot_of
-#elif defined(SANSA_M200V4)
-.set row, (1<<5) /* enable output on A5 */
-.set col, (1<<0) /* read keyscan column A0 */
-
- ldr r0, =GPIOA
- mov r1, #row
- str r1, [r0, #0x400]
- str r1, [r0, #(4*row)]
-
- ldr r2, [r0, #(4*col)]
-
- /* check value read (1 means button pressed) */
- cmp r2, #0
- bne boot_of
-#else
- #error No target-specific key check defined!
-#endif
-
- /* The dualboot button was not held, so we boot rockbox */
- ldr r0, ucl_rb_end /* Address of compressed image */
- ldr r1, ucl_rb_size /* Compressed size */
- b decompress
-
-boot_of:
- ldr r0, ucl_of_end /* Address of compressed image */
- ldr r1, ucl_of_size /* Compressed size */
-
-
-decompress:
- /* At this point: */
- /* r0 = source_end for UCL image to copy */
- /* r1 = size of UCL image to copy */
-
- ldr r3, ucl_dest
- add r5, r3, #2 /* r5 is entry point of copy of uclunpack */
- /* function, plus one (for thumb mode */
-
- sub r4, r3, r1 /* r4 := destination_start - 1 */
-
-fw_copy:
- ldrb r2, [r0], #-1
- strb r2, [r3], #-1
- cmp r3, r4 /* Stop when we reached dest_start-1 */
- bne fw_copy
-
- /* Call the ucl decompress function, which will branch to 0x0 */
- /* on completion */
- add r0, r3, #1 /* r0 := Start of compressed image */
- /* r1 already contains compressed size */
- mov r2, #0 /* r2 := Destination for unpacking */
- bx r5 /* Branch to uclunpack, switching to thumb */
-
- /* never reached : uclunpack will branch to the reset vector (0x0) */
diff --git a/rbutil/mkamsboot/dualboot/nrv2e_d8.S b/rbutil/mkamsboot/dualboot/nrv2e_d8.S
deleted file mode 100644
index d24fb94b2a..0000000000
--- a/rbutil/mkamsboot/dualboot/nrv2e_d8.S
+++ /dev/null
@@ -1,198 +0,0 @@
-/* arm_nrv2e_d8.S -- ARM decompressor for NRV2E
-
- This file is part of the UPX executable compressor.
-
- Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996-2008 Laszlo Molnar
- Copyright (C) 2000-2008 John F. Reiser
- All Rights Reserved.
-
- UPX and the UCL library are free software; you can redistribute them
- and/or modify them 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; see the file COPYING.
- If not, write to the Free Software Foundation, Inc.,
- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Markus F.X.J. Oberhumer Laszlo Molnar
- <markus@oberhumer.com> <ml1050@users.sourceforge.net>
-
- John F. Reiser
- <jreiser@users.sourceforge.net>
-*/
-#define SAFE 0 /* 1 for src+dst bounds checking: cost 40 bytes */
-
-#define src r0
-#define len r1 /* overlaps 'cnt' */
-#define dst r2
-#define tmp r3
-#define bits r4
-#define off r5
-#define wrnk r6 /* 0x500 M2_MAX_OFFSET before "wrinkle" */
-#define srclim r7
-#if 1==SAFE /*{*/
-#define dstlim r12
-#endif /*}*/
-
-#define cnt r1 /* overlaps 'len' while reading an offset */
-
-#if 1==SAFE /*{*/
-#define CHECK_SRC cmp src,srclim; bhs bad_src_n2e
-#define CHECK_DST cmp dst,dstlim; bhs bad_dst_n2e
-#else /*}{*/
-#define CHECK_SRC /*empty*/
-#define CHECK_DST /*empty*/
-#endif /*}*/
-
-#if 0 /*{ DEBUG only: check newly-decompressed against original dst */
-#define CHECK_BYTE \
- push {wrnk}; \
- ldrb wrnk,[dst]; \
- cmp wrnk,tmp; beq 0f; bkpt; \
-0: pop {wrnk}
-#else /*}{*/
-#define CHECK_BYTE /*empty*/
-#endif /*}*/
-
-/* "mov lr,pc; bxx ..." implements conditional subroutine call
- *
- * NOTE: the lsb will not be set, so you MUST NOT use 'bx lr' to return,
- * else the T bit will be cleared and processor will go in ARM state */
-#define GETBIT add bits,bits; mov lr,pc; beq get1_n2e
-
-#define getnextb(reg) GETBIT; adc reg,reg
-#define jnextb0 GETBIT; bcc
-#define jnextb1 GETBIT; bcs
-
-#ifndef PURE_THUMB
-ucl_nrv2e_decompress_8: .globl ucl_nrv2e_decompress_8 @ ARM mode
- .type ucl_nrv2e_decompress_8, %function
-/* error = (*)(char const *src, int len_src, char *dst, int *plen_dst)
- Actual decompressed length is stored through plen_dst.
- For SAFE mode: at call, *plen_dst must be allowed length of output buffer.
-*/
- adr r12,1+.thumb_nrv2e_d8; bx r12 @ enter THUMB mode
-#endif
- .code 16 @ THUMB mode
- .thumb_func
-
-.thumb_nrv2e_d8:
-#if 0
- push {r2,r3, r4,r5,r6,r7, lr}
-#define sp_DST0 0 /* stack offset of original dst */
-#endif
- add srclim,len,src @ srclim= eof_src;
-#if 1==SAFE /*{*/
- ldr tmp,[r3] @ len_dst
- add tmp,dst
- mov dstlim,tmp
-#endif /*}*/
- mov bits,#1; neg off,bits @ off= -1 initial condition
- lsl bits,#31 @ 1<<31: refill next time
- mov wrnk,#5
- lsl wrnk,#8 @ 0x500 @ nrv2e M2_MAX_OFFSET
- b top_n2e
-
-#if 1==SAFE /*{*/
-bad_dst_n2e: # return value will be 2
- add src,srclim,#1
-bad_src_n2e: # return value will be 1
- add src,#1
-#endif /*}*/
-eof_n2e:
-#if 0
- pop {r3,r4} @ r3= orig_dst; r4= plen_dst
- sub src,srclim @ 0 if actual src length equals expected length
- sub dst,r3 @ actual dst length
- str dst,[r4]
- pop {r4,r5,r6,r7 /*,pc*/}
- pop {r1}; bx r1 @ "pop {,pc}" fails return to ARM mode on ARMv4T
-#else
- mov r0, #0
- bx r0 /* Branch to 0x0, switch to ARM mode */
-#endif
-
-get1_n2e: @ In: Carry set [from adding 0x80000000 (1<<31) to itself]
- ldrb bits,[src] @ zero-extend next byte
- adc bits,bits @ double and insert CarryIn as low bit
- CHECK_SRC
- add src,#1
- lsl bits,#24 @ move to top byte, and set CarryOut from old bit 8
- /* NOTE: the following instruction will not work on ARMv7+, because
- * it will update the T bit and return into ARM state */
- mov pc,lr @ return, stay in current (THUMB) mode
-
-lit_n2e:
- CHECK_SRC; ldrb tmp,[src]; add src,#1
- CHECK_BYTE
- CHECK_DST; strb tmp,[dst]; add dst,#1
-top_n2e:
- jnextb1 lit_n2e
- mov cnt,#1; b getoff_n2e
-
-off_n2e:
- sub cnt,#1
- getnextb(cnt)
-getoff_n2e:
- getnextb(cnt)
- jnextb0 off_n2e
-
- sub tmp,cnt,#3 @ set Carry
- mov len,#0 @ Carry unaffected
- blo offprev_n2e @ cnt was 2; tests Carry only
- lsl tmp,#8
- CHECK_SRC; ldrb off,[src]; add src,#1 @ low 7+1 bits
- orr off,tmp
- mvn off,off; beq eof_n2e @ off= ~off
- asr off,#1; bcs lenlast_n2e
- b lenmore_n2e
-
-offprev_n2e:
- jnextb1 lenlast_n2e
-lenmore_n2e:
- mov len,#1
- jnextb1 lenlast_n2e
-len_n2e:
- getnextb(len)
- jnextb0 len_n2e
- add len,#6-2
- b gotlen_n2e
-
-lenlast_n2e:
- getnextb(len) @ 0,1,2,3
- add len,#2
-gotlen_n2e: @ 'cmn': add the inputs, set condition codes, discard the sum
- cmn wrnk,off; bcs near_n2e @ within M2_MAX_OFFSET
- add len,#1 @ too far away, so minimum match length is 3
-near_n2e:
-#if 1==SAFE /*{*/
- ldr tmp,[sp,#sp_DST0]
- sub tmp,dst
- sub tmp,off; bhi bad_dst_n2e @ reaching back too far
-
- add tmp,dst,cnt
- cmp tmp,dstlim; bhi bad_dst_n2e @ too much output
-#endif /*}*/
- ldrb tmp,[dst] @ force cacheline allocate
-copy_n2e:
- ldrb tmp,[dst,off]
- CHECK_BYTE
- strb tmp,[dst]; add dst,#1
- sub len,#1; bne copy_n2e
- b top_n2e
-
-#ifndef PURE_THUMB
- .size ucl_nrv2e_decompress_8, .-ucl_nrv2e_decompress_8
-#endif
-
-/*
-vi:ts=8:et:nowrap
- */
diff --git a/rbutil/mkamsboot/main.c b/rbutil/mkamsboot/main.c
deleted file mode 100644
index cf40811ace..0000000000
--- a/rbutil/mkamsboot/main.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * mkamsboot - a tool for merging bootloader code into an Sansa V2
- * (AMS) firmware file
- *
- * Copyright (C) 2008 Dave Chapman
- *
- * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <ucl/ucl.h>
-
-#include "mkamsboot.h"
-
-/* Header for ARM code binaries */
-#include "dualboot.h"
-
-/* Win32 compatibility */
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-/* standalone executable */
-int main(int argc, char* argv[])
-{
- char *infile, *bootfile, *outfile;
- int fdout;
- off_t len;
- uint32_t n;
- unsigned char* buf;
- int firmware_size;
- int bootloader_size;
- unsigned char* of_packed;
- int of_packedsize;
- unsigned char* rb_packed;
- int rb_packedsize;
- int patchable;
- int totalsize;
- int model;
- char errstr[200];
- struct md5sums sum;
- char md5sum[33]; /* 32 digits + \0 */
-
- sum.md5 = md5sum;
-
-/* VERSION comes frome the Makefile */
- fprintf(stderr,
-"mkamsboot Version " VERSION "\n"
-"This is free software; see the source for copying conditions. There is NO\n"
-"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
-"\n");
-
- if(argc != 4) {
- printf("Usage: mkamsboot <firmware file> <boot file> <output file>\n");
- return 1;
- }
-
- infile = argv[1];
- bootfile = argv[2];
- outfile = argv[3];
-
- /* Load bootloader file */
- rb_packed = load_rockbox_file(bootfile, &model, &bootloader_size,
- &rb_packedsize, errstr, sizeof(errstr));
- if (rb_packed == NULL) {
- fprintf(stderr, "%s", errstr);
- fprintf(stderr, "[ERR] Could not load %s\n", bootfile);
- return 1;
- }
-
- /* Load original firmware file */
- buf = load_of_file(infile, model, &len, &sum,
- &firmware_size, &of_packed, &of_packedsize, errstr, sizeof(errstr));
-
- if (buf == NULL) {
- free(rb_packed);
- fprintf(stderr, "%s", errstr);
- fprintf(stderr, "[ERR] Could not load %s\n", infile);
- return 1;
- }
-
- fprintf(stderr, "[INFO] Original firmware MD5 checksum match\n");
- fprintf(stderr, "[INFO] Model: Sansa %s v%d - Firmware version: %s\n",
- ams_identity[sum.model].model_name,
- ams_identity[sum.model].hw_revision, sum.version);
-
-
- printf("[INFO] Firmware patching has begun !\n\n");
-
- fprintf(stderr, "[INFO] Original firmware size: %8d bytes\n",
- firmware_size);
- fprintf(stderr, "[INFO] Packed OF size: %8d bytes\n",
- of_packedsize);
- fprintf(stderr, "[INFO] Bootloader size: %8d bytes\n",
- bootloader_size);
- fprintf(stderr, "[INFO] Packed bootloader size: %8d bytes\n",
- rb_packedsize);
- fprintf(stderr, "[INFO] Dual-boot function size: %8d bytes\n",
- ams_identity[sum.model].bootloader_size);
- fprintf(stderr, "[INFO] UCL unpack function size: %8zu bytes\n",
- sizeof(nrv2e_d8));
- fprintf(stderr, "[INFO] Original firmware version: %8u bytes\n",
- 0x200);
-
- patchable = check_sizes(sum.model, rb_packedsize, bootloader_size,
- of_packedsize, firmware_size, &totalsize, errstr, sizeof(errstr));
-
- fprintf(stderr, "[INFO] Total size of new image: %8d bytes\n", totalsize);
-
- if (!patchable) {
- fprintf(stderr, "%s", errstr);
- free(buf);
- free(of_packed);
- free(rb_packed);
- return 1;
- }
-
- patch_firmware(sum.model, ams_identity[sum.model].fw_revision,
- firmware_size, buf, len, of_packed, of_packedsize, rb_packed,
- rb_packedsize);
-
- /* Write the new firmware */
- fdout = open(outfile, O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, 0666);
-
- if (fdout < 0) {
- fprintf(stderr, "[ERR] Could not open %s for writing\n", outfile);
- free(buf);
- free(of_packed);
- free(rb_packed);
- return 1;
- }
-
- n = write(fdout, buf, len);
-
- if (n != (unsigned)len) {
- fprintf(stderr, "[ERR] Could not write firmware file\n");
- free(buf);
- free(of_packed);
- free(rb_packed);
- return 1;
- }
-
- close(fdout);
- free(buf);
- free(of_packed);
- free(rb_packed);
- fprintf(stderr, "\n[INFO] Patching succeeded!\n");
-
- return 0;
-}
-
diff --git a/rbutil/mkamsboot/md5.c b/rbutil/mkamsboot/md5.c
deleted file mode 100644
index 530d8df15a..0000000000
--- a/rbutil/mkamsboot/md5.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * RFC 1321 compliant MD5 implementation
- *
- * Copyright (C) 2001-2003 Christophe Devine
- *
- * 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
- */
-
-#include <string.h>
-
-#include "md5.h"
-
-#define GET_UINT32(n,b,i) \
-{ \
- (n) = ( (uint32) (b)[(i) ] ) \
- | ( (uint32) (b)[(i) + 1] << 8 ) \
- | ( (uint32) (b)[(i) + 2] << 16 ) \
- | ( (uint32) (b)[(i) + 3] << 24 ); \
-}
-
-#define PUT_UINT32(n,b,i) \
-{ \
- (b)[(i) ] = (uint8) ( (n) ); \
- (b)[(i) + 1] = (uint8) ( (n) >> 8 ); \
- (b)[(i) + 2] = (uint8) ( (n) >> 16 ); \
- (b)[(i) + 3] = (uint8) ( (n) >> 24 ); \
-}
-
-void md5_starts( md5_context *ctx )
-{
- ctx->total[0] = 0;
- ctx->total[1] = 0;
-
- ctx->state[0] = 0x67452301;
- ctx->state[1] = 0xEFCDAB89;
- ctx->state[2] = 0x98BADCFE;
- ctx->state[3] = 0x10325476;
-}
-
-void md5_process( md5_context *ctx, uint8 data[64] )
-{
- uint32 X[16], A, B, C, D;
-
- GET_UINT32( X[0], data, 0 );
- GET_UINT32( X[1], data, 4 );
- GET_UINT32( X[2], data, 8 );
- GET_UINT32( X[3], data, 12 );
- GET_UINT32( X[4], data, 16 );
- GET_UINT32( X[5], data, 20 );
- GET_UINT32( X[6], data, 24 );
- GET_UINT32( X[7], data, 28 );
- GET_UINT32( X[8], data, 32 );
- GET_UINT32( X[9], data, 36 );
- GET_UINT32( X[10], data, 40 );
- GET_UINT32( X[11], data, 44 );
- GET_UINT32( X[12], data, 48 );
- GET_UINT32( X[13], data, 52 );
- GET_UINT32( X[14], data, 56 );
- GET_UINT32( X[15], data, 60 );
-
-#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
-
-#define P(a,b,c,d,k,s,t) \
-{ \
- a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \
-}
-
- A = ctx->state[0];
- B = ctx->state[1];
- C = ctx->state[2];
- D = ctx->state[3];
-
-#define F(x,y,z) (z ^ (x & (y ^ z)))
-
- P( A, B, C, D, 0, 7, 0xD76AA478 );
- P( D, A, B, C, 1, 12, 0xE8C7B756 );
- P( C, D, A, B, 2, 17, 0x242070DB );
- P( B, C, D, A, 3, 22, 0xC1BDCEEE );
- P( A, B, C, D, 4, 7, 0xF57C0FAF );
- P( D, A, B, C, 5, 12, 0x4787C62A );
- P( C, D, A, B, 6, 17, 0xA8304613 );
- P( B, C, D, A, 7, 22, 0xFD469501 );
- P( A, B, C, D, 8, 7, 0x698098D8 );
- P( D, A, B, C, 9, 12, 0x8B44F7AF );
- P( C, D, A, B, 10, 17, 0xFFFF5BB1 );
- P( B, C, D, A, 11, 22, 0x895CD7BE );
- P( A, B, C, D, 12, 7, 0x6B901122 );
- P( D, A, B, C, 13, 12, 0xFD987193 );
- P( C, D, A, B, 14, 17, 0xA679438E );
- P( B, C, D, A, 15, 22, 0x49B40821 );
-
-#undef F
-
-#define F(x,y,z) (y ^ (z & (x ^ y)))
-
- P( A, B, C, D, 1, 5, 0xF61E2562 );
- P( D, A, B, C, 6, 9, 0xC040B340 );
- P( C, D, A, B, 11, 14, 0x265E5A51 );
- P( B, C, D, A, 0, 20, 0xE9B6C7AA );
- P( A, B, C, D, 5, 5, 0xD62F105D );
- P( D, A, B, C, 10, 9, 0x02441453 );
- P( C, D, A, B, 15, 14, 0xD8A1E681 );
- P( B, C, D, A, 4, 20, 0xE7D3FBC8 );
- P( A, B, C, D, 9, 5, 0x21E1CDE6 );
- P( D, A, B, C, 14, 9, 0xC33707D6 );
- P( C, D, A, B, 3, 14, 0xF4D50D87 );
- P( B, C, D, A, 8, 20, 0x455A14ED );
- P( A, B, C, D, 13, 5, 0xA9E3E905 );
- P( D, A, B, C, 2, 9, 0xFCEFA3F8 );
- P( C, D, A, B, 7, 14, 0x676F02D9 );
- P( B, C, D, A, 12, 20, 0x8D2A4C8A );
-
-#undef F
-
-#define F(x,y,z) (x ^ y ^ z)
-
- P( A, B, C, D, 5, 4, 0xFFFA3942 );
- P( D, A, B, C, 8, 11, 0x8771F681 );
- P( C, D, A, B, 11, 16, 0x6D9D6122 );
- P( B, C, D, A, 14, 23, 0xFDE5380C );
- P( A, B, C, D, 1, 4, 0xA4BEEA44 );
- P( D, A, B, C, 4, 11, 0x4BDECFA9 );
- P( C, D, A, B, 7, 16, 0xF6BB4B60 );
- P( B, C, D, A, 10, 23, 0xBEBFBC70 );
- P( A, B, C, D, 13, 4, 0x289B7EC6 );
- P( D, A, B, C, 0, 11, 0xEAA127FA );
- P( C, D, A, B, 3, 16, 0xD4EF3085 );
- P( B, C, D, A, 6, 23, 0x04881D05 );
- P( A, B, C, D, 9, 4, 0xD9D4D039 );
- P( D, A, B, C, 12, 11, 0xE6DB99E5 );
- P( C, D, A, B, 15, 16, 0x1FA27CF8 );
- P( B, C, D, A, 2, 23, 0xC4AC5665 );
-
-#undef F
-
-#define F(x,y,z) (y ^ (x | ~z))
-
- P( A, B, C, D, 0, 6, 0xF4292244 );
- P( D, A, B, C, 7, 10, 0x432AFF97 );
- P( C, D, A, B, 14, 15, 0xAB9423A7 );
- P( B, C, D, A, 5, 21, 0xFC93A039 );
- P( A, B, C, D, 12, 6, 0x655B59C3 );
- P( D, A, B, C, 3, 10, 0x8F0CCC92 );
- P( C, D, A, B, 10, 15, 0xFFEFF47D );
- P( B, C, D, A, 1, 21, 0x85845DD1 );
- P( A, B, C, D, 8, 6, 0x6FA87E4F );
- P( D, A, B, C, 15, 10, 0xFE2CE6E0 );
- P( C, D, A, B, 6, 15, 0xA3014314 );
- P( B, C, D, A, 13, 21, 0x4E0811A1 );
- P( A, B, C, D, 4, 6, 0xF7537E82 );
- P( D, A, B, C, 11, 10, 0xBD3AF235 );
- P( C, D, A, B, 2, 15, 0x2AD7D2BB );
- P( B, C, D, A, 9, 21, 0xEB86D391 );
-
-#undef F
-
- ctx->state[0] += A;
- ctx->state[1] += B;
- ctx->state[2] += C;
- ctx->state[3] += D;
-}
-
-void md5_update( md5_context *ctx, uint8 *input, uint32 length )
-{
- uint32 left, fill;
-
- if( ! length ) return;
-
- left = ctx->total[0] & 0x3F;
- fill = 64 - left;
-
- ctx->total[0] += length;
- ctx->total[0] &= 0xFFFFFFFF;
-
- if( ctx->total[0] < length )
- ctx->total[1]++;
-
- if( left && length >= fill )
- {
- memcpy( (void *) (ctx->buffer + left),
- (void *) input, fill );
- md5_process( ctx, ctx->buffer );
- length -= fill;
- input += fill;
- left = 0;
- }
-
- while( length >= 64 )
- {
- md5_process( ctx, input );
- length -= 64;
- input += 64;
- }
-
- if( length )
- {
- memcpy( (void *) (ctx->buffer + left),
- (void *) input, length );
- }
-}
-
-static uint8 md5_padding[64] =
-{
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-void md5_finish( md5_context *ctx, uint8 digest[16] )
-{
- uint32 last, padn;
- uint32 high, low;
- uint8 msglen[8];
-
- high = ( ctx->total[0] >> 29 )
- | ( ctx->total[1] << 3 );
- low = ( ctx->total[0] << 3 );
-
- PUT_UINT32( low, msglen, 0 );
- PUT_UINT32( high, msglen, 4 );
-
- last = ctx->total[0] & 0x3F;
- padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
-
- md5_update( ctx, md5_padding, padn );
- md5_update( ctx, msglen, 8 );
-
- PUT_UINT32( ctx->state[0], digest, 0 );
- PUT_UINT32( ctx->state[1], digest, 4 );
- PUT_UINT32( ctx->state[2], digest, 8 );
- PUT_UINT32( ctx->state[3], digest, 12 );
-}
-
diff --git a/rbutil/mkamsboot/md5.h b/rbutil/mkamsboot/md5.h
deleted file mode 100644
index 71fa395548..0000000000
--- a/rbutil/mkamsboot/md5.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef _MD5_H
-#define _MD5_H
-
-#ifndef uint8
-#define uint8 unsigned char
-#endif
-
-#ifndef uint32
-#define uint32 unsigned long int
-#endif
-
-typedef struct
-{
- uint32 total[2];
- uint32 state[4];
- uint8 buffer[64];
-}
-md5_context;
-
-void md5_starts( md5_context *ctx );
-void md5_update( md5_context *ctx, uint8 *input, uint32 length );
-void md5_finish( md5_context *ctx, uint8 digest[16] );
-
-#endif /* md5.h */
-
diff --git a/rbutil/mkamsboot/mkamsboot.c b/rbutil/mkamsboot/mkamsboot.c
deleted file mode 100644
index 09eb15ee43..0000000000
--- a/rbutil/mkamsboot/mkamsboot.c
+++ /dev/null
@@ -1,595 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * mkamsboot.c - a tool for merging bootloader code into an Sansa V2
- * (AMS) firmware file
- *
- * Copyright (C) 2008 Dave Chapman
- *
- * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-/*
-
-Insert a Rockbox bootloader into a Sansa AMS original firmware file.
-
-Layout of a Sansa AMS original firmware file:
-
- ---------------------- 0x0
-| HEADER |
-|----------------------| 0x400
-| FIRMWARE BLOCK | (contains the OF version on some fuzev2 firmwares
-|----------------------| 0x600
-| FIRMWARE BLOCK |
-|----------------------| 0x400 + firmware block size
-| LIBRARIES/DATA |
- ---------------------- END
-
-We replace the main firmware block while preserving the potential OF version
-(bytes 0x600..0x400+firmware_size) as follows:
-
-
- ---------------------- 0x0
-| |
-| Dual-boot code |
-| |
-|----------------------|
-| EMPTY SPACE |
-|----------------------|
-| |
-| compressed RB image |
-| |
-|----------------------|
-| |
-| compressed OF image |
-| |
-|----------------------|
-| UCL unpack function |
- ----------------------
-
-This entire block fits into the space previously occupied by the main
-firmware block - the space saved by compressing the OF image is used
-to store the compressed version of the Rockbox bootloader.
-
-On version 1 firmwares, the OF image is typically about 120KB, which allows
-us to store a Rockbox bootloader with an uncompressed size of about 60KB-70KB.
-Version 2 firmwares are bigger and are stored in SDRAM (instead of IRAM).
-In both cases, the RAM we are using is mapped at offset 0x0.
-
-mkamsboot then corrects the checksums and writes a new legal firmware
-file which can be installed on the device.
-
-When the Sansa device boots, this firmware block is loaded to RAM at
-address 0x0 and executed.
-
-Firstly, the dual-boot code will copy the UCL unpack function to the
-end of RAM.
-
-Then, depending on the detection of the dual-boot keypress, either the
-OF image or the Rockbox image is copied to the end of RAM (just before
-the ucl unpack function) and uncompressed to the start of RAM.
-
-Finally, the ucl unpack function branches to address 0x0, passing
-execution to the uncompressed firmware.
-
-
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <ucl/ucl.h>
-
-#include "mkamsboot.h"
-
-#include "md5.h"
-
-/* Header for ARM code binaries */
-#include "dualboot.h"
-
-/* Win32 compatibility */
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-/* fw_revision: version 2 is used in Clipv2, Clip+ and Fuzev2 firmwares */
-/* hw_revision: 4 for m200, 2 for e200/c200, 1 or 2 for fuze/clip, 1 for clip+ */
-const struct ams_models ams_identity[] = {
- [MODEL_C200V2] = { 2, 1, "c200", dualboot_c200v2, sizeof(dualboot_c200v2), "c2v2", 44 },
- [MODEL_CLIPPLUS]= { 1, 2, "Clip+", dualboot_clipplus, sizeof(dualboot_clipplus), "cli+", 66 },
- [MODEL_CLIPV2] = { 2, 2, "Clip", dualboot_clipv2, sizeof(dualboot_clipv2), "clv2", 60 },
- [MODEL_CLIP] = { 1, 1, "Clip", dualboot_clip, sizeof(dualboot_clip), "clip", 40 },
- [MODEL_E200V2] = { 2, 1, "e200", dualboot_e200v2, sizeof(dualboot_e200v2), "e2v2", 41 },
- [MODEL_FUZEV2] = { 2, 2, "Fuze", dualboot_fuzev2, sizeof(dualboot_fuzev2), "fuz2", 68 },
- [MODEL_FUZE] = { 1, 1, "Fuze", dualboot_fuze, sizeof(dualboot_fuze), "fuze", 43 },
- [MODEL_M200V4] = { 4, 1, "m200", dualboot_m200v4, sizeof(dualboot_m200v4), "m2v4", 42 },
- [MODEL_CLIPZIP] = { 1, 2, "ClipZip", dualboot_clipzip, sizeof(dualboot_clipzip), "clzp", 79 },
-};
-
-
-/* Checksums of unmodified original firmwares - for safety, and device
- detection */
-static struct md5sums sansasums[] = {
- /* NOTE: Different regional versions of the firmware normally only
- differ in the filename - the md5sums are identical */
-
- /* model version md5 */
- { MODEL_E200V2, "3.01.11", "e622ca8cb6df423f54b8b39628a1f0a3" },
- { MODEL_E200V2, "3.01.14", "2c1d0383fc3584b2cc83ba8cc2243af6" },
- { MODEL_E200V2, "3.01.16", "12563ad71b25a1034cf2092d1e0218c4" },
-
- { MODEL_FUZE, "1.01.11", "cac8ffa03c599330ac02c4d41de66166" },
- { MODEL_FUZE, "1.01.15", "df0e2c1612727f722c19a3c764cff7f2" },
- { MODEL_FUZE, "1.01.22", "5aff5486fe8dd64239cc71eac470af98" },
- { MODEL_FUZE, "1.02.26", "7c632c479461c48c8833baed74eb5e4f" },
- { MODEL_FUZE, "1.02.28", "5b34260f6470e75f702a9c6825471752" },
- { MODEL_FUZE, "1.02.31", "66d01b37462a5ef7ccc6ad37188b4235" },
-
- { MODEL_C200V2, "3.02.05", "b6378ebd720b0ade3fad4dc7ab61c1a5" },
-
- { MODEL_M200V4, "4.00.45", "82e3194310d1514e3bbcd06e84c4add3" },
- { MODEL_M200V4, "4.01.08-A", "fc9dd6116001b3e6a150b898f1b091f0" },
- { MODEL_M200V4, "4.01.08-E", "d3fb7d8ec8624ee65bc99f8dab0e2369" },
-
- { MODEL_CLIP, "1.01.17", "12caad785d506219d73f538772afd99e" },
- { MODEL_CLIP, "1.01.18", "d720b266bd5afa38a198986ef0508a45" },
- { MODEL_CLIP, "1.01.20", "236d8f75189f468462c03f6d292cf2ac" },
- { MODEL_CLIP, "1.01.29", "c12711342169c66e209540cd1f27cd26" },
- { MODEL_CLIP, "1.01.30", "f2974d47c536549c9d8259170f1dbe4d" },
- { MODEL_CLIP, "1.01.32", "d835d12342500732ffb9c4ee54abec15" },
- { MODEL_CLIP, "1.01.35", "b4d0edb3b8f2a4e8eee0a344f7f8e480" },
-
- { MODEL_CLIPV2, "2.01.16", "c57fb3fcbe07c2c9b360f060938f80cb" },
- { MODEL_CLIPV2, "2.01.32", "0ad3723e52022509089d938d0fbbf8c5" },
- { MODEL_CLIPV2, "2.01.35", "a3cbbd22b9508d7f8a9a1a39acc342c2" },
-
- { MODEL_CLIPPLUS, "01.02.09", "656d38114774c2001dc18e6726df3c5d" },
- { MODEL_CLIPPLUS, "01.02.13", "5f89872b79ef440b0e5ee3a7a44328b2" },
- { MODEL_CLIPPLUS, "01.02.15", "680a4f521e790ad25b93b1b16f3a207d" },
- { MODEL_CLIPPLUS, "01.02.16", "055a53de1dfb09f6cb71c504ad48bd13" },
- { MODEL_CLIPPLUS, "01.02.18", "80b547244438b113e2a55ff0305f12c0" },
-
- { MODEL_FUZEV2, "2.01.17", "8b85fb05bf645d08a4c8c3e344ec9ebe" },
- { MODEL_FUZEV2, "2.02.26", "d4f6f85c3e4a8ea8f2e5acc421641801" },
- { MODEL_FUZEV2, "2.03.31", "74fb197ccd51707388f3b233402186a6" },
- { MODEL_FUZEV2, "2.03.33", "1599cc73d02ea7fe53fe2d4379c24b66" },
-
- { MODEL_CLIPZIP, "1.01.12", "45adea0873326b5af34f096e5c402f78" },
- { MODEL_CLIPZIP, "1.01.15", "f62af954334cd9ba1a87a7fa58ec6074" },
- { MODEL_CLIPZIP, "1.01.17", "27bcb343d6950f35dc261629e22ba60c" },
- { MODEL_CLIPZIP, "1.01.18", "ef16aa9e02b49885ebede5aa149502e8" },
- { MODEL_CLIPZIP, "1.01.20", "d88c8977cc6a952d3f51ece105869d97" },
- { MODEL_CLIPZIP, "1.01.21", "92c814d6e3250189706a36d2b49b6152" },
-};
-
-#define NUM_MD5S (sizeof(sansasums)/sizeof(sansasums[0]))
-
-static unsigned int model_memory_size(int model)
-{
- /* The OF boots with IRAM (320kB) mapped at 0x0 */
-
- if(model == MODEL_CLIPV2)
- {
- /* The decompressed Clipv2 OF is around 380kB.
- * Let's use the full IRAM (1MB on AMSv2)
- */
- return 1 << 20;
- }
- else
- {
- /* The IRAM is 320kB on AMSv1, and 320 will be enough on Fuzev1/Clip+ */
- return 320 << 10;
- }
-}
-
-int firmware_revision(int model)
-{
- return ams_identity[model].fw_revision;
-}
-
-static off_t filesize(int fd)
-{
- struct stat buf;
-
- if (fstat(fd, &buf) < 0) {
- perror("[ERR] Checking filesize of input file");
- return -1;
- } else {
- return(buf.st_size);
- }
-}
-
-static uint32_t get_uint32le(unsigned char* p)
-{
- return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
-}
-
-static uint32_t get_uint32be(unsigned char* p)
-{
- return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
-}
-
-static void put_uint32le(unsigned char* p, uint32_t x)
-{
- p[0] = x & 0xff;
- p[1] = (x >> 8) & 0xff;
- p[2] = (x >> 16) & 0xff;
- p[3] = (x >> 24) & 0xff;
-}
-
-void calc_MD5(unsigned char* buf, int len, char *md5str)
-{
- int i;
- md5_context ctx;
- unsigned char md5sum[16];
-
- md5_starts(&ctx);
- md5_update(&ctx, buf, len);
- md5_finish(&ctx, md5sum);
-
- for (i = 0; i < 16; ++i)
- sprintf(md5str + 2*i, "%02x", md5sum[i]);
-}
-
-/* Calculate a simple checksum used in Sansa Original Firmwares */
-static uint32_t calc_checksum(unsigned char* buf, uint32_t n)
-{
- uint32_t sum = 0;
- uint32_t i;
-
- for (i=0;i<n;i+=4)
- sum += get_uint32le(buf + i);
-
- return sum;
-}
-
-/* Compress using nrv2e algorithm : Thumb decompressor fits in 168 bytes ! */
-static unsigned char* uclpack(unsigned char* inbuf, int insize, int* outsize)
-{
- int maxsize;
- unsigned char* outbuf;
- int r;
-
- /* The following formula comes from the UCL documentation */
- maxsize = insize + (insize / 8) + 256;
-
- /* Allocate some memory for the output buffer */
- outbuf = malloc(maxsize);
-
- if (outbuf == NULL)
- return NULL;
-
- r = ucl_nrv2e_99_compress(
- (const ucl_bytep) inbuf,
- (ucl_uint) insize,
- (ucl_bytep) outbuf,
- (ucl_uintp) outsize,
- 0, 10, NULL, NULL);
-
- if (r != UCL_E_OK || *outsize > maxsize) {
- /* this should NEVER happen, and implies memory corruption */
- fprintf(stderr, "internal error - compression failed: %d\n", r);
- free(outbuf);
- return NULL;
- }
-
- return outbuf;
-}
-
-#define ERROR(format, ...) \
- do { \
- snprintf(errstr, errstrsize, format, __VA_ARGS__); \
- goto error; \
- } while(0)
-
-/* Loads a Sansa AMS Original Firmware file into memory */
-unsigned char* load_of_file(
- char* filename, int model, off_t* bufsize, struct md5sums *sum,
- int* firmware_size, unsigned char** of_packed,
- int* of_packedsize, char* errstr, int errstrsize)
-{
- int fd;
- unsigned char* buf =NULL;
- off_t n;
- unsigned int i=0;
- uint32_t checksum;
- unsigned int last_word;
-
- fd = open(filename, O_RDONLY|O_BINARY);
- if (fd < 0)
- ERROR("[ERR] Could not open %s for reading\n", filename);
-
- *bufsize = filesize(fd);
-
- buf = malloc(*bufsize);
- if (buf == NULL)
- ERROR("[ERR] Could not allocate memory for %s\n", filename);
-
- n = read(fd, buf, *bufsize);
-
- if (n != *bufsize)
- ERROR("[ERR] Could not read file %s\n", filename);
-
- /* check the file */
-
- /* Calculate MD5 checksum of OF */
- calc_MD5(buf, *bufsize, sum->md5);
-
- while ((i < NUM_MD5S) && (strcmp(sansasums[i].md5, sum->md5) != 0))
- i++;
-
- if (i < NUM_MD5S) {
- *sum = sansasums[i];
- if(sum->model != model) {
- ERROR("[ERR] OF File provided is %sv%d version %s, not for %sv%d\n",
- ams_identity[sum->model].model_name, ams_identity[sum->model].hw_revision,
- sum->version, ams_identity[model].model_name, ams_identity[model].hw_revision
- );
- }
- } else {
- /* OF unknown, give a list of tested versions for the requested model */
-
- char tested_versions[100];
- tested_versions[0] = '\0';
-
- for (i = 0; i < NUM_MD5S ; i++)
- if (sansasums[i].model == model) {
- if (tested_versions[0] != '\0') {
- strncat(tested_versions, ", ",
- sizeof(tested_versions) - strlen(tested_versions) - 1);
- }
- strncat(tested_versions, sansasums[i].version,
- sizeof(tested_versions) - strlen(tested_versions) - 1);
- }
-
- ERROR("[ERR] Original firmware unknown, please try another version."
- " Tested %sv%d versions are: %s\n",
- ams_identity[model].model_name, ams_identity[model].hw_revision, tested_versions);
- }
-
- /* TODO: Do some more sanity checks on the OF image. Some images (like
- m200v4) dont have a checksum at the end, only padding (0xdeadbeef). */
- last_word = *bufsize - 4;
- checksum = get_uint32le(buf + last_word);
- if (checksum != 0xefbeadde && checksum != calc_checksum(buf, last_word))
- ERROR("%s", "[ERR] Whole file checksum failed\n");
-
- if (ams_identity[sum->model].bootloader == NULL)
- ERROR("[ERR] Unsupported model - \"%s\"\n", ams_identity[sum->model].model_name);
-
- /* Get the firmware size */
- if (ams_identity[sum->model].fw_revision == 1)
- *firmware_size = get_uint32le(&buf[0x0c]);
- else if (ams_identity[sum->model].fw_revision == 2)
- *firmware_size = get_uint32le(&buf[0x10]);
-
- /* Compress the original firmware image */
- *of_packed = uclpack(buf + 0x400, *firmware_size, of_packedsize);
- if (*of_packed == NULL)
- ERROR("[ERR] Could not compress %s\n", filename);
-
- return buf;
-
-error:
- free(buf);
- return NULL;
-}
-
-/* Loads a rockbox bootloader file into memory */
-unsigned char* load_rockbox_file(
- char* filename, int *model, int* bufsize, int* rb_packedsize,
- char* errstr, int errstrsize)
-{
- int fd;
- unsigned char* buf = NULL;
- unsigned char* packed = NULL;
- unsigned char header[8];
- uint32_t sum;
- off_t n;
- int i;
-
- fd = open(filename, O_RDONLY|O_BINARY);
- if (fd < 0)
- ERROR("[ERR] Could not open %s for reading\n", filename);
-
- /* Read Rockbox header */
- n = read(fd, header, sizeof(header));
- if (n != sizeof(header))
- ERROR("[ERR] Could not read file %s\n", filename);
-
- for(*model = 0; *model < NUM_MODELS; (*model)++)
- if (memcmp(ams_identity[*model].rb_model_name, header + 4, 4) == 0)
- break;
-
- if(*model == NUM_MODELS)
- ERROR("[ERR] Model name \"%4.4s\" unknown. Is this really a rockbox bootloader?\n", header + 4);
-
- *bufsize = filesize(fd) - sizeof(header);
-
- buf = malloc(*bufsize);
- if (buf == NULL)
- ERROR("[ERR] Could not allocate memory for %s\n", filename);
-
- n = read(fd, buf, *bufsize);
-
- if (n != *bufsize)
- ERROR("[ERR] Could not read file %s\n", filename);
-
- /* Check checksum */
- sum = ams_identity[*model].rb_model_num;
- for (i = 0; i < *bufsize; i++) {
- /* add 8 unsigned bits but keep a 32 bit sum */
- sum += buf[i];
- }
-
- if (sum != get_uint32be(header))
- ERROR("[ERR] Checksum mismatch in %s\n", filename);
-
- packed = uclpack(buf, *bufsize, rb_packedsize);
- if(packed == NULL)
- ERROR("[ERR] Could not compress %s\n", filename);
-
- free(buf);
- return packed;
-
-error:
- free(buf);
- return NULL;
-}
-
-#undef ERROR
-
-/* Patches a Sansa AMS Original Firmware file */
-void patch_firmware(
- int model, int fw_revision, int firmware_size, unsigned char* buf,
- int len, unsigned char* of_packed, int of_packedsize,
- unsigned char* rb_packed, int rb_packedsize)
-{
- unsigned char *p;
- uint32_t sum, filesum;
- uint32_t ucl_dest;
- unsigned int i;
-
- /* Zero the original firmware area - not needed, but helps debugging */
- memset(buf + 0x600, 0, firmware_size);
-
- /* Insert dual-boot bootloader at offset 0x200, we preserve the OF
- * version string located between 0x0 and 0x200 */
- memcpy(buf + 0x600, ams_identity[model].bootloader, ams_identity[model].bootloader_size);
-
- /* Insert vectors, they won't overwrite the OF version string */
- static const uint32_t goto_start = 0xe3a0fc02; // mov pc, #0x200
- static const uint32_t infinite_loop = 0xeafffffe; // 1: b 1b
- /* ALL vectors: infinite loop */
- for (i=0; i < 8; i++)
- put_uint32le(buf + 0x400 + 4*i, infinite_loop);
- /* Now change only the interesting vectors */
- /* Reset/SWI vectors: branch to our dualboot code at 0x200 */
- put_uint32le(buf + 0x400 + 4*0, goto_start); // Reset
- put_uint32le(buf + 0x400 + 4*2, goto_start); // SWI
-
- /* We are filling the firmware buffer backwards from the end */
- p = buf + 0x400 + firmware_size;
-
- /* 1 - UCL unpack function */
- p -= sizeof(nrv2e_d8);
- memcpy(p, nrv2e_d8, sizeof(nrv2e_d8));
-
- /* 2 - Compressed copy of original firmware */
- p -= of_packedsize;
- memcpy(p, of_packed, of_packedsize);
-
- /* 3 - Compressed copy of Rockbox bootloader */
- p -= rb_packedsize;
- memcpy(p, rb_packed, rb_packedsize);
-
- /* Write the locations of the various images to the variables at the
- start of the dualboot image - we save the location of the last byte
- in each image, along with the size in bytes */
-
- /* UCL unpack function */
- put_uint32le(&buf[0x604], firmware_size - 1);
- put_uint32le(&buf[0x608], sizeof(nrv2e_d8));
-
- /* Compressed original firmware image */
- put_uint32le(&buf[0x60c], firmware_size - sizeof(nrv2e_d8) - 1);
- put_uint32le(&buf[0x610], of_packedsize);
-
- /* Compressed Rockbox image */
- put_uint32le(&buf[0x614], firmware_size - sizeof(nrv2e_d8) - of_packedsize
- - 1);
- put_uint32le(&buf[0x618], rb_packedsize);
-
- ucl_dest = model_memory_size(model) - 1; /* last byte of memory */
- put_uint32le(&buf[0x61c], ucl_dest);
-
- /* Update the firmware block checksum */
- sum = calc_checksum(buf + 0x400, firmware_size);
-
- if (fw_revision == 1) {
- put_uint32le(&buf[0x04], sum);
- put_uint32le(&buf[0x204], sum);
- } else if (fw_revision == 2) {
- put_uint32le(&buf[0x08], sum);
- put_uint32le(&buf[0x208], sum);
-
- /* Update the header checksums */
- put_uint32le(&buf[0x1fc], calc_checksum(buf, 0x1fc));
- put_uint32le(&buf[0x3fc], calc_checksum(buf + 0x200, 0x1fc));
- }
-
- /* Update the whole-file checksum */
- filesum = 0;
- for (i=0;i < (unsigned)len - 4; i+=4)
- filesum += get_uint32le(&buf[i]);
-
- put_uint32le(buf + len - 4, filesum);
-}
-
-/* returns != 0 if the firmware can be safely patched */
-int check_sizes(int model, int rb_packed_size, int rb_unpacked_size,
- int of_packed_size, int of_unpacked_size, int *total_size,
- char *errstr, int errstrsize)
-{
- /* XXX: we keep the first 0x200 bytes block unmodified, we just replace
- * the ARM vectors */
- unsigned int packed_size = ams_identity[model].bootloader_size + sizeof(nrv2e_d8) +
- of_packed_size + rb_packed_size + 0x200;
-
- /* how much memory is available */
- unsigned int memory_size = model_memory_size(model);
-
- /* the memory used when unpacking the OF */
- unsigned int ram_of = sizeof(nrv2e_d8) + of_packed_size + of_unpacked_size;
-
- /* the memory used when unpacking the bootloader */
- unsigned int ram_rb = sizeof(nrv2e_d8) + rb_packed_size + rb_unpacked_size;
-
- *total_size = packed_size;
-
-#define ERROR(format, ...) \
- do { \
- snprintf(errstr, errstrsize, format, __VA_ARGS__); \
- return 0; \
- } while(0)
-
- /* will packed data fit in the OF file ? */
- if(packed_size > of_unpacked_size)
- ERROR(
- "[ERR] Packed data (%d bytes) doesn't fit in the firmware "
- "(%d bytes)\n", packed_size, of_unpacked_size
- );
-
- else if(ram_rb > memory_size)
- ERROR("[ERR] Rockbox can't be unpacked at runtime, needs %d bytes "
- "of memory and only %d available\n", ram_rb, memory_size
- );
-
- else if(ram_of > memory_size)
- ERROR("[ERR] OF can't be unpacked at runtime, needs %d bytes "
- "of memory and only %d available\n", ram_of, memory_size
- );
-
- return 1;
-
-#undef ERROR
-}
diff --git a/rbutil/mkamsboot/mkamsboot.h b/rbutil/mkamsboot/mkamsboot.h
deleted file mode 100644
index 263fe9e9c1..0000000000
--- a/rbutil/mkamsboot/mkamsboot.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * mkamsboot.h - a tool for merging bootloader code into an Sansa V2
- * (AMS) firmware file
- *
- * Copyright (C) 2008 Dave Chapman
- *
- * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#ifndef MKAMSBOOT_H
-#define MKAMSBOOT_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Supported models */
-enum {
- MODEL_UNKNOWN = -1,
- MODEL_FUZE = 0,
- MODEL_CLIP,
- MODEL_CLIPV2,
- MODEL_E200V2,
- MODEL_M200V4,
- MODEL_C200V2,
- MODEL_CLIPPLUS,
- MODEL_FUZEV2,
- MODEL_CLIPZIP,
- /* new models go here */
-
- NUM_MODELS
-};
-
-
-/* Holds info about the OF */
-struct md5sums {
- int model;
- char *version;
- char *md5;
-};
-
-struct ams_models {
- unsigned short hw_revision;
- unsigned short fw_revision;
- /* Descriptive name of this model */
- const char* model_name;
- /* Dualboot functions for this model */
- const unsigned char* bootloader;
- /* Size of dualboot functions for this model */
- int bootloader_size;
- /* Model name used in the Rockbox header in ".sansa" files - these match the
- -add parameter to the "scramble" tool */
- const char* rb_model_name;
- /* Model number used to initialise the checksum in the Rockbox header in
- ".sansa" files - these are the same as MODEL_NUMBER in config-target.h */
- const int rb_model_num;
-};
-extern const struct ams_models ams_identity[];
-
-/* load_rockbox_file()
- *
- * Loads a rockbox bootloader file into memory
- *
- * ARGUMENTS
- *
- * filename : bootloader file to load
- * model : will be set to this bootloader's model
- * bootloader_size : set to the uncompressed bootloader size
- * rb_packed_size : set to the size of compressed bootloader
- * errstr : provided buffer to store an eventual error
- * errstrsize : size of provided error buffer
- *
- * RETURN VALUE
- * pointer to allocated memory containing the content of compressed bootloader
- * or NULL in case of error (errstr will hold a description of the error)
- */
-
-unsigned char* load_rockbox_file(
- char* filename, int *model, int* bootloader_size, int* rb_packedsize,
- char* errstr, int errstrsize);
-
-
-/* load_of_file()
- *
- * Loads a Sansa AMS Original Firmware file into memory
- *
- * ARGUMENTS
- *
- * filename : firmware file to load
- * model : desired player's model
- * bufsize : set to firmware file size
- * md5sum : set to file md5sum, must be at least 33 bytes long
- * firmware_size : set to firmware block's size
- * of_packed : pointer to allocated memory containing the compressed
- * original firmware block
- * of_packedsize : size of compressed original firmware block
- * errstr : provided buffer to store an eventual error
- * errstrsize : size of provided error buffer
- *
- * RETURN VALUE
- * pointer to allocated memory containing the content of Original Firmware
- * or NULL in case of error (errstr will hold a description of the error)
- */
-
-unsigned char* load_of_file(
- char* filename, int model, off_t* bufsize, struct md5sums *sum,
- int* firmware_size, unsigned char** of_packed,
- int* of_packedsize, char* errstr, int errstrsize);
-
-
-/* patch_firmware()
- *
- * Patches a Sansa AMS Original Firmware file
- *
- * ARGUMENTS
- *
- * model : firmware model (MODEL_XXX)
- * fw_version : firmware format version (1 or 2)
- * firmware_size : size of uncompressed original firmware block
- * buf : pointer to original firmware file
- * len : size of original firmware file
- * of_packed : pointer to compressed original firmware block
- * of_packedsize : size of compressed original firmware block
- * rb_packed : pointer to compressed rockbox bootloader
- * rb_packed_size : size of compressed rockbox bootloader
- */
-
-void patch_firmware(
- int model, int fw_version, int firmware_size, unsigned char* buf,
- int len, unsigned char* of_packed, int of_packedsize,
- unsigned char* rb_packed, int rb_packedsize);
-
-
-/* check_sizes()
- *
- * Verify if the given bootloader can be embedded in the OF file, while still
- * allowing both the bootloader and the OF to be unpacked at runtime
- *
- * ARGUMENTS
- *
- * model : firmware model (MODEL_XXX)
- * rb_packed_size : size of compressed rockbox bootloader
- * rb_unpacked_size : size of compressed rockbox bootloader
- * of_packed_size : size of compressed original firmware block
- * of_unpacked_size : size of compressed original firmware block
- * total_size : will contain the size of useful data that would be
- * written to the firmware block, even in case of an
- * error
- * errstr : provided buffer to store an eventual error
- * errstrsize : size of provided error buffer
- *
- * RETURN VALUE
- * 0 if the conditions aren't met, 1 if we can go and patch the firmware
-*/
-
-int check_sizes(int model, int rb_packed_size, int rb_unpacked_size,
- int of_packed_size, int of_unpacked_size, int *total_size,
- char *errstr, int errstrsize);
-
-/* firmware_revision()
- *
- * returns the firmware revision for a particular model
- *
- * ARGUMENTS
- *
- * model : firmware model (MODEL_XXX)
- *
- * RETURN VALUE
- * firmware version
-*/
-int firmware_revision(int model);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif