summaryrefslogtreecommitdiffstats
path: root/rbutil/e200rpatcher
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2021-12-15 21:04:28 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2021-12-24 18:05:53 +0100
commitc876d3bbefe0dc00c27ca0c12d29da5874946962 (patch)
tree69f468a185a369b01998314bc3ecc19b70f4fcaa /rbutil/e200rpatcher
parent6c6f0757d7a902feb293be165d1490c42bc8e7ad (diff)
downloadrockbox-c876d3bbefe0dc00c27ca0c12d29da5874946962.tar.gz
rockbox-c876d3bbefe0dc00c27ca0c12d29da5874946962.zip
rbutil: Merge rbutil with utils folder.
rbutil uses several components from the utils folder, and can be considered part of utils too. Having it in a separate folder is an arbitrary split that doesn't help anymore these days, so merge them. This also allows other utils to easily use libtools.make without the need to navigate to a different folder. Change-Id: I3fc2f4de19e3e776553efb5dea5f779dfec0dc21
Diffstat (limited to 'rbutil/e200rpatcher')
-rw-r--r--rbutil/e200rpatcher/Makefile56
-rw-r--r--rbutil/e200rpatcher/README48
-rw-r--r--rbutil/e200rpatcher/e200rpatcher.c241
-rw-r--r--rbutil/e200rpatcher/e200rpatcher.manifest13
-rw-r--r--rbutil/e200rpatcher/e200rpatcher.rc1
5 files changed, 0 insertions, 359 deletions
diff --git a/rbutil/e200rpatcher/Makefile b/rbutil/e200rpatcher/Makefile
deleted file mode 100644
index dfe5c1e037..0000000000
--- a/rbutil/e200rpatcher/Makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-CFLAGS=-Wall -W
-
-ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
-OUTPUT=e200rpatcher.exe
-CROSS=
-CFLAGS+=-mno-cygwin
-else
-OUTPUT=e200rpatcher
-CROSS=i586-mingw32msvc-
-endif
-
-LIBS = -lusb
-WINLIBS = -I libusb-win32-device-bin-0.1.12.1/include libusb-win32-device-bin-0.1.12.1/lib/dynamic/libusb_dyn.c
-
-NATIVECC = gcc
-CC = $(CROSS)gcc
-WINDRES = $(CROSS)windres
-
-all: $(OUTPUT)
-
-e200rpatcher: e200rpatcher.c bootimg.c
- gcc $(CFLAGS) $(LIBS) -o e200rpatcher e200rpatcher.c bootimg.c
- strip e200rpatcher
-
-e200rpatcher.exe: e200rpatcher.c bootimg.c e200rpatcher-rc.o
- $(CC) $(CFLAGS) $(WINLIBS) -o e200rpatcher.exe e200rpatcher.c bootimg.c e200rpatcher-rc.o
- $(CROSS)strip e200rpatcher.exe
-
-e200rpatcher-rc.o: e200rpatcher.rc e200rpatcher.manifest
- $(WINDRES) -i e200rpatcher.rc -o e200rpatcher-rc.o
-
-e200rpatcher-mac: e200rpatcher-i386 e200rpatcher-ppc
- lipo -create e200rpatcher-ppc e200rpatcher-i386 -output e200rpatcher-mac
-
-e200rpatcher.dmg: e200rpatcher-mac
- mkdir -p e200rpatcher-dmg
- cp -p e200rpatcher-mac e200rpatcher-dmg
- hdiutil create -srcfolder e200rpatcher-dmg e200rpatcher.dmg
-
-e200rpatcher-i386: e200rpatcher.c bootimg.c usb.h libusb-i386.a
- gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -framework iokit -framework coreservices -arch i386 $(CFLAGS) -o e200rpatcher-i386 e200rpatcher.c bootimg.c -I. libusb-i386.a
- strip e200rpatcher-i386
-
-e200rpatcher-ppc: e200rpatcher.c bootimg.c usb.h libusb-ppc.a
- gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -framework iokit -framework coreservices -arch ppc $(CFLAGS) -o e200rpatcher-ppc e200rpatcher.c bootimg.c -I. libusb-ppc.a
- strip e200rpatcher-ppc
-
-bin2c: ../tools/bin2c.c
- $(NATIVECC) $(CFLAGS) -o bin2c ../tools/bin2c.c
-
-bootimg.c: bootloader.bin bin2c
- ./bin2c bootloader.bin bootimg
-
-clean:
- rm -f e200rpatcher.exe e200rpatcher-mac e200rpatcher-i386 e200rpatcher-ppc e200rpatcher bin2c bootimg.c bootimg.h *~ e200rpatcher.dmg
- rm -rf e200rpatcher-dmg
diff --git a/rbutil/e200rpatcher/README b/rbutil/e200rpatcher/README
deleted file mode 100644
index 1942b3aa7a..0000000000
--- a/rbutil/e200rpatcher/README
+++ /dev/null
@@ -1,48 +0,0 @@
-INTRODUCTION
-
-e200rpatcher is a tool for uploading and executing an application to
-an E200R in manufacturing mode. It is intended to be used to upload
-the patching application to allow Rockbox installs.
-
-e200rpatcher requires libusb (v0.1.2 has been tested successfully) for
-cross-platform USB access. No-one has yet successfully installed
-e200rpatcher on Windows, but it works on Linux and Mac OS X (and
-should be fine on other Unix-like systems that libusb supports).
-
-GENERAL BUILD INSTRUCTIONS
-
-A pre-requisite for compiling e200rpatcher is a file called
-"bootloader.bin" - this is the output of running an "I" (installer)
-build for the E200R target.
-
-In the Rockbox source directory, do:
-
-mkdir build-e200rbootbin
-cd build-e200rbootbin
-../tools/configure
-[Select E200R, then I for installer]
-make
-
-This should give you a bootloader/bootloader/bin file which you should
-copy to the e200rpatcher source directory.
-
-BUILDING ON LINUX
-
-The Makefile expects libusb (and the headers) to be installed on your
-system and will link dynamically. Just type "make".
-
-BUILDING ON A MAC
-
-To build the mac version (target e200rpatcher-mac in the Makefile)
-requires three files from libusb to be copied to the current
-directory:
-
-usb.h (copied from your libusb build directory)
-libusb-i386.a (copied and renamed from .libs/libusb.a in an i386 build)
-libusb-ppc.a (copied and renamed from .libs/libusb.a in a PPC build)
-
-To build the required libusb.a files, just run ./configure && make for
-libusb. If anyone knows how to cross-compile a static libusb.a please
-make the information known - this is currently done by compiling
-natively on the appropriate hardware.
-
diff --git a/rbutil/e200rpatcher/e200rpatcher.c b/rbutil/e200rpatcher/e200rpatcher.c
deleted file mode 100644
index be09370997..0000000000
--- a/rbutil/e200rpatcher/e200rpatcher.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 Dave Chapman
- *
- * USB code based on ifp-line - http://ifp-driver.sourceforge.net
- *
- * ifp-line is (C) Pavel Kriz, Jun Yamishiro and Joe Roback and
- * licensed under the GPL (v2)
- *
- *
- * 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 <inttypes.h>
-#include <usb.h>
-#include <string.h>
-#include "stdbool.h"
-
-#include "bootimg.h"
-
-#define VERSION "0.2"
-
-/* USB IDs for Manufacturing Mode */
-#define E200R_VENDORID 0x0781
-#define E200R_PRODUCTID 0x0720
-
-#define E200R_BULK_TO 1
-#define TOUT 5000
-#define MAX_TRANSFER 64 /* Number of bytes to send in one write */
-
-#ifndef MAX
-#define MAX(a,b) (((a)>(b))?(a):(b))
-#endif
-
-static void put_int32le(uint32_t x, char* p)
-{
- p[0] = x & 0xff;
- p[1] = (x >> 8) & 0xff;
- p[2] = (x >> 16) & 0xff;
- p[3] = (x >> 24) & 0xff;
-}
-
-int upload_app(usb_dev_handle* dh)
-{
- char buf[4];
- int err;
- int tosend;
- char* p = (char*)bootimg;
- int bytesleft = LEN_bootimg;
-
- /* Write the data length */
-
- put_int32le(LEN_bootimg, buf);
-
- err = usb_bulk_write(dh, E200R_BULK_TO, buf, 4, TOUT);
-
- if (err < 0)
- {
- fprintf(stderr,"[ERR] Error writing data length\n");
- fprintf(stderr,"[ERR] Bulk write error (%d, %s)\n", err, strerror(-err));
- return -1;
- }
-
- /* Now send the data, MAX_TRANSFER bytes at a time. */
-
- while (bytesleft > 0)
- {
- tosend = MAX(MAX_TRANSFER, bytesleft);
-
- err = usb_bulk_write(dh, E200R_BULK_TO, p, tosend, TOUT);
-
- if (err < 0)
- {
- fprintf(stderr,"[ERR] Error writing data\n");
- fprintf(stderr,"[ERR] Bulk write error (%d, %s)\n", err, strerror(-err));
- return -1;
- }
-
- p += tosend;
- bytesleft -= tosend;
- }
-
- return 0;
-}
-
-
-/* The main function */
-
-void do_patching(void)
-{
- struct usb_bus *busses;
- struct usb_bus *bus;
- struct usb_device *tmp_dev;
- struct usb_device *dev = NULL;
- usb_dev_handle *dh;
- int err;
-
- fprintf(stderr,"[INFO] Searching for E200R\n");
-
- usb_init();
-
- if(usb_find_busses() < 0) {
- fprintf(stderr, "[ERR] Could not find any USB busses.\n");
- return;
- }
-
- if (usb_find_devices() < 0) {
- fprintf(stderr, "[ERR] USB devices not found(nor hubs!).\n");
- return;
- }
-
- /* C calling convention, it's not nice to use global stuff */
- busses = usb_get_busses();
-
- for (bus = busses; bus; bus = bus->next) {
- for (tmp_dev = bus->devices; tmp_dev; tmp_dev = tmp_dev->next) {
- if (tmp_dev->descriptor.idVendor == E200R_VENDORID &&
- tmp_dev->descriptor.idProduct == E200R_PRODUCTID ) {
-
- dev = tmp_dev;
- goto found;
-
- }
- }
- }
-
- if (dev == NULL) {
- fprintf(stderr, "[ERR] E200R device not found.\n");
- fprintf(stderr, "[ERR] Ensure your E200R is in manufacturing mode and run e200rpatcher again.\n");
- return;
- }
-
-found:
- if ( (dh = usb_open(dev)) == NULL) {
- fprintf(stderr,"[ERR] Unable to open E200R device.\n");
- return;
- }
-
- err = usb_set_configuration(dh, 1);
-
- if (err < 0) {
- fprintf(stderr, "[ERR] usb_set_configuration failed (%d)\n", err);
- usb_close(dh);
- return;
- }
-
- /* "must be called" written in the libusb documentation */
- err = usb_claim_interface(dh, dev->config->interface->altsetting->bInterfaceNumber);
- if (err < 0) {
- fprintf(stderr, "[ERR] Unable to claim interface (%d)\n", err);
- usb_close(dh);
- return;
- }
-
- fprintf(stderr,"[INFO] Found E200R, uploading patching application.\n");
-
- /* Now we can transfer the application to the device. */
-
- if (upload_app(dh) < 0)
- {
- fprintf(stderr,"[ERR] Upload of application failed.\n");
- }
- else
- {
- fprintf(stderr,"[INFO] Patching application uploaded successfully!\n");
- }
-
- /* release claimed interface */
- usb_release_interface(dh, dev->config->interface->altsetting->bInterfaceNumber);
-
- usb_close(dh);
-}
-void print_usage(void)
-{
- fprintf(stderr,"Usage: e200rpatcher [options]\n");
- fprintf(stderr,"Options:\n");
- fprintf(stderr," -s, --silent\t\tDont display instructions\n");
-}
-
-int main(int argc, char* argv[])
-{
- char input[4];
- int silent = 0;
- int i;
-
- /* check args */
- if ((argc > 1) && ((strcmp(argv[1],"-h")==0) || (strcmp(argv[1],"--help")==0))) {
- print_usage();
- return 1;
- }
- for (i=1;i<argc;i++)
- {
- if (!strcmp(argv[i], "--silent") || !strcmp(argv[i], "-s"))
- silent = 1;
- }
-
- printf("e200rpatcher v" VERSION " - (C) 2007 Jonathan Gordon & Dave Chapman\n");
- printf("This is free software; see the source for copying conditions. There is NO\n");
- printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
-
- if (!silent)
- {
- printf("Attach your E200R in \"manufacturing mode\" as follows:\n");
- printf(" 1) Power-off your E200R\n");
- printf(" 2) Turn ON the lock/hold switch\n");
- printf(" 3) Press and hold the SELECT button and whilst it is held down,\n");
- printf(" attach your E200R to your computer via USB\n");
- printf(" 4) After attaching to USB, keep the SELECT button held for 10 seconds.\n");
- printf("\n");
- printf("NOTE: If your E200R starts in the normal Sansa firmware, you have\n");
- printf(" failed to enter manufacturing mode and should try again at step 1).\n\n");
-
- printf("[INFO] Press Enter to continue:");
- fgets(input, 4, stdin);
- }
- do_patching();
-
- if (!silent)
- {
- printf("[INFO] Press ENTER to exit: ");
- fgets(input, 4, stdin);
- }
-
- return 0;
-}
diff --git a/rbutil/e200rpatcher/e200rpatcher.manifest b/rbutil/e200rpatcher/e200rpatcher.manifest
deleted file mode 100644
index ec0c49df33..0000000000
--- a/rbutil/e200rpatcher/e200rpatcher.manifest
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
- <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="e200rpatcher.exe" type="win32"/>
-
- <!-- Identify the application security requirements. -->
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
- <security>
- <requestedPrivileges>
- <requestedExecutionLevel level="requireAdministrator"/>
- </requestedPrivileges>
- </security>
- </trustInfo>
-</assembly>
diff --git a/rbutil/e200rpatcher/e200rpatcher.rc b/rbutil/e200rpatcher/e200rpatcher.rc
deleted file mode 100644
index 4d80442d44..0000000000
--- a/rbutil/e200rpatcher/e200rpatcher.rc
+++ /dev/null
@@ -1 +0,0 @@
-1 24 MOVEABLE PURE "e200rpatcher.manifest"