ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
dev_table.h
Go to the documentation of this file.
1/*
2 stm32flash - Open Source ST STM32 flash program for Arduino
3 Copyright (C) 2010 Geoffrey McRae <geoff@spacevs.com>
4 Copyright (C) 2014-2015 Antonio Borneo <borneo.antonio@gmail.com>
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19*/
20#pragma once
21
23#ifdef USE_SHD_FIRMWARE_DATA
24#include "esphome/core/hal.h"
25#include "stm32flash.h"
26
28
29constexpr uint32_t SZ_128 = 0x00000080;
30constexpr uint32_t SZ_256 = 0x00000100;
31constexpr uint32_t SZ_1K = 0x00000400;
32constexpr uint32_t SZ_2K = 0x00000800;
33constexpr uint32_t SZ_16K = 0x00004000;
34constexpr uint32_t SZ_32K = 0x00008000;
35constexpr uint32_t SZ_64K = 0x00010000;
36constexpr uint32_t SZ_128K = 0x00020000;
37constexpr uint32_t SZ_256K = 0x00040000;
38
39/*
40 * Page-size for page-by-page flash erase.
41 * Arrays are zero terminated; last non-zero value is automatically repeated
42 * In PROGMEM and read by direct indexing: each entry is an aligned 32-bit load, which is safe from flash on ESP8266
43 */
44
45/* fixed size pages */
46alignas(4) constexpr uint32_t p_128[] PROGMEM = {SZ_128, 0}; // NOLINT
47alignas(4) constexpr uint32_t p_256[] PROGMEM = {SZ_256, 0}; // NOLINT
48alignas(4) constexpr uint32_t p_1k[] PROGMEM = {SZ_1K, 0}; // NOLINT
49alignas(4) constexpr uint32_t p_2k[] PROGMEM = {SZ_2K, 0}; // NOLINT
50/* F2 and F4 page size */
51alignas(4) constexpr uint32_t f2f4[] PROGMEM = {SZ_16K, SZ_16K, SZ_16K, SZ_16K, SZ_64K, SZ_128K, 0}; // NOLINT
52/* F4 dual bank page size */
53alignas(4) constexpr uint32_t f4db[] PROGMEM = {SZ_16K, SZ_16K, SZ_16K, SZ_16K, SZ_64K, SZ_128K, SZ_128K, // NOLINT
55/* F7 page size */
56alignas(4) constexpr uint32_t f7[] PROGMEM = {SZ_32K, SZ_32K, SZ_32K, SZ_32K, SZ_128K, SZ_256K, 0}; // NOLINT
57
58/*
59 * Device table, corresponds to the "Bootloader device-dependant parameters"
60 * table in ST document AN2606.
61 * Note that the option bytes upper range is inclusive!
62 */
63alignas(4) constexpr stm32_dev_t DEVICES[] PROGMEM = {
64 /* ID SRAM-address-range FLASH-address-range PPS PSize
65 Option-byte-addr-range System-mem-addr-range Flags */
66 /* F0 */
67 // STM32F030x8/F05xxx
68 {0x440, 0x20000800, 0x20002000, 0x08000000, 0x08010000, 4, p_1k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFEC00, 0x1FFFF800, 0},
69 // STM32F030xC/F09xxx
70 {0x442, 0x20001800, 0x20008000, 0x08000000, 0x08040000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC800, 0x1FFFF800,
71 F_OBLL},
72 // STM32F03xx4/6
73 {0x444, 0x20000800, 0x20001000, 0x08000000, 0x08008000, 4, p_1k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFEC00, 0x1FFFF800, 0},
74 // STM32F04xxx/F070x6
75 {0x445, 0x20001800, 0x20001800, 0x08000000, 0x08008000, 4, p_1k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC400, 0x1FFFF800, 0},
76 // STM32F070xB/F071xx/F72xx
77 {0x448, 0x20001800, 0x20004000, 0x08000000, 0x08020000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC800, 0x1FFFF800, 0},
78 /* F1 */
79 // STM32F10xxx Low-density
80 {0x412, 0x20000200, 0x20002800, 0x08000000, 0x08008000, 4, p_1k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800, 0},
81 // STM32F10xxx Medium-density
82 {0x410, 0x20000200, 0x20005000, 0x08000000, 0x08020000, 4, p_1k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800, 0},
83 // STM32F10xxx High-density
84 {0x414, 0x20000200, 0x20010000, 0x08000000, 0x08080000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800, 0},
85 // STM32F10xxx Medium-density VL
86 {0x420, 0x20000200, 0x20002000, 0x08000000, 0x08020000, 4, p_1k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800, 0},
87 // STM32F10xxx High-density VL
88 {0x428, 0x20000200, 0x20008000, 0x08000000, 0x08080000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800, 0},
89 // STM32F105xx/F107xx
90 {0x418, 0x20001000, 0x20010000, 0x08000000, 0x08040000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFB000, 0x1FFFF800, 0},
91 // STM32F10xxx XL-density
92 {0x430, 0x20000800, 0x20018000, 0x08000000, 0x08100000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFE000, 0x1FFFF800, 0},
93 /* F2 */
94 // STM32F2xxxx
95 {0x411, 0x20002000, 0x20020000, 0x08000000, 0x08100000, 1, f2f4, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF7800, 0},
96 /* F3 */
97 // STM32F373xx/F378xx
98 {0x432, 0x20001400, 0x20008000, 0x08000000, 0x08040000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800, 0},
99 // STM32F302xB(C)/F303xB(C)/F358xx
100 {0x422, 0x20001400, 0x2000A000, 0x08000000, 0x08040000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800, 0},
101 // STM32F301xx/F302x4(6/8)/F318xx
102 {0x439, 0x20001800, 0x20004000, 0x08000000, 0x08010000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800, 0},
103 // STM32F303x4(6/8)/F334xx/F328xx
104 {0x438, 0x20001800, 0x20003000, 0x08000000, 0x08010000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800, 0},
105 // STM32F302xD(E)/F303xD(E)/F398xx
106 {0x446, 0x20001800, 0x20010000, 0x08000000, 0x08080000, 2, p_2k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800, 0},
107 /* F4 */
108 // STM32F40xxx/41xxx
109 {0x413, 0x20003000, 0x20020000, 0x08000000, 0x08100000, 1, f2f4, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF7800, 0},
110 // STM32F42xxx/43xxx
111 {0x419, 0x20003000, 0x20030000, 0x08000000, 0x08200000, 1, f4db, 0x1FFEC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF7800, 0},
112 // STM32F401xB(C)
113 {0x423, 0x20003000, 0x20010000, 0x08000000, 0x08040000, 1, f2f4, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF7800, 0},
114 // STM32F401xD(E)
115 {0x433, 0x20003000, 0x20018000, 0x08000000, 0x08080000, 1, f2f4, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF7800, 0},
116 // STM32F410xx
117 {0x458, 0x20003000, 0x20008000, 0x08000000, 0x08020000, 1, f2f4, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF7800, 0},
118 // STM32F411xx
119 {0x431, 0x20003000, 0x20020000, 0x08000000, 0x08080000, 1, f2f4, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF7800, 0},
120 // STM32F446xx
121 {0x421, 0x20003000, 0x20020000, 0x08000000, 0x08080000, 1, f2f4, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF7800, 0},
122 // STM32F469xx
123 {0x434, 0x20003000, 0x20060000, 0x08000000, 0x08200000, 1, f4db, 0x1FFEC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF7800, 0},
124 /* F7 */
125 // STM32F74xxx/75xxx
126 {0x449, 0x20004000, 0x20050000, 0x08000000, 0x08100000, 1, f7, 0x1FFF0000, 0x1FFF001F, 0x1FF00000, 0x1FF0EDC0, 0},
127 /* L0 */
128 // STM32L031xx/041xx
129 {0x425, 0x20001000, 0x20002000, 0x08000000, 0x08008000, 32, p_128, 0x1FF80000, 0x1FF8001F, 0x1FF00000, 0x1FF01000,
130 0},
131 // STM32L05xxx/06xxx
132 {0x417, 0x20001000, 0x20002000, 0x08000000, 0x08010000, 32, p_128, 0x1FF80000, 0x1FF8001F, 0x1FF00000, 0x1FF01000,
133 0},
134 // STM32L07xxx/08xxx
135 {0x447, 0x20002000, 0x20005000, 0x08000000, 0x08030000, 32, p_128, 0x1FF80000, 0x1FF8001F, 0x1FF00000, 0x1FF02000,
136 0},
137 /* L1 */
138 // STM32L1xxx6(8/B)
139 {0x416, 0x20000800, 0x20004000, 0x08000000, 0x08020000, 16, p_256, 0x1FF80000, 0x1FF8001F, 0x1FF00000, 0x1FF01000,
140 F_NO_ME},
141 // STM32L1xxx6(8/B)A
142 {0x429, 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, p_256, 0x1FF80000, 0x1FF8001F, 0x1FF00000, 0x1FF01000,
143 0},
144 // STM32L1xxxC
145 {0x427, 0x20001000, 0x20008000, 0x08000000, 0x08040000, 16, p_256, 0x1FF80000, 0x1FF8001F, 0x1FF00000, 0x1FF02000,
146 0},
147 // STM32L1xxxD
148 {0x436, 0x20001000, 0x2000C000, 0x08000000, 0x08060000, 16, p_256, 0x1FF80000, 0x1FF8009F, 0x1FF00000, 0x1FF02000,
149 0},
150 // STM32L1xxxE
151 {0x437, 0x20001000, 0x20014000, 0x08000000, 0x08080000, 16, p_256, 0x1FF80000, 0x1FF8009F, 0x1FF00000, 0x1FF02000,
152 F_NO_ME},
153 /* L4 */
154 // STM32L476xx/486xx
155 {0x415, 0x20003100, 0x20018000, 0x08000000, 0x08100000, 1, p_2k, 0x1FFF7800, 0x1FFFF80F, 0x1FFF0000, 0x1FFF7000, 0},
156 /* These are not (yet) in AN2606: */
157 // Medium_Density PL
158 {0x641, 0x20000200, 0x20005000, 0x08000000, 0x08020000, 4, p_1k, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800, 0},
159 // STM32W-128K
160 {0x9a8, 0x20000200, 0x20002000, 0x08000000, 0x08020000, 4, p_1k, 0x08040800, 0x0804080F, 0x08040000, 0x08040800, 0},
161 // STM32W-256K
162 {0x9b0, 0x20000200, 0x20004000, 0x08000000, 0x08040000, 4, p_2k, 0x08040800, 0x0804080F, 0x08040000, 0x08040800, 0},
163 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, nullptr, 0x0, 0x0, 0x0, 0x0, 0x0},
164};
165
166} // namespace esphome::shelly_dimmer
167
168#endif // USE_SHD_FIRMWARE_DATA
constexpr uint32_t SZ_1K
Definition dev_table.h:31
constexpr uint32_t p_128[] PROGMEM
Definition dev_table.h:46
constexpr uint32_t SZ_32K
Definition dev_table.h:34
constexpr uint32_t SZ_16K
Definition dev_table.h:33
constexpr uint32_t SZ_64K
Definition dev_table.h:35
constexpr uint32_t SZ_2K
Definition dev_table.h:32
constexpr uint32_t SZ_256
Definition dev_table.h:30
constexpr uint32_t SZ_128K
Definition dev_table.h:36
struct Stm32Dev { const uint32_t id; const uint32_t ram_start, ram_end; const uint32_t fl_start, fl_end; const uint32_t fl_pps; const uint32_t *fl_ps; const uint32_t opt_start, opt_end; const uint32_t mem_start, mem_end; const uint32_t flags;} stm32_dev_t
Definition stm32flash.h:76
constexpr uint32_t SZ_128
Definition dev_table.h:29
constexpr uint32_t SZ_256K
Definition dev_table.h:37
static void uint32_t