Skip to content

Commit cd4a43f

Browse files
authored
Add support for partition-tables. (#67)
1 parent ee51f38 commit cd4a43f

File tree

7 files changed

+201
-105
lines changed

7 files changed

+201
-105
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ on:
2323
required: false
2424
type: boolean
2525
default: true
26+
build-partitions:
27+
description: Build partitions
28+
required: false
29+
type: boolean
30+
default: true
2631
toit-version:
2732
description: Toit SDK version to check out
2833
required: true
@@ -192,7 +197,7 @@ jobs:
192197
artifacts: |
193198
envelopes/*
194199
body: |
195-
Envelopes for Toit SDK ${{ github.event.inputs.toit-version }}
200+
Envelopes and partitions for Toit SDK ${{ github.event.inputs.toit-version }}
196201
allowUpdates: true
197202
token: ${{ secrets.GITHUB_TOKEN }}
198203
tag: ${{ github.event.inputs.toit-version }}
@@ -300,7 +305,7 @@ jobs:
300305
artifacts: |
301306
envelopes/*
302307
body: |
303-
Envelopes for Toit SDK ${{ github.event.inputs.toit-version }}
308+
Envelopes and partition tables for Toit SDK ${{ github.event.inputs.toit-version }}
304309
allowUpdates: true
305310
token: ${{ secrets.GITHUB_TOKEN }}
306311
tag: ${{ github.event.inputs.toit-version }}
@@ -371,7 +376,47 @@ jobs:
371376
artifacts: |
372377
envelopes/*
373378
body: |
374-
Envelopes for Toit SDK ${{ github.event.inputs.toit-version }}
379+
Envelopes and partition tables for Toit SDK ${{ github.event.inputs.toit-version }}
380+
allowUpdates: true
381+
token: ${{ secrets.GITHUB_TOKEN }}
382+
tag: ${{ github.event.inputs.toit-version }}
383+
commit: main
384+
385+
release-partition-tables:
386+
name: "Release partition tables - ${{ github.event.inputs.toit-version }}"
387+
if: ${{ github.event.inputs.build-partitions == 'true' }}
388+
runs-on: ubuntu-latest
389+
390+
steps:
391+
- name: Show inputs
392+
run: echo "${{ toJSON(github.event.inputs) }}"
393+
394+
- uses: actions/checkout@v4
395+
396+
- name: Set the git version
397+
run: |
398+
echo "TOIT_GIT_VERSION=${{ github.event.inputs.toit-version }}" >> $GITHUB_ENV
399+
400+
- name: Prepare partition tables
401+
shell: bash
402+
run: |
403+
mkdir -p build
404+
shopt -s nullglob
405+
for csv_file in partitions/esp32/*/partitions.csv; do
406+
variant=$(basename "$(dirname "$csv_file")")
407+
if [ -e "partitions/esp32/$variant/partitions.csv" ]; then
408+
cp "$csv_file" "build/partitions-esp32-$variant.csv"
409+
fi
410+
done
411+
412+
- name: Release
413+
if: ${{ github.event.inputs.upload-release == 'true' }}
414+
uses: ncipollo/release-action@v1
415+
with:
416+
artifacts: |
417+
build/partitions-*.csv
418+
body: |
419+
Envelopes and partition tables for Toit SDK ${{ github.event.inputs.toit-version }}
375420
allowUpdates: true
376421
token: ${{ secrets.GITHUB_TOKEN }}
377422
tag: ${{ github.event.inputs.toit-version }}

README.md

Lines changed: 7 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Envelopes
22

3-
Envelopes for Toit.
3+
Envelopes and partition tables for Toit.
44

55
This repository contains a tool to generate envelopes for Toit. It
66
also automatically builds envelopes for the variants that are stored in
@@ -19,105 +19,10 @@ compiled with and for SDK v2.0.0-alpha.90 are found on the
1919
[v2.0.0-alpha.90 release](https://github.com/toitlang/envelopes/releases/tag/v2.0.0-alpha.90)
2020
page.
2121

22-
## Variants
22+
See the [variants/README.md](variants/README.md) for a list of the
23+
most commonly used variants. You can also browse the `variants`
24+
directory for more variants.
2325

24-
### esp32
25-
26-
A generic ESP32 variant. This is the default variant when using Toit.
27-
It is built for maximum compatibility.
28-
29-
This variant supports Ethernet, but without the clock output.
30-
31-
### esp32-spiram
32-
33-
An ESP32 variant for boards with SPIRAM. Otherwise the same as the ESP32 variant.
34-
35-
### esp32-eth-clk-out0 and esp32-eth-clk-out17
36-
37-
A variant for ESP32 boards with Ethernet and a clock output on pin 0/17.
38-
39-
Olimex boards with Ethernet should use this variant. The WROOM versions need
40-
`esp32-eth-clk-out17` and the WROVER versions need `esp32-eth-clk-out0`.
41-
42-
### esp32c3
43-
44-
A generic [ESP32-C3 variant](variants/esp32c). This is the default variant
45-
when using Toit on ESP32-C3 boards.
46-
47-
### esp32s2
48-
49-
A generic [ESP32-S2 variant](variants/esp32s2). This is the default variant
50-
when using Toit on ESP32-S2 boards.
51-
52-
### esp32s3
53-
54-
A generic [ESP32-S3 variant](variants/esp32s3). This is the default variant
55-
when using Toit on ESP32-S3 boards.
56-
57-
This variant is configured for external Quad PSRAM.
58-
59-
### esp32s3-spiram-octo
60-
61-
A [variant](variants/esp32s3-spiram-octo/) for ESP32-S3 boards with external
62-
octal PSRAM.
63-
64-
These boards are faster, but often more expensive.
65-
66-
### esp32-no-ble
67-
68-
A [variant](variants/esp32-no-ble/) for ESP32 boards. This variant
69-
saves some RAM and flash space by removing the Bluetooth stack.
70-
The saved IRAM enables us to make the Toit interpreter a little faster
71-
and add support for external RAM (PSRAM, aka SPIRAM).
72-
73-
## Contributing
74-
75-
Feel free to open issues and pull requests with new variants. Make sure
76-
they have a description (README.md) with the purpose and the changes.
77-
We will automatically build them whenever a new Toit version is released.
78-
79-
Note that some variants are featured here. Consult the
80-
Toit team before adding new variants to this README.
81-
82-
### Creating a variant
83-
84-
Variants are created by copying an existing variant and making the
85-
necessary changes. These consists of either overwriting existing files
86-
or by applying patches.
87-
88-
#### Partition changes
89-
90-
For partition changes, simply copy the new `partitions.csv` into the
91-
variant directory. The `esp32-ota-1c0000` is an example of this where
92-
the OTA partition size has been increased.
93-
94-
#### sdkconfig changes
95-
96-
For `sdkconfig` changes, a patch to the original `sdkconfig.defaults`
97-
file is typically preferred.
98-
99-
For example, to create a variant `esp32s3-foo`.
100-
* Check out Toit (or use an existing checkout).
101-
* Copy the existing `toolchains/esp32s3` directory to `toolchains/esp32s3-foo`:
102-
`cp -r toolchains/esp32s3 toolchains/esp32s3-foo`.
103-
* Run `make IDF_TARGET=esp32s3 ESP32_CHIP=esp32s3-foo menuconfig` and make the changes you want.
104-
This automatically updates the `sdkconfig.defaults` as well.
105-
* Create patch by running:
106-
```
107-
diff -aur \
108-
--label toit/toolchains/esp32s3/sdkconfig.defaults \
109-
--label synthesized/esp32s3-foo/sdkconfig.defaults \
110-
toolchains/esp32s3/sdkconfig.defaults \
111-
toolchains/esp32s3-foo/sdkconfig.defaults \
112-
> toolchains/esp32s3-foo/sdkconfig.defaults.patch
113-
```
114-
The labels are not crucial, but make it easier for us to update the
115-
patch at a later time.
116-
* Create a new variant in this (`envelopes`) repository and copy the patch file into it.
117-
118-
#### Main changes
119-
120-
For changes to the `main` directory (be it the `toit.c` or the `CMakelists.txt` in it),
121-
use a recursive diff to create a patch on the original `main` directory.
122-
123-
The synthetization tool will use the flag `-p1` when applying the patch.
26+
See the [partitions/esp32/README.md](partitions/esp32/README.md) for
27+
a list of the most commonly used partition tables. You can also browse
28+
the `partitions/esp32` directory for more partition tables.

partitions/esp32/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Partition tables
2+
3+
This directory contains partition tables for ESP32 devices and their variants.
4+
5+
During flashing, users can override the default partition table that comes
6+
with the envelope that they are flashing.
7+
8+
Here is a list of the most commonly used partition tables:
9+
10+
## OTA-1C0000
11+
12+
A partition table that sets the size of the OTA partitions
13+
to 0x1C0000 (1835008) bytes. This table is typically used for
14+
use-cases where programs are bundled with the firmware (like with
15+
[Artemis](https://github.com/toitware/artemis)).
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# OTA-1C0000
2+
3+
A partition table that sets the size of the OTA partitions
4+
to 0x1C0000 (1835008) bytes.
5+
6+
As a consequence the size of the programs partition is set to
7+
0x60000 (393216) bytes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (C) 2023 Toitware ApS.
2+
#
3+
# Use of this source code is governed by a BSD0-style license that can be
4+
# found in the LICENSE_BSD0 file.
5+
6+
# Partition Table for Toit.
7+
8+
# Name, Type, SubType, Offset, Size
9+
# bootloader,, , 0x001000, 0x007000
10+
# partitions,, , 0x008000, 0x000c00
11+
secure, 0x42, 0x00, 0x009000, 0x004000,
12+
otadata, data, ota, 0x00d000, 0x002000,
13+
phy_init, data, phy, 0x00f000, 0x001000,
14+
ota_0, app, ota_0, 0x010000, 0x1c0000,
15+
ota_1, app, ota_1, 0x1d0000, 0x1c0000,
16+
nvs, data, nvs, 0x390000, 0x010000,
17+
programs, 0x40, 0x00, 0x3A0000, 0x060000, encrypted

variants/Contributing.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Contributing
2+
3+
Feel free to open issues and pull requests with new variants. Make sure
4+
they have a description (README.md) with the purpose and the changes. If
5+
they are generally useful, we will add them to the repository.
6+
7+
Variants in this repository are automatically built whenever a new Toit
8+
version is released.
9+
10+
## Creating a variant
11+
12+
Variants are created by copying an existing variant and making the
13+
necessary changes. These consists of either overwriting existing files
14+
or by applying patches.
15+
16+
### Partition changes
17+
18+
For partition changes, simply copy the new `partitions.csv` into the
19+
variant directory. The `esp32-ota-1c0000` is an example of this where
20+
the OTA partition size has been increased.
21+
22+
### sdkconfig changes
23+
24+
For `sdkconfig` changes, a patch to the original `sdkconfig.defaults`
25+
file is typically preferred.
26+
27+
For example, to create a variant `esp32s3-foo`.
28+
* Check out Toit (or use an existing checkout).
29+
* Copy the existing `toolchains/esp32s3` directory to `toolchains/esp32s3-foo`:
30+
`cp -r toolchains/esp32s3 toolchains/esp32s3-foo`.
31+
* Run `make IDF_TARGET=esp32s3 ESP32_CHIP=esp32s3-foo menuconfig` and make the changes you want.
32+
This automatically updates the `sdkconfig.defaults` as well.
33+
* Create patch by running:
34+
```
35+
diff -aur \
36+
--label toit/toolchains/esp32s3/sdkconfig.defaults \
37+
--label synthesized/esp32s3-foo/sdkconfig.defaults \
38+
toolchains/esp32s3/sdkconfig.defaults \
39+
toolchains/esp32s3-foo/sdkconfig.defaults \
40+
> toolchains/esp32s3-foo/sdkconfig.defaults.patch
41+
```
42+
The labels are not crucial, but make it easier for us to update the
43+
patch at a later time.
44+
* Create a new variant in this (`envelopes`) repository and copy the patch file into it.
45+
46+
### Main changes
47+
48+
For changes to the `main` directory (be it the `toit.c` or the `CMakelists.txt` in it),
49+
use a recursive diff to create a patch on the original `main` directory.
50+
51+
The synthetization tool will use the flag `-p1` when applying the patch.

variants/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Variants
2+
3+
Some commonly used variants are featured here. You can also browse this
4+
directory for more variants.
5+
6+
See the [Contributing](Contributing.md) guide for how to create a new variant.
7+
8+
9+
## esp32
10+
11+
A generic ESP32 variant. This is the default variant when using Toit.
12+
It is built for maximum compatibility.
13+
14+
This variant supports Ethernet, but without the clock output.
15+
16+
## esp32-spiram
17+
18+
An ESP32 variant for boards with SPIRAM. Otherwise the same as the ESP32 variant.
19+
20+
## esp32-eth-clk-out0 and esp32-eth-clk-out17
21+
22+
A variant for ESP32 boards with Ethernet and a clock output on pin 0/17.
23+
24+
Olimex boards with Ethernet should use this variant. The WROOM versions need
25+
`esp32-eth-clk-out17` and the WROVER versions need `esp32-eth-clk-out0`.
26+
27+
## esp32c3
28+
29+
A generic [ESP32-C3 variant](esp32c). This is the default variant
30+
when using Toit on ESP32-C3 boards.
31+
32+
## esp32s2
33+
34+
A generic [ESP32-S2 variant](esp32s2). This is the default variant
35+
when using Toit on ESP32-S2 boards.
36+
37+
## esp32s3
38+
39+
A generic [ESP32-S3 variant](esp32s3). This is the default variant
40+
when using Toit on ESP32-S3 boards.
41+
42+
This variant is configured for external Quad PSRAM.
43+
44+
## esp32s3-spiram-octo
45+
46+
A [variant](esp32s3-spiram-octo/) for ESP32-S3 boards with external
47+
octal PSRAM.
48+
49+
These boards are faster, but often more expensive.
50+
51+
## esp32-no-ble
52+
53+
A [variant](esp32-no-ble/) for ESP32 boards. This variant
54+
saves some RAM and flash space by removing the Bluetooth stack.
55+
The saved IRAM enables us to make the Toit interpreter a little faster
56+
and add support for external RAM (PSRAM, aka SPIRAM).

0 commit comments

Comments
 (0)