Howto Build armulator on cygwin Chen Yu 2002-12-6 This methods has been tested in cygwin 1.3.10-cygwin1.3.12+ environment 1. Install cygwin 1.3.10 + in windows2000/xp, must install gcc and some related packages (don't need XFree86 packages). 2. Get gdb-5.0.tar.bz2 and gdb-5.0-uclinux-armulator-20020816.patch.gz to directory /home/Administrator/ , unpack and patch files. cd /home/Administrator/ bzip2 -d gdb-5.0.tar.gz2 tar xvf gdb-5.0.tar gzip -d gdb-5.0-uclinux-armulator-20020816.patch.gz patch -p0 < gdb-5.0-uclinux-armulator-20020816.patch Now the all armulator source codes are in /home/Administrator/gdb-5.0/ 3. copy some missing files to gdb source directory. gdb missing two endian.h files. We copy RedHat7.2 's include files first build /usr/include/bits directory mkdir /usr/include/bits then copy files, from linux's files /usr/include/bits/endian.h /usr/include/endian.h to cygwin's files /usr/include/bits/endian.h /usr/include/endian.h we should copy some cygwin's include files to gdb if we use cygwin 1.3.10 cp /usr/include/mingw/wctype.h /home/Administrator/gdb-5.0/gdb/ cp /usr/include/mingw/_mingw.h /home/Administrator/gdb-5.0/gdb/ if we use cygwin 1.3.12 + cp /usr/include/mingw32/wctype.h /home/Administrator/gdb-5.0/gdb/ cp /usr/include/mingw32/_mingw.h /home/Administrator/gdb-5.0/gdb/ 4. configure gdb if there isn't /usr/local/bin/gtk-config.exe file in cygwin environment, do below commands touch /usr/local/bin/gtk-config touch /usr/local/bin/gtk-config.exe chmod 755 /usr/local/bin/gtk-config /usr/local/bin/gtk-config.exe else we do nothing. After we did these things, do below commands cd /home/Administrator/gdb-5.0/ ./configure --target=arm-elf --prefix=/usr/local --without-gtk-prefix --without-gtk-exec-prefix --disable-gtktest if there isn't /usr/local/bin/gtk-config.exe file in cygwin environment, do below commands rm -f /usr/local/bin/gtk-config /usr/local/bin/gtk-config.exe else we do nothing. 5. Change some gdb files. --------------------------------------------------------------------------------------------------- If we use cygwin 1.3.12 +, then do nothing, but if we use cygwin1.3.10, then we should do someting, Change /home/Administrator/gdb-5.0/sim/arm/Makefile, find string 'CONFIG_LIBS = -lnsl' from CONFIG_LIBS = -lnsl to CONFIG_LIBS = -lintl Change /home/Administrator/gdb-5.0/gdb/Makefile, find string 'WIN32LIBS =' from WIN32LIBS = to WIN32LIBS = -lintl /usr/lib/libiberty.a /usr/lib/mingw/libcrtdll.a /usr/lib/w32api/libmsvcp60.a If we use cygwin1.3.10, we should do : Change files /home/Administrator/gdb-5.0/sim/arm/Makefile /home/Administrator/gdb-5.0/gdb/Makefile /home/Administrator/gdb-5.0/gdb/rdi-share/Makefile /home/Administrator/gdb-5.0/bfd/doc/Makefile /home/Administrator/gdb-5.0/bfd/Makefile /home/Administrator/gdb-5.0/opcode/Makefile from EXEEXT = to EXEEXT = .exe -------------------------------------------------------------------------------------------------- We should below things in cygwin 1.3.10 or 1.3.12+ : Change /gdb/rdi-share/Makfile, find string '$(AR) cru libangsd.a $(libangsd_a_OBJECTS) $(libangsd_a_LIBADD)' from $(AR) cru libangsd.a $(libangsd_a_OBJECTS) $(libangsd_a_LIBADD) to $(AR) q libangsd.a $(libangsd_a_OBJECTS) $(libangsd_a_LIBADD) Change /home/Administrator/gdb-5.0/gdb/utils.c, find '#include ' from #include to #include Change /home/Administrator/gdb-5.0/sim/arm/armlcd.c, the source code is below: ----------------------------------------------------------------------------------- /* armlcd.c - LCD display emulation in an X window. ARMulator extensions for the ARM7100 family. Copyright (C) 1999 Ben Williamson 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 /* chy change 2002-12-3 #include */ #include "armdefs.h" #define MAX_DEPTH 4 /* bits per pixel */ #define GREY_LEVELS 16 #define LCD_BASE 0xC0000000 /*chy change 2002-12-3*/ #define NO_LCD #ifdef NO_LCD void lcd_enable(ARMul_State *state, int width, int height, int depth){}; void lcd_disable(ARMul_State *state) {}; void lcd_write(ARMul_State *state, ARMword addr, ARMword data){}; void lcd_cycle(ARMul_State *state){}; void lcd_dirty(ARMul_State *state, ARMword addr){}; void lcd_clean(ARMul_State *state){}; #else static GtkWidget *window; static GdkGC *gc[GREY_LEVELS]; static int no_X = 0; static int lcd_width, lcd_height, lcd_depth; static int lcd_palette[GREY_LEVELS] = {0, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; static gint expose_event (GtkWidget *widget, GdkEventExpose *event) { /* event->area.x, event->area.y, event->area.width, event->area.height */ return FALSE; } static gint button_press_event (GtkWidget *widget, GdkEventButton *event) { /* event->x, event->y, event->button */ return TRUE; } static gint motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { /* event->x, event->y */ return TRUE; } extern int global_argc; extern char **global_argv; void lcd_cycle(ARMul_State *state) { gtk_main_iteration_do(FALSE); } void lcd_enable(ARMul_State *state, int width, int height, int depth) { int i; static int once = 0; GdkColormap *colormap; if (getenv("DISPLAY") == NULL) { no_X++; return; } if (!once) { once++; gtk_init(&global_argc, &global_argv); } lcd_width = width; lcd_height = height; lcd_depth = depth; state->io.lcd_limit = LCD_BASE + (width * height * depth / 8); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_name(window, "DXTree"); gtk_widget_set_usize(window, width, height); gtk_signal_connect(GTK_OBJECT(window), "expose_event", (GtkSignalFunc)expose_event, NULL); gtk_signal_connect(GTK_OBJECT(window), "motion_notify_event", (GtkSignalFunc)motion_notify_event, NULL); gtk_signal_connect(GTK_OBJECT(window), "button_press_event", (GtkSignalFunc)button_press_event, NULL); gtk_widget_set_events(window, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); gtk_widget_show(window); colormap = gdk_window_get_colormap(window->window); for (i = 0; i < GREY_LEVELS; i++) { GdkColor color; /* #7fc5a7 is a nice LCDish colour */ color.red = (15 - i) * (0x7f00 / GREY_LEVELS); color.green = (15 - i) * (0xc500 / GREY_LEVELS); color.blue = (15 - i) * (0xa700 / GREY_LEVELS); gdk_color_alloc (colormap, &color); gc[i] = gdk_gc_new(window->window); gdk_gc_set_foreground(gc[i], &color); } } void lcd_disable(ARMul_State *state) { int i; if (no_X) return; for (i = 0; i < GREY_LEVELS; i++) { if (gc[i]) { gdk_gc_destroy(gc[i]); gc[i] = NULL; } } if (window) { gtk_widget_destroy(window); window = NULL; } } void lcd_write(ARMul_State *state, ARMword addr, ARMword data) { ARMword offset; int pixnum, x, y, bit; if (no_X) return; offset = (addr & ~3) - LCD_BASE; pixnum = offset * 8 / lcd_depth; x = pixnum % lcd_width; y = pixnum / lcd_width; assert(y < lcd_height); for (bit = 0; bit < 32; bit += lcd_depth) { /* XXX need palette code here */ int pix = (data >> bit) % (1 << lcd_depth); gdk_draw_point(window->window, gc[lcd_palette[pix]], x, y); x++; } } #endif --------------------------------------------------------------------------------------------- 6. now build gdb, do below commands: cd /home/Administrator/gdb-5.0/ ./make ./make install strip /usr/local/bin/arm-elf-gdb.exe /usr/local/bin/arm-elf-run.exe Now, armulator should be OK!