Commit graph

427 commits

Author SHA1 Message Date
Alberto Escolar Piedras
5bf7109767 samples/subsys/usb/cdc_acm: Enable for native_sim
Allow this sample in native_sim, and set it as default
integration platform instead of native_posix.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-16 09:37:59 +01:00
Alberto Escolar Piedras
5776d74943 samples/subsys/usb/console: Remove platform_exclude
native_posix and native_sim are already excluded thru
the lack of required tags.
Let's remove the platform exclude instead of adding also
native_sim to it explicitly.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-16 09:37:59 +01:00
Armando Visconti
22295ee47a sample: board: add SensorTile.box Pro sample for testing sensors
Add sample to test SensorTile.box Pro sensors on board.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-11-03 11:46:22 +01:00
Tomasz Moń
afc034e294 samples: cdc_acm: Throttle RX when ringbuf is full
Prevent infinite loop inside interrupt handler when there is incoming
data available and ring buffer is full.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-10-23 12:04:15 +02:00
Flavio Ceolin
e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Johann Fischer
9dc12095a0 samples: usb: mass: update build instruction using RAM disk
Follow up on commit f67dd39bb2
("drivers: ramdisk: use devicetree to instantiate RAM disk").
Unfortunately, the additional argument must be passed for the default
build. Using app.overlay would not always help since the sample has few
board-specific overlays.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-03 14:41:49 +01:00
Benjamin Cabé
c702b03abd samples: webusb: Fix HTML validator issues
Running the HTML code through W3C Validator revealed several issues with
the markup that this commit fixes.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-09-25 09:48:01 +02:00
Andrei Emeltchenko
5942343a81 samples: webusb: Update README
Update webusb README with recent changes after index.html was moved to
sample from the external repository.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-09-25 09:48:01 +02:00
Andrei Emeltchenko
17fcf58a5e doc: samples: usb: Include only README to TOC
Include only README.rst to docs, skipping helpers included with :doc:
directive.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-09-25 09:48:01 +02:00
Benjamin Cabé
43c139a5f6 samples: webusb: Include demo.rst to documentation
Include demo.rst to the webusb sample documentation.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-09-25 09:48:01 +02:00
Andrei Emeltchenko
0aaa5a9ac2 samples: webusb: Copy needed file from the external repository
Copy file index.html from the external repository
finikorg/webusb-sample.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-09-25 09:48:01 +02:00
Saw Xu
8951bab7e7 samples: subsys: usb: audio: Add volume control case
Add sample code for getting volume to headset sample and
headphone_microphone sample

Signed-off-by: Saw Xu <Saw1993@126.com>
2023-09-21 15:04:14 +02:00
Benjamin Cabé
4f1cd0e428 doc: Migrate subsys/ code samples to new Sphinx extension
This migrates the subsys code samples to the new Sphinx code-sample
extension, making it easier to find relevant samples when browsing
API reference.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-09-21 09:28:31 +02:00
Johann Fischer
f67dd39bb2 drivers: ramdisk: use devicetree to instantiate RAM disk
Rework RAM disk driver to be configured using devicetree and
support multiple instances.

This patch also removes a copy of the RAM disk driver,
tests/subsys/fs/fat_fs_dual_drive/src/disk_access_test_drv.c,
that was there for testing multiple disk drivers support.

Bonus: one SYS_INIT() less and a memory region can be exported to the
host.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-09-18 17:36:50 +02:00
Benjamin Cabé
30cd9a22cf doc: fs: samples: Use new Sphinx extension to document samples
Use the new code-sample directive and roles to document the filesystem
samples so that they show up as "Related samples" when browsing the API
documentation.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-09-14 15:07:12 +02:00
Nick Ward
2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00
Florian La Roche
5727503489 style: move ALWAYS_INLINE to the beginning to resolve compiler warnings
With gcc from the zephyr sdk and -Wold-style-declaration is giving this
output:
zephyr/arch/arm/core/aarch32/cortex_a_r/fault.c:101:1: warning:
  'inline' is not at beginning of declaration [-Wold-style-declaration]
  101 | static void ALWAYS_INLINE
                    z_arm_fpu_caller_save(struct __fpu_sf *fpu)
      | ^~~~~~

I searched to all of the source code to find these further occurances
where inline is not at the beginning of a function declaration.

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
2023-08-23 14:44:23 +02:00
Daniel Leung
dc0cec972d samples: usb: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 11:39:58 +02:00
Johann Fischer
42ddc614b1 samples: hid-mouse: rework sample to use input subsys
Overall, this makes the sample code much simpler and smaller.
Whit the changes introduced in commit commit 57e0da4d80
("boards: add zephyr,code properties to the various gpio-keys nodes")'
this example will work out of the box with any board that has at least
zephyr,code = <INPUT_KEY_0>; in its devicetree.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-08-17 09:37:03 +01:00
Johann Fischer
ee43610b96 samples: usb: hid: remove SYS_INIT
There is no need to use SYS_INIT as the HID specific initialisation
can be done in the main before the usb_enable() call.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-08-04 10:41:38 +02:00
Johann Fischer
430818ecaa sample/tests: remove CONFIG_USB_COMPOSITE_DEVICE usage
This is no longer necessary, as this option is selected as a dependency
for class implementations where it is required.
Also remove redundant test cases.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-07-26 14:37:15 +02:00
Loic Poulain
df7749129f samples: cdc_acm: Add 96b_carbon to usbd-next board
This board can rely on udc_stm32 usbd-next driver.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2023-07-13 10:44:42 +02:00
Maximilian Deubel
860515a3ad samples: subsys: usb: webusb: Fix Win10 detection
This patch refactors the usage of MS OS 2.0 descriptors in the
WebUSB sample. The function subset header was removed since it
is not allowed for non-composite devices.
Also, a new random GUID was added for automatic driver installation.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2023-07-10 09:26:30 +02:00
Francois Ramu
f94fd8e60c samples: subsys: usb cdc acm composite with mini nb of USB EndPoints
The stm32f207 and stm32f429 target boards only have 4 bidir EP
on the USB FS node. This is not enough to run the sample:
simply exclude those 2 target platforms

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-07-07 09:18:09 +02:00
Benjamin Cabé
a76396fb7a doc: update stale links to MCUboot documentation
mcuboot.com/documentation --> docs.mcuboot.com

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-06-07 04:40:47 -04:00
Benjamin Cabé
7cf347769a doc: update LittleFS Github repo URLs
LittleFS now lives in the littlefs-project GH organization.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-06-07 04:40:47 -04:00
Tomasz Moń
5d87abccb2 samples: usb: mass: Set next stack max LUNs to 3
Mass storage sample contains separate Kconfig options for RAM, Flash and
SDMMC disk drivers. All disk drivers can be enabled simultaneously and
therefore the maximum number of concurrent LUNs is 3.

Configure Mass Storage class maximum LUNs to 3 to solve initialization
failures on targets that enable more than one disk driver at a time.
Each additional supported LUN increases the Mass Storage class memory
usage by 48 bytes (struct scsi_ctx) on 32-bit targets. Allocating 3 SCSI
context structures allows the sample to work regardless what disk
drivers are concurrently enabled.

Fixes: #57657

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-06-06 11:12:55 -04:00
Johann Fischer
9a4ed741d6 usb: device_next: use specific macros for string descriptors
Add and use specific macros for manufacturer, product, and
serial number string descriptors.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-26 09:48:19 -04:00
Torsten Rasmussen
1120934874 doc: samples: update OVERLAY_CONFIG to EXTRA_CONF_FILE
Update rst files to use EXTRA_CONF_FILE instead of OVERLAY_CONFIG.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2023-05-23 16:40:21 +02:00
Johann Fischer
0724453c64 samples: cdc_acm: add DT overlay to support snps,dwc2 on nucleo_f413zh
Add DT overlay to be able to support and test usb_dc_dw driver
(snps,dwc2) on nucleo_f413zh board. This disables STM32 shim
driver described and configured on the SoC and board level.

