Commit aac0c29d4b8418c5c78b552070ffeda022b16949

Authored by Tom Rini

Merge tag 'dm-pull-15jan19' of git://git.denx.de/u-boot-dm

Fix recent changes to serial API for driver model
Buildman clang support and a few fixes
Small fixes to 'dm tree' and regmap test
Improve sandbox build compatibility
A few other minor fixes

Showing 25 changed files Side-by-side Diff

... ... @@ -109,16 +109,9 @@
109 109 #
110 110 # From buildman, exit code 129 means warnings only. If we've been asked to
111 111 # use clang only do one configuration.
112   - - if [[ "${TOOLCHAIN}" == "clang" ]]; then
  112 + - if [[ "${BUILDMAN}" != "" ]]; then
113 113 ret=0;
114   - make O=../.bm-work/${TEST_PY_BD} HOSTCC=clang-7 CC=clang-7 -j$(nproc)
115   - KCFLAGS=-Werror sandbox_config all || ret=$?;
116   - if [[ $ret -ne 0 ]]; then
117   - exit $ret;
118   - fi;
119   - elif [[ "${BUILDMAN}" != "" ]]; then
120   - ret=0;
121   - tools/buildman/buildman -P -E ${BUILDMAN} || ret=$?;
  114 + tools/buildman/buildman -P -E ${BUILDMAN} ${OVERRIDE}|| ret=$?;
122 115 if [[ $ret -ne 0 && $ret -ne 129 ]]; then
123 116 tools/buildman/buildman -sdeP ${BUILDMAN};
124 117 exit $ret;
... ... @@ -351,7 +344,7 @@
351 344 env:
352 345 - TEST_PY_BD="sandbox"
353 346 BUILDMAN="^sandbox$"
354   - TOOLCHAIN="clang"
  347 + OVERRIDE="clang-7"
355 348 - name: "test/py sandbox_spl"
356 349 env:
357 350 - TEST_PY_BD="sandbox_spl"
arch/sandbox/config.mk
... ... @@ -11,10 +11,8 @@
11 11 ifneq ($(NO_SDL),)
12 12 PLATFORM_CPPFLAGS += -DSANDBOX_NO_SDL
13 13 else
14   -ifdef CONFIG_SANDBOX_SDL
15 14 PLATFORM_LIBS += $(shell sdl-config --libs)
16 15 PLATFORM_CPPFLAGS += $(shell sdl-config --cflags)
17   -endif
18 16 endif
19 17  
20 18 cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
arch/sandbox/cpu/sdl.c
... ... @@ -6,7 +6,7 @@
6 6 #include <errno.h>
7 7 #include <unistd.h>
8 8 #include <linux/input.h>
9   -#include <SDL/SDL.h>
  9 +#include <SDL.h>
