From 0eb5d5ecae36a2bdee6518ecaebc76d7a31f21bd Mon Sep 17 00:00:00 2001 From: Kano Date: Sun, 22 Jan 2012 00:03:02 +1100 Subject: [PATCH 1/3] Fix send() for JSON strings --- api-example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-example.c b/api-example.c index 4c76135d..0a327e88 100755 --- a/api-example.c +++ b/api-example.c @@ -214,7 +214,7 @@ int callapi(char *command, char *host, short int port) return 1; } - n = send(sock, command, strlen(command)+1, 0); + n = send(sock, command, strlen(command), 0); if (SOCKETFAIL(n)) { printf("Send failed: %s\n", SOCKERRMSG); ret = 1; From b2e15e493e92a5f7c3fd92859d11fe4f88051f07 Mon Sep 17 00:00:00 2001 From: Kano Date: Sun, 22 Jan 2012 00:06:31 +1100 Subject: [PATCH 2/3] Include HDD install details and related changes --- linux-usb-cgminer | 100 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/linux-usb-cgminer b/linux-usb-cgminer index a529263f..f3d3b541 100644 --- a/linux-usb-cgminer +++ b/linux-usb-cgminer @@ -12,6 +12,14 @@ The copy in cgminer (check to make sure it isn't older) is: The original old verion on bitcointalk is: https://bitcointalk.org/index.php?topic=28402.msg426741#msg426741 +======== + +I have said to select English for the install process for 2 reasons: +1) I don't know any other spoken language very well +and +2) I'm not sure what problems installing under a different language +might cause (it will probably cause no problems but I don't know) + Software ======== Short hardware comment: @@ -19,7 +27,10 @@ Your mining computer doesn't need any HDD or CD/DVD/BD as long as it has at least 2GB of RAM, can boot USB, has some network connection to the internet and of course a reasonable mining ATI graphics card ... Or you can boot a windows PC with the USB to only do mining ... and ignore -the system HDD ... wasting energy running the HDD :) +the system HDD ... wasting energy running the HDD (roughly 10 Watts per HDD) :) + +If you wish to install to an HDD instead of a USB, + see the changes to the instructions at the end To create the USB, you need of course a 4GB USB and temporarily need a PC with a CD (or DVD/BD) writer, a USB port and of course an internet @@ -30,6 +41,9 @@ connection to the PC 2) Burn it to CD then boot that temporarily on any PC with a CD/DVD/BD and a USB port (this and the next 2 step won't effect that PC) + Select "English" then select "Try Xubuntu without installing" + and wait for the desktop to appear + (this happens by default if you wait for the timeouts) 3) Plug in your 4GB USB device and it should appear on the desktop - you can leave it's contents as long as there is at least 2.8GB free @@ -205,3 +219,87 @@ The fix is to simply link the old curses library to the new name e.g.: cd /lib64/ sudo ln -s libncurses.so.5 libtinfo.so.5 + +======== + +If you wish to install to an HDD instead of a USB: +-------------------------------------------------- + +As per before: + +1) Download the xubuntu 11.04 desktop live CD iso for amd64 + ( look here for mirrors: http://www.xubuntu.org/getubuntu ) + +Then: + +2) Burn it to CD then boot that on your new mining PC + Select "English" then select "Install Xubuntu" + (you have 30 seconds to do this) + +3) When the Install window comes up - again select "English" and click "Forward" + +4) The next page will show you if you meet certain install requirements + (make sure you do meet them all) + Don't select the download option + The 3rd party option isn't needed for mining so ignore that also + + Click "Forward" + +5) With "Allocate drive space" it's probably easiest to say to use the + "Erase" option. + + This is just for mining right? :) + + However, if you have anything on the HDD that you want to keep - the + "Erase" install process will delete it - so back it up (quit the install) + Also make sure there are no OTHER HDD attached that it may erase also + i.e. only have attached the one HDD that you want to install onto unless + you know exactly what you are doing + + If you see the "Install Xubuntu 11.04 alongside 'something'" then that + just means that the HDD wasn't blank. + If you want to try this option - do that yourself and then skip to step + 7) below when you get to that. + + There are plenty of other options available if you select "Something else" + but I'm not going to go into all the details here other than to say that + my preferred partioning is: /boot = 1GB = ext2, swap = twice memory size, + / = 100GB = ext3 and the rest: /extra = ext3 + + Click "Forward" + +6) If you selected "Erase" then it allows you to choose the drive to install to + Then click "Install Now" + +7) "Where are you?" sort that out then click "Forward" + +8) "Keyboard layout" sort that out (use the default) then click "Forward" + +9) "Who are you?" The important one here is "Pick a username:" coz that's + the name you will need to ssh into, to access it remotely (and of course + the "Choose a Password" you set) + + If you set the "username" to anything but "ubuntu" then: wherever in this + document I have mentioned the username "ubuntu" you must of course use the + username you chose here instead of "ubuntu" + + Important: set it to "log in automatically" if you ever want to be able + to start cgminer without being in front of the computer since 'X' must + be running to use cgminer properly + That does of course mean that the computer isn't secure from anyone who + has access to it - but then again no computer that can automatically + reboot is secure from anyone who has access to the actual computer itself + + Then click "Forward" + +10) Of course when it completes click on "Restart Now" + ... and remove the Xubuntu CD when it asks you + +11) Wait for it to finish rebooting ... and it will auto login + (unless you didn't do step 9) "Important:") + +12) After it logs in, an upgrade popup for 11.10 (or later) will appear + Select "Don't Upgrade" + +13) Now go to step 6) of the USB script above for what to do next and that + covers everything else needed From 8e275d9f23e6b7ecc3f1e994e74fc83a2c54ba3a Mon Sep 17 00:00:00 2001 From: Kano Date: Sun, 22 Jan 2012 00:13:27 +1100 Subject: [PATCH 3/3] Make all CPU code compile time optional - off by default --- api.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/api.c b/api.c index 73cd3b19..14760edf 100644 --- a/api.c +++ b/api.c @@ -1,5 +1,5 @@ /* - * Copyright 2011 Andrew Smith + * Copyright 2011-2012 Andrew Smith * Copyright 2011-2012 Con Kolivas * * This program is free software; you can redistribute it and/or modify it @@ -150,7 +150,11 @@ static const char SEPARATOR = '|'; #define _SUMMARY "SUMMARY" #define _STATUS "STATUS" #define _VERSION "VERSION" + +#ifdef WANT_CPUMINE #define _CPU "CPU" +#endif + #define _GPU "GPU" #define _CPUS "CPUS" #define _GPUS "GPUS" @@ -170,7 +174,11 @@ static const char ISJSON = '{'; #define JSON_STATUS JSON1 _STATUS JSON2 #define JSON_VERSION JSON1 _VERSION JSON2 #define JSON_GPU JSON1 _GPU JSON2 + +#ifdef WANT_CPUMINE #define JSON_CPU JSON1 _CPU JSON2 +#endif + #define JSON_GPUS JSON1 _GPUS JSON2 #define JSON_CPUS JSON1 _CPUS JSON2 #define JSON_BYE JSON1 _BYE JSON1 @@ -195,10 +203,14 @@ static const char *JSON_PARAMETER = "parameter"; #define MSG_GPUREI 13 #define MSG_INVCMD 14 #define MSG_MISID 15 -#define MSG_CPUNON 16 #define MSG_GPUDEV 17 + +#ifdef WANT_CPUMINE +#define MSG_CPUNON 16 #define MSG_CPUDEV 18 #define MSG_INVCPU 19 +#endif + #define MSG_NUMGPU 20 #define MSG_NUMCPU 21 #define MSG_VERSION 22 @@ -219,7 +231,11 @@ enum code_parameters { PARAM_GPUMAX, PARAM_CPUMAX, PARAM_PMAX, +#ifdef WANT_CPUMINE PARAM_GCMAX, +#else + PARAM_GMAX, +#endif PARAM_CMD, PARAM_NONE }; @@ -238,26 +254,33 @@ struct CODES { { SEVERITY_ERR, MSG_GPUNON, PARAM_NONE, "No GPUs" }, { SEVERITY_SUCC, MSG_POOL, PARAM_PMAX, "%d Pool(s)" }, { SEVERITY_ERR, MSG_NOPOOL, PARAM_NONE, "No pools" }, +#ifdef WANT_CPUMINE { SEVERITY_SUCC, MSG_DEVS, PARAM_GCMAX, "%d GPU(s) - %d CPU(s)" }, { SEVERITY_ERR, MSG_NODEVS, PARAM_NONE, "No GPUs/CPUs" }, +#else + { SEVERITY_SUCC, MSG_DEVS, PARAM_GMAX, "%d GPU(s)" }, + { SEVERITY_ERR, MSG_NODEVS, PARAM_NONE, "No GPUs" }, +#endif { SEVERITY_SUCC, MSG_SUMM, PARAM_NONE, "Summary" }, { SEVERITY_INFO, MSG_GPUDIS, PARAM_GPU, "GPU %d set disable flag" }, { SEVERITY_INFO, MSG_GPUREI, PARAM_GPU, "GPU %d restart attempted" }, { SEVERITY_ERR, MSG_INVCMD, PARAM_NONE, "Invalid command" }, { SEVERITY_ERR, MSG_MISID, PARAM_NONE, "Missing device id parameter" }, - { SEVERITY_ERR, MSG_CPUNON, PARAM_NONE, "No CPUs" }, { SEVERITY_SUCC, MSG_GPUDEV, PARAM_GPU, "GPU%d" }, +#ifdef WANT_CPUMINE + { SEVERITY_ERR, MSG_CPUNON, PARAM_NONE, "No CPUs" }, { SEVERITY_SUCC, MSG_CPUDEV, PARAM_CPU, "CPU%d" }, { SEVERITY_ERR, MSG_INVCPU, PARAM_CPUMAX, "Invalid CPU id %d - range is 0 - %d" }, +#endif { SEVERITY_SUCC, MSG_NUMGPU, PARAM_NONE, "GPU count" }, { SEVERITY_SUCC, MSG_NUMCPU, PARAM_NONE, "CPU count" }, - { SEVERITY_SUCC, MSG_VERSION, PARAM_CPU, "CGMiner versions" }, + { SEVERITY_SUCC, MSG_VERSION, PARAM_NONE, "CGMiner versions" }, { SEVERITY_ERR, MSG_INVJSON, PARAM_NONE, "Invalid JSON" }, { SEVERITY_ERR, MSG_MISSCMD, PARAM_CMD, "Missing JSON '%s'" }, { SEVERITY_FAIL } }; -static const char *APIVERSION = "0.7"; +static const char *APIVERSION = "0.8"; static const char *DEAD = "Dead"; static const char *SICK = "Sick"; static const char *NOSTART = "NoStart"; @@ -278,7 +301,9 @@ static char *message(int messageid, int gpuid, bool isjson) { char severity; char *ptr; +#ifdef WANT_CPUMINE int cpu; +#endif int i; for (i = 0; codes[i].severity != SEVERITY_FAIL; i++) { @@ -319,6 +344,7 @@ static char *message(int messageid, int gpuid, bool isjson) case PARAM_PMAX: sprintf(ptr, codes[i].description, total_pools); break; +#ifdef WANT_CPUMINE case PARAM_GCMAX: if (opt_n_threads > 0) cpu = num_processors; @@ -327,6 +353,11 @@ static char *message(int messageid, int gpuid, bool isjson) sprintf(ptr, codes[i].description, nDevs, cpu); break; +#else + case PARAM_GMAX: + sprintf(ptr, codes[i].description, nDevs); + break; +#endif case PARAM_CMD: sprintf(ptr, codes[i].description, JSON_COMMAND); break; @@ -423,6 +454,7 @@ void gpustatus(int gpu, bool isjson) } } +#ifdef WANT_CPUMINE void cpustatus(int cpu, bool isjson) { char buf[BUFSIZ]; @@ -448,6 +480,7 @@ void cpustatus(int cpu, bool isjson) strcat(io_buffer, buf); } } +#endif void devstatus(SOCKETTYPE c, char *param, bool isjson) { @@ -472,6 +505,7 @@ void devstatus(SOCKETTYPE c, char *param, bool isjson) gpustatus(i, isjson); } +#ifdef WANT_CPUMINE if (opt_n_threads > 0) for (i = 0; i < num_processors; i++) { if (isjson && (i > 0 || nDevs > 0)) @@ -479,6 +513,7 @@ void devstatus(SOCKETTYPE c, char *param, bool isjson) cpustatus(i, isjson); } +#endif if (isjson) strcat(io_buffer, JSON_CLOSE); @@ -517,6 +552,7 @@ void gpudev(SOCKETTYPE c, char *param, bool isjson) strcat(io_buffer, JSON_CLOSE); } +#ifdef WANT_CPUMINE void cpudev(SOCKETTYPE c, char *param, bool isjson) { int id; @@ -549,6 +585,7 @@ void cpudev(SOCKETTYPE c, char *param, bool isjson) if (isjson) strcat(io_buffer, JSON_CLOSE); } +#endif void poolstatus(SOCKETTYPE c, char *param, bool isjson) { @@ -776,13 +813,18 @@ void gpucount(SOCKETTYPE c, char *param, bool isjson) void cpucount(SOCKETTYPE c, char *param, bool isjson) { char buf[BUFSIZ]; + int count = 0; + +#ifdef WANT_CPUMINE + count = opt_n_threads > 0 ? num_processors : 0; +#endif strcpy(io_buffer, message(MSG_NUMCPU, 0, isjson)); if (isjson) - sprintf(buf, "," JSON_CPUS "{\"Count\":%d}" JSON_CLOSE, opt_n_threads > 0 ? num_processors : 0); + sprintf(buf, "," JSON_CPUS "{\"Count\":%d}" JSON_CLOSE, count); else - sprintf(buf, _CPUS ",Count=%d%c", opt_n_threads > 0 ? num_processors : 0, SEPARATOR); + sprintf(buf, _CPUS ",Count=%d%c", count, SEPARATOR); strcat(io_buffer, buf); } @@ -814,7 +856,9 @@ struct CMDS { { "gpudisable", gpudisable }, { "gpurestart", gpurestart }, { "gpu", gpudev }, +#ifdef WANT_CPUMINE { "cpu", cpudev }, +#endif { "gpucount", gpucount }, { "cpucount", cpucount }, { "quit", doquit },