Obviously,it works with other STM32F4 boards as well, but we
do not have a mechanism to apply it generically yet, upcoming
snippet support may fix that. Until then, we need something for
development and as an example.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-05-10 20:07:04 +09:00
Gerard Marull-Paretas
93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Alberto Escolar Piedras
01c9b1483f samples/usb: Fix filtering for POSIX arch
Some of these samples were filtering all POSIX arch
boards out by explictly listing them by name
(and for the nrf52_bsim by lack of usb_device).

Instead filter by the architecture.

There is no functional difference in tree with this change.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-04 16:48:01 -04:00
Keith Packard
4134858868 tests/samples: Replace minimal libc malloc configs with common ones
With the minimal C library malloc implementation moving to libc/common, all
of the related Kconfig variables have also changed. Update uses within the
tree.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-27 20:17:24 +09:00
Keith Packard
0b90fd5adf samples, tests, boards: Switch main return type from void to int
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Most of these changes were automated using coccinelle with the following
script:

@@
@@
- void
+ int
main(...) {
	...
-	return;
+	return 0;
	...
}

Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Gerard Marull-Paretas
a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Jamie McCrae
7931424414 samples: dfu: Fix missing Kconfigs
Adds some missing Kconfigs which are now needed to enable img_mgmt.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-06 12:33:02 +01:00
Tomasz Moń
e776241fbb samples: usb: mass: Increase main stack size
Increase main stack size for next USB device stack config to prevent
stack overflow when FatFs is used. The new main stack size value matches
the value used in old stack mass storage sample config.

Fixes: #55210

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-03-02 15:05:58 +01:00
Tomasz Moń
509c033c1d usb: device_next: new USB Mass Storage implementation
Introduce new USB Mass Storage Bulk-Only Transport implementation
written from scratch. Main goal behind new implementation was to
separate USB and SCSI parts as clearly as possible.

Limited set of SCSI disk commands is implemented in separate source code
file that is internal to USB device stack. While it should be possible
to use the SCSI implementation by other components there is currently no
other user besides USB MSC and therefore SCSI header is kept private.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-02-24 15:19:20 +01:00
Andrei Emeltchenko
2e6248cb86 samples: usb: Remove unneeded old configuration
Remove OVERLAY_CONFIG and DTC_OVERLAY_FILE from sample configuration.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-02-23 17:51:31 +01:00
Andrei Emeltchenko
5b0b6e36f2 samples: usb: Allow test to build in CI
Remove dependency on usb_device for virtual USB device / hosts sample.
This allows sample to be built in CI.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-02-23 17:51:31 +01:00
Jamie McCrae
11c7371f99 samples: Explicitly disable boot USB device support init at boot
Disables having USB enabled for boards that configure USB CDC for
console, shell or logging at bootup in applications that enable USB
to prevent a conflict arising whereby USB is registered from
multiple points and later calls fail.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-10 12:21:10 +01:00
Johann Fischer
f09111a2a9 samples: cdc_acm: do not block for one second after DTR set
There is no need to block the thread for a second.
Let it sleep for 100 milliseconds, which should be enough
to set the host baud rate.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-01-10 10:30:46 +01:00
Henrik Brix Andersen
11aa8454f0 Revert "random: Change testing random generator"
This reverts commit d6881de3b3.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-09 19:29:50 +09:00
Declan Snyder
d6881de3b3 random: Change testing random generator
The old random timer test was not random-looking
enough on some platforms.

Replace with new test which is psuedo-xoshiro.

The generator is still deterministic
and does not depend on entropy at all,
but should look more random for testing.

Change name of generator tree-wide also.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-09 10:16:55 +01:00
Fabio Baltieri
792469aae9 yamllint: indentation: fix files in samples/
Fix the YAML files indentation for files in samples/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 14:23:53 +01:00
Fabio Baltieri
5c32300861 yamllint: fix all yamllint truthy errors
Fix all thruthy errors detected by yamllint:

yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
  grep '(truthy)'

This only accepts true/false for boolean properties. Seems like python
takes all sort of formats:

https://github.com/yaml/pyyaml/blob/master/lib/yaml/constructor.py#L224-L235

But the current specs only mention "true" or "false"

https://yaml.org/spec/1.2.2/#10212-boolean

Which is the standard yamllint config.

Excluding codeconv and workflow files, as some are using yes/no instead
in the respective documentation.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 01:16:45 +09:00
Erwan Gouriou
66d4c64966 all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-21 10:09:23 +01:00
Johann Fischer
eb6207707a samples: usb: shell: extend new USB support sample by host support
Extend new USB support sample to include experimental host support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-16 13:21:12 +01:00
Johann Fischer
a01fbd0731 sample: usb: shell: add keybord harness string
Add keybord harness string to sample.yaml file.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-12 15:00:20 +01:00
Johann Fischer
dc26a617d7 samples: usb: console: enable optional new USB device support
Add code and configuration to enable new USB device support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-02 12:55:18 +01:00
Johann Fischer
13766dd417 samples: cdc_acm: enable optional new USB device support
Add code and configuration to enable new USB device support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-02 12:55:18 +01:00
Johann Fischer
f5ef4c4288 samples: usb: add shell sample for new USB support
The sample enables new experimental USB device support
and the shell function.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-02 12:55:18 +01:00
Anas Nashif
ba7d730e9b tests/samples: use integration_plaforms in more tests/samples
integration_platforms help us control what get built/executed in CI and
for each PR submitted. They do not filter out platforms, instead they
just minimize the amount of builds/testing for a particular
tests/sample.
Tests still run on all supported platforms when not in integration mode.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-29 16:03:23 +01:00
Johann Fischer
1c4011ff6e usb: remove usb_pid.Kconfig file
Remove Kconfig file samples/subsys/usb/usb_pid.Kconfig added in
the commit e5cbe6a9e7 ("usb: cdc: Add unique PIDs for each sample")
with the motivation to have a separate ID for each sample supposedly
to be recognizable by the host.

The new USB support does not use the options, VID/PID is set
directly in the application. As a note, it is not necessary to have
unique PID for each sample, especially for the well known USB classes.

Replace the individual Kconfig options in the documentation
by a table with the references to the samples and PIDs.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-11-22 11:09:21 +01:00
Gerson Fernando Budke
92ca06577f samples: usb: mass: Add support to TFM NS boards
This add TFM cmake definitions to build mass storage sample for non
secure firmware boards versions. The stm32l562e_dk_ns board was used
to demonstrate. It uses SDMMC/SD with TFM profile large. Tests were
conducted using a 2GB transflash card with FAT-32 partition.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2022-11-10 11:26:11 +00:00
Gerson Fernando Budke
151e145b44 boards: arm: stm32l562e_dk: Enable usb tags for tests
This enables usb and usb_device tag for tests. It explicitly disable
samples/subsys/usb/dfu for non-secure version of this board due to
building errors, which can be explored in future.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2022-11-10 11:26:11 +00:00
Maciej Perkowski
15afd31862 tests: usb: Make tests for usb mass sample more robust
It was found that the existing regex check was not enough to validate
correctness of execution of mass samples. Tests would pass even when
a filesystem failed to be mounted. An additional line to check is added
to validate the setup of a filesystem.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-11-08 10:45:08 +01:00
Johann Fischer
b26fca430c drivers: flashdisk: remove all DISK_FLASH* Kconfig options
Remove all obsolete DISK_FLASH* Kconfig options.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-10-28 12:45:58 +02:00
Tomasz Moń
51c46e98c7 samples: usb: mass: add disk description to overlays
Add flash disk description to overlays. Specify custom flashdisk
partition for fat fs api test to match the Kconfig values, because
native posix storage partition is too small for FatFS filesystem.

