|
35 | 35 | assert isdir(FRAMEWORK_DIR) |
36 | 36 |
|
37 | 37 | # default configuration values |
| 38 | +vector = int(board.get("build.vec_tab_addr", "0x8000000"), 16) |
38 | 39 | error_led_port = "GPIOA" |
39 | 40 | error_led_pin = 7 |
| 41 | +ldscript = "jtag.ld" |
| 42 | +board_type = "discovery_f4" |
40 | 43 |
|
41 | 44 | # remap board configuration values |
42 | 45 | mcu_type = board.get("build.mcu")[:-2] |
43 | | -if "stm32f407ve" in mcu_type: |
44 | | - ldscript = "jtag.ld" |
| 46 | +if "f407ve" in mcu_type: |
45 | 47 | variant = "generic_f407v" |
46 | | - |
| 48 | + board_type = "generic_f407v" |
| 49 | +elif "f407vg" in mcu_type: |
| 50 | + error_led_port = "GPIOD" |
| 51 | + error_led_pin = 14 |
| 52 | + variant = "discovery_f407" |
47 | 53 |
|
48 | 54 | # upload related configuration remap |
49 | | -# for all generic boards |
50 | 55 | upload_protocol = env.subst("$UPLOAD_PROTOCOL") |
51 | 56 |
|
| 57 | +if upload_protocol == "dfu": |
| 58 | + vector = 0x8004000 |
| 59 | + if "f407v" in mcu_type: |
| 60 | + ldscript = "bootloader_8004000.ld" |
| 61 | + |
52 | 62 | env.Append( |
53 | | - CFLAGS=[ |
54 | | - "-std=gnu11" |
55 | | - ], |
| 63 | + CFLAGS=["-std=gnu11"], |
| 64 | + |
| 65 | + CXXFLAGS=["-std=gnu++11"], |
56 | 66 |
|
57 | 67 | CCFLAGS=[ |
58 | 68 | "-MMD", |
59 | | - "--param", |
60 | | - "max-inline-insns-single=500" |
61 | | - ], |
62 | | - |
63 | | - CXXFLAGS=[ |
64 | | - "-std=gnu++11" |
| 69 | + "--param", "max-inline-insns-single=500", |
65 | 70 | ], |
66 | 71 |
|
67 | 72 | CPPDEFINES=[ |
68 | 73 | ("DEBUG_LEVEL", "DEBUG_NONE"), |
69 | | - ("BOARD_%s" % variant), |
| 74 | + ("BOARD_%s" % board_type), |
70 | 75 | ("ERROR_LED_PORT", error_led_port), |
71 | 76 | ("ERROR_LED_PIN", error_led_pin), |
72 | 77 | ("ARDUINO", 10610), |
73 | 78 | ("ARDUINO_%s" % variant.upper()), |
74 | 79 | ("ARDUINO_ARCH_STM32F4"), |
75 | 80 | ("VECT_TAB_FLASH"), |
76 | | - ("USER_ADDR_ROM=0x08000000"), |
| 81 | + ("USER_ADDR_ROM", vector), |
77 | 82 | ("__STM32F4__"), |
78 | | - ("MCU_%s" % mcu_type.upper()), |
79 | | - ("SERIAL_USB") # this is so that usb serial is connected when the board boots, use USB_MSC for having USB Mass Storage (MSC) instead |
| 83 | + ("STM32_HIGH_DENSITY"), |
| 84 | + ("USB_NC") |
80 | 85 | ], |
81 | 86 |
|
82 | 87 | CPPPATH=[ |
|
88 | 93 | join(FRAMEWORK_DIR, "system", "libmaple"), |
89 | 94 | ], |
90 | 95 |
|
91 | | - LIBPATH=[join(FRAMEWORK_DIR, "variants", variant, "ld")], |
92 | | - |
93 | | - LIBS=["c"] |
| 96 | + LIBPATH=[join(FRAMEWORK_DIR, "variants", variant, "ld")] |
94 | 97 | ) |
95 | 98 |
|
96 | 99 | # remap ldscript |
|
102 | 105 | env['LINKFLAGS'].remove(item) |
103 | 106 |
|
104 | 107 | # remove unused libraries |
105 | | -for item in ("stdc++", "nosys"): |
| 108 | +for item in ("c", "stdc++", "nosys"): |
106 | 109 | if item in env['LIBS']: |
107 | 110 | env['LIBS'].remove(item) |
108 | 111 |
|
| 112 | +# remove USB inactive serial flag if other flags are used |
| 113 | +if "SERIAL_USB" in env['CPPDEFINES'] or "USB_MSC" in env['CPPDEFINES']: |
| 114 | + env['CPPDEFINES'].remove("USB_NC") |
| 115 | + |
109 | 116 | # |
110 | 117 | # Lookup for specific core's libraries |
111 | 118 | # |
|
0 commit comments