From 95fd101d515e1d3819840207a9bdc6c1343bf9b8 Mon Sep 17 00:00:00 2001 From: qiuyiuestc Date: Thu, 4 Feb 2010 14:46:09 +0000 Subject: [PATCH] support GCC compiler git-svn-id: https://rt-thread.googlecode.com/svn/trunk@371 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/mini2440/key.c | 136 ++++++++++++++-------------- bsp/mini2440/rtconfig.h | 5 +- bsp/mini2440/rtconfig.py | 17 ++-- bsp/mini2440/startup.c | 26 +++++- net/apps/ftpd.c | 1 + net/lwip/src/arch/include/arch/cc.h | 9 +- rtgui/SConscript | 1 + rtgui/common/font_hz_bmp.c | 5 + rtgui/common/hz16font.c | 2 +- rtgui/common/rtgui_system.c | 4 +- rtgui/include/rtgui/rtgui_config.h | 5 +- rtgui/widgets/filelist_view.c | 2 +- 12 files changed, 125 insertions(+), 88 deletions(-) diff --git a/bsp/mini2440/key.c b/bsp/mini2440/key.c index 5c52fd2c1..9fc655a02 100644 --- a/bsp/mini2440/key.c +++ b/bsp/mini2440/key.c @@ -21,88 +21,90 @@ key_power GPG11 static void key_thread_entry(void *parameter) { - rt_time_t next_delay; - struct rtgui_event_kbd kbd_event; + rt_time_t next_delay; + struct rtgui_event_kbd kbd_event; - /* init gpio configuration */ - GPGCON = GPGCON & (~((3<<22)|(3<<6)|(3<<0)|(3<<10)|(3<<12)|(3<<14))) | - ((2<<22)|(2<<6)|(2<<0)|(2<<10)|(2<<12)|(2<<14)); + /* init gpio configuration */ + GPGCON = GPGCON & (~((3<<22)|(3<<6)|(3<<0)|(3<<10)|(3<<12)|(3<<14))) | + ((2<<22)|(2<<6)|(2<<0)|(2<<10)|(2<<12)|(2<<14)); - /* init keyboard event */ - RTGUI_EVENT_KBD_INIT(&kbd_event); - kbd_event.mod = RTGUI_KMOD_NONE; - kbd_event.unicode = 0; + /* init keyboard event */ + RTGUI_EVENT_KBD_INIT(&kbd_event); + kbd_event.mod = RTGUI_KMOD_NONE; + kbd_event.unicode = 0; - while (1) - { - next_delay = 20; + while (1) + { + next_delay = 20; kbd_event.key = RTGUIK_UNKNOWN; - kbd_event.type = RTGUI_KEYDOWN; - if ( key_enter_GETVALUE() == 0 ) - { - rt_thread_delay(next_delay); - if (key_enter_GETVALUE() == 0) - { - /* HOME key */ - rt_kprintf("key_home\n"); - kbd_event.key = RTGUIK_HOME; - } - else - { - rt_kprintf("key_enter\n"); - kbd_event.key = RTGUIK_RETURN; - } - } - - if ( key_down_GETVALUE() == 0 ) - { - rt_kprintf("key_down\n"); - kbd_event.key = RTGUIK_DOWN; - } - - if ( key_up_GETVALUE() == 0 ) - { - rt_kprintf("key_up\n"); - kbd_event.key = RTGUIK_UP; - } - - if ( key_right_GETVALUE() == 0 ) - { - rt_kprintf("key_right\n"); - kbd_event.key = RTGUIK_RIGHT; - } - - if ( key_left_GETVALUE() == 0 ) - { - rt_kprintf("key_left\n"); - kbd_event.key = RTGUIK_LEFT; - } + kbd_event.type = RTGUI_KEYDOWN; + if ( key_enter_GETVALUE() == 0 ) + { + rt_thread_delay(next_delay); + if (key_enter_GETVALUE() == 0) + { + /* HOME key */ + rt_kprintf("key_home\n"); + kbd_event.key = RTGUIK_HOME; + } + else + { + rt_kprintf("key_enter\n"); + kbd_event.key = RTGUIK_RETURN; + } + } + + if ( key_down_GETVALUE() == 0 ) + { + rt_kprintf("key_down\n"); + kbd_event.key = RTGUIK_DOWN; + } + + if ( key_up_GETVALUE() == 0 ) + { + rt_kprintf("key_up\n"); + kbd_event.key = RTGUIK_UP; + } + + if ( key_right_GETVALUE() == 0 ) + { + rt_kprintf("key_right\n"); + kbd_event.key = RTGUIK_RIGHT; + } + + if ( key_left_GETVALUE() == 0 ) + { + rt_kprintf("key_left\n"); + kbd_event.key = RTGUIK_LEFT; + } if (kbd_event.key != RTGUIK_UNKNOWN) { - /* post down event */ - rtgui_server_post_event(&(kbd_event.parent), sizeof(kbd_event)); + /* post down event */ + rtgui_server_post_event(&(kbd_event.parent), sizeof(kbd_event)); next_delay = 10; - /* delay to post up event */ - rt_thread_delay(next_delay); + /* delay to post up event */ + rt_thread_delay(next_delay); - /* post up event */ - kbd_event.type = RTGUI_KEYUP; - rtgui_server_post_event(&(kbd_event.parent), sizeof(kbd_event)); + /* post up event */ + kbd_event.type = RTGUI_KEYUP; + rtgui_server_post_event(&(kbd_event.parent), sizeof(kbd_event)); } - /* wait next key press */ - rt_thread_delay(next_delay); - } + /* wait next key press */ + rt_thread_delay(next_delay); + } } void rt_hw_key_init() { - rt_thread_t key_tid; - key_tid = rt_thread_create("key", - key_thread_entry, RT_NULL, - 512, 30, 5); - if (key_tid != RT_NULL) rt_thread_startup(key_tid); + #if 0 + rt_thread_t key_tid; + key_tid = rt_thread_create("key", + key_thread_entry, RT_NULL, + 512, 30, 5); + if (key_tid != RT_NULL) rt_thread_startup(key_tid); + #endif } diff --git a/bsp/mini2440/rtconfig.h b/bsp/mini2440/rtconfig.h index 1f6a77cbb..6cf7dc716 100644 --- a/bsp/mini2440/rtconfig.h +++ b/bsp/mini2440/rtconfig.h @@ -70,9 +70,6 @@ /* SECTION: finsh, a C-Express shell */ /* Using FinSH as Shell*/ #define RT_USING_FINSH -/* Using symbol table */ -#define FINSH_USING_SYMTAB -#define FINSH_USING_DESCRIPTION /* SECTION: a runtime libc library */ /* a runtime libc library */ @@ -94,7 +91,7 @@ #define RT_USING_DFS_EFSL #define RT_USING_DFS_YAFFS2 -#define RT_USING_WORKDIR +/* #define DFS_USING_WORKDIR */ /* the max number of mounted filesystem */ #define DFS_FILESYSTEMS_MAX 2 diff --git a/bsp/mini2440/rtconfig.py b/bsp/mini2440/rtconfig.py index fb5e5e506..ae3d48f2f 100644 --- a/bsp/mini2440/rtconfig.py +++ b/bsp/mini2440/rtconfig.py @@ -25,10 +25,10 @@ ARCH='arm' CPU='s3c24x0' TextBase='0x30000000' -#PLATFORM = 'gcc' -#EXEC_PATH = 'E:/Program Files/CodeSourcery/Sourcery G++ Lite/bin' -PLATFORM = 'armcc' -EXEC_PATH = 'E:/Keil' +PLATFORM = 'gcc' +EXEC_PATH = 'E:/Program Files/CodeSourcery/Sourcery G++ Lite/bin' +#PLATFORM = 'armcc' +#EXEC_PATH = 'E:/Keil' BUILD = 'debug' if PLATFORM == 'gcc': @@ -38,15 +38,15 @@ if PLATFORM == 'gcc': AS = PREFIX + 'gcc' AR = PREFIX + 'ar' LINK = PREFIX + 'gcc' - TARGET_EXT = 'elf' + TARGET_EXT = 'axf' SIZE = PREFIX + 'size' OBJDUMP = PREFIX + 'objdump' OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=arm920t' - CFLAGS = DEVICE + ' -Dsourcerygxx' + ' -nostdinc' - AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' - LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=main.elf.map,-cref,-u,Reset_Handler -T mini2440_ram.ld' + CFLAGS = DEVICE + ' -DRT_USING_MINILIBC' + ' -nostdinc -nostdlib -fno-builtin' + AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' + ' -DTEXT_BASE=' + TextBase + LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=main.elf.map,-cref,-u,_start -T mini2440_ram.ld' + ' -Ttext ' + TextBase CPATH = '' LPATH = '' @@ -89,6 +89,7 @@ elif PLATFORM == 'armcc': RT_USING_MINILIBC = False if RT_USING_FINSH: + CFLAGS += ' -D FINSH_USING_SYMTAB -DFINSH_USING_DESCRIPTION' LFLAGS += ' --keep __fsym_* --keep __vsym_*' if RT_USING_WEBSERVER: CFLAGS += ' -DWEBS -DUEMF -DRTT -D__NO_FCNTL=1 -DRT_USING_WEBSERVER' diff --git a/bsp/mini2440/startup.c b/bsp/mini2440/startup.c index 87b40d4c8..e5184dd24 100644 --- a/bsp/mini2440/startup.c +++ b/bsp/mini2440/startup.c @@ -48,10 +48,34 @@ extern struct rt_device uart0_device; extern int Image$$ER_ZI$$ZI$$Base; extern int Image$$ER_ZI$$ZI$$Length; extern int Image$$ER_ZI$$ZI$$Limit; -#else +#elif (defined (__GNUC__)) + rt_uint8_t _irq_stack_start[1024]; + rt_uint8_t _fiq_stack_start[1024]; + rt_uint8_t _undefined_stack_start[512]; + rt_uint8_t _abort_stack_start[512]; + rt_uint8_t _svc_stack_start[1024] SECTION(".nobss"); extern int __bss_end; #endif +/** + * Fix me + */ + #if (defined (__GNUC__)) +void *_sbrk (int incr) +{ + extern int __bss_end; /* Set by linker. */ + static char * heap_end; + char * prev_heap_end; + + if (heap_end == 0) + heap_end = & __bss_end; + + prev_heap_end = heap_end; + heap_end += incr; + + return (void *) prev_heap_end; +} +#endif #ifdef RT_USING_FINSH extern void finsh_system_init(void); diff --git a/net/apps/ftpd.c b/net/apps/ftpd.c index 658b2acf1..bbc2c6121 100644 --- a/net/apps/ftpd.c +++ b/net/apps/ftpd.c @@ -4,6 +4,7 @@ #include #include #include +#include #define FTP_PORT 21 #define FTP_SRV_ROOT "/" diff --git a/net/lwip/src/arch/include/arch/cc.h b/net/lwip/src/arch/include/arch/cc.h index 00b14bd83..75ac1b176 100644 --- a/net/lwip/src/arch/include/arch/cc.h +++ b/net/lwip/src/arch/include/arch/cc.h @@ -59,6 +59,11 @@ typedef rt_uint32_t mem_ptr_t; #define LWIP_PROVIDE_ERRNO #endif +#ifdef RT_USING_MINILIBC +#include +#define LWIP_TIMEVAL_PRIVATE 0 +#endif + #if defined(__CC_ARM) /* ARMCC compiler */ #define PACK_STRUCT_FIELD(x) x #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) @@ -76,10 +81,10 @@ typedef rt_uint32_t mem_ptr_t; #define PACK_STRUCT_BEGIN #define PACK_STRUCT_END #endif - + void sys_arch_assert(const char* file, int line); #define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0) -#define LWIP_PLATFORM_ASSERT(x) { rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__); } +#define LWIP_PLATFORM_ASSERT(x) { rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__); } #define SYS_ARCH_DECL_PROTECT(x) #define SYS_ARCH_PROTECT(x) diff --git a/rtgui/SConscript b/rtgui/SConscript index 8d8473d03..892bc401e 100644 --- a/rtgui/SConscript +++ b/rtgui/SConscript @@ -23,6 +23,7 @@ common/image_hdc.c common/region.c common/hz12font.c common/hz16font.c +common/font_hz_bmp.c """) server_src = Split(""" diff --git a/rtgui/common/font_hz_bmp.c b/rtgui/common/font_hz_bmp.c index 29e72f452..239f6f9fe 100644 --- a/rtgui/common/font_hz_bmp.c +++ b/rtgui/common/font_hz_bmp.c @@ -1,6 +1,9 @@ + #include #include +#ifdef RTGUI_USING_HZ_BMP + static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect); static void rtgui_hz_bitmap_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect); struct rtgui_font_engine hz_bmp_font_engine = @@ -69,3 +72,5 @@ static void rtgui_hz_bitmap_font_get_metrics(struct rtgui_font* font, const rt_u rect->x2 = (rt_int16_t)(bmp_font->width * rt_strlen((const char*)text)); rect->y2 = bmp_font->height; } + +#endif diff --git a/rtgui/common/hz16font.c b/rtgui/common/hz16font.c index 07c8e3f88..9650a5fa6 100644 --- a/rtgui/common/hz16font.c +++ b/rtgui/common/hz16font.c @@ -16746,7 +16746,7 @@ struct rtgui_font rtgui_font_hz16 = 16, /* height */ 1, /* refer count */ &hz_bmp_font_engine,/* font engine */ - &hz16, /* font private data */ + (void *)&hz16, /* font private data */ }; /* size = 267616 bytes */ diff --git a/rtgui/common/rtgui_system.c b/rtgui/common/rtgui_system.c index f420be078..b64940a9c 100644 --- a/rtgui/common/rtgui_system.c +++ b/rtgui/common/rtgui_system.c @@ -343,8 +343,8 @@ rt_err_t rtgui_thread_send(rt_thread_t tid, rtgui_event_t* event, rt_size_t even struct rtgui_thread* thread; rtgui_event_dump(tid, event); - if (event->type != RTGUI_EVENT_TIMER) - rt_kprintf("event size: %d\n", event_size); + /* if (event->type != RTGUI_EVENT_TIMER) + rt_kprintf("event size: %d\n", event_size); */ /* find rtgui_thread */ thread = (struct rtgui_thread*) (tid->user_data); diff --git a/rtgui/include/rtgui/rtgui_config.h b/rtgui/include/rtgui/rtgui_config.h index 7c1eee618..3a2c8ac76 100644 --- a/rtgui/include/rtgui/rtgui_config.h +++ b/rtgui/include/rtgui/rtgui_config.h @@ -29,11 +29,12 @@ #define RTGUI_USING_STDIO_FILERW #define RTGUI_IMAGE_PNG #define RTGUI_IMAGE_JPEG - #define RTGUI_USING_FONT12 #else #define RTGUI_USING_DFS_FILERW -#define RTGUI_USING_HZ_FILE +//#define RTGUI_USING_HZ_FILE +#define RTGUI_USING_HZ_BMP +#define RTGUI_USING_FONT12 #endif // #define RTGUI_USING_SMALL_SIZE diff --git a/rtgui/widgets/filelist_view.c b/rtgui/widgets/filelist_view.c index 406029ed9..894ac965f 100644 --- a/rtgui/widgets/filelist_view.c +++ b/rtgui/widgets/filelist_view.c @@ -457,7 +457,7 @@ rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_widget* widget, struct if (strcmp(view->items[view->current_item].name, ".") == 0) return RT_FALSE; if (strcmp(view->items[view->current_item].name, "..") == 0) { - char *ptr; + rt_uint8_t *ptr; ptr = strrchr(view->current_directory, PATH_SEPARATOR); if (ptr == RT_NULL) return RT_FALSE; -- GitLab