-
Notifications
You must be signed in to change notification settings - Fork 2k
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
periph/flashpage: extend API #16972
periph/flashpage: extend API #16972
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also extend tests/periph_flashpage
so we can see / verify the output of those functions.
209939e
to
7309c9c
Compare
@benpicco Added the symbols to |
Looks like you missed esp8266/32 |
I don't think esp8266/32 implements the flashpage driver ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right the files in drivers/periph_common
all get compiled always - so you'll need
7309c9c
to
42e4e78
Compare
I think its msp430 that's missing... |
42e4e78
to
0babf55
Compare
0babf55
to
1f28e34
Compare
@MrKevinWeiss do you have remote access to the frdm-k22f? Could you paste output of:
|
|
master
this PR
|
Ok so test does not pass in master either |
Yes it should. I think I could fix the _cca_length = 44;
MEMORY
{
rom (rx) : ORIGIN = _rom_start_addr + _rom_offset, LENGTH = _fw_rom_length - _cca_length
cca : ORIGIN = 0x0027ffd4, LENGTH = _cca_length
sram0 : ORIGIN = 0x20000000, LENGTH = 16K /* Lost in PM2 and PM3 */
sram1 : ORIGIN = 0x20004000, LENGTH = 16K
ram (w!rx) : ORIGIN = _ram_start_addr, LENGTH = _ram_length
} |
aeb4404
to
be254d4
Compare
@fjmolinas can you test if it works on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing on openmote-b
tests/periph_flashpage
Connect to serial port /dev/riot/tty-openmote-b
Welcome to pyterm!
Type '/exit' to exit.
>
> test_last_raw
> test_last_raw
wrote raw short buffer to last flash page
> help
help
Command Description
---------------------------------------
info Show information about pages
dump Dump the selected page to STDOUT
dump_local Dump the local page buffer to STDOUT
read Copy the given page to the local page buffer and dump to STDOUT
write Write the local page buffer to the given page
write_raw Write (ASCII, max 64B) data to the given address
erase Erase the given page buffer
edit Write bytes to the local page buffer
test Write and verify test pattern
test_last_pagewise Write and verify test pattern on last page available
test_last_pagewise
test_last_raw Write and verify raw short write on last page available
> test_last_pagewise
wrote local page buffer to last flash page
> help
help
Command Description
---------------------------------------
info Show information about pages
dump Dump the selected page to STDOUT
dump_local Dump the local page buffer to STDOUT
read Copy the given page to the local page buffer and dump to STDOUT
write Write the local page buffer to the given page
write_raw Write (ASCII, max 64B) data to the given address
erase Erase the given page buffer
edit Write bytes to the local page buffer
test Write and verify test pattern
test_last_pagewise Write and verify test pattern on last page available
test_last_raw Write and verify raw short write on last page available
>
examples/suit_update
Running from slot 0
> ifconfig
Iface 4 HWaddr: EE:6B:EE:D1:62:F7
L2-PDU:1500 MTU:1500 HL:64 RTR
Source address length: 6
Link type: wired
inet6 addr: fe80::ec6b:eeff:fed1:62f7 scope: link VAL
pinging node...
PING fe80::ec6b:eeff:fed1:62f7%riot0(fe80::ec6b:eeff:fed1:62f7%riot0) 56 data bytes
--- fe80::ec6b:eeff:fed1:62f7%riot0 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 57.773/57.773/57.773/0.000 ms
pinging node succeeded.
TEST PASSED
tests/riotboot
> getslotaddr 0
getslotaddr 0
Slot 0 address=0x00201400
> dumpaddrs
dumpaddrs
slot 0: metadata: 0x201000 image: 0x00201400
slot 1: metadata: 0x240000 image: 0x00240400
>
TEST PASSED
One thing is that I notice is that when using riotboot
2 pages are subtracted from ROM_LEN
to not write over the CCA region, this probably means that an extra 44 bytes are lost from the last page. But I think the extra complexity in the build system to sabe thos extra 44bytes is out of scope here.
@MrKevinWeiss can you open an issue for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, failing tests as reported by @MrKevinWeiss are also failing in master, see #17057.
Was it intended to add the new files (flashpage.c) to the doxygen group |
That is a stupid mistake on my side because I copied the header from another file. It should be |
Of course :) |
In a follow up PR based on the functionality introduced in this PR, concerns about the necessity of the functionality were raised. I think the mentioned arguments are correct and reduce the necessity of the What are you opinions on this @benpicco @fjmolinas ? |
Since commit 3a11b1f (RIOT-OS#16972) building RIOT applications with `BOARD=hifive1` causes the following linker error to be emitted on my system: /opt/rv32imc/lib/gcc/riscv32-unknown-elf/10.2.0/../../../../riscv32-unknown-elf/bin/ld:riscv_base.ld:220: warning: memory region `rom' not declared This is due to the fact that the RISC-V linker script doesn't have a rom memory region. While many other ARM-based boards have a rom memory region defined in the linker script, the corresponding region name in the RISC-V linker script is flash and rom is not declared as a memory region hence the warning. I think this was accidentally overlooked in 3a11b1f. It is fixed in this commit by replacing the rom region with the flash region. The linker script identifiers (e.g. _srom and _erom) are not renamed.
Contribution description
This PR extends the flashpage API with two functions that return information about the first and last free flashpage.
This is supposed to make it easier store data in flash without accidentally corrupting e.g. firmware or bootloaders.
I am aware that as of now this only adds the function implementations for Cortex-M CPUs.
I am opening this PR to start a discussion if this approach is correct and a reasonable addition to the API. If it is, I will also add function implementations for other CPUs implementing the flashpage APl.