uboot.pp 2.54 KB
Newer Older
1
class nest::base::firmware::uboot {
James T. Lee's avatar
James T. Lee committed
2
3
  # For nest::base::portage::makeopts
  include '::nest::base::portage'
4

James T. Lee's avatar
James T. Lee committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  Nest::Lib::Kconfig {
    config => '/usr/src/u-boot/.config',
  }

  $uboot_branch = $facts['profile']['platform'] ? {
    'pinebookpro' => 'pinebookpro',
    default       => 'main',
  }

  vcsrepo { '/usr/src/u-boot':
    ensure   => latest,
    provider => git,
    source   => 'https://gitlab.james.tl/nest/forks/u-boot.git',
    revision => $uboot_branch,
  }

  $defconfig = $facts['profile']['platform'] ? {
22
23
24
    'beagleboneblack' => 'am335x_evm_defconfig',
    'pinebookpro'     => 'pinebook-pro-rk3399_defconfig',
    'raspberrypi'     => 'rpi_arm64_defconfig',
James T. Lee's avatar
James T. Lee committed
25
26
27
28
29
30
31
32
33
  }

  exec { 'uboot-defconfig':
    command => "/usr/bin/make ${defconfig}",
    cwd     => '/usr/src/u-boot',
    creates => '/usr/src/u-boot/.config',
    require => Vcsrepo['/usr/src/u-boot'],
  }

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  nest::lib::kconfig {
    # Replace boot delay with interrupt
    'CONFIG_BOOTDELAY':
      value => 0;
    'CONFIG_AUTOBOOT_KEYED':
      value => y;
    'CONFIG_AUTOBOOT_PROMPT':
      value => 'Press Ctrl-C to interrupt autoboot\n';
    'CONFIG_AUTOBOOT_KEYED_CTRLC':
      value => y,
    ;

    # Always use default environment to avoid divergence
    'CONFIG_ENV_IS_NOWHERE':
      value => y;
    'CONFIG_ENV_IS_IN_FAT':
      value => n,
    ;
  }

James T. Lee's avatar
James T. Lee committed
54
55
56
57
58
  case $facts['profile']['platform'] {
    'pinebookpro': {
      $build_options = 'BL31=/usr/src/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf'

      nest::lib::kconfig {
59
        # May want to use SPI for other things
James T. Lee's avatar
James T. Lee committed
60
61
62
63
64
65
66
67
68
69
        'CONFIG_ENV_IS_IN_SPI_FLASH':
          value => n,
        ;

        # Hangs system during early kernel init
        'CONFIG_USB_OHCI_GENERIC':
          value => n,
        ;
      }
    }
70
71
72
73
74
75
76

    'raspberrypi': {
      # Fails with "Unknown partition table type 0"
      nest::lib::kconfig { 'CONFIG_MMC_SDHCI_SDMA':
        value => n,
      }
    }
James T. Lee's avatar
James T. Lee committed
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  }

  exec { 'uboot-olddefconfig':
    command     => '/usr/bin/make olddefconfig',
    cwd         => '/usr/src/u-boot',
    refreshonly => true,
  }
  ~>
  exec { 'uboot-build':
    command     => "/usr/bin/make ${::nest::base::portage::makeopts} ${build_options}",
    cwd         => '/usr/src/u-boot',
    path        => ['/usr/lib/distcc/bin', '/usr/bin', '/bin'],
    environment => 'HOME=/root',  # for distcc
    timeout     => 0,
    # just attempt once per config change
    refreshonly => true,
    noop        => !$facts['build'],
  }

  Exec['uboot-defconfig']
  -> Nest::Lib::Kconfig <| config == '/usr/src/u-boot/.config' |>
  ~> Exec['uboot-olddefconfig']
99
}