Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disco_l475_iot1 enter in loop when updating #2

Open
nandojve opened this issue May 26, 2020 · 0 comments
Open

disco_l475_iot1 enter in loop when updating #2

nandojve opened this issue May 26, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@nandojve
Copy link

Describe the bug
The board disco_l475_iot1 enter on a loop when updating.

To Reproduce
Build updatehub from topic/wifi for disco_iot1.

Expected behavior
The board must update, reboot, test and confirm new version instead start download again.

Impact
Never stop the update the image.

Screenshots or console output

*** Booting Zephyr OS build v2.3.0-rc1-138-g1d06829ef97b  ***
[00:00:00.005,000] <inf> mcuboot: Starting bootloader
[00:00:00.006,000] <inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x1
[00:00:00.006,000] <inf> mcuboot: Scratch: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.006,000] <inf> mcuboot: Boot source: primary slot
[00:00:00.013,000] <inf> mcuboot: Swap type: none


uart:~$ *** Booting Zephyr OS build v2.3.0-rc1-299-gbd918389d9a3  ***
[00:00:00.538,000] <inf> main: UpdateHub sample app started
[00:00:00.546,000] <inf> main: Confirming the boot image
[00:00:03.632,000] <inf> main: WIFI Connected
[00:00:03.657,000] <inf> main: Starting UpdateHub polling mode
[00:00:04.225,000] <inf> updatehub: Probe metadata received
[00:00:10.712,000] <dbg> updatehub.install_update_cb: Flash: Address: 0x00000000, Size: 1024, Flush: 0

...

[00:02:36.359,000] <dbg> updatehub.install_update_cb: Flash: Address: 0x00040000, Size: 1024, Flush: 0
[00:02:36.897,000] <dbg> updatehub.install_update_cb: Flash: Address: 0x00040400, Size: 304, Flush: 1
[00:02:36.912,000] <inf> updatehub: Firmware downloaded successfully
[00:02:38.619,000] <inf> updatehub: Image flashed successfully, you can reboot now
uart:~$ *** Booting Zephyr OS build v2.3.0-rc1-138-g1d06829ef97b  ***
[00:00:00.005,000] <inf> mcuboot: Starting bootloader
[00:00:00.006,000] <inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x1
[00:00:00.006,000] <inf> mcuboot: Scratch: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.006,000] <inf> mcuboot: Boot source: primary slot
[00:00:00.013,000] <inf> mcuboot: Swap type: test


uart:~$ *** Booting Zephyr OS build v2.3.0-rc1-299-gbd918389d9a3  ***
[00:00:00.538,000] <inf> main: UpdateHub sample app started
[00:00:00.546,000] <inf> main: Confirming the boot image
[00:00:03.769,000] <inf> main: WIFI Connected
[00:00:03.858,000] <inf> main: Starting UpdateHub polling mode
[00:00:04.425,000] <inf> updatehub: Probe metadata received
[00:00:10.912,000] <dbg> updatehub.install_update_cb: Flash: Address: 0x00000000, Size: 1024, Flush: 0

...

[00:02:36.559,000] <dbg> updatehub.install_update_cb: Flash: Address: 0x00040000, Size: 1024, Flush: 0
[00:02:37.097,000] <dbg> updatehub.install_update_cb: Flash: Address: 0x00040400, Size: 304, Flush: 1
[00:02:37.112,000] <inf> updatehub: Firmware downloaded successfully
[00:02:38.819,000] <inf> updatehub: Image flashed successfully, you can reboot now
uart:~$ *** Booting Zephyr OS build v2.3.0-rc1-138-g1d06829ef97b  ***
[00:00:00.005,000] <inf> mcuboot: Starting bootloader
[00:00:00.006,000] <inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x1
[00:00:00.006,000] <inf> mcuboot: Scratch: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.006,000] <inf> mcuboot: Boot source: primary slot
[00:00:00.013,000] <inf> mcuboot: Swap type: test


uart:~$ *** Booting Zephyr OS build v2.3.0-rc1-299-gbd918389d9a3  ***
[00:00:00.538,000] <inf> main: UpdateHub sample app started
[00:00:00.546,000] <inf> main: Confirming the boot image
[00:00:03.638,000] <inf> main: WIFI Connected
[00:00:03.657,000] <inf> main: Starting UpdateHub polling mode
[00:00:04.225,000] <inf> updatehub: Probe metadata received
[00:00:10.712,000] <dbg> updatehub.install_update_cb: Flash: Address: 0x00000000, Size: 1024, Flush: 0
...

