Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: flash: sam: fix flash erase last page #80800

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bjarki-andreasen
Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen commented Nov 3, 2024

The implementation for erasing pages in the flash_sam.c driver indicated a successful erase after exceeding the last page to be erased successfully. Since the last page has no proceeding page, the succeeded status was not set.

This fix switches around the status to be set as succeeded before erase begins, to have the succeeded status cleared if page unlock or erase fails.

fixes: #70344

The implementation for erasing pages in the flash_sam.c driver
indicated a successful erase after exceeding the last page to be
erased successfully. Since the last page has no proceeding page,
the succeeded status was not set.

This fix switches around the status to be set as succeeded before
erase begins, to have the succeeded status cleared if page unlock
or erase fails.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
@bjarki-andreasen bjarki-andreasen added bug The issue is a bug, or the PR is fixing a bug DNM This PR should not be merged (Do Not Merge) labels Nov 3, 2024
@bjarki-andreasen bjarki-andreasen added this to the v4.0.0 milestone Nov 3, 2024
@zephyrbot zephyrbot added area: Flash platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) labels Nov 3, 2024
@bjarki-andreasen
Copy link
Collaborator Author

DNM until it has been tested on real hardware :)

de-nordic
de-nordic previously approved these changes Dec 16, 2024
@pdgendt pdgendt added the block: HW Test Testing on hardware required before merging label Dec 16, 2024
@nandojve
Copy link
Member

Hardware tests on sam_v71_xult/samv71q21.
Assuming that tests cover the last sector.

