You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2015/11/19 01:12:19 UTC
[06/14] incubator-mynewt-larva git commit: Use
flash_area_to_nffs_desc() to construct parameters.
Use flash_area_to_nffs_desc() to construct parameters.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/de3c2d96
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/de3c2d96
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/de3c2d96
Branch: refs/heads/master
Commit: de3c2d9633226f5538028d845966496ce57f89bf
Parents: 8ebf6cd
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Nov 18 16:00:49 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Nov 18 16:00:49 2015 -0800
----------------------------------------------------------------------
project/boot/src/boot.c | 51 ++++++++++++++++----------------------------
1 file changed, 18 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/de3c2d96/project/boot/src/boot.c
----------------------------------------------------------------------
diff --git a/project/boot/src/boot.c b/project/boot/src/boot.c
index 241ceb6..4b96ed4 100755
--- a/project/boot/src/boot.c
+++ b/project/boot/src/boot.c
@@ -67,14 +67,13 @@ main(void)
{
struct nffs_area_desc descs[NFFS_AREA_MAX];
/** Contains indices of the areas which can contain image data. */
- struct flash_area secs[SEC_CNT_MAX];
- /** Areas representing the beginning of image slots. */
uint8_t img_areas[NFFS_AREA_MAX];
+ /** Areas representing the beginning of image slots. */
uint8_t img_starts[2];
int cnt;
+ int total;
struct boot_rsp rsp;
int rc;
- int i, j;
struct boot_req req = {
.br_area_descs = descs,
.br_image_areas = img_areas,
@@ -82,37 +81,23 @@ main(void)
};
os_init();
- rc = flash_area_to_sectors(FLASH_AREA_IMAGE_0, &cnt, NULL);
- assert(rc == 0 && cnt < SEC_CNT_MAX);
- rc = flash_area_to_sectors(FLASH_AREA_IMAGE_0, &cnt, secs);
+ rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_0, &cnt, NULL);
+ assert(rc == 0 && cnt);
+ rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_0, &cnt, descs);
img_starts[0] = 0;
- for (i = 0; i < cnt; i++) {
- img_areas[i] = i;
- descs[i].nad_flash_id = secs[i].fa_flash_id;
- descs[i].nad_offset = secs[i].fa_off;
- descs[i].nad_length = secs[i].fa_size;
- }
- rc = flash_area_to_sectors(FLASH_AREA_IMAGE_1, &cnt, secs);
- if (rc == 0 && cnt > 0) {
- img_starts[1] = i;
- for (j = 0; j < cnt; j++, i++) {
- img_areas[i] = i;
- descs[i].nad_flash_id = secs[j].fa_flash_id;
- descs[i].nad_offset = secs[j].fa_off;
- descs[i].nad_length = secs[j].fa_size;
- }
- }
- rc = flash_area_to_sectors(FLASH_AREA_IMAGE_SCRATCH, &cnt, secs);
- if (rc == 0) {
- for (j = 0; j < cnt; j++) {
- img_areas[i] = i;
- descs[i].nad_flash_id = secs[j].fa_flash_id;
- descs[i].nad_offset = secs[j].fa_off;
- descs[i].nad_length = secs[j].fa_size;
- }
- }
- req.br_num_image_areas = i;
- req.br_scratch_area_idx = i - 1;
+ total = cnt;
+
+ rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_1, &cnt, &descs[total]);
+ assert(rc == 0);
+ img_starts[1] = total;
+ total += cnt;
+
+ rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_SCRATCH, &cnt, &descs[total]);
+ assert(rc == 0);
+ req.br_scratch_area_idx = total;
+
+ total += 1;
+ req.br_num_image_areas = total;
rc = boot_go(&req, &rsp);
assert(rc == 0);