10 10 #include <asm/state.h>
11 11  
12 12 /**
arch/sandbox/dts/sandbox.dts
... ... @@ -100,11 +100,13 @@
100 100 eeprom@2c {
101 101 reg = <0x2c>;
102 102 compatible = "i2c-eeprom";
  103 + sandbox,emul = <&emul_eeprom>;
103 104 };
104 105  
105 106 rtc_0: rtc@43 {
106 107 reg = <0x43>;
107 108 compatible = "sandbox-rtc";
  109 + sandbox,emul = <&emul0>;
108 110 };
109 111 sandbox_pmic: sandbox_pmic {
110 112 reg = <0x40>;
111 113  
112 114  
... ... @@ -115,18 +117,14 @@
115 117 };
116 118  
117 119 i2c_emul: emul {
118   - #address-cells = <1>;
119   - #size-cells = <0>;
120 120 reg = <0xff>;
121 121 compatible = "sandbox,i2c-emul-parent";
122   - emul-eeprom {
123   - reg = <0x2c>;
  122 + emul_eeprom: emul-eeprom {
124 123 compatible = "sandbox,i2c-eeprom";
125 124 sandbox,filename = "i2c.bin";
126 125 sandbox,size = <256>;
127 126 };
128   - emul0 {
129   - reg = <0x43>;
  127 + emul0: emul0 {
130 128 compatible = "sandbox,i2c-rtc";
131 129 };
132 130 };
arch/sandbox/dts/sandbox64.dts
... ... @@ -90,11 +90,13 @@
90 90 eeprom@2c {
91 91 reg = <0x2c>;
92 92 compatible = "i2c-eeprom";
  93 + sandbox,emul = <&emul_eeprom>;
93 94 };
94 95  
95 96 rtc_0: rtc@43 {
96 97 reg = <0x43>;
97 98 compatible = "sandbox-rtc";
  99 + sandbox,emul = <&emul0>;
98 100 };
99 101 sandbox_pmic: sandbox_pmic {
100 102 reg = <0x40>;
101 103  
... ... @@ -107,12 +109,12 @@
107 109 i2c_emul: emul {
108 110 reg = <0xff>;
109 111 compatible = "sandbox,i2c-emul-parent";
110   - emul-eeprom {
  112 + emul_eeprom: emul-eeprom {
111 113 compatible = "sandbox,i2c-eeprom";
112 114 sandbox,filename = "i2c.bin";
113 115 sandbox,size = <256>;
114 116 };
115   - emul0 {
  117 + emul0: emul0 {
116 118 compatible = "sandbox,i2c-rtc";
117 119 };
118 120 };
arch/sandbox/include/asm/io.h
... ... @@ -173,6 +173,18 @@
173 173 {
174 174 }
175 175  
  176 +static inline void memset_io(volatile void *addr, unsigned char val, int count)
  177 +{
  178 +}
  179 +
  180 +static inline void memcpy_fromio(void *dst, const volatile void *src, int count)
  181 +{
  182 +}
  183 +
  184 +static inline void memcpy_toio(volatile void *dst, const void *src, int count)
  185 +{
  186 +}
  187 +
176 188 #define insw(port, buf, ns) _insw((u16 *)port, buf, ns)
177 189 #define outsw(port, buf, ns) _outsw((u16 *)port, buf, ns)
178 190  
arch/x86/lib/acpi_table.c
... ... @@ -342,6 +342,7 @@
342 342 struct acpi_table_header *header = &(spcr->header);
343 343 struct serial_device_info serial_info = {0};
344 344 ulong serial_address, serial_offset;
  345 + struct udevice *dev;
345 346 uint serial_config;
346 347 uint serial_width;
347 348 int access_size;
... ... @@ -353,7 +354,10 @@
353 354 header->length = sizeof(struct acpi_spcr);
354 355 header->revision = 2;
355 356  
356   - ret = serial_getinfo(&serial_info);
  357 + /* Read the device once, here. It is reused below */
  358 + ret = uclass_first_device_err(UCLASS_SERIAL, &dev);
  359 + if (!ret)
  360 + ret = serial_getinfo(dev, &serial_info);
357 361 if (ret)
358 362 serial_info.type = SERIAL_CHIP_UNKNOWN;
359 363  
... ... @@ -431,9 +435,9 @@
431 435 break;
432 436 }
433 437  
434   - ret = serial_getconfig(&serial_config);
435   - if (ret)
436   - serial_config = SERIAL_DEFAULT_CONFIG;
  438 + serial_config = SERIAL_DEFAULT_CONFIG;
  439 + if (dev)
  440 + ret = serial_getconfig(dev, &serial_config);
437 441  
438 442 spcr->parity = SERIAL_GET_PARITY(serial_config);
439 443 spcr->stop_bits = SERIAL_GET_STOP(serial_config);
common/fdt_support.c
... ... @@ -1025,7 +1025,7 @@
1025 1025 s = fdt_read_number(range + na + pna, ns);
1026 1026 da = fdt_read_number(addr, na);
1027 1027  
1028   - debug("OF: default map, cp=%llu, s=%llu, da=%llu\n", cp, s, da);
  1028 + debug("OF: default map, cp=%llx, s=%llx, da=%llx\n", cp, s, da);
1029 1029  
1030 1030 if (da < cp || da >= (cp + s))
1031 1031 return OF_BAD_ADDR;
... ... @@ -1080,7 +1080,7 @@
1080 1080 s = fdt_read_number(range + na + pna, ns);
1081 1081 da = fdt_read_number(addr + 1, na - 1);
1082 1082  
1083   - debug("OF: ISA map, cp=%llu, s=%llu, da=%llu\n", cp, s, da);
  1083 + debug("OF: ISA map, cp=%llx, s=%llx, da=%llx\n", cp, s, da);
