Skip to content

Commit 0fd2b9f

Browse files
committed
Added documentation
1 parent d9f6b66 commit 0fd2b9f

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

Diff for: docs/platform-specification.md

+53
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,59 @@ Sketch uses 924 bytes (2%) of program storage space. Maximum is 32256 bytes.
309309
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
310310
```
311311

312+
#### Recipes to compute binary sketch size for more complex systems (since Arduino CLI >=0.21.0)
313+
314+
A platform may provide a tool for the specific purpose to analize the binaries and compute the sketch size and memory
315+
usage statistics. This is especially useful for boards with non-trivial memory layouts where the classic reg-exp based
316+
approach is not sufficient.
317+
318+
The command line to run is specified with the recipe **recipe.advanced_size.pattern**.
319+
320+
The expected output from the tool is a JSON object with the following format:
321+
322+
```json
323+
{
324+
"output": "Your sketch use 2200 bytes of program memory out of 8192 (22%)\nThe static RAM used is 200 bytes (of 2048 max)\n",
325+
"severity": "info",
326+
"sections": [
327+
{ "name": "text", "size": 2200, "maxsize": 8192 },
328+
{ "name": "data", "size": 200, "maxsize": 2048 }
329+
]
330+
}
331+
```
332+
333+
The meaning of the fields is the following:
334+
335+
- `output`: is a preformatted text that is displayed as-is in console.
336+
- `severity`: indicates the warning level of the output messages, it can be `info`, `warning` or `error`. Warnings and
337+
errors are displayed in red (or in a different color than normal output). Errors will make the build/upload fail.
338+
- `sections`: is an array containing the memory sections and their usage level. Each item representis a memory section.
339+
This array is used to report memory usage in a machine-readable format if requested by the user.
340+
341+
When the `severity` is set to `error` the build/upload is interrupted and an exception is returned to the calling
342+
process. In this case an extra exception message must be provided through the `error` field, for example:
343+
344+
```json
345+
{
346+
"output": "Your sketch use 12200 bytes of program memory out of 8192 (122%)",
347+
"severity": "error",
348+
"error": "Sketch is too big!",
349+
"sections": [
350+
{ "name": "text", "size": 12200, "maxsize": 8192 },
351+
{ "name": "data", "size": 200, "maxsize": 2048 }
352+
]
353+
}
354+
```
355+
356+
This means that the `sections` part is **NOT** used to automatically check if the sketch size exceeds the available
357+
memory: this check is now delegated to the tool that must report a `"severity":"error"` with a meaningful error message.
358+
359+
If both **recipe.size.pattern** and **recipe.advanced_size.pattern** are present then **recipe.advanced_size.pattern**
360+
will be used. Since the **recipe.advanced_size.pattern** feature is avaiable starting from Arduino CLI>=0.21.0, to
361+
maximize backward compatibility, we recommend to provide both **recipe.size.pattern** and
362+
**recipe.advanced_size.pattern** if possible, so the old versions of the IDE/CLI will continue to work (even with a less
363+
detailed memory usage reports).
364+
312365
#### Recipes to export compiled binary
313366

314367
When you do a **Sketch > Export compiled Binary** in the Arduino IDE, the compiled binary is copied from the build

0 commit comments

Comments
 (0)