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 
66 typedef struct {
68  size_t offset;
69  unsigned flashpage;
70  uint8_t flashpage_buf[FLASHPAGE_SIZE];
72 
76 #define RIOTBOOT_FLASHWRITE_SKIPLEN sizeof(RIOTBOOT_MAGIC)
77 
94 int riotboot_flashwrite_init_raw(riotboot_flashwrite_t *state, int target_slot,
95  size_t offset);
96 
112  int target_slot)
113 {
114  /* initialize state, but skip "RIOT" */
115  return riotboot_flashwrite_init_raw(state, target_slot,
117 }
118 
134  const uint8_t *bytes, size_t len, bool more);
135 
148  const uint8_t *bytes, size_t len);
149 
161 {
162  return riotboot_flashwrite_finish_raw(state, (const uint8_t *)"RIOT",
164 }
165 
174 
186 int riotboot_flashwrite_verify_sha256(const uint8_t *sha256_digest,
187  size_t img_size, int target_slot);
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #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:76
unsigned flashpage
update is at this flashpage
Definition: flashwrite.h:69
static int riotboot_flashwrite_finish(riotboot_flashwrite_t *state)
Finish a firmware update (riotboot version)
Definition: flashwrite.h:160
size_t offset
update is at this position
Definition: flashwrite.h:68
int target_slot
update targets this slot
Definition: flashwrite.h:67
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:111
#define FLASHPAGE_SIZE
Flash page configuration.
Definition: cpu_conf.h:44
firmware update state structure
Definition: flashwrite.h:66
int riotboot_flashwrite_verify_sha256(const uint8_t *sha256_digest, size_t img_size, int target_slot)
Verify the digest of an image.