Environment (please complete the following information):

  • OS: Linux
  • Toolchain Zephyr SDK 0.11.2
  • Commit SHA e71313e
@nandojve nandojve added the bug Something isn't working label May 26, 2020
nandojve pushed a commit that referenced this issue Jul 29, 2020
This makes the gatt metrics also available for
gatt write-without-rsp-cb so it now prints the rate of each write:

uart:~$ gatt write-without-response-cb 1e ff 10 10
Write #1: 16 bytes (0 bps)
Write #2: 32 bytes (3445948416 bps)
Write #3: 48 bytes (2596929536 bps)
Write zephyrproject-rtos#4: 64 bytes (6400 bps)
Write zephyrproject-rtos#5: 80 bytes (8533 bps)
Write zephyrproject-rtos#6: 96 bytes (10666 bps)
Write zephyrproject-rtos#7: 112 bytes (8533 bps)
Write zephyrproject-rtos#8: 128 bytes (9955 bps)
Write zephyrproject-rtos#9: 144 bytes (11377 bps)
Write zephyrproject-rtos#10: 160 bytes (7680 bps)
Write zephyrproject-rtos#11: 176 bytes (8533 bps)
Write zephyrproject-rtos#12: 192 bytes (9386 bps)
Write Complete (err 0)
Write zephyrproject-rtos#13: 208 bytes (8533 bps)
Write zephyrproject-rtos#14: 224 bytes (9244 bps)
Write zephyrproject-rtos#15: 240 bytes (9955 bps)
Write zephyrproject-rtos#16: 256 bytes (8000 bps)

Signed-off-by: Luiz Augusto von Dentz <[email protected]>
nandojve pushed a commit that referenced this issue Nov 12, 2020
The _ldiv5() is an optimized divide-by-5 function that is smaller and
faster than the generic libgcc implementation.

Yet it can be made even smaller and faster with this replacement
implementation based on a reciprocal multiplication plus some tricks.

For example, here's the assembly from the original code on ARM:

_ldiv5:
        ldr     r3, [r0]
        movw    ip, zephyrproject-rtos#52429
        ldr     r1, [r0, zephyrproject-rtos#4]
        movt    ip, 52428
        adds    r3, r3, #2
        push    {r4, r5, r6, r7, lr}
        mov     lr, #0
        adc     r1, r1, lr
        adds    r2, lr, lr
        umull   r7, r6, ip, r1
        lsr     r6, r6, #2
        adc     r7, r6, r6
        adds    r2, r2, r2
        adc     r7, r7, r7
        adds    r2, r2, lr
        adc     r7, r7, r6
        subs    r3, r3, r2
        sbc     r7, r1, r7
        lsr     r2, r3, #3
        orr     r2, r2, r7, lsl zephyrproject-rtos#29
        umull   r2, r1, ip, r2
        lsr     r2, r1, #2
        lsr     r7, r1, zephyrproject-rtos#31
        lsl     r1, r2, #3
        adds    r4, lr, r1
        adc     r5, r6, r7
        adds    r2, r1, r1
        adds    r2, r2, r2
        adds    r2, r2, r1
        subs    r2, r3, r2
        umull   r3, r2, ip, r2
        lsr     r2, r2, #2
        adds    r4, r4, r2
        adc     r5, r5, #0
        strd    r4, [r0]
        pop     {r4, r5, r6, r7, pc}

And here's the resulting assembly with this commit applied:

_ldiv5:
        push    {r4, r5, r6, r7}
        movw    r4, zephyrproject-rtos#13107
        ldr     r6, [r0]
        movt    r4, 13107
        ldr     r1, [r0, zephyrproject-rtos#4]
        mov     r3, #0
        umull   r6, r7, r6, r4
        add     r2, r4, r4, lsl #1
        umull   r4, r5, r1, r4
        adds    r1, r6, r2
        adc     r2, r7, r2
        adds    ip, r6, r4
        adc     r1, r7, r5
        adds    r2, ip, r2
        adc     r2, r1, r3
        adds    r2, r4, r2
        adc     r3, r5, r3
        strd    r2, [r0]
        pop     {r4, r5, r6, r7}
        bx      lr

So we're down to 20 instructions from 36 initially, with only 2 umull
instructions instead of 3, and slightly smaller stack footprint.

Signed-off-by: Nicolas Pitre <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant