Skip to content

sw: Fix RAM boot detection#331

Open
michalsieron wants to merge 1 commit into
im-tomu:masterfrom
antmicro:fix-ram-boot-detection
Open

sw: Fix RAM boot detection#331
michalsieron wants to merge 1 commit into
im-tomu:masterfrom
antmicro:fix-ram-boot-detection

Conversation

@michalsieron
Copy link
Copy Markdown

Up until now, docs said that RAM boot happens, when foboot finds 0x17ab0f23 in first 56 bytes of loaded binary.

That wasn't the case, it was checking only first 12 bytes.
for loop did at most (max_check/4)-1 iterations, which is equal to 15, because max_check has the value of rx_buffer size from usb-dev.c, which is 64 bytes.

15 times 4 byte words results in 60 checked bytes, but there was also division by 4 when accessing items of dfu_buffer, which reduced number of checks to 3 resulting in 12 bytes checked.

I also corrected the docs from 56 checked bytes to 60.

Up until now, docs said that RAM boot happens, when foboot finds
`0x17ab0f23` in first 56 bytes of loaded binary.

That wasn't the case, it was checking only first 12 bytes.
`for` loop did at most `(max_check/4)-1` iterations, which is equal to 15,
because `max_check` has the value of `rx_buffer` size from usb-dev.c.

15 times 4 byte words results in 60 checked bytes, but there was also
division by 4 when accessing items of `dfu_buffer`, which reduced number
of checks to 3.

I also corrected the docs from 56 checked bytes to 60.
@mithro mithro requested a review from xobs March 17, 2022 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant