1rec {
2 pcBase = {
3 name = "pc";
4 uboot = null;
5 kernelHeadersBaseConfig = "defconfig";
6 kernelBaseConfig = "defconfig";
7 # Build whatever possible as a module, if not stated in the extra config.
8 kernelAutoModules = true;
9 kernelTarget = "bzImage";
10 };
11
12 pc64 = pcBase // { kernelArch = "x86_64"; };
13
14 pc32 = pcBase // { kernelArch = "i386"; };
15
16 pc32_simplekernel = pc32 // {
17 kernelAutoModules = false;
18 };
19
20 pc64_simplekernel = pc64 // {
21 kernelAutoModules = false;
22 };
23
24 pogoplug4 = {
25 name = "pogoplug4";
26
27 gcc = {
28 arch = "armv5te";
29 float = "soft";
30 };
31
32 kernelMajor = "2.6";
33 kernelHeadersBaseConfig = "multi_v5_defconfig";
34 kernelBaseConfig = "multi_v5_defconfig";
35 kernelArch = "arm";
36 kernelAutoModules = false;
37 kernelExtraConfig =
38 ''
39 # Ubi for the mtd
40 MTD_UBI y
41 UBIFS_FS y
42 UBIFS_FS_XATTR y
43 UBIFS_FS_ADVANCED_COMPR y
44 UBIFS_FS_LZO y
45 UBIFS_FS_ZLIB y
46 UBIFS_FS_DEBUG n
47 '';
48 kernelMakeFlags = [ "LOADADDR=0x8000" ];
49 kernelTarget = "uImage";
50 # TODO reenable once manual-config's config actually builds a .dtb and this is checked to be working
51 #kernelDTB = true;
52
53 # XXX can be anything non-null, pkgs actually only cares if it is set or not
54 uboot = "pogoplug4";
55 };
56
57 sheevaplug = {
58 name = "sheevaplug";
59 kernelMajor = "2.6";
60 kernelHeadersBaseConfig = "multi_v5_defconfig";
61 kernelBaseConfig = "multi_v5_defconfig";
62 kernelArch = "arm";
63 kernelAutoModules = false;
64 kernelExtraConfig = ''
65 BLK_DEV_RAM y
66 BLK_DEV_INITRD y
67 BLK_DEV_CRYPTOLOOP m
68 BLK_DEV_DM m
69 DM_CRYPT m
70 MD y
71 REISERFS_FS m
72 BTRFS_FS m
73 XFS_FS m
74 JFS_FS m
75 EXT4_FS m
76 USB_STORAGE_CYPRESS_ATACB m
77
78 # mv cesa requires this sw fallback, for mv-sha1
79 CRYPTO_SHA1 y
80 # Fast crypto
81 CRYPTO_TWOFISH y
82 CRYPTO_TWOFISH_COMMON y
83 CRYPTO_BLOWFISH y
84 CRYPTO_BLOWFISH_COMMON y
85
86 IP_PNP y
87 IP_PNP_DHCP y
88 NFS_FS y
89 ROOT_NFS y
90 TUN m
91 NFS_V4 y
92 NFS_V4_1 y
93 NFS_FSCACHE y
94 NFSD m
95 NFSD_V2_ACL y
96 NFSD_V3 y
97 NFSD_V3_ACL y
98 NFSD_V4 y
99 NETFILTER y
100 IP_NF_IPTABLES y
101 IP_NF_FILTER y
102 IP_NF_MATCH_ADDRTYPE y
103 IP_NF_TARGET_LOG y
104 IP_NF_MANGLE y
105 IPV6 m
106 VLAN_8021Q m
107
108 CIFS y
109 CIFS_XATTR y
110 CIFS_POSIX y
111 CIFS_FSCACHE y
112 CIFS_ACL y
113
114 WATCHDOG y
115 WATCHDOG_CORE y
116 ORION_WATCHDOG m
117
118 ZRAM m
119 NETCONSOLE m
120
121 # Disable OABI to have seccomp_filter (required for systemd)
122 # https://github.com/raspberrypi/firmware/issues/651
123 OABI_COMPAT n
124
125 # Fail to build
126 DRM n
127 SCSI_ADVANSYS n
128 USB_ISP1362_HCD n
129 SND_SOC n
130 SND_ALI5451 n
131 FB_SAVAGE n
132 SCSI_NSP32 n
133 ATA_SFF n
134 SUNGEM n
135 IRDA n
136 ATM_HE n
137 SCSI_ACARD n
138 BLK_DEV_CMD640_ENHANCED n
139
140 FUSE_FS m
141
142 # systemd uses cgroups
143 CGROUPS y
144
145 # Latencytop
146 LATENCYTOP y
147
148 # Ubi for the mtd
149 MTD_UBI y
150 UBIFS_FS y
151 UBIFS_FS_XATTR y
152 UBIFS_FS_ADVANCED_COMPR y
153 UBIFS_FS_LZO y
154 UBIFS_FS_ZLIB y
155 UBIFS_FS_DEBUG n
156
157 # Kdb, for kernel troubles
158 KGDB y
159 KGDB_SERIAL_CONSOLE y
160 KGDB_KDB y
161 '';
162 kernelMakeFlags = [ "LOADADDR=0x0200000" ];
163 kernelTarget = "uImage";
164 uboot = "sheevaplug";
165 # Only for uboot = uboot :
166 ubootConfig = "sheevaplug_config";
167 kernelDTB = true; # Beyond 3.10
168 gcc = {
169 arch = "armv5te";
170 float = "soft";
171 };
172 };
173
174 raspberrypi = {
175 name = "raspberrypi";
176 kernelMajor = "2.6";
177 kernelHeadersBaseConfig = "bcm2835_defconfig";
178 kernelBaseConfig = "bcmrpi_defconfig";
179 kernelDTB = true;
180 kernelArch = "arm";
181 kernelAutoModules = false;
182 kernelExtraConfig = ''
183 BLK_DEV_RAM y
184 BLK_DEV_INITRD y
185 BLK_DEV_CRYPTOLOOP m
186 BLK_DEV_DM m
187 DM_CRYPT m
188 MD y
189 REISERFS_FS m
190 BTRFS_FS y
191 XFS_FS m
192 JFS_FS y
193 EXT4_FS y
194
195 IP_PNP y
196 IP_PNP_DHCP y
197 NFS_FS y
198 ROOT_NFS y
199 TUN m
200 NFS_V4 y
201 NFS_V4_1 y
202 NFS_FSCACHE y
203 NFSD m
204 NFSD_V2_ACL y
205 NFSD_V3 y
206 NFSD_V3_ACL y
207 NFSD_V4 y
208 NETFILTER y
209 IP_NF_IPTABLES y
210 IP_NF_FILTER y
211 IP_NF_MATCH_ADDRTYPE y
212 IP_NF_TARGET_LOG y
213 IP_NF_MANGLE y
214 IPV6 m
215 VLAN_8021Q m
216
217 CIFS y
218 CIFS_XATTR y
219 CIFS_POSIX y
220 CIFS_FSCACHE y
221 CIFS_ACL y
222
223 ZRAM m
224
225 # Disable OABI to have seccomp_filter (required for systemd)
226 # https://github.com/raspberrypi/firmware/issues/651
227 OABI_COMPAT n
228
229 # Fail to build
230 DRM n
231 SCSI_ADVANSYS n
232 USB_ISP1362_HCD n
233 SND_SOC n
234 SND_ALI5451 n
235 FB_SAVAGE n
236 SCSI_NSP32 n
237 ATA_SFF n
238 SUNGEM n
239 IRDA n
240 ATM_HE n
241 SCSI_ACARD n
242 BLK_DEV_CMD640_ENHANCED n
243
244 FUSE_FS m
245
246 # nixos mounts some cgroup
247 CGROUPS y
248
249 # Latencytop
250 LATENCYTOP y
251 '';
252 kernelTarget = "zImage";
253 uboot = null;
254 gcc = {
255 arch = "armv6";
256 fpu = "vfp";
257 float = "hard";
258 # TODO(@Ericson2314) what is this and is it a good idea? It was
259 # used in some cross compilation examples but not others.
260 #
261 # abi = "aapcs-linux";
262 };
263 };
264
265 raspberrypi2 = armv7l-hf-multiplatform // {
266 name = "raspberrypi2";
267 kernelBaseConfig = "bcm2709_defconfig";
268 kernelDTB = true;
269 kernelAutoModules = false;
270 kernelExtraConfig = ''
271 BLK_DEV_RAM y
272 BLK_DEV_INITRD y
273 BLK_DEV_CRYPTOLOOP m
274 BLK_DEV_DM m
275 DM_CRYPT m
276 MD y
277 REISERFS_FS m
278 BTRFS_FS y
279 XFS_FS m
280 JFS_FS y
281 EXT4_FS y
282
283 IP_PNP y
284 IP_PNP_DHCP y
285 NFS_FS y
286 ROOT_NFS y
287 TUN m
288 NFS_V4 y
289 NFS_V4_1 y
290 NFS_FSCACHE y
291 NFSD m
292 NFSD_V2_ACL y
293 NFSD_V3 y
294 NFSD_V3_ACL y
295 NFSD_V4 y
296 NETFILTER y
297 IP_NF_IPTABLES y
298 IP_NF_FILTER y
299 IP_NF_MATCH_ADDRTYPE y
300 IP_NF_TARGET_LOG y
301 IP_NF_MANGLE y
302 IPV6 m
303 VLAN_8021Q m
304
305 CIFS y
306 CIFS_XATTR y
307 CIFS_POSIX y
308 CIFS_FSCACHE y
309 CIFS_ACL y
310
311 ZRAM m
312
313 # Disable OABI to have seccomp_filter (required for systemd)
314 # https://github.com/raspberrypi/firmware/issues/651
315 OABI_COMPAT n
316
317 # Fail to build
318 DRM n
319 SCSI_ADVANSYS n
320 USB_ISP1362_HCD n
321 SND_SOC n
322 SND_ALI5451 n
323 FB_SAVAGE n
324 SCSI_NSP32 n
325 ATA_SFF n
326 SUNGEM n
327 IRDA n
328 ATM_HE n
329 SCSI_ACARD n
330 BLK_DEV_CMD640_ENHANCED n
331
332 FUSE_FS m
333
334 # nixos mounts some cgroup
335 CGROUPS y
336
337 # Latencytop
338 LATENCYTOP y
339
340 # Disable the common config Xen, it doesn't build on ARM
341 XEN? n
342 '';
343 kernelTarget = "zImage";
344 uboot = null;
345 };
346
347 scaleway-c1 = armv7l-hf-multiplatform // {
348 gcc = {
349 cpu = "cortex-a9";
350 fpu = "vfpv3";
351 float = "hard";
352 };
353 };
354
355 utilite = {
356 name = "utilite";
357 kernelMajor = "2.6";
358 kernelHeadersBaseConfig = "multi_v7_defconfig";
359 kernelBaseConfig = "multi_v7_defconfig";
360 kernelArch = "arm";
361 kernelAutoModules = false;
362 kernelExtraConfig =
363 ''
364 # Ubi for the mtd
365 MTD_UBI y
366 UBIFS_FS y
367 UBIFS_FS_XATTR y
368 UBIFS_FS_ADVANCED_COMPR y
369 UBIFS_FS_LZO y
370 UBIFS_FS_ZLIB y
371 UBIFS_FS_DEBUG n
372 '';
373 kernelMakeFlags = [ "LOADADDR=0x10800000" ];
374 kernelTarget = "uImage";
375 kernelDTB = true;
376 uboot = true; #XXX: any non-null value here is needed so that mkimage is present to build kernelTarget uImage
377 gcc = {
378 cpu = "cortex-a9";
379 fpu = "neon";
380 float = "hard";
381 };
382 };
383
384 guruplug = sheevaplug // {
385 # Define `CONFIG_MACH_GURUPLUG' (see
386 # <http://kerneltrap.org/mailarchive/git-commits-head/2010/5/19/33618>)
387 # and other GuruPlug-specific things. Requires the `guruplug-defconfig'
388 # patch.
389
390 kernelBaseConfig = "guruplug_defconfig";
391 #kernelHeadersBaseConfig = "guruplug_defconfig";
392 };
393
394 fuloong2f_n32 = {
395 name = "fuloong2f_n32";
396 kernelMajor = "2.6";
397 kernelHeadersBaseConfig = "fuloong2e_defconfig";
398 kernelBaseConfig = "lemote2f_defconfig";
399 kernelArch = "mips";
400 kernelAutoModules = false;
401 kernelExtraConfig = ''
402 MIGRATION n
403 COMPACTION n
404
405 # nixos mounts some cgroup
406 CGROUPS y
407
408 BLK_DEV_RAM y
409 BLK_DEV_INITRD y
410 BLK_DEV_CRYPTOLOOP m
411 BLK_DEV_DM m
412 DM_CRYPT m
413 MD y
414 REISERFS_FS m
415 EXT4_FS m
416 USB_STORAGE_CYPRESS_ATACB m
417
418 IP_PNP y
419 IP_PNP_DHCP y
420 IP_PNP_BOOTP y
421 NFS_FS y
422 ROOT_NFS y
423 TUN m
424 NFS_V4 y
425 NFS_V4_1 y
426 NFS_FSCACHE y
427 NFSD m
428 NFSD_V2_ACL y
429 NFSD_V3 y
430 NFSD_V3_ACL y
431 NFSD_V4 y
432
433 # Fail to build
434 DRM n
435 SCSI_ADVANSYS n
436 USB_ISP1362_HCD n
437 SND_SOC n
438 SND_ALI5451 n
439 FB_SAVAGE n
440 SCSI_NSP32 n
441 ATA_SFF n
442 SUNGEM n
443 IRDA n
444 ATM_HE n
445 SCSI_ACARD n
446 BLK_DEV_CMD640_ENHANCED n
447
448 FUSE_FS m
449
450 # Needed for udev >= 150
451 SYSFS_DEPRECATED_V2 n
452
453 VGA_CONSOLE n
454 VT_HW_CONSOLE_BINDING y
455 SERIAL_8250_CONSOLE y
456 FRAMEBUFFER_CONSOLE y
457 EXT2_FS y
458 EXT3_FS y
459 REISERFS_FS y
460 MAGIC_SYSRQ y
461
462 # The kernel doesn't boot at all, with FTRACE
463 FTRACE n
464 '';
465 kernelTarget = "vmlinux";
466 uboot = null;
467 gcc = {
468 arch = "loongson2f";
469 abi = "n32";
470 };
471 };
472
473 beaglebone = armv7l-hf-multiplatform // {
474 name = "beaglebone";
475 kernelBaseConfig = "omap2plus_defconfig";
476 kernelAutoModules = false;
477 kernelExtraConfig = ""; # TBD kernel config
478 kernelTarget = "zImage";
479 uboot = null;
480 };
481
482 armv7l-hf-multiplatform = {
483 name = "armv7l-hf-multiplatform";
484 kernelMajor = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc.
485 kernelHeadersBaseConfig = "multi_v7_defconfig";
486 kernelBaseConfig = "multi_v7_defconfig";
487 kernelArch = "arm";
488 kernelDTB = true;
489 kernelAutoModules = true;
490 kernelPreferBuiltin = true;
491 uboot = null;
492 kernelTarget = "zImage";
493 kernelExtraConfig = ''
494 # Fix broken sunxi-sid nvmem driver.
495 TI_CPTS y
496
497 # Hangs ODROID-XU4
498 ARM_BIG_LITTLE_CPUIDLE n
499 '';
500 gcc = {
501 # Some table about fpu flags:
502 # http://community.arm.com/servlet/JiveServlet/showImage/38-1981-3827/blogentry-103749-004812900+1365712953_thumb.png
503 # Cortex-A5: -mfpu=neon-fp16
504 # Cortex-A7 (rpi2): -mfpu=neon-vfpv4
505 # Cortex-A8 (beaglebone): -mfpu=neon
506 # Cortex-A9: -mfpu=neon-fp16
507 # Cortex-A15: -mfpu=neon-vfpv4
508
509 # More about FPU:
510 # https://wiki.debian.org/ArmHardFloatPort/VfpComparison
511
512 # vfpv3-d16 is what Debian uses and seems to be the best compromise: NEON is not supported in e.g. Scaleway or Tegra 2,
513 # and the above page suggests NEON is only an improvement with hand-written assembly.
514 arch = "armv7-a";
515 fpu = "vfpv3-d16";
516 float = "hard";
517
518 # For Raspberry Pi the 2 the best would be:
519 # cpu = "cortex-a7";
520 # fpu = "neon-vfpv4";
521 };
522 };
523
524 aarch64-multiplatform = {
525 name = "aarch64-multiplatform";
526 kernelMajor = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc.
527 kernelHeadersBaseConfig = "defconfig";
528 kernelBaseConfig = "defconfig";
529 kernelArch = "arm64";
530 kernelDTB = true;
531 kernelAutoModules = true;
532 kernelPreferBuiltin = true;
533 kernelExtraConfig = ''
534 # Raspberry Pi 3 stuff. Not needed for kernels >= 4.10.
535 ARCH_BCM2835 y
536 BCM2835_MBOX y
537 BCM2835_WDT y
538 RASPBERRYPI_FIRMWARE y
539 RASPBERRYPI_POWER y
540 SERIAL_8250_BCM2835AUX y
541 SERIAL_8250_EXTENDED y
542 SERIAL_8250_SHARE_IRQ y
543
544 # Cavium ThunderX stuff.
545 PCI_HOST_THUNDER_ECAM y
546
547 # The default (=y) forces us to have the XHCI firmware available in initrd,
548 # which our initrd builder can't currently do easily.
549 USB_XHCI_TEGRA m
550 '';
551 uboot = null;
552 kernelTarget = "Image";
553 gcc = {
554 arch = "armv8-a";
555 };
556 };
557
558 selectBySystem = system: {
559 "i686-linux" = pc32;
560 "x86_64-linux" = pc64;
561 "armv5tel-linux" = sheevaplug;
562 "armv6l-linux" = raspberrypi;
563 "armv7l-linux" = armv7l-hf-multiplatform;
564 "aarch64-linux" = aarch64-multiplatform;
565 "mips64el-linux" = fuloong2f_n32;
566 }.${system} or pcBase;
567}