flashwrite.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Kaspar Schleiser <kaspar@schleiser.de>
3  * 2018 Inria
4  * 2018 Freie Universit├Ąt Berlin
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
50 #ifndef RIOTBOOT_FLASHWRITE_H
51 #define RIOTBOOT_FLASHWRITE_H
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 #include "riotboot/slot.h"
58 #include "periph/flashpage.h"
59 
63 typedef struct {
65  size_t offset;
66  unsigned flashpage;
67  uint8_t flashpage_buf[FLASHPAGE_SIZE];
69 
73 #define RIOTBOOT_FLASHWRITE_SKIPLEN sizeof(RIOTBOOT_MAGIC)
74 
91 int riotboot_flashwrite_init_raw(riotboot_flashwrite_t *state, int target_slot,
92  size_t offset);
93 
109  int target_slot)
110 {
111  /* initialize state, but skip "RIOT" */
112  return riotboot_flashwrite_init_raw(state, target_slot,
114 }
115 
131  const uint8_t *bytes, size_t len, bool more);
132 
145  const uint8_t *bytes, size_t len);
146 
158 {
159  return riotboot_flashwrite_finish_raw(state, (const uint8_t *)"RIOT",
161 }
162 
171 
183 int riotboot_flashwrite_verify_sha256(const uint8_t *sha256_digest,
184  size_t img_size, int target_slot);
185 
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif /* RIOTBOOT_FLASHWRITE_H */
int riotboot_flashwrite_init_raw(riotboot_flashwrite_t *state, int target_slot, size_t offset)
Initialize firmware update (raw version)
int riotboot_flashwrite_finish_raw(riotboot_flashwrite_t *state, const uint8_t *bytes, size_t len)
Finish a firmware update (raw version)
Low-level flash page peripheral driver interface.
Slot management tools.
#define RIOTBOOT_FLASHWRITE_SKIPLEN
Amount of bytes to skip at initial write of first page.
Definition: flashwrite.h:73
unsigned flashpage
update is at this flashpage
Definition: flashwrite.h:66
static int riotboot_flashwrite_finish(riotboot_flashwrite_t *state)
Finish a firmware update (riotboot version)
Definition: flashwrite.h:157
size_t offset
update is at this position
Definition: flashwrite.h:65
int target_slot
update targets this slot
Definition: flashwrite.h:64
int riotboot_flashwrite_putbytes(riotboot_flashwrite_t *state, const uint8_t *bytes, size_t len, bool more)
Feed bytes into the firmware writer.
size_t riotboot_flashwrite_slotsize(const riotboot_flashwrite_t *state)
Get a slot&#39;s size.
static int riotboot_flashwrite_init(riotboot_flashwrite_t *state, int target_slot)
Initialize firmware update (riotboot version)
Definition: flashwrite.h:108
#define FLASHPAGE_SIZE
Flash page configuration.
Definition: cpu_conf.h:44
firmware update state structure
Definition: flashwrite.h:63
int riotboot_flashwrite_verify_sha256(const uint8_t *sha256_digest, size_t img_size, int target_slot)
Verify the digest of an image.