Co-authored-by: Johann Fischer <johann.fischer@nordicsemi.no>
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-10-28 12:45:58 +02:00
Fabio Baltieri
b1715156dd samples: usb: dfu: exclude lpcxpresso55s69_cpu0
Exclude lpcxpresso55s69_cpu0 from the USB DFU tests, this triggers a
build assert due to unsupported flash write block size (512 bytes,
mcuboot supports 8 to 32).

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-09-23 11:31:52 +00:00
Dominik Ermel
80e34e2a24 samples: usb: mass: Switch to FIXED_PARTITION_ macros
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 09:56:37 +02:00
Gerard Marull-Paretas
79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Mahesh Mahadevan
e1818f16fa samples: usb: Exclude frdm_kl25z from USB DFU test
Flash is disabled on frdm_kl25z

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2022-09-01 12:36:01 -05:00
Gerard Marull-Paretas
a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Gerard Marull-Paretas
dee062bf0b samples: usb: audio: initialize devices at compile time
Initialize devices at compile time, allowing to constify device pointer.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Francois Ramu
31b9a6acc6 samples: usb: audio application uses static dev declaration
This change the applications to get device from the
compatible of the zephyr_udc0 node.
It is defined by the DTC_OVERLAY_FILE="app.overlay"

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-07-21 13:24:24 -05:00
Kumar Gala
6f5e75ba31 samples: usb: dfu: Fix building of sample on a few platforms
Fix building this sample on bl5340_dvk_cpuapp_ns and
pinnacle_100_dvk.  On these boards the NORDIC_QSPI_NOR
driver needs to be enabled for the sample to build.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 15:29:41 +00:00
Kumar Gala
28143b1cdc samples: subsys: Remove label property from devicetree overlays
"label" properties are not required.  Remove them from samples.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 10:30:20 +02:00
Kumar Gala
cbc848f328 dts: bindings: device labels are now optional
All in tree device drivers use some form of DEVICE_DT_GET
so we no longer need to require label properties.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-18 10:39:14 +00:00
Maciej Perkowski
d224d7fcd5 sample: usb: Change integration_platforms to platform_allow
The sample proviades required overlays only for 3 platforms.
Therefore, flash scenarios can only work on those 3 platforms.
To reflect this, platform_allow has to be used instead of
integration_platforms, so boards without overlays are not picked up
into a scope.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-07-07 10:11:44 +02:00
Kumar Gala
6a177e0a31 samples: usb: hid-cdc: Convert to use gpio_dt_spec
Move sample to use gpio_dt_spec for GPIO access.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-07 10:11:29 +02:00
Johann Fischer
6a102eeffd samples: usb: add integration platforms to flash tests in USB MSC sample
Add integration platforms to mass_flash_fatfs and mass_flash_littlefs
tests as these options are tuned for specific platforms.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-07-04 16:57:48 +02:00
Johann Fischer
fbe7a1067d samples: usb: fix flash test subsections in USB MSC sample
Test sections, mass_flash_fatfs and mass_flash_littlefs,
and corresponding Kconfig options are mixed up.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-07-04 16:57:48 +02:00
Jordan Yates
75680f7ae0 treewide: update flash_area name retrieval
Update usage of `flash_area->fa_dev_name` to `flash_area->fa_dev->name`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-02 16:04:16 +02:00
Gerard Marull-Paretas
c7b5b3c419 samples: migrate includes to contain <zephyr/...> prefix
In order to bring consistency in-tree, migrate all samples to the use
the new prefix <zephyr/...>. Note that the conversion has been scripted:

```python
from pathlib import Path
import re

EXTENSIONS = ("c", "h", "cpp", "rst")

for p in Path(".").glob("samples/**/*"):
    if not p.is_file() or p.suffix and p.suffix[1:] not in EXTENSIONS:
        continue

    content = ""
    with open(p) as f:
        for line in f:
            m = re.match(r"^(.*)#include <(.*)>(.*)$", line)
            if (m and
                not m.group(2).startswith("zephyr/") and
                (Path(".") / "include" / "zephyr" / m.group(2)).exists()):
                content += (
                    m.group(1) +
                    "#include <zephyr/" + m.group(2) +">" +
                    m.group(3) + "\n"
                )
            else:
                content += line

    with open(p, "w") as f:
        f.write(content)
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 11:29:59 +02:00
Aleksandar Markovic
9760c83267 samples: cdc_acm_composite: Use proper type for variable 'read'
Function uart_fifo_read() returns 'int' (it may return negative values
in error cases). Its return value is stored in the variable 'read' that
is, however, of type 'size_t'.

Change the type of the variable 'read' from 'size_t' to 'int' to
accomodate proper handling of uart_fifo_read() invocation.

Coverity-CID: 248408

Signed-off-by: Aleksandar Markovic <aleksandar.markovic.sa@gmail.com>
2022-04-26 12:05:26 -04:00
Anas Nashif
2d97bdd85d samples: add module requirement into samples
Do not build those samples if the needed modules are not available in
the workspace.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-19 09:38:55 -04:00
Martijn Stommels
0b1f97031a usb: dfu: update sample README
Some information in the USB DFU sample was out of date.

Also added some example lines for the Permanent download and automatic
reboot features.

Signed-off-by: Martijn Stommels <martijn@martijnpc.nl>
2022-03-31 15:33:16 +02:00
Martijn Stommels
49cb6537be usb: dfu: add permanent download and automatic reboot
This commit adds the USB_DFU_PERMANENT_DOWNLOAD and USB_DFU_REBOOT and
symbols.When the permanent download symbol is enabled, slot 1 will be
marked as confirmed. With the reboot symbol enabled, the devices
automatically reboots after the download is completed.

The functionality is split into two symbols to allow the automatic
reboot without confirming the image. This enables image confirmation via
another channel. For example via the shell’s Mcuboot commands.

This functionality allows downloading an image to the device without the
user having to interact with the device. It is useful in cases where
ease of use is more important then safety. For example  when using USB
download for daily development. This is especially applicable for
devices with a closed case.

The changes were tested on an nrf52840dk. The following line can be used
to build the USB DFU example with the symbols enabled.

west build -b nrf52840dk_nrf52840 zephyr/samples/subsys/usb/dfu \
-d build-dfu -- -DCONFIG_BOOTLOADER_MCUBOOT=y \
-DOVERLAY_CONFIG=overlay-reboot-permanent.conf \
-DCONFIG_MCUBOOT_SIGNATURE_KEY_FILE\
=\"bootloader/mcuboot/root-rsa-2048.pem\"

Fixes #41921

Signed-off-by: Martijn Stommels <martijn@martijnpc.nl>
2022-03-31 15:33:16 +02:00
Nazar Kazakov
f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Henrik Brix Andersen
d4023b3c1b drivers: gpio: move non-standard dts flags to be soc specific
Reserve the upper 8 bits of gpio_dt_flags_t for SoC specific flags and
move the non-standard, hardware-specific GPIO devicetree flags (IO
voltage level, drive strength, debounce filter) from the generic
dt-bindings/gpio/gpio.h header to SoC specific dt-bindings headers.

Some of the SoC specific dt-bindings flags take up more bits than
necessary in order to retain backwards compatibility with the deprecated
GPIO flags. The width of these fields can be reduced/optimized once the
deprecated flags are removed.

Remove hardcoded use of GPIO_INT_DEBOUNCE in GPIO client drivers. This
flag can now be set in the devicetree for boards/SoCs with debounce
filter support. The SoC specific debounce flags have had the _INT part
of their name removed since these flag must be passed to
gpio_pin_configure(), not gpio_pin_interrupt_configure().

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-10 13:46:34 -05:00
Gerard Marull-Paretas
260deccb6e doc: use :kconfig:option: domain role
Kconfig options now belong to the Kconfig domain, therefore, the
:kconfig:option: role needs to be used.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-02 09:28:37 +01:00
Johann Fischer
3b7807cc9b usb: dfu: disable USB DFU uploading by default
Firmware uploading to the host may not always be desired,
disable it by default.

Enable it for existing USB DFU sample to keep
the usual behavior, add note about new option to README.rst.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-02-18 09:32:22 -08:00
Daniel Leung
c955a44f13 usb: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Piotr Golyzniak
22e82ecf6d samples: fix wrong extra_args definitions
Fix wrong extra_args definitions wich cause that this args were not used
by CMake during building this samples via Twister in CI.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-01-04 17:15:06 -05:00
Dominik Ermel
659fee4460 samples: subsys: dfu: Fix image signing tool executable name
It is imgtool.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-12-21 17:08:35 +01:00
Johann Fischer
5296339fde usb: rework to use macro STRUCT_SECTION_FOREACH
Replace deprecated macro USBD_CFG_DATA_DEFINE by
USBD_DEFINE_CFG_DATA which places usb_cfg_data structures
in specific iterable section.

Replace __usb_data_start, __usb_data_end usage patterns
  size_t size = (__usb_data_end - __usb_data_start);
  for (size_t i = 0; i < size; i++) {...}
by
  STRUCT_SECTION_FOREACH(usb_cfg_data, ...) {...}

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-12-10 07:22:15 -06:00
Johann Fischer
af620ef196 sample: dfu: exclude b_u585i_iot02a board
Exclude b_u585i_iot02a board from USB DFU sample since
it has no flash driver.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-12-10 12:47:10 +01:00
Jordan Yates
8e99db5801 Kconfig: net: deprecate NET_BUF_USER_DATA_LEN
As user data sizes are now set on a per pool basis, this Kconfig option
has no purpose.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-11-24 16:04:50 +02:00
Johann Fischer
cf8d7764da usb: fix bulk endpoint configuration for high-speed capable device
In the current USB device support, the sizes of bulk endpoint
are mostly configure through Kconfig and do not care if a device
is high-speed capable. The information if a USB device controller
supports high-speed comes from devicetree. Add a Kconfig option to
map this information and configure bulk endpoint sizes
accordingly.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-11-24 12:28:02 +01:00
Johann Fischer
67a265b0df samples: cdc_acm: check return value of uart_fifo_read()
uart_fifo_read() can return negative values in case
it is not implemented or CONFIG_UART_INTERRUPT_DRIVEN
is not enabled. Both cases can not actually happen in the
case of CDC ACM UART, check it anyway in case behavior
of the UART API changes unnoticed.

Align the code in RX path code of both camples and
enable TX interrupt only if data was received successfully.

Fixes: #39835
Fixes: #39824
Fixes: #39809
Coverity-CID: 240667
Coverity-CID: 240679
Coverity-CID: 240697

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-11-24 10:50:11 +01:00
Johann Fischer
0908a52d0d samples: usb: console: fix configuration
This sample uses console driver and therefore
Kconfig option CONFIG_CONSOLE and CONFIG_UART_CONSOLE
are required.

Kconfig option CONFIG_USB_UART_CONSOLE no longer has
any influence here and should be removed.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-11-18 14:29:18 +01:00
Johann Fischer
02c32d4474 usb: move USB_DEVICE_REMOTE_WAKEUP option to drivers
Kconfig USB_DEVICE_REMOTE_WAKEUP option depends only on
USB device controller capability, but is not controlled
by the USB device controller drivers configuration.
Move USB_DEVICE_REMOTE_WAKEUP option to drivers and
make it promptless.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-11-08 17:01:32 +01:00
Bartosz Bilas
865ff22b3f samples: subsys: dfu: update URL of the MCUboot zephyr readme
Switch to the new MCUboot zephyr documentation URL
since the old one returns error 404.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-11-02 13:25:43 +01:00
Henrik Brix Andersen
265cdf8dc6 cmake: use find_package() instead of literal include in tests and samples
Convert remaining tests and samples to using find_package() instead of
literally including the CMake boilerplate code.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2021-11-01 10:33:09 -04:00
Johann Fischer
fb454d09bb doc: usb: refactor USB device support documentation structure
Move related areas to their own files and order
documentation logically from lower to upper layer.
Fix gross errors and inconsistencies.

Co-authored-by: Carles Cufí <carles.cufi@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-10-06 11:51:07 +02:00
Christopher Friedt
650b111ba5 drivers: flash: Kconfig.sam: -depends on and +dfu sample exclude
The additional depends on SOC_FAMILY_SAM was redundant.

Add sam4l_ek to dfu sample exclude since it was failing on
arduino_due.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-09-02 13:23:47 -04:00
Hake Huang
cc760c5401 sample: usb: hid-cdc: add a sleep for cpu to response
add a sleep while the uart init is fail.
so cpu will have chance to output error message

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-08-24 16:37:44 -05:00
Johann Fischer
0f5490a004 samples: usb: console: convert README to RST file
Convert README to RST file.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-23 18:53:47 -04:00
Johann Fischer
c3f87d9247 samples: usb: console: get CDC ACM UART device from devicetree
Add app.overlay which contains chosen node and cdc-acm-uart node.
Rework sample to get CDC ACM UART device from devicetree.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-23 18:53:47 -04:00