1084 1084  
1085 1085 if (da < cp || da >= (cp + s))
1086 1086 return OF_BAD_ADDR;
... ... @@ -16,7 +16,7 @@
16 16 struct udevice *child;
17 17  
18 18 /* print the first 20 characters to not break the tree-format. */
19   - printf(" %-10.10s %d [ %c ] %-20.20s ", dev->uclass->uc_drv->name,
  19 + printf(" %-10.10s %2d [ %c ] %-20.20s ", dev->uclass->uc_drv->name,
20 20 dev_get_uclass_index(dev, NULL),
21 21 dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name);
22 22  
... ... @@ -49,7 +49,7 @@
49 49  
50 50 root = dm_root();
51 51 if (root) {
52   - printf(" Class index Probed Driver Name\n");
  52 + printf(" Class Index Probed Driver Name\n");
53 53 printf("-----------------------------------------------------------\n");
54 54 show_devices(root, -1, 0);
55 55 }
drivers/net/sandbox-raw.c
... ... @@ -152,7 +152,6 @@
152 152 struct eth_pdata *pdata = dev_get_platdata(dev);
153 153 struct eth_sandbox_raw_priv *priv = dev_get_priv(dev);
154 154 const char *ifname;
155   - u32 local;
156 155 int ret;
157 156  
158 157 pdata->iobase = dev_read_addr(dev);
... ... @@ -173,10 +172,10 @@
173 172 priv->host_ifindex, priv->host_ifname);
174 173 }
175 174  
176   - local = sandbox_eth_raw_os_is_local(priv->host_ifname);
177   - if (local < 0)
178   - return local;
179   - priv->local = local;
  175 + ret = sandbox_eth_raw_os_is_local(priv->host_ifname);
  176 + if (ret < 0)
  177 + return ret;
  178 + priv->local = ret;
180 179  
181 180 return 0;
182 181 }
drivers/serial/serial-uclass.c
... ... @@ -294,49 +294,40 @@
294 294 ops->setbrg(gd->cur_serial_dev, gd->baudrate);
295 295 }
296 296  
297   -int serial_getconfig(uint *config)
  297 +int serial_getconfig(struct udevice *dev, uint *config)
298 298 {
299 299 struct dm_serial_ops *ops;
300 300  
301   - if (!gd->cur_serial_dev)
302   - return 0;
303   -
304   - ops = serial_get_ops(gd->cur_serial_dev);
  301 + ops = serial_get_ops(dev);
305 302 if (ops->getconfig)
306   - return ops->getconfig(gd->cur_serial_dev, config);
  303 + return ops->getconfig(dev, config);
307 304  
308 305 return 0;
309 306 }
310 307  
311   -int serial_setconfig(uint config)
  308 +int serial_setconfig(struct udevice *dev, uint config)
312 309 {
313 310 struct dm_serial_ops *ops;
314 311  
315   - if (!gd->cur_serial_dev)
316   - return 0;
317   -
318   - ops = serial_get_ops(gd->cur_serial_dev);
  312 + ops = serial_get_ops(dev);
319 313 if (ops->setconfig)
320   - return ops->setconfig(gd->cur_serial_dev, config);
  314 + return ops->setconfig(dev, config);
321 315  
322 316 return 0;
323 317 }
324 318  
325   -int serial_getinfo(struct serial_device_info *info)
  319 +int serial_getinfo(struct udevice *dev, struct serial_device_info *info)
326 320 {
327 321 struct dm_serial_ops *ops;
328 322  
329   - if (!gd->cur_serial_dev)
330   - return -ENODEV;
331   -
332 323 if (!info)
333 324 return -EINVAL;
334 325  
335 326 info->baudrate = gd->baudrate;
336 327  
337   - ops = serial_get_ops(gd->cur_serial_dev);
  328 + ops = serial_get_ops(dev);
338 329 if (ops->getinfo)
339   - return ops->getinfo(gd->cur_serial_dev, info);
  330 + return ops->getinfo(dev, info);
340 331  
341 332 return -EINVAL;
342 333 }
... ... @@ -351,8 +351,6 @@
351 351 void smp_kick_all_cpus(void);
352 352  
353 353 /* $(CPU)/serial.c */
354   -struct serial_device_info;
355   -
356 354 int serial_init (void);
357 355 void serial_setbrg (void);
358 356 void serial_putc (const char);
... ... @@ -360,9 +358,6 @@
360 358 void serial_puts (const char *);
361 359 int serial_getc (void);
362 360 int serial_tstc (void);
363   -int serial_getconfig(uint *config);
364   -int serial_setconfig(uint config);
365   -int serial_getinfo(struct serial_device_info *info);
366 361  
367 362 /* $(CPU)/speed.c */
368 363 int get_clocks (void);
... ... @@ -73,7 +73,8 @@
73 73 * @return 0 if log record was emitted, -ve on error
74 74 */
75 75 int _log(enum log_category_t cat, enum log_level_t level, const char *file,
76   - int line, const char *func, const char *fmt, ...);
  76 + int line, const char *func, const char *fmt, ...)
  77 + __attribute__ ((format (__printf__, 6, 7)));
