summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/easylogo/easylogo.c98
-rw-r--r--tools/env/fw_env.config2
-rw-r--r--tools/ncb.c2
-rwxr-xr-xtools/netconsole42
4 files changed, 136 insertions, 8 deletions
diff --git a/tools/easylogo/easylogo.c b/tools/easylogo/easylogo.c
index 00a1e4e..41e5838 100644
--- a/tools/easylogo/easylogo.c
+++ b/tools/easylogo/easylogo.c
@@ -3,15 +3,19 @@
** ==============================
** (C) 2000 by Paolo Scaffardi (arsenio@tin.it)
** AIRVENT SAM s.p.a - RIMINI(ITALY)
+** (C) 2007-2008 Mike Frysinger <vapier@gentoo.org>
**
** This is still under construction!
*/
+#include <errno.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
#pragma pack(1)
@@ -49,6 +53,17 @@ typedef struct {
int width, height, pixels, bpp, pixel_size, size, palette_size, yuyv;
} image_t;
+void *xmalloc (size_t size)
+{
+ void *ret = malloc (size);
+ if (!ret) {
+ fprintf (stderr, "\nerror: malloc(%zu) failed: %s",
+ size, strerror(errno));
+ exit (1);
+ }
+ return ret;
+}
+
void StringUpperCase (char *str)
{
int count = strlen (str);
@@ -171,7 +186,7 @@ int image_load_tga (image_t * image, char *filename)
image->pixel_size = ((image->bpp - 1) / 8) + 1;
image->pixels = image->width * image->height;
image->size = image->pixels * image->pixel_size;
- image->data = malloc (image->size);
+ image->data = xmalloc (image->size);
if (image->bpp != 24) {
printf ("Bpp not supported: %d!\n", image->bpp);
@@ -192,7 +207,7 @@ int image_load_tga (image_t * image, char *filename)
/* Swapping image */
if (!(header.ImageDescriptorByte & 0x20)) {
- unsigned char *temp = malloc (image->size);
+ unsigned char *temp = xmalloc (image->size);
int linesize = image->pixel_size * image->width;
void *dest = image->data,
*source = temp + image->size - linesize;
@@ -239,7 +254,7 @@ int image_rgb_to_yuyv (image_t * rgb_image, image_t * yuyv_image)
yuyv_image->pixels = yuyv_image->width * yuyv_image->height;
yuyv_image->size = yuyv_image->pixels * yuyv_image->pixel_size;
dest = (unsigned short *) (yuyv_image->data =
- malloc (yuyv_image->size));
+ xmalloc (yuyv_image->size));
yuyv_image->palette = 0;
yuyv_image->palette_size = 0;
@@ -261,6 +276,8 @@ int image_rgb_to_yuyv (image_t * rgb_image, image_t * yuyv_image)
return 0;
}
+int use_gzip = 0;
+
int image_save_header (image_t * image, char *filename, char *varname)
{
FILE *file = fopen (filename, "w");
@@ -283,6 +300,65 @@ int image_save_header (image_t * image, char *filename, char *varname)
fprintf (file, " *\t\t'x'\t\tis the horizontal position\n");
fprintf (file, " *\t\t'y'\t\tis the vertical position\n */\n\n");
+ /* gzip compress */
+ if (use_gzip & 0x1) {
+ const char *errstr = NULL;
+ unsigned char *compressed;
+ struct stat st;
+ FILE *gz;
+ char *gzfilename = xmalloc(strlen (filename) + 20);
+ char *gzcmd = xmalloc(strlen (filename) + 20);
+
+ sprintf (gzfilename, "%s.gz", filename);
+ sprintf (gzcmd, "gzip > %s", gzfilename);
+ gz = popen (gzcmd, "w");
+ if (!gz) {
+ errstr = "\nerror: popen() failed";
+ goto done;
+ }
+ if (fwrite (image->data, image->size, 1, gz) != 1) {
+ errstr = "\nerror: writing data to gzip failed";
+ goto done;
+ }
+ if (pclose (gz)) {
+ errstr = "\nerror: gzip process failed";
+ goto done;
+ }
+
+ gz = fopen (gzfilename, "r");
+ if (!gz) {
+ errstr = "\nerror: open() on gzip data failed";
+ goto done;
+ }
+ if (stat (gzfilename, &st)) {
+ errstr = "\nerror: stat() on gzip file failed";
+ goto done;
+ }
+ compressed = xmalloc (st.st_size);
+ if (fread (compressed, st.st_size, 1, gz) != 1) {
+ errstr = "\nerror: reading gzip data failed";
+ goto done;
+ }
+ fclose (gz);
+
+ unlink (gzfilename);
+
+ dataptr = compressed;
+ count = st.st_size;
+ fprintf (file, "#define EASYLOGO_ENABLE_GZIP %i\n\n", count);
+ if (use_gzip & 0x2)
+ fprintf (file, "static unsigned char EASYLOGO_DECOMP_BUFFER[%i];\n\n", image->size);
+
+ done:
+ free (gzfilename);
+ free (gzcmd);
+
+ if (errstr) {
+ perror (errstr);
+ return -1;
+ }
+ }
+
/* Headers */
fprintf (file, "#include <video_easylogo.h>\n\n");
/* Macros */
@@ -300,8 +376,8 @@ int image_save_header (image_t * image, char *filename, char *varname)
fprintf (file, "#define DEF_%s_SIZE\t\t%d\n\n", def_name,
image->size);
/* Declaration */
- fprintf (file, "unsigned char DEF_%s_DATA[DEF_%s_SIZE] = {\n",
- def_name, def_name);
+ fprintf (file, "unsigned char DEF_%s_DATA[] = {\n",
+ def_name);
/* Data */
while (count)
@@ -359,6 +435,8 @@ static void usage (int exit_status)
"\n"
"Options:\n"
" -r Output RGB instead of YUYV\n"
+ " -g Compress with gzip\n"
+ " -b Preallocate space in bss for decompressing image\n"
" -h Help output\n"
"\n"
"Where: 'inputfile' is the TGA image to load\n"
@@ -377,7 +455,7 @@ int main (int argc, char *argv[])
image_t rgb_logo, yuyv_logo;
- while ((c = getopt(argc, argv, "hr")) > 0) {
+ while ((c = getopt(argc, argv, "hrgb")) > 0) {
switch (c) {
case 'h':
usage (0);
@@ -386,6 +464,14 @@ int main (int argc, char *argv[])
use_rgb = true;
puts ("Using 24-bit RGB Output Fromat");
break;
+ case 'g':
+ use_gzip |= 0x1;
+ puts ("Compressing with gzip");
+ break;
+ case 'b':
+ use_gzip |= 0x2;
+ puts ("Preallocating bss space for decompressing image");
+ break;
default:
usage (1);
break;
diff --git a/tools/env/fw_env.config b/tools/env/fw_env.config
index 0fe37c9..c8f12cf 100644
--- a/tools/env/fw_env.config
+++ b/tools/env/fw_env.config
@@ -1,5 +1,5 @@
# Configuration file for fw_(printenv/saveenv) utility.
-# Up to two entries are valid, in this case the redundand
+# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# Notice, that the "Number of sectors" is ignored on NOR.
diff --git a/tools/ncb.c b/tools/ncb.c
index 74deebb..7e123f1 100644
--- a/tools/ncb.c
+++ b/tools/ncb.c
@@ -8,7 +8,7 @@ int main (int argc, char *argv[])
int s, len, o, port = 6666;
char buf[512];
struct sockaddr_in addr;
- int addr_len = sizeof addr;
+ socklen_t addr_len = sizeof addr;
if (argc > 1)
port = atoi (argv[1]);
diff --git a/tools/netconsole b/tools/netconsole
new file mode 100755
index 0000000..09c8981
--- /dev/null
+++ b/tools/netconsole
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+usage() {
+ (
+ echo "Usage: $0 <board IP> [board port]"
+ echo ""
+ echo "If port is not specified, '6666' will be used"
+ [ -z "$*" ] && exit 0
+ echo ""
+ echo "ERROR: $*"
+ exit 1
+ ) 1>&2
+ exit $?
+}
+
+while [ -n "$1" ] ; do
+ case $1 in
+ -h|--help) usage;;
+ --) break;;
+ -*) usage "Invalid option $1";;
+ *) break;;
+ esac
+ shift
+done
+
+ip=$1
+port=${2:-6666}
+
+if [ -z "${ip}" ] || [ -n "$3" ] ; then
+ usage "Invalid number of arguments"
+fi
+
+for nc in netcat nc ; do
+ type ${nc} >/dev/null && break
+done
+
+trap "stty icanon echo intr ^C" 0 2 3 5 10 13 15
+echo "NOTE: the interrupt signal (normally ^C) has been remapped to ^T"
+
+stty -icanon -echo intr ^T
+${nc} -u -l -p ${port} < /dev/null &
+exec ${nc} -u ${ip} ${port}