-
Notifications
You must be signed in to change notification settings - Fork 0
/
mix.exs
183 lines (158 loc) · 4.79 KB
/
mix.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
defmodule CustomRpi3.MixProject do
use Mix.Project
@github_organization "ejc123"
@app :custom_rpi3
@source_url "https://github.com/#{@github_organization}/#{@app}"
@version Path.join(__DIR__, "VERSION")
|> File.read!()
|> String.trim()
def project do
[
app: @app,
version: @version,
elixir: "~> 1.6",
compilers: Mix.compilers() ++ [:nerves_package],
nerves_package: nerves_package(),
description: description(),
package: package(),
deps: deps(),
aliases: [loadconfig: [&bootstrap/1]],
docs: docs(),
preferred_cli_env: %{
docs: :docs,
"hex.build": :docs,
"hex.publish": :docs
}
]
end
def application do
check_rpi_v2_ack!()
[]
end
defp bootstrap(args) do
set_target()
Application.start(:nerves_bootstrap)
# We're compiling locally so ack v2 req
Application.put_env(:nerves, :rpi_v2_ack, true)
Mix.Task.run("loadconfig", args)
end
defp nerves_package do
[
type: :system,
artifact_sites: [
{:github_releases, "#{@github_organization}/#{@app}"}
],
build_runner_opts: build_runner_opts(),
platform: Nerves.System.BR,
platform_config: [
defconfig: "nerves_defconfig"
],
# The :env key is an optional experimental feature for adding environment
# variables to the crosscompile environment. These are intended for
# llvm-based tooling that may need more precise processor information.
env: [
{"TARGET_ARCH", "arm"},
{"TARGET_CPU", "cortex_a53"},
{"TARGET_OS", "linux"},
{"TARGET_ABI", "gnueabihf"},
{"TARGET_GCC_FLAGS",
"-mabi=aapcs-linux -mfpu=fp-armv8 -marm -fstack-protector-strong -mfloat-abi=hard -mcpu=cortex-a53 -fPIE -pie -Wl,-z,now -Wl,-z,relro"}
],
checksum: package_files()
]
end
defp deps do
[
{:nerves, "~> 1.5.4 or ~> 1.6.0 or ~> 1.7.15 or ~> 1.8", runtime: false},
{:nerves_system_br, "1.22.4", runtime: false},
{:nerves_toolchain_armv7_nerves_linux_gnueabihf, "~> 1.8.0", runtime: false},
{:nerves_system_linter, "~> 0.4", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.22", only: :docs, runtime: false}
]
end
defp description do
"""
Nerves System - Raspberry Pi 3 B / B+
"""
end
defp docs do
[
extras: ["README.md", "CHANGELOG.md"],
main: "readme",
assets: "assets",
source_ref: "v#{@version}",
source_url: @source_url,
skip_undefined_reference_warnings_on: ["CHANGELOG.md"]
]
end
defp package do
[
maintainers: ["Eric J. Christeson"],
files: package_files(),
licenses: ["Apache-2.0"],
links: %{"GitHub" => @source_url}
]
end
defp package_files do
[
"fwup_include",
"rootfs_overlay",
"CHANGELOG.md",
"cmdline.txt",
"config.txt",
"fwup-revert.conf",
"fwup.conf",
"LICENSE",
"linux-5.15.defconfig",
"mix.exs",
"nerves_defconfig",
"nerves_initramfs.conf",
"post-build.sh",
"post-createfs.sh",
"ramoops.dts",
"README.md",
"VERSION"
]
end
defp build_runner_opts() do
# Download source files first to get download errors right away.
[make_args: primary_site() ++ ["source", "all", "legal-info"]]
end
defp primary_site() do
case System.get_env("BR2_PRIMARY_SITE") do
nil -> []
primary_site -> ["BR2_PRIMARY_SITE=#{primary_site}"]
end
end
defp set_target() do
if function_exported?(Mix, :target, 1) do
apply(Mix, :target, [:target])
else
System.put_env("MIX_TARGET", "target")
end
end
defp check_rpi_v2_ack!() do
acked? = Application.get_env(:nerves, :rpi_v2_ack) || System.get_env("NERVES_RPI_V2_ACK")
unless acked? do
Mix.raise("""
You are using #{@app} >= 2.0.0 which is technically
backwards compatible, but requires one manual step if
you are attempting to update the firmware on an existing
device via ssh, upload script, NervesHub, or other remote
firmware update procedure.
You will need to validate the running firmware on the
device before installing a firmware built with this system.
Otherwise, you will get an unexpected and misleading fwup error.
To validate and avoid the fwup error, run:
Nerves.Runtime.validate_firmware()
Or if using :nerves_runtime < 0.11.2, run:
Nerves.Runtime.KV.put("nerves_fw_validated", "1")
If you are burning the firmware directly to a SD card, then
nothing needs to be done.
To allow compilation to complete, acknowledge you have read
this warning by adding this line to your `config.exs`:
config :nerves, rpi_v2_ack: true
""")
end
end
end