*** Booting MCUboot v2.1.0-rc1-171-g5d6471bac184 ***
*** Using Zephyr OS build v4.0.0-2332-ga64d44172fe3 ***
I: Starting bootloader
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Scratch: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: primary slot
I: Image index: 0, Swap type: none
E: Unable to find bootable image
*** Booting Zephyr OS build v4.0.0-2332-ga64d44172fe3 ***
Running TESTSUITE flash_page_layout
===================================================================
START - test_erase_single_pages_in_part
I: Erasing section of size 917504 at offset 1048576 controlled by flash-controller@400e0c00
I: Writing across page boundary at 1056768, between page index 134 and 135
I: Writing across page boundary at 1064960, between page index 135 and 136
I: Writing across page boundary at 1073152, between page index 136 and 137
I: Writing across page boundary at 1081344, between page index 137 and 138
I: Writing across page boundary at 1089536, between page index 138 and 139
I: Writing across page boundary at 1097728, between page index 139 and 140
I: Writing across page boundary at 1105920, between page index 140 and 141
I: Writing across page boundary at 1114112, between page index 141 and 142
I: Writing across page boundary at 1122304, between page index 142 and 143
I: Writing across page boundary at 1130496, between page index 143 and 144
I: Writing across page boundary at 1138688, between page index 144 and 145
I: Writing across page boundary at 1146880, between page index 145 and 146
I: Writing across page boundary at 1155072, between page index 146 and 147
I: Writing across page boundary at 1163264, between page index 147 and 148
I: Writing across page boundary at 1171456, between page index 148 and 149
I: Writing across page boundary at 1179648, between page index 149 and 150
I: Writing across page boundary at 1187840, between page index 150 and 151
I: Writing across page boundary at 1196032, between page index 151 and 152
I: Writing across page boundary at 1204224, between page index 152 and 153
I: Writing across page boundary at 1212416, between page index 153 and 154
I: Writing across page boundary at 1220608, between page index 154 and 155
I: Writing across page boundary at 1228800, between page index 155 and 156
I: Writing across page boundary at 1236992, between page index 156 and 157
I: Writing across page boundary at 1245184, between page index 157 and 158
I: Writing across page boundary at 1253376, between page index 158 and 159
I: Writing across page boundary at 1261568, between page index 159 and 160
I: Writing across page boundary at 1269760, between page index 160 and 161
I: Writing across page boundary at 1277952, between page index 161 and 162
I: Writing across page boundary at 1286144, between page index 162 and 163
I: Writing across page boundary at 1294336, between page index 163 and 164
I: Writing across page boundary at 1302528, between page index 164 and 165
I: Writing across page boundary at 1310720, between page index 165 and 166
I: Writing across page boundary at 1318912, between page index 166 and 167
I: Writing across page boundary at 1327104, between page index 167 and 168
I: Writing across page boundary at 1335296, between page index 168 and 169
I: Writing across page boundary at 1343488, between page index 169 and 170
I: Writing across page boundary at 1351680, between page index 170 and 171
I: Writing across page boundary at 1359872, between page index 171 and 172
I: Writing across page boundary at 1368064, between page index 172 and 173
I: Writing across page boundary at 1376256, between page index 173 and 174
I: Writing across page boundary at 1384448, between page index 174 and 175
I: Writing across page boundary at 1392640, between page index 175 and 176
I: Writing across page boundary at 1400832, between page index 176 and 177
I: Writing across page boundary at 1409024, between page index 177 and 178
I: Writing across page boundary at 1417216, between page index 178 and 179
I: Writing across page boundary at 1425408, between page index 179 and 180
I: Writing across page boundary at 1433600, between page index 180 and 181
I: Writing across page boundary at 1441792, between page index 181 and 182
I: Writing across page boundary at 1449984, between page index 182 and 183
I: Writing across page boundary at 1458176, between page index 183 and 184
I: Writing across page boundary at 1466368, between page index 184 and 185
I: Writing across page boundary at 1474560, between page index 185 and 186
I: Writing across page boundary at 1482752, between page index 186 and 187
I: Writing across page boundary at 1490944, between page index 187 and 188
I: Writing across page boundary at 1499136, between page index 188 and 189
I: Writing across page boundary at 1507328, between page index 189 and 190
I: Writing across page boundary at 1515520, between page index 190 and 191
I: Writing across page boundary at 1523712, between page index 191 and 192
I: Writing across page boundary at 1531904, between page index 192 and 193
I: Writing across page boundary at 1540096, between page index 193 and 194
I: Writing across page boundary at 1548288, between page index 194 and 195
I: Writing across page boundary at 1556480, between page index 195 and 196
I: Writing across page boundary at 1564672, between page index 196 and 197
I: Writing across page boundary at 1572864, between page index 197 and 198
I: Writing across page boundary at 1581056, between page index 198 and 199
I: Writing across page boundary at 1589248, between page index 199 and 200
I: Writing across page boundary at 1597440, between page index 200 and 201
I: Writing across page boundary at 1605632, between page index 201 and 202
I: Writing across page boundary at 1613824, between page index 202 and 203
I: Writing across page boundary at 1622016, between page index 203 and 204
I: Writing across page boundary at 1630208, between page index 204 and 205
I: Writing across page boundary at 1638400, between page index 205 and 206
I: Writing across page boundary at 1646592, between page index 206 and 207
I: Writing across page boundary at 1654784, between page index 207 and 208
I: Writing across page boundary at 1662976, between page index 208 and 209
I: Writing across page boundary at 1671168, between page index 209 and 210
I: Writing across page boundary at 1679360, between page index 210 and 211
I: Writing across page boundary at 1687552, between page index 211 and 212
I: Writing across page boundary at 1695744, between page index 212 and 213
I: Writing across page boundary at 1703936, between page index 213 and 214
I: Writing across page boundary at 1712128, between page index 214 and 215
I: Writing across page boundary at 1720320, between page index 215 and 216
I: Writing across page boundary at 1728512, between page index 216 and 217
I: Writing across page boundary at 1736704, between page index 217 and 218
I: Writing across page boundary at 1744896, between page index 218 and 219
I: Writing across page boundary at 1753088, between page index 219 and 220
I: Writing across page boundary at 1761280, between page index 220 and 221
I: Writing across page boundary at 1769472, between page index 221 and 222
I: Writing across page boundary at 1777664, between page index 222 and 223
I: Writing across page boundary at 1785856, between page index 223 and 224
I: Writing across page boundary at 1794048, between page index 224 and 225
I: Writing across page boundary at 1802240, between page index 225 and 226
I: Writing across page boundary at 1810432, between page index 226 and 227
I: Writing across page boundary at 1818624, between page index 227 and 228
I: Writing across page boundary at 1826816, between page index 228 and 229
I: Writing across page boundary at 1835008, between page index 229 and 230
I: Writing across page boundary at 1843200, between page index 230 and 231
I: Writing across page boundary at 1851392, between page index 231 and 232
I: Writing across page boundary at 1859584, between page index 232 and 233
I: Writing across page boundary at 1867776, between page index 233 and 234
I: Writing across page boundary at 1875968, between page index 234 and 235
I: Writing across page boundary at 1884160, between page index 235 and 236
I: Writing across page boundary at 1892352, between page index 236 and 237
I: Writing across page boundary at 1900544, between page index 237 and 238
I: Writing across page boundary at 1908736, between page index 238 and 239
I: Writing across page boundary at 1916928, between page index 239 and 240
I: Writing across page boundary at 1925120, between page index 240 and 241
I: Writing across page boundary at 1933312, between page index 241 and 242
I: Writing across page boundary at 1941504, between page index 242 and 243
I: Writing across page boundary at 1949696, between page index 243 and 244
I: Writing across page boundary at 1957888, between page index 244 and 245
I: Erasing page at 1048576 of size 8192 with index 134
I: Erasing page at 1056768 of size 8192 with index 135
I: Erasing page at 1064960 of size 8192 with index 136
I: Erasing page at 1073152 of size 8192 with index 137
I: Erasing page at 1081344 of size 8192 with index 138
I: Erasing page at 1089536 of size 8192 with index 139
I: Erasing page at 1097728 of size 8192 with index 140
I: Erasing page at 1105920 of size 8192 with index 141
I: Erasing page at 1114112 of size 8192 with index 142
I: Erasing page at 1122304 of size 8192 with index 143
I: Erasing page at 1130496 of size 8192 with index 144
I: Erasing page at 1138688 of size 8192 with index 145
I: Erasing page at 1146880 of size 8192 with index 146
I: Erasing page at 1155072 of size 8192 with index 147
I: Erasing page at 1163264 of size 8192 with index 148
I: Erasing page at 1171456 of size 8192 with index 149
I: Erasing page at 1179648 of size 8192 with index 150
I: Erasing page at 1187840 of size 8192 with index 151
I: Erasing page at 1196032 of size 8192 with index 152
I: Erasing page at 1204224 of size 8192 with index 153
I: Erasing page at 1212416 of size 8192 with index 154
I: Erasing page at 1220608 of size 8192 with index 155
I: Erasing page at 1228800 of size 8192 with index 156
I: Erasing page at 1236992 of size 8192 with index 157
I: Erasing page at 1245184 of size 8192 with index 158
I: Erasing page at 1253376 of size 8192 with index 159
I: Erasing page at 1261568 of size 8192 with index 160
I: Erasing page at 1269760 of size 8192 with index 161
I: Erasing page at 1277952 of size 8192 with index 162
I: Erasing page at 1286144 of size 8192 with index 163
I: Erasing page at 1294336 of size 8192 with index 164
I: Erasing page at 1302528 of size 8192 with index 165
I: Erasing page at 1310720 of size 8192 with index 166
I: Erasing page at 1318912 of size 8192 with index 167
I: Erasing page at 1327104 of size 8192 with index 168
I: Erasing page at 1335296 of size 8192 with index 169
I: Erasing page at 1343488 of size 8192 with index 170
I: Erasing page at 1351680 of size 8192 with index 171
I: Erasing page at 1359872 of size 8192 with index 172
I: Erasing page at 1368064 of size 8192 with index 173
I: Erasing page at 1376256 of size 8192 with index 174
I: Erasing page at 1384448 of size 8192 with index 175
I: Erasing page at 1392640 of size 8192 with index 176
I: Erasing page at 1400832 of size 8192 with index 177
I: Erasing page at 1409024 of size 8192 with index 178
I: Erasing page at 1417216 of size 8192 with index 179
I: Erasing page at 1425408 of size 8192 with index 180
I: Erasing page at 1433600 of size 8192 with index 181
I: Erasing page at 1441792 of size 8192 with index 182
I: Erasing page at 1449984 of size 8192 with index 183
I: Erasing page at 1458176 of size 8192 with index 184
I: Erasing page at 1466368 of size 8192 with index 185
I: Erasing page at 1474560 of size 8192 with index 186
I: Erasing page at 1482752 of size 8192 with index 187
I: Erasing page at 1490944 of size 8192 with index 188
I: Erasing page at 1499136 of size 8192 with index 189
I: Erasing page at 1507328 of size 8192 with index 190
I: Erasing page at 1515520 of size 8192 with index 191
I: Erasing page at 1523712 of size 8192 with index 192
I: Erasing page at 1531904 of size 8192 with index 193
I: Erasing page at 1540096 of size 8192 with index 194
I: Erasing page at 1548288 of size 8192 with index 195
I: Erasing page at 1556480 of size 8192 with index 196
I: Erasing page at 1564672 of size 8192 with index 197
I: Erasing page at 1572864 of size 8192 with index 198
I: Erasing page at 1581056 of size 8192 with index 199
I: Erasing page at 1589248 of size 8192 with index 200
I: Erasing page at 1597440 of size 8192 with index 201
I: Erasing page at 1605632 of size 8192 with index 202
I: Erasing page at 1613824 of size 8192 with index 203
I: Erasing page at 1622016 of size 8192 with index 204
I: Erasing page at 1630208 of size 8192 with index 205
I: Erasing page at 1638400 of size 8192 with index 206
I: Erasing page at 1646592 of size 8192 with index 207
I: Erasing page at 1654784 of size 8192 with index 208
I: Erasing page at 1662976 of size 8192 with index 209
I: Erasing page at 1671168 of size 8192 with index 210
I: Erasing page at 1679360 of size 8192 with index 211
I: Erasing page at 1687552 of size 8192 with index 212
I: Erasing page at 1695744 of size 8192 with index 213
I: Erasing page at 1703936 of size 8192 with index 214
I: Erasing page at 1712128 of size 8192 with index 215
I: Erasing page at 1720320 of size 8192 with index 216
I: Erasing page at 1728512 of size 8192 with index 217
I: Erasing page at 1736704 of size 8192 with index 218
I: Erasing page at 1744896 of size 8192 with index 219
I: Erasing page at 1753088 of size 8192 with index 220
I: Erasing page at 1761280 of size 8192 with index 221
I: Erasing page at 1769472 of size 8192 with index 222
I: Erasing page at 1777664 of size 8192 with index 223
I: Erasing page at 1785856 of size 8192 with index 224
I: Erasing page at 1794048 of size 8192 with index 225
I: Erasing page at 1802240 of size 8192 with index 226
I: Erasing page at 1810432 of size 8192 with index 227
I: Erasing page at 1818624 of size 8192 with index 228
I: Erasing page at 1826816 of size 8192 with index 229
I: Erasing page at 1835008 of size 8192 with index 230
I: Erasing page at 1843200 of size 8192 with index 231
I: Erasing page at 1851392 of size 8192 with index 232
I: Erasing page at 1859584 of size 8192 with index 233
I: Erasing page at 1867776 of size 8192 with index 234
I: Erasing page at 1875968 of size 8192 with index 235
I: Erasing page at 1884160 of size 8192 with index 236
I: Erasing page at 1892352 of size 8192 with index 237
I: Erasing page at 1900544 of size 8192 with index 238
I: Erasing page at 1908736 of size 8192 with index 239
I: Erasing page at 1916928 of size 8192 with index 240
I: Erasing page at 1925120 of size 8192 with index 241
I: Erasing page at 1933312 of size 8192 with index 242
I: Erasing page at 1941504 of size 8192 with index 243
I: Erasing page at 1949696 of size 8192 with index 244
I: Erasing page at 1957888 of size 8192 with index 245
 PASS - test_erase_single_pages_in_part in 9.084 seconds
