Browse Source

x86: host machine native gcc support and use qemu to run

parai.wang 7 years ago
parent
commit
5ba5ebc8be
3 changed files with 30 additions and 7 deletions
  1. 16 0
      bsp/x86/Makefile
  2. 8 1
      bsp/x86/drivers/board.c
  3. 6 6
      bsp/x86/rtconfig.py

+ 16 - 0
bsp/x86/Makefile

@@ -0,0 +1,16 @@
+
+all:floppy.img
+	scons
+	mkdir -p tmp
+	sudo mount -t vfat floppy.img tmp -o loop
+	sudo cp rtthread.elf tmp/boot/oskernel
+	sudo umount tmp
+
+clean:
+	scons -c clean
+
+floppy.img:
+	wget https://github.com/bajdcc/tinix/raw/master/floppy.img
+
+run:
+	qemu-system-i386 -fda floppy.img -boot a -m 64M

+ 8 - 1
bsp/x86/drivers/board.c

@@ -71,5 +71,12 @@ void reboot(void)
 }
 }
 FINSH_FUNCTION_EXPORT(reboot, reboot PC)
 FINSH_FUNCTION_EXPORT(reboot, reboot PC)
 #endif
 #endif
-
+#ifdef RT_USING_DFS
+#include <time.h>
+time_t time(time_t* tm)
+{
+	(void)tm;
+	return 0;
+}
+#endif
 /*@}*/
 /*@}*/

+ 6 - 6
bsp/x86/rtconfig.py

@@ -32,20 +32,20 @@ BUILD = 'debug'
 
 
 if PLATFORM == 'gcc':
 if PLATFORM == 'gcc':
     # toolchains
     # toolchains
-    PREFIX = 'i686-elf-'
-    CC = PREFIX + 'gcc'
-    AS = PREFIX + 'gcc'
+    PREFIX = ''
+    CC = PREFIX + 'gcc -m32 -fno-builtin -fno-stack-protector'
+    AS = PREFIX + 'gcc -m32'
     AR = PREFIX + 'ar'
     AR = PREFIX + 'ar'
-    LINK = PREFIX + 'gcc'
+    LINK = PREFIX + 'ld -melf_i386'
     TARGET_EXT = 'elf'
     TARGET_EXT = 'elf'
     SIZE = PREFIX + 'size'
     SIZE = PREFIX + 'size'
     OBJDUMP = PREFIX + 'objdump'
     OBJDUMP = PREFIX + 'objdump'
     OBJCPY = PREFIX + 'objcopy'
     OBJCPY = PREFIX + 'objcopy'
 
 
-    DEVICE = ' -mtune=generic'
+    DEVICE = ''
     CFLAGS = DEVICE + ' -Wall'
     CFLAGS = DEVICE + ' -Wall'
     AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
     AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
-    LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-ia32.map,-cref,-u,_start -T x86_ram.lds -nostdlib'
+    LFLAGS = DEVICE + ' -Map rtthread-ia32.map -T x86_ram.lds -nostdlib'
 
 
     CPATH = ''
     CPATH = ''
     LPATH = ''
     LPATH = ''