77 78  
78 79 /* Define this at the top of a file to add a prefix to debug messages */
79 80 #ifndef pr_fmt
... ... @@ -248,6 +248,8 @@
248 248 * @cond: Break condition (usually involving @val)
249 249 * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops).
250 250 * @timeout_ms: Timeout in ms, 0 means never timeout
  251 + * @test_add_time: Used for sandbox testing - amount of time to add after
  252 + * starting the loop (0 if not testing)
251 253 *
252 254 * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
253 255 * error return value in case of a error read. In the two former cases,
254 256  
... ... @@ -256,8 +258,12 @@
256 258 *
257 259 * This is modelled after the regmap_read_poll_timeout macros in linux but
258 260 * with millisecond timeout.
  261 + *
  262 + * The _test version is for sandbox testing only. Do not use this in normal
  263 + * code as it advances the timer.
259 264 */
260   -#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
  265 +#define regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
  266 + timeout_ms, test_add_time) \
261 267 ({ \
262 268 unsigned long __start = get_timer(0); \
263 269 int __ret; \
... ... @@ -267,6 +273,8 @@
267 273 break; \
268 274 if (cond) \
269 275 break; \
  276 + if (IS_ENABLED(CONFIG_SANDBOX) && test_add_time) \
  277 + sandbox_timer_add_offset(test_add_time); \
270 278 if ((timeout_ms) && get_timer(__start) > (timeout_ms)) { \
271 279 __ret = regmap_read((map), (addr), &(val)); \
272 280 break; \
... ... @@ -276,6 +284,10 @@
276 284 } \
277 285 __ret ?: ((cond) ? 0 : -ETIMEDOUT); \
278 286 })
  287 +
  288 +#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
  289 + regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
  290 + timeout_ms, 0) \
279 291  
280 292 /**
281 293 * regmap_update_bits() - Perform a read/modify/write using a mask
... ... @@ -235,9 +235,7 @@
235 235 * Get a current config for this device.
236 236 *
237 237 * @dev: Device pointer
238   - * @parity: parity to use
239   - * @bits: bits number to use
240   - * @stop: stop bits number to use
  238 + * @serial_config: Returns config information (see SERIAL_... above)
241 239 * @return 0 if OK, -ve on error
242 240 */
243 241 int (*getconfig)(struct udevice *dev, uint *serial_config);
... ... @@ -257,6 +255,7 @@
257 255 *
258 256 * @dev: Device pointer
259 257 * @info: struct serial_device_info to fill
  258 + * @return 0 if OK, -ve on error
260 259 */
261 260 int (*getinfo)(struct udevice *dev, struct serial_device_info *info);
262 261 };
... ... @@ -280,6 +279,39 @@
280 279  
281 280 /* Access the serial operations for a device */
282 281 #define serial_get_ops(dev) ((struct dm_serial_ops *)(dev)->driver->ops)
  282 +
  283 +/**
  284 + * serial_getconfig() - Get the uart configuration
  285 + * (parity, 5/6/7/8 bits word length, stop bits)
  286 + *
  287 + * Get a current config for this device.
  288 + *
  289 + * @dev: Device pointer
  290 + * @serial_config: Returns config information (see SERIAL_... above)
  291 + * @return 0 if OK, -ve on error
  292 + */
  293 +int serial_getconfig(struct udevice *dev, uint *config);
  294 +
  295 +/**
  296 + * serial_setconfig() - Set up the uart configuration
  297 + * (parity, 5/6/7/8 bits word length, stop bits)
  298 + *
  299 + * Set up a new config for this device.
  300 + *
  301 + * @dev: Device pointer
  302 + * @serial_config: number of bits, parity and number of stopbits to use
  303 + * @return 0 if OK, -ve on error
  304 + */
  305 +int serial_setconfig(struct udevice *dev, uint config);
  306 +
  307 +/**
  308 + * serial_getinfo() - Get serial device information
  309 + *
  310 + * @dev: Device pointer
  311 + * @info: struct serial_device_info to fill
  312 + * @return 0 if OK, -ve on error
  313 + */
  314 +int serial_getinfo(struct udevice *dev, struct serial_device_info *info);