===================================================================
START - test_write_across_page_boundaries_in_part
I: Erasing section of size 917504 at offset 1048576 controlled by flash-controller@400e0c00
I: Writing across page boundary at 1056768, between page index 134 and 135
I: Writing across page boundary at 1064960, between page index 135 and 136
I: Writing across page boundary at 1073152, between page index 136 and 137
I: Writing across page boundary at 1081344, between page index 137 and 138
I: Writing across page boundary at 1089536, between page index 138 and 139
I: Writing across page boundary at 1097728, between page index 139 and 140
I: Writing across page boundary at 1105920, between page index 140 and 141
I: Writing across page boundary at 1114112, between page index 141 and 142
I: Writing across page boundary at 1122304, between page index 142 and 143
I: Writing across page boundary at 1130496, between page index 143 and 144
I: Writing across page boundary at 1138688, between page index 144 and 145
I: Writing across page boundary at 1146880, between page index 145 and 146
I: Writing across page boundary at 1155072, between page index 146 and 147
I: Writing across page boundary at 1163264, between page index 147 and 148
I: Writing across page boundary at 1171456, between page index 148 and 149
I: Writing across page boundary at 1179648, between page index 149 and 150
I: Writing across page boundary at 1187840, between page index 150 and 151
I: Writing across page boundary at 1196032, between page index 151 and 152
I: Writing across page boundary at 1204224, between page index 152 and 153
I: Writing across page boundary at 1212416, between page index 153 and 154
I: Writing across page boundary at 1220608, between page index 154 and 155
I: Writing across page boundary at 1228800, between page index 155 and 156
I: Writing across page boundary at 1236992, between page index 156 and 157
I: Writing across page boundary at 1245184, between page index 157 and 158
I: Writing across page boundary at 1253376, between page index 158 and 159
I: Writing across page boundary at 1261568, between page index 159 and 160
I: Writing across page boundary at 1269760, between page index 160 and 161
I: Writing across page boundary at 1277952, between page index 161 and 162
I: Writing across page boundary at 1286144, between page index 162 and 163
I: Writing across page boundary at 1294336, between page index 163 and 164
I: Writing across page boundary at 1302528, between page index 164 and 165
I: Writing across page boundary at 1310720, between page index 165 and 166
I: Writing across page boundary at 1318912, between page index 166 and 167
I: Writing across page boundary at 1327104, between page index 167 and 168
I: Writing across page boundary at 1335296, between page index 168 and 169
I: Writing across page boundary at 1343488, between page index 169 and 170
I: Writing across page boundary at 1351680, between page index 170 and 171
I: Writing across page boundary at 1359872, between page index 171 and 172
I: Writing across page boundary at 1368064, between page index 172 and 173
I: Writing across page boundary at 1376256, between page index 173 and 174
I: Writing across page boundary at 1384448, between page index 174 and 175
I: Writing across page boundary at 1392640, between page index 175 and 176
I: Writing across page boundary at 1400832, between page index 176 and 177
I: Writing across page boundary at 1409024, between page index 177 and 178
I: Writing across page boundary at 1417216, between page index 178 and 179
I: Writing across page boundary at 1425408, between page index 179 and 180
I: Writing across page boundary at 1433600, between page index 180 and 181
I: Writing across page boundary at 1441792, between page index 181 and 182
I: Writing across page boundary at 1449984, between page index 182 and 183
I: Writing across page boundary at 1458176, between page index 183 and 184
I: Writing across page boundary at 1466368, between page index 184 and 185
I: Writing across page boundary at 1474560, between page index 185 and 186
I: Writing across page boundary at 1482752, between page index 186 and 187
I: Writing across page boundary at 1490944, between page index 187 and 188
I: Writing across page boundary at 1499136, between page index 188 and 189
I: Writing across page boundary at 1507328, between page index 189 and 190
I: Writing across page boundary at 1515520, between page index 190 and 191
I: Writing across page boundary at 1523712, between page index 191 and 192
I: Writing across page boundary at 1531904, between page index 192 and 193
I: Writing across page boundary at 1540096, between page index 193 and 194
I: Writing across page boundary at 1548288, between page index 194 and 195
I: Writing across page boundary at 1556480, between page index 195 and 196
I: Writing across page boundary at 1564672, between page index 196 and 197
I: Writing across page boundary at 1572864, between page index 197 and 198
I: Writing across page boundary at 1581056, between page index 198 and 199
I: Writing across page boundary at 1589248, between page index 199 and 200
I: Writing across page boundary at 1597440, between page index 200 and 201
I: Writing across page boundary at 1605632, between page index 201 and 202
I: Writing across page boundary at 1613824, between page index 202 and 203
I: Writing across page boundary at 1622016, between page index 203 and 204
I: Writing across page boundary at 1630208, between page index 204 and 205
I: Writing across page boundary at 1638400, between page index 205 and 206
I: Writing across page boundary at 1646592, between page index 206 and 207
I: Writing across page boundary at 1654784, between page index 207 and 208
I: Writing across page boundary at 1662976, between page index 208 and 209
I: Writing across page boundary at 1671168, between page index 209 and 210
I: Writing across page boundary at 1679360, between page index 210 and 211
I: Writing across page boundary at 1687552, between page index 211 and 212
I: Writing across page boundary at 1695744, between page index 212 and 213
I: Writing across page boundary at 1703936, between page index 213 and 214
I: Writing across page boundary at 1712128, between page index 214 and 215
I: Writing across page boundary at 1720320, between page index 215 and 216
I: Writing across page boundary at 1728512, between page index 216 and 217
I: Writing across page boundary at 1736704, between page index 217 and 218
I: Writing across page boundary at 1744896, between page index 218 and 219
I: Writing across page boundary at 1753088, between page index 219 and 220
I: Writing across page boundary at 1761280, between page index 220 and 221
I: Writing across page boundary at 1769472, between page index 221 and 222
I: Writing across page boundary at 1777664, between page index 222 and 223
I: Writing across page boundary at 1785856, between page index 223 and 224
I: Writing across page boundary at 1794048, between page index 224 and 225
I: Writing across page boundary at 1802240, between page index 225 and 226
I: Writing across page boundary at 1810432, between page index 226 and 227
I: Writing across page boundary at 1818624, between page index 227 and 228
I: Writing across page boundary at 1826816, between page index 228 and 229
I: Writing across page boundary at 1835008, between page index 229 and 230
I: Writing across page boundary at 1843200, between page index 230 and 231
I: Writing across page boundary at 1851392, between page index 231 and 232
I: Writing across page boundary at 1859584, between page index 232 and 233
I: Writing across page boundary at 1867776, between page index 233 and 234
I: Writing across page boundary at 1875968, between page index 234 and 235
I: Writing across page boundary at 1884160, between page index 235 and 236
I: Writing across page boundary at 1892352, between page index 236 and 237
I: Writing across page boundary at 1900544, between page index 237 and 238
I: Writing across page boundary at 1908736, between page index 238 and 239
I: Writing across page boundary at 1916928, between page index 239 and 240
I: Writing across page boundary at 1925120, between page index 240 and 241
I: Writing across page boundary at 1933312, between page index 241 and 242
I: Writing across page boundary at 1941504, between page index 242 and 243
I: Writing across page boundary at 1949696, between page index 243 and 244
I: Writing across page boundary at 1957888, between page index 244 and 245
 PASS - test_write_across_page_boundaries_in_part in 4.651 seconds
