nonblocking image upload#613
Conversation
|
You can find the documentation preview for this PR here. |
|
@michalek-no it would help us to review this PR if you could point to the functionality that you changed/added from the Zephyr implementation, and fix the errors that GitHub is complaining about in the |
7e95fc5 to
7d19184
Compare
7d19184 to
26a859c
Compare
|
I have a PR for |
8a30e6c to
f26f1a3
Compare
1d5e92d to
62ca667
Compare
6a43719 to
3b7bbaf
Compare
|
rebase |
ee821c2 to
05f0f3e
Compare
| @@ -423,19 +478,63 @@ int img_mgmt_write_image_data(unsigned int offset, const void *data, unsigned in | |||
| int img_mgmt_write_image_data(unsigned int offset, const void *data, unsigned int num_bytes, | |||
There was a problem hiding this comment.
some comments in code on what is done? why? would be very helpfull.
There was a problem hiding this comment.
This file is so much different then sdk-zephyr origin that I would:
- move NCS-BM implementation of img_mgmt_read() & int img_mgmt_write_image_data() to a brand new file.
- cut this fille content as you already did (+ removal of what the new file implements instead).
There was a problem hiding this comment.
Not necessary in this PR.
fbfe7c8 to
1cf28f0
Compare
|
|
||
| ring_buf_put(&ring_buf, data, pad); | ||
| rb_size = ring_buf_get_claim(&ring_buf, &rb_data, PKTBUF_SZ); | ||
| ring_buf_get_finish(&ring_buf, rb_size); |
There was a problem hiding this comment.
I don't think it's correct to call ring_buf_get_finish() here. That functions allows the data you claimed using ring_buf_get_claim() to be overwritten in the buffer, but at this point the data may not have been written yet. You need to keep this data unchanged while it is being written to NVM, meaning until you receive the event from bm_storage.
There was a problem hiding this comment.
Not calling finish() causes size_get() to return incorrect values. 'ongoing' var keeps track on available space.
There was a problem hiding this comment.
can we use value from ring_buf_get_claim() instead of size_get() here? Then we can release at the bm_event.
| ring_buf_put(&ring_buf, data, num_bytes); | ||
| } | ||
|
|
||
| if (last) { |
There was a problem hiding this comment.
When last, it seems you retrieve up to CHUNK_SZ bytes first, then write those bytes, then retrieve everything else that's left and write that. I don't think you need to write twice in this case; could you not simply retrieve everything that's left and write it at once?
There was a problem hiding this comment.
This handles possibility we hit ring buffer wrap around
| static uint8_t ongoing; | ||
| static int write_offset; | ||
|
|
||
| static void bm_storage_evt_handler_writes(struct bm_storage_evt *evt) |
There was a problem hiding this comment.
Instead you should inspect the event from bm_storage and free the data there.
1cf28f0 to
f352147
Compare
| } | ||
| } | ||
|
|
||
| struct bm_storage_config s0_config = { |
| }, | ||
| }; | ||
|
|
||
| struct bm_storage_config s1_config = { |
| rb_data, rb_size, NULL); | ||
|
|
||
| if (err) { | ||
| rc = IMG_MGMT_ERR_INVALID_IMAGE_TOO_LARGE; |
There was a problem hiding this comment.
There are three places where we can get IMG_MGMT_ERR_INVALID_IMAGE_TOO_LARGE here, shouldn't we at least have LOG_DBG, in all of them, with the err being reported?
| if (ring_buf_size_get(&ring_buf)) { | ||
| rb_size = ring_buf_get_claim(&ring_buf, &rb_data, PKTBUF_SZ); | ||
| ring_buf_get_finish(&ring_buf, rb_size); | ||
| int err = bm_storage_write(&s0_storage, |
There was a problem hiding this comment.
Eclipsing err variable declaration in upper scope.
| int err = bm_storage_write(&s0_storage, | ||
| write_offset, rb_data, rb_size, NULL); |
There was a problem hiding this comment.
This is still unaligned
|
rebase |
| int err = bm_storage_write(&s0_storage, | ||
| write_offset, rb_data, rb_size, NULL); |
There was a problem hiding this comment.
This is still unaligned
| int img_mgmt_find_by_hash(uint8_t *find, struct image_version *ver); | ||
| int img_mgmt_find_by_ver(struct image_version *find, uint8_t *hash); | ||
| int img_mgmt_state_read(struct smp_streamer *ctxt); | ||
| int img_mgmt_state_write(struct smp_streamer *njb); | ||
| int img_mgmt_flash_area_id(int slot); |
There was a problem hiding this comment.
nit: Missing descriptions
There was a problem hiding this comment.
I see the rest are removed, will be good with some description for img_mgmt_state_read().
|
|
||
| ring_buf_put(&ring_buf, data, pad); | ||
| rb_size = ring_buf_get_claim(&ring_buf, &rb_data, PKTBUF_SZ); | ||
| ring_buf_get_finish(&ring_buf, rb_size); |
There was a problem hiding this comment.
can we use value from ring_buf_get_claim() instead of size_get() here? Then we can release at the bm_event.
| struct zcbor_string img_data; | ||
| struct zcbor_string data_sha; |
There was a problem hiding this comment.
Add descriptions here?
There was a problem hiding this comment.
let's leave this minor stuff for the future
|
@nrfconnect/ncs-co-build-system Please review! We need to get this in this week. |
| * @param ver output buffer for image version | ||
| * @param hash output buffer for image hash | ||
| * @param flags output buffer for image flags | ||
| * @param image_slot Image slot number. |
There was a problem hiding this comment.
why not fix these issues upstream and bring the fixed version in?
|
Have not reviewed C code, first 3 comments mandatory, last one a suggestion |
img_mgmt.h img_mgmt_priv.h img_mgmt.c zephyr_img_mgmt.c cherry-picked from sdk-zephyr dbcfb77ce3d20784406d4d73a1de3f7f1bcea07c Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
|
@nordicjm My comment to what you posted there: |
access to slot0 and slot1 partitions are handled via bm_storage subsystem Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
removed bm unneeded stuff Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
No description provided.