Commit graph

582 commits

Author SHA1 Message Date
Loic Poulain fa2da6713b usb: stm32: Fix null dereference in ep_write
ret_bytes param is optional and then can be NULL.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2017-11-09 09:13:14 -05:00
Loic Poulain 4a2e967a87 usb: stm32: Fix TX FIFO overwrite
In the same way as dw driver, check that FIFO is empty before
writing any new data. This patch introduces a boolean semaphore
which is requested before any new TX transfer and released on
transfer completion.

This fixes usb-ecm support on 96b_carbon board.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2017-11-09 09:13:14 -05:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Andrei Emeltchenko fe9dee0107 usb: dw: Add sleep before FIFO flash
Adding sleep before TX FIFO flash fixes splitting networking packets
sent over USB endpoints making ECM broken since there is no flow
control other then frame sizes.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-10-28 14:38:19 -04:00
Andrei Emeltchenko b722dc589e usb: dw: Fix debug log specifier for FIFO not empty
The situation when FIFO is not empty is not a bug and it is spamming
console when only bugs are enabled.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-10-28 14:38:19 -04:00
Andy Ross 5aee94e4cf usb_dw_dc: Cleanup: write DIEPCTL register just once
The enable and clear NAK bit can be legally written together, do it in
just one write.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-10-28 14:38:19 -04:00
Andy Ross eebb17ca52 usb_dc_dw: Correctness: use bytewise I/O in FIFO fill
The Designware FIFO is filled in units of 32 bit words, but the buffer
we are passed is not guaranteed to be a multiple of 4 bytes long, nor
aligned on a 4-byte boundary.  So in theory we are reading 0-3 bytes
of unused garbage from the end of the array.

That's currently benign on supported platforms with this hardware,
which all support misaligned reads.  But not all do.  And the incoming
arrival of memory protection opens the possibility that those extra
bytes would cross a protection boundary and cause a crash or security
bug.

Do this right.

(Note that this is fixed to little endian byte order.  The Designware
databook is frustratingly silent on the endianness it expects, but
existing hardware I can see is definitely LE and I see a few spots in
the Linux dwc2 driver that likewise assume LE).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-10-28 14:38:19 -04:00
Andy Ross f591e58211 usb_dc_dw: Correctly assign endpoint FIFOs
The designware hardware in dedicated FIFO mode (which is all we
support right now for lack of shared-FIFO hardware) has one hardware
FIFO per IN (i.e. transmit) endpoint.  But it doesn't assign them on
its own, it's the drivers responsibility to populate the TxFNum field
of the DIEPCTL registers with integer indices corresponding to the
desired FIFO.

We weren't doing that, which meant that all IN endpoints were sharing
the same FIFO zero which is supposed to be dedicated to EP0 control
transfers.  The net effect is that sometimes outbound transfers would
be corrupted, showing data from the wrong endpoint.  More often that
not this would leak from control transfers over to the
higher-bandwidth bulk endpoints of the application, but occasionally
you'd see a control transfer itself get borked and the USB device
would glitch.

Get this right and set the FIFOs properly.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-10-28 14:38:19 -04:00
Andy Ross e6874a0c61 usb_dw_dc: Fix locking correctness
There is no particular reason this spot in usb_dw_tx() cannot be
reached by racing threads on the same endpoint, though existing API
usage in the tree is all unithreaded.  The FIFO state read at the top
of the function must still be true at the bottom or else the packet
byte count will be corrupt.

Also, as described in an existing comment, the databook has some
scary-sounding warnings about access to the registers during FIFO
operations, even if they "should" be on separate endpoints and
unrelated.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-10-28 14:38:19 -04:00
David B. Kinder 4600c37ff1 doc: Fix misspellings in header/doxygen comments
Occasional scan for misspellings missed during PR reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-10-17 19:40:29 -04:00
Loic Poulain 8a11f91252 usb: Add support for STM32 family USB driver
This is a USB controller driver for STM32F4xx devices using
the STM32 Cube HAL_PCD framework. This has been tested with
the cdc_acm driver on a 96b_carbon board (STM32F401RE).

This is a refactoring of:
usb: usb_dc_stm: Add support for STM32Cube HAL_PCD USB driver
Signed-off-by: Christer Weinigel <christer@weinigel.se>
[daniel.thompson@linaro.org: Removed STM32F40(157) defconfig changes
together with STM32F4Discovery pinmux and defconfig changes, updated
clock settings and pad configuration to match latest mainline]
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
[giannis.damigos@gmail.com: Change uint*_t types to u*_t types,
change SYS_LOG_USB_DC_STM_LEVEL to SYS_LOG_USB_DRIVER_LEVEL and
update pinmux to match latest arm branch]
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2017-10-17 09:14:47 -04:00
Andrei Emeltchenko 4efaefba5c usb: Allow to select configuration for composite devices
Composite multifunction USB devices should be able to know about
configuration change, implement it through existing callback.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:00:23 -04:00
Andrei Emeltchenko 5522875a75 usb: Correct length print modifier
Length should be logged in decimal notation.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:00:23 -04:00
Anas Nashif 09bcd8ee74 Kconfig: make all syslog variables depend on SYS_LOG
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-04 14:34:54 -05:00
Johann Fischer 3dd51d52a2 drivers: usb: use generic option name for log level
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-06-28 09:02:27 -04:00
David B. Kinder 93e4d7258d spell: fix Kconfig help typos: /boards /drivers
Fix misspellings in Kconfig help text

Change-Id: I3ae28a5d23d8e266612114bc0eb8a6e158129dc7
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-21 21:31:30 +00:00
Kumar Gala ccad5bf3e3 drivers: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I08f51e2bfd475f6245771c1bd2df7ffc744c48c4
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 10:06:48 -05:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Flavio Santes 358056692f drivers/usb: Use the right data-type
Use uint32_t instead of int.