283 315  
284 316 void atmel_serial_initialize(void);
285 317 void mcf_serial_initialize(void);
lib/efi_loader/efi_file.c
... ... @@ -221,8 +221,8 @@
221 221 struct file_handle *fh = to_fh(file);
222 222 efi_status_t ret;
223 223  
224   - EFI_ENTRY("%p, %p, \"%ls\", %llx, %llu", file, new_handle, file_name,
225   - open_mode, attributes);
  224 + EFI_ENTRY("%p, %p, \"%ls\", %llx, %llu", file, new_handle,
  225 + (wchar_t *)file_name, open_mode, attributes);
226 226  
227 227 /* Check parameters */
228 228 if (!file || !new_handle || !file_name) {
... ... @@ -95,16 +95,6 @@
95 95  
96 96 debug("%s: %s: ", __func__, prop_name);
97 97  
98   - if (na > (sizeof(fdt_addr_t) / sizeof(fdt32_t))) {
99   - debug("(na too large for fdt_addr_t type)\n");
100   - return FDT_ADDR_T_NONE;
101   - }
102   -
103   - if (ns > (sizeof(fdt_size_t) / sizeof(fdt32_t))) {
104   - debug("(ns too large for fdt_size_t type)\n");
105   - return FDT_ADDR_T_NONE;
106   - }
107   -
108 98 prop = fdt_getprop(blob, node, prop_name, &len);
109 99 if (!prop) {
110 100 debug("(not found)\n");
... ... @@ -160,9 +160,10 @@
160 160 start = get_timer(0);
161 161  
162 162 ut_asserteq(-ETIMEDOUT,
163   - regmap_read_poll_timeout(map, 0, reg,
164   - (reg == 0xcacafafa),
165   - 1, 5 * CONFIG_SYS_HZ));
  163 + regmap_read_poll_timeout_test(map, 0, reg,
  164 + (reg == 0xcacafafa),
  165 + 1, 5 * CONFIG_SYS_HZ,
  166 + 5 * CONFIG_SYS_HZ));
166 167  
167 168 ut_assert(get_timer(start) > (5 * CONFIG_SYS_HZ));
168 169  
... ... @@ -23,23 +23,24 @@
23 23 * test with default config which is the only one supported by
24 24 * sandbox_serial driver
25 25 */
26   - ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG));
27   - ut_assertok(serial_getconfig(&value_serial));
  26 + ut_assertok(serial_setconfig(dev_serial, SERIAL_DEFAULT_CONFIG));
  27 + ut_assertok(serial_getconfig(dev_serial, &value_serial));
28 28 ut_assert(value_serial == SERIAL_DEFAULT_CONFIG);
29   - ut_assertok(serial_getinfo(&info_serial));
  29 + ut_assertok(serial_getinfo(dev_serial, &info_serial));
30 30 ut_assert(info_serial.type == SERIAL_CHIP_UNKNOWN);
31 31 ut_assert(info_serial.addr == SERIAL_DEFAULT_ADDRESS);
32 32 /*
33 33 * test with a parameter which is NULL pointer
34 34 */
35   - ut_asserteq(-EINVAL, serial_getconfig(NULL));
36   - ut_asserteq(-EINVAL, serial_getinfo(NULL));
  35 + ut_asserteq(-EINVAL, serial_getconfig(dev_serial, NULL));
  36 + ut_asserteq(-EINVAL, serial_getinfo(dev_serial, NULL));
