6 #TCHAIN = "arm-none-eabi"
10 vars.Add("PM_UART_BAUD", "Baud rate of the ipm serial connection.", "19200")
11 vars.Add("IPM", "Add the interactive library to the standard lib", True)
12 vars.Add("MCU", "Type of ARM device; the arg to -mcpu.", "cortex-m3")
13 vars.Add("NM", "", "arm-eabi-nm")
14 vars.Add("OBJCOPY", "", "%s-objcopy" % TCHAIN)
15 vars.Add("OBJDUMP", "", "%s-objdump" % TCHAIN)
16 vars.Add("SIZE", "", "%s-size" % TCHAIN)
17 #vars.Add("DEBUG","", True)
19 CFLAGS = " -DUART_BAUD=$PM_UART_BAUD -Dgcc" \
20 " -DUSE_STDPERIPH_DRIVER -DSTM32F10X_HD" \
22 " -mcpu=$MCU -mthumb -Os -fomit-frame-pointer -mlittle-endian" \
23 " -ffunction-sections -fdata-sections -fno-strict-aliasing"
25 LDFLAGS = "-mcpu=$MCU -mthumb -Wl,-T -Xlinker src/platform/stm32/stm32f10x.ld" \
26 " -u _start-Wl,-e,Reset_Handler -Wl,-static -Wl,--gc-sections" \
27 " -nostartfiles -Wl,--allow-multiple-definition"
29 AFLAGS = "-x assembler-with-cpp $_CPPINCFLAGS -mcpu=$MCU -mthumb -Wall -c"
31 if "DEBUG" in vars.args.keys():
32 CFLAGS = "-g -gstabs -D__DEBUG__=1 " + CFLAGS
34 SOURCES = ["main.c", "plat.c", "stm32f10x_it.c", "syscalls.c"]
35 SOURCES += glob.glob("FWlib/src/*.c")
36 SOURCES += glob.glob("FWlib/src/*.s")
38 PY_SOURCES = ["main.py"]
39 PM_LIB_ROOT = ["pmvm_%s" % vars.args["PLATFORM"]]
41 env = Environment(variables = vars,
42 CPPPATH = ["#src/vm", "#src/platform/stm32", "#src/platform/stm32/FWlib/inc"],
43 CC = "%s-gcc" % TCHAIN,
44 AS = "%s-gcc" % TCHAIN,
47 CXX = "%s-g++" % TCHAIN,
48 AR = "%s-ar" % TCHAIN,
50 RANLIB = "%s-ranlib" % TCHAIN,
54 vmlib = SConscript(["../../vm/SConscript"], ["env", "vars"])
56 pmfeatures = env.Command(["pmfeatures.h"], ["pmfeatures.py"],
57 "src/tools/pmGenPmFeatures.py $SOURCE > $TARGET")
59 img_sources = env.Command(["main_img.c", "main_nat.c"], [PY_SOURCES],
60 "src/tools/pmImgCreator.py -f src/platform/stm32/pmfeatures.py -c -u " \
61 "-o src/platform/stm32/main_img.c " \
62 "--native-file=src/platform/stm32/main_nat.c $SOURCES")
64 elf = env.Program("main.elf", SOURCES + img_sources + vmlib,
65 LIBS = [PM_LIB_ROOT,"c","gcc","m"], LIBPATH = ["../../vm"])
67 bin = env.Command("main.bin", "main.elf", "$OBJCOPY -O binary $SOURCE $TARGET")