===================================================================
TESTSUITE flash_page_layout succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [flash_page_layout]: pass = 2, fail = 0, skip = 0, total = 2 duration = 13.735 seconds
 - PASS - [flash_page_layout.test_erase_single_pages_in_part] duration = 9.084 seconds
 - PASS - [flash_page_layout.test_write_across_page_boundaries_in_part] duration = 4.651 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL

@nandojve
Copy link
Member

@bjarki-andreasen ,

The current tests with the samv71 partition cover the last page? If yes, I'm ready to approve.

@bjarki-andreasen
Copy link
Collaborator Author

bjarki-andreasen commented Dec 18, 2024

To erase the last page for that board, change this line

DT_NODELABEL(slot1_partition)
to
DT_NODELABEL(scratch_partition) and run the suite again :) we are looking for:

I: Erasing page at 2088960 of size 8192 with index 259
 PASS - test_erase_single_pages_in_part in 9.084 seconds

the board has a scratch partition at the end of the flash area :)

@nandojve
Copy link
Member

To erase the last page for that board, change this line

DT_NODELABEL(slot1_partition)

to
DT_NODELABEL(scratch_partition) and run the suite again :) we are looking for:

I: Erasing page at 2088960 of size 8192 with index 259
 PASS - test_erase_single_pages_in_part in 9.084 seconds

