[riot-notifications] [RIOT-OS/RIOT] riotboot/flashwrite: use flashpage_raw when available (#11683)

Francisco notifications at github.com
Wed Jun 12 19:02:12 CEST 2019

The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.

### Contribution description

Put here the description of your contribution:
- describe which part(s) of RIOT is (are) involved
- if it's a bug fix, describe the bug that it solves and how it is solved
- you can also give more information to reviewers about how to test your changes

The following PR allows using `flashpage_write_raw()` to finish an update process. The main objective of this is to support OTA on `stm32f4/2/7`. Since the flash is sector based if at the finish we are to perform an erase operation the whole sector would be erased (sectors that go from 16KB to 256KB). The idea is that since we only need to write 4 bytes if `flashpage_write_raw()` is available erasing the sector again can be avoided since it was already erased at the start of the `flashwrite` process. So as long as the first 4 bytes are kept in an erased state '0xFF' `flashpage_write_raw()` can be used.

### Testing procedure

1. Verify that everything still works on supported board that support and don't support flashpage. Applying this diff can help in testing over ethos:

diff --git a/tests/riotboot_flashwrite/Makefile b/tests/riotboot_flashwrite/Makefile
index 32f127d70..d3c9f20b4 100644
--- a/tests/riotboot_flashwrite/Makefile
+++ b/tests/riotboot_flashwrite/Makefile
@@ -39,11 +39,17 @@ LOW_MEMORY_BOARDS := nucleo-f334r8
 # uncomment these to use ethos
-#USEMODULE += ethos gnrc_uhcpc
+USEMODULE += ethos gnrc_uhcpc  stdio_uart_rx
 ## ethos baudrate can be configured from make command
-#ETHOS_BAUDRATE ?= 115200
+TAP ?= tap0
+IPV6_PREFIX ?= 2001:db8::/64
+TERMPROG ?= sudo sh $(RIOTTOOLS)/ethos/start_network.sh
 ifneq (,$(filter $(BOARD),$(LOW_MEMORY_BOARDS)))
   $(info Using low-memory configuration for microcoap_server.)

for nucleo-l073rz:

- provided the node `make -C tests/riotboot_flashwrite/ BOARD= nucleo-l073rz riotboot/flash term`
- compile new firmware: `make -C tests/riotboot_flashwrite/ BOARD= nucleo-l073rzriotboot`
- launch an updated: `coap-client -m post coap://[fe80::2%tap0]/flashwrite -f tests/riotboot_flashwrite/bin/ nucleo-l073rz/tests_riotboot_flashwrite-slot1.riot.bin -b 64`

for samr21-xpro:

- provided the node `make -C tests/riotboot_flashwrite/ BOARD= samr21-xpro riotboot/flash term`
- compile new firmware: `make -C tests/riotboot_flashwrite/ BOARD= samr21-xpro rzriotboot`
- launch an updated: `coap-client -m post coap://[fe80::2%tap0]/flashwrite -f tests/riotboot_flashwrite/bin/  samr21-xpro/tests_riotboot_flashwrite-slot1.riot.bin -b 64`

When the update finished reboot the node manually it should have started from a different slot.

2. rebase on top of https://github.com/RIOT-OS/RIOT/pull/11682 and https://github.com/RIOT-OS/RIOT/pull/11681 and test over an stm32f4 board, e.g. `nucleo-f446re`

- provided the node `make -C tests/riotboot_flashwrite/ BOARD=nucleo-f446re riotboot/flash term`
- compile new firmware: `make -C tests/riotboot_flashwrite/ BOARD=nucleo-f446re riotboot`
- launch an updated: `coap-client -m post coap://[fe80::2%tap0]/flashwrite -f tests/riotboot_flashwrite/bin/ nucleo-f446retests_riotboot_flashwrite-slot1.riot.bin -b 64`

Details steps to test your contribution:
- which test/example to compile for which board and is there a 'test' command
- how to know that it was not working/available in master
- the expected success test output

### Issues/PRs references

Examples: Fixes #1234. See also #5678. Depends on PR #9876.

Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.

Related to https://github.com/RIOT-OS/RIOT/pull/11682 and https://github.com/RIOT-OS/RIOT/pull/1168
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * periph/flashpage: add variable for value of erased byte
  * riotboot/flashwrite: use flashpage_raw for MAGIC number

-- File Changes --

    M Makefile.dep (1)
    M drivers/include/periph/flashpage.h (9)
    M sys/riotboot/flashwrite.c (44)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190612/087f6172/attachment-0001.html>

More information about the notifications mailing list