Change-Id: I7d73a3fea61e48663aeada6792b9b6c19db1cb35
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-21 12:54:53 +00:00
Anas Nashif a9e879e273 logging: move sys_log to subsys/logging
Move logging out of misc/ to its own subsystem. Anything related to
logging and any new logging features or backends could be added here
instead of the generic location in misc/ which is overcrowded with
options that are not related to eachother.

Jira: ZEP-1467
Change-Id: If6a3ea625c3a3562a7a61a0ba5fd7e6ca75518ba
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:39 +00:00
Kumar Gala fe144ff2d4 drivers: usb: remove unneeded include path additions
We can locally reference the file we need, so don't add a -I we don't
need.

Change-Id: I4d9507d5368073443dcc78a5821fe09d3e0b9bfc
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-12-10 02:15:48 +00:00
Sergio Rodriguez 3932dd98a7 drivers: usb: update to unified kernel
Change-Id: Ie0cb514f3d84f7f87a0cf3f3a477df5cf04886d4
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-11-11 02:48:20 +00:00
Jithu Joseph 7eab305593 usb: Add end-point stall APIs and flow control APIS
USB class drivers may need to offload some work from
upcall interrupt context to a background fiber. This
requires some way to defer taking more data from host
till the offloaded work completes. Two APIs are added to
achieve this.

Further USB class drivers sometimes need to set STALL condition
on end-points to signal errors to host.These too are
added.

Change-Id: Ic973522c3394e23d7f9c4c67affc0cd050afc20f
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2016-11-09 02:45:46 +00:00
Iván Briano 0094ab228d ext qmsi: Update to QMSI 1.3 release
Update the QMSI drop we maintain in Zephyr, and fix the build where
needed:

- QM_SCSS_INT is renamed to QM_INTERRUPT_ROUTER;
- every member of QM_INTERRUPT_ROUTER was renamed as well;
- QM_IRQ_* renamed too, mostly added _INT at the end;
- some isr functions were renamed to keep their names consistent;
- build for x86 needs to define QM_LAKEMONT, as QM_SENSOR was for ARC.

Change-Id: I459029ca0d373f6c831e2bb8ebd52402a55994d1
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-10-31 13:26:06 +00:00
Jesus Sanchez-Palencia 7c0fc99c79 ext qmsi: Update to QMSI 1.2 release
Update the QMSI drop we maintain in Zephyr, and fix the build where
needed:

- QM_USB_BASE is renamed to QM_USB_0_BASE;
- parameter int_en from qm_uart cfg struct was removed;
- driver's folder now has a new structure, fix makefiles accordingly;
- QM_WDT_MODE and related renamed to QM_WDT_CR_RMOD;
- QM_SCSS_AON renamed to QM_AONC.

Change-Id: Iffe9c66b7a3f2fe64418326e20ff0894149b3044
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
2016-10-18 23:26:01 +00:00
Jesus Sanchez-Palencia 8108aa8990 usb_dw: Clear device address on USB Reset
During USB device reset, the controller must have its device address
cleared (set to 0). This is not really taken into account by most host
side stacks, which is the reason why this bug didn't show up before.
It was found when we were trying to run the USB20CV [1] compliance test
suite on Windows.

Without this fix the device doesn't show up on the targets list, which
means device enumeration failed. With this patch in place the bug is
fixed and the device gets listed.

Tested with the CDC ACM sample application.

Jira: ZEP-950

[1] http://www.usb.org/developers/tools/usb20_tools/

Change-Id: I0b78f7ce043fa29dde0fb7f3b3aecee9844f4d11
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
2016-09-21 12:19:05 +00:00
Anas Nashif 5363d14a9e boards: rename Quark SE Devboard to Quark SE C1000
This board now has an official name and will be available soon:

http://www.intel.com/content/www/us/en/embedded/products/quark/mcu/se-soc/overview.html

Jira: ZEP-758
Change-Id: Ia16d33722308cf81471321c3063bdc75055a4d50
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-09-16 03:10:31 +00:00
Andrei Emeltchenko ecdcbe5077 usb: Add error log to help debugging
Change-Id: Id320dc2b85f0a48a8f81425468aa3229b1e7d0cb
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-08-10 15:27:36 +00:00
Genaro Saucedo Tejada 7a0b987dc5 sys_log: replace old debug macros at DesignWare USB driver
DesignWare USB driver is now using new system log macros, updated
the Kconfig variable to be a level rather than a bool and the .conf
files at samples.

JIRA: ZEP-311

Change-Id: Ief46cadd954ca4b30a3a1cf2eba6e44ccbc9bc9f
Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
2016-08-01 01:54:56 +00:00
Adrian Bradianu 6840ee35a4 usb: dw: Protect FIFO writes
Protect FIFO writes against other USB register accesses.
According to "DesignWare Cores USB 1.1/2.0 Device Subsystem-AHB/VCI Databook":
"During FIFO access, the application must not access the UDC/Subsystem
registers or vendor registers (for ULPI mode). After starting to access a
FIFO, the application must complete the transaction before accessing the
register."

Change-Id: I2aed833acaa2970310b6fd48f41a95bee2182ec1
Signed-off-by: Adrian Bradianu <adrian.bradianu@windriver.com>
2016-07-08 18:22:18 +00:00
Adrian Bradianu ff712114ef usb: dw: Add Quark SE USB device controller driver
Quark SE USB device (Designware IP) controller driver implements
the low level control routines to deal directly with the hardware.
Only FIFO mode supported.

Change-Id: I086186df017734579f0363ed79effc1481ff32c2
Signed-off-by: Adrian Bradianu <adrian.bradianu@windriver.com>
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2016-06-30 00:21:39 +00:00