Commit Graph

12 Commits

Author SHA1 Message Date
Harald Welte
050b9dde68 HACK: Solve weird problem with lost OUT transfer on ping-pong endpoint
This adds an unconditional endpoint reset procedure to every SET_FEATURE(UnHalt).

It doesn't really make sense that this is required, *particularly* as
we *MUST NOT* set bEndpoint->bank to 0 here.

Without this patch, I'm observing the following problem:

Every first OUT transfer after a SET_INTERFACE + UNHALT on a bulk endpoint
is lost. "lost" means that it completes successfully on the host, can
be seen completing successfully with an ACK on a USB bus analyzer,
but still doesn't show up in the firmware.  No Endpoint Interrupt
is generated.

This can be reproduced by calling libusb_set_interface_alt_setting()
from the host and then submitting a single OUT transfer.

Change-Id: I18ed530e617baddf76e8f9829512443ce2a76e0d
2022-03-03 19:06:12 +01:00
Kévin Redon
b6e2f0f8e7 DFU: add DFU application
this adds the DFU as application, allowing to flash the bootloader.
a USB DFU alternative is added to flash the bootloader partition.

when the DFU is started as bootloader, the partition/alternative
to flash the bootloader is marked as "not available", and
ineffective.
the same happens for the application partition when DFU is started
as application.

this distinction is make at compile time, not at runtime, because
of size restrictions (the bootloader was already close to the
16 kB limit).
*_dfu_flash.bin should not be mixed with *_dfu_dfu.bin.
*_dfu_dfu.bin should be flashed as application using the already
existing DFU bootloader.
once this images is started (as application), the *_dfu_flash.bin
should be flashed as bootloader using the DFU application.

once the DFU bootloader has been flashed, soft resetting
(not re-powering) will cause the bootloader to start, allowing to
flash the application with a normal image (e.g. not DFU),
replacing the DFU application.
this switch to DFU only happens after downloading (e.g. flashing).

it is planned to have the DFU application erase itself after
flashing, but this is currently not implemented.

Change-Id: Ic273bb593a7669111b0219fe301d7897419167c8
2020-01-16 20:35:04 +00:00
Harald Welte
5b136021d8 host_communication: Send zero-length-packet on wMaxPacketSize
We need to send zero-length packets on bulk endpoints whenever the
transfer size is exactly a multiple of the wMaxPacketSize.

See USB 2.0 Specification Section 5.8.3 titled "Bulk Transfer Packet
Size constraints."

Change-Id: Ice3842399d5a5c4a18383860f81074497c6e7c9b
Closes: OS#4331
2019-12-16 00:08:46 +01:00
Harald Welte
b0b457df63 USBD_HAL: Don't disable UDP peripheral clock on suspend
Change-Id: I2169e2140762b37661f4567bb148326afd85cddc
Closes: OS#4329
2019-12-15 17:25:13 +01:00
Kévin Redon
75a5f224c0 minor: improve trace output
the USB trace now respects the global setting.
the verbosity is also decreased, not showing USB activity unless
debugging.
this also saves some space.

the reset cause is now printed.
the strings increase the bootloader size, but it already exceeded
the 16 kB limit when trace level is set to info.

Change-Id: I9ba08d4bb4f188f6e7a202ea86acb7a42a2054f3
2019-12-11 16:58:07 +01:00
Kévin Redon
93717e43b3 set linux end of line
Change-Id: I5200f0d6f39b0641cac26a4109a3cd33e8474b9b
2018-07-11 22:01:58 +02:00
Harald Welte
d1e963479e DFU: fix transitions between runtime and DFU mode
we now always go through a processor reset to avoid any state that might
be persistent/left-over during the switch.
2017-03-03 00:34:17 +01:00
Harald Welte
0af4948211 cstartup / USBD: Use correct Makefile conditionals for DFU 2017-03-02 23:18:02 +01:00
Harald Welte
adba0ce80b fix g_dfu access from both DFU and runtime access
We need to refer to g_dfu as a pointer from all code.  In DFU mode, it
gets assigned to the address of _g_dfu, which is placed by the linker
script at the start of RAM.  In runtime mode, the pointer is statically
defined to point at the start of RAM.  The linker script for the runtime
(dfu environment) is adjusted to save the first 32 bytes for the _g_dfu
structure.
2017-02-28 01:10:32 +01:00
Harald Welte
3f5e3ddffc Change directory structure to align with Atmel softpack
This way we can easily check with 'diff' for differences in our code and
Atmel softpack.  Also, this layout is more suitable for building various
different firmware images (e.g. factory-test, dfu-loader, main
application) for a variety of different boards (simtrace, owhw, qmod).
2017-02-27 14:24:11 +01:00
Christina Quast
b0bbb1b52e Removed sym links, replaced them with actual folders 2015-04-07 20:04:19 +02:00
Christina Quast
5a67c0fef3 Renamed main folder to firmware 2015-04-07 18:24:06 +02:00