37 37 /*
38 38 * test with a serial config which is not supported by
39 39 * sandbox_serial driver: test with wrong parity
40 40 */
41 41 ut_asserteq(-ENOTSUPP,
42   - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_ODD,
  42 + serial_setconfig(dev_serial,
  43 + SERIAL_CONFIG(SERIAL_PAR_ODD,
43 44 SERIAL_8_BITS,
44 45 SERIAL_ONE_STOP)));
45 46 /*
... ... @@ -47,7 +48,8 @@
47 48 * sandbox_serial driver: test with wrong bits number
48 49 */
49 50 ut_asserteq(-ENOTSUPP,
50   - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE,
  51 + serial_setconfig(dev_serial,
  52 + SERIAL_CONFIG(SERIAL_PAR_NONE,
51 53 SERIAL_6_BITS,
52 54 SERIAL_ONE_STOP)));
53 55  
... ... @@ -56,7 +58,8 @@
56 58 * sandbox_serial driver: test with wrong stop bits number
57 59 */
58 60 ut_asserteq(-ENOTSUPP,
59   - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE,
  61 + serial_setconfig(dev_serial,
  62 + SERIAL_CONFIG(SERIAL_PAR_NONE,
60 63 SERIAL_8_BITS,
61 64 SERIAL_TWO_STOP)));
62 65  
test/py/tests/test_bind.py
... ... @@ -13,7 +13,8 @@
13 13 else:
14 14 leaf = leaf + '`'
15 15 leaf = leaf + '-- ' + name
16   - line = ' *{:10.10} [0-9]* \[ [ +] \] {:20.20} {}$'.format(uclass, drv, leaf)
  16 + line = (' *{:10.10} [0-9]* \[ [ +] \] {:20.20} {}$'
  17 + .format(uclass, drv, leaf))
17 18 prog = re.compile(line)
18 19 for l in lines:
19 20 if prog.match(l):
tools/buildman/README
... ... @@ -1046,6 +1046,16 @@
1046 1046  
1047 1047 The -U option uses the u-boot.env files which are produced by a build.
1048 1048  
  1049 +
  1050 +Building with clang
  1051 +===================
  1052 +
  1053 +To build with clang (sandbox only), use the -O option to override the
  1054 +toolchain. For example:
  1055 +
  1056 + buildman -O clang-7 --board sandbox
  1057 +
  1058 +
1049 1059 Other options
1050 1060 =============
1051 1061  
... ... @@ -1169,8 +1179,6 @@
1169 1179 problems, perhaps by building a few boards for each arch, or checking
1170 1180 commits for changed files and building only boards which use those files.
1171 1181  
1172   -A specific problem to fix is that Ctrl-C does not exit buildman cleanly when
1173   -multiple builder threads are active.
1174 1182  
1175 1183 Credits
1176 1184 =======
tools/buildman/builderthread.py
... ... @@ -156,7 +156,12 @@
156 156 if result.already_done:
157 157 # Get the return code from that build and use it
158 158 with open(done_file, 'r') as fd:
159   - result.return_code = int(fd.readline())
  159 + try:
  160 + result.return_code = int(fd.readline())
  161 + except ValueError:
  162 + # The file may be empty due to running out of disk space.
  163 + # Try a rebuild
  164 + result.return_code = RETURN_CODE_RETRY
160 165  
161 166 # Check the signal that the build needs to be retried
162 167 if result.return_code == RETURN_CODE_RETRY:
... ... @@ -224,6 +229,7 @@
224 229 config_args = ['%s_defconfig' % brd.target]
225 230 config_out = ''
226 231 args.extend(self.builder.toolchains.GetMakeArguments(brd))
  232 + args.extend(self.toolchain.MakeArgs())
227 233  
228 234 # If we need to reconfigure, do that now
229 235 if do_config:
tools/buildman/cmdline.py
... ... @@ -74,6 +74,8 @@
74 74 parser.add_option('-o', '--output-dir', type='string',
75 75 dest='output_dir', default='..',
76 76 help='Directory where all builds happen and buildman has its workspace (default is ../)')
  77 + parser.add_option('-O', '--override-toolchain', type='string',
  78 + help="Override host toochain to use for sandbox (e.g. 'clang-7')")
77 79 parser.add_option('-Q', '--quick', action='store_true',
78 80 default=False, help='Do a rough build, with limited warning resolution')
79 81 parser.add_option('-p', '--full-path', action='store_true',
tools/buildman/control.py
... ... @@ -141,7 +141,7 @@
141 141  
142 142 no_toolchains = toolchains is None
143 143 if no_toolchains:
144   - toolchains = toolchain.Toolchains()
  144 + toolchains = toolchain.Toolchains(options.override_toolchain)
145 145  
146 146 if options.fetch_arch:
147 147 if options.fetch_arch == 'list':
tools/buildman/toolchain.py
... ... @@ -54,9 +54,11 @@
54 54 arch: Architecture of toolchain as determined from the first
55 55 component of the filename. E.g. arm-linux-gcc becomes arm
56 56 priority: Toolchain priority (0=highest, 20=lowest)
  57 + override_toolchain: Toolchain to use for sandbox, overriding the normal
  58 + one
57 59 """
58 60 def __init__(self, fname, test, verbose=False, priority=PRIORITY_CALC,
59   - arch=None):
  61 + arch=None, override_toolchain=None):
60 62 """Create a new toolchain object.
61 63  
62 64 Args:
... ... @@ -68,6 +70,7 @@
68 70 """
69 71 self.gcc = fname
70 72 self.path = os.path.dirname(fname)
  73 + self.override_toolchain = override_toolchain
71 74  
72 75 # Find the CROSS_COMPILE prefix to use for U-Boot. For example,
73 76 # 'arm-linux-gnueabihf-gcc' turns into 'arm-linux-gnueabihf-'.
... ... @@ -81,6 +84,8 @@
81 84 self.arch = arch
82 85 else:
83 86 self.arch = self.cross[:pos] if pos != -1 else 'sandbox'
  87 + if self.arch == 'sandbox' and override_toolchain:
  88 + self.gcc = override_toolchain
84 89  
85 90 env = self.MakeEnvironment(False)
86 91  
... ... @@ -130,8 +135,8 @@
130 135 def GetWrapper(self, show_warning=True):
131 136 """Get toolchain wrapper from the setting file.
132 137 """
133   - value = ''
134   - for name, value in bsettings.GetItems('toolchain-wrapper'):
  138 + value = ''
  139 + for name, value in bsettings.GetItems('toolchain-wrapper'):
135 140 if not value:
136 141 print "Warning: Wrapper not found"
137 142 if value:
138 143  
... ... @@ -150,11 +155,18 @@
150 155 Args:
151 156 full_path: Return the full path in CROSS_COMPILE and don't set
152 157 PATH
  158 + Returns:
  159 + Dict containing the environemnt to use. This is based on the current
  160 + environment, with changes as needed to CROSS_COMPILE, PATH and
  161 + LC_ALL.
153 162 """
154 163 env = dict(os.environ)
155 164 wrapper = self.GetWrapper()
156 165  
157   - if full_path:
  166 + if self.override_toolchain:
  167 + # We'll use MakeArgs() to provide this
  168 + pass
  169 + elif full_path:
158 170 env['CROSS_COMPILE'] = wrapper + os.path.join(self.path, self.cross)
159 171 else:
160 172 env['CROSS_COMPILE'] = wrapper + self.cross
161 173  
... ... @@ -164,7 +176,23 @@
164 176  
165 177 return env
166 178  
  179 + def MakeArgs(self):
  180 + """Create the 'make' arguments for a toolchain
167 181  
  182 + This is only used when the toolchain is being overridden. Since the
  183 + U-Boot Makefile sets CC and HOSTCC explicitly we cannot rely on the
  184 + environment (and MakeEnvironment()) to override these values. This
  185 + function returns the arguments to accomplish this.
  186 +
  187 + Returns:
  188 + List of arguments to pass to 'make'
  189 + """
  190 + if self.override_toolchain:
  191 + return ['HOSTCC=%s' % self.override_toolchain,
  192 + 'CC=%s' % self.override_toolchain]
  193 + return []
  194 +
  195 +
168 196 class Toolchains:
169 197 """Manage a list of toolchains for building U-Boot
170 198  
171 199  
... ... @@ -180,10 +208,11 @@
180 208 paths: List of paths to check for toolchains (may contain wildcards)
181 209 """
182 210  
183   - def __init__(self):
  211 + def __init__(self, override_toolchain=None):
184 212 self.toolchains = {}
185 213 self.prefixes = {}
186 214 self.paths = []
  215 + self.override_toolchain = override_toolchain
187 216 self._make_flags = dict(bsettings.GetItems('make-flags'))
188 217  
189 218 def GetPathList(self, show_warning=True):
... ... @@ -234,7 +263,8 @@
234 263 priority: Priority to use for this toolchain
235 264 arch: Toolchain architecture, or None if not known
236 265 """
237   - toolchain = Toolchain(fname, test, verbose, priority, arch)
  266 + toolchain = Toolchain(fname, test, verbose, priority, arch,
  267 + self.override_toolchain)
238 268 add_it = toolchain.ok
239 269 if toolchain.arch in self.toolchains:
240 270 add_it = (toolchain.priority <