the board has a scratch partition at the end of the flash area :)

I can do that and provide feedback, yes. But in this case, it will be nice if we extend the test to run over these two partitions. I want to avoid regressions here. I'm fine if you want to do on another PR too to not switch your tasks at moment.

@nandojve
Copy link
Member

Running test using the scratch_partition

*** Booting MCUboot v2.1.0-rc1-171-g5d6471bac184 ***
*** Using Zephyr OS build v4.0.0-2332-ga64d44172fe3 ***
I: Starting bootloader
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Scratch: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: primary slot
I: Image index: 0, Swap type: none
E: Unable to find bootable image
*** Booting Zephyr OS build v4.0.0-2332-ga64d44172fe3 ***
Running TESTSUITE flash_page_layout
===================================================================
START - test_erase_single_pages_in_part
I: Erasing section of size 131072 at offset 1966080 controlled by flash-controller@400e0c00
I: Writing across page boundary at 1974272, between page index 246 and 247
I: Writing across page boundary at 1982464, between page index 247 and 248
I: Writing across page boundary at 1990656, between page index 248 and 249
I: Writing across page boundary at 1998848, between page index 249 and 250
I: Writing across page boundary at 2007040, between page index 250 and 251
I: Writing across page boundary at 2015232, between page index 251 and 252
I: Writing across page boundary at 2023424, between page index 252 and 253
I: Writing across page boundary at 2031616, between page index 253 and 254
I: Writing across page boundary at 2039808, between page index 254 and 255
I: Writing across page boundary at 2048000, between page index 255 and 256
I: Writing across page boundary at 2056192, between page index 256 and 257
I: Writing across page boundary at 2064384, between page index 257 and 258
I: Writing across page boundary at 2072576, between page index 258 and 259
I: Erasing page at 1966080 of size 8192 with index 246
I: Erasing page at 1974272 of size 8192 with index 247
I: Erasing page at 1982464 of size 8192 with index 248
I: Erasing page at 1990656 of size 8192 with index 249
I: Erasing page at 1998848 of size 8192 with index 250
I: Erasing page at 2007040 of size 8192 with index 251
I: Erasing page at 2015232 of size 8192 with index 252
I: Erasing page at 2023424 of size 8192 with index 253
I: Erasing page at 2031616 of size 8192 with index 254
I: Erasing page at 2039808 of size 8192 with index 255
I: Erasing page at 2048000 of size 8192 with index 256
I: Erasing page at 2056192 of size 8192 with index 257
I: Erasing page at 2064384 of size 8192 with index 258
I: Erasing page at 2072576 of size 8192 with index 259

    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/flash/erase_blocks/src/main.c:184: test_flash_erase_page: (flash_erase(flash_contr)
Failed to erase page
 FAIL - test_erase_single_pages_in_part in 1.118 seconds
===================================================================
START - test_write_across_page_boundaries_in_part
I: Erasing section of size 131072 at offset 1966080 controlled by flash-controller@400e0c00
I: Writing across page boundary at 1974272, between page index 246 and 247
I: Writing across page boundary at 1982464, between page index 247 and 248
I: Writing across page boundary at 1990656, between page index 248 and 249
I: Writing across page boundary at 1998848, between page index 249 and 250
I: Writing across page boundary at 2007040, between page index 250 and 251
I: Writing across page boundary at 2015232, between page index 251 and 252
I: Writing across page boundary at 2023424, between page index 252 and 253
I: Writing across page boundary at 2031616, between page index 253 and 254
I: Writing across page boundary at 2039808, between page index 254 and 255
I: Writing across page boundary at 2048000, between page index 255 and 256
I: Writing across page boundary at 2056192, between page index 256 and 257
I: Writing across page boundary at 2064384, between page index 257 and 258
I: Writing across page boundary at 2072576, between page index 258 and 259
 PASS - test_write_across_page_boundaries_in_part in 0.586 seconds
===================================================================
TESTSUITE flash_page_layout failed.

------ TESTSUITE SUMMARY START ------

SUITE FAIL -  50.00% [flash_page_layout]: pass = 1, fail = 1, skip = 0, total = 2 duration = 1.704 seconds
 - FAIL - [flash_page_layout.test_erase_single_pages_in_part] duration = 1.118 seconds
 - PASS - [flash_page_layout.test_write_across_page_boundaries_in_part] duration = 0.586 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION FAILED

@bjarki-andreasen
Copy link
Collaborator Author

well that sucks :)

@nandojve
Copy link
Member

nandojve commented Jan 3, 2025

Hi @bjarki-andreasen ,

I was wondering if you had time to look on it again.

@nandojve
Copy link
Member

friendly ping : )

@bjarki-andreasen
Copy link
Collaborator Author

I'm getting a dev kit in the coming days, then I will fix it properly

Add default partition table used with common apps like test suites
and the bootloader.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
To fully test the flash controllers, the test suite should erase
the very first pages, and the very last page to find bugs in the
extremes.

Using an overlay to update the partition layout to extend slot1 to
the end makes this possible.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
@bjarki-andreasen
Copy link
Collaborator Author

I extended the test suite to include board overlays so we can adjust the slot1 partition to extend to the very end of the flash area. With this, and running the test suite both with and without MCU boot on an sam4e_xpro, it runs without error, erasing the last page successfully:

I: Writing across page boundary at 1044480, between page index 258 and 259
 PASS - test_write_across_page_boundaries_in_part in 3.587 seconds

I did not need to change the driver, from what I can tell the bug was indeed fixed :)

@bjarki-andreasen bjarki-andreasen removed the DNM This PR should not be merged (Do Not Merge) label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Flash block: HW Test Testing on hardware required before merging bug The issue is a bug, or the PR is fixing a bug platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Current Atmel SAM flash driver will not erase last page
6 participants