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>
There is a spi-flash fl256s on emsdp board, which can be
contolled by DesignWare SPI driver. Now add DW SPI and
SPI-FLASH support for emsdp board.
Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
Yaml description for simulators should contain simulation_exec
telling which tool to use. nsim_em11d was missing this entry
causing twister to only build but not execute tests on this
platform. Value from other nsims was used.
Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
Enable FPU for nsim_sem_mpu_stack_guard to fix zdsp.basicmath.fpu
failure due to lack of FPU option. Add FPU feature to its related
mdb.args, also for nsim_sem and nsim_em7d_v22 boards.
Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
To run zdsp tests on nsim_sem and nsim_em7d_v22, FPU feature
is needed to be added in their nsim.props file.
Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
Allow cross-compile toolchain for all ARC target which support zephyr
toolchain.
This aligns the behavior between ARC targets - as some of them
were supporting zephyr toolchain but weren't supporting cross-compile
toolchain (which wasn't actually true).
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
The XY Memory is a feature commonly found in DSP processors to increase
the DSP performance. The XY component allows a ARC processor to
implicitly load source operands and store results into a closely coupled
memory using a single instruction.
Add XY memory for ARC EM9D/EM11D processors including em_starterkit,
em_starterkit_em11d. emsdp_em9d, nsim_em, iotdk.
Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
We mark MPU existing for nSIM HS SoC, but doesn't enable
it for nsim_hs board. Fix that.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Provide the information as part of the board yaml file, this way we will
know what binary to check for.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add XIP support with MWDT toolchain. To have it proper tested
add separate nsim platforms for XIP (flash + sram) and
non-XIP (sram) memory organization in addition to existing
nsim_hs platfor with CCMs (ICCM + DCCM) memory organization.
This PR also enables MPU for all nsim hs3x based platforms
(like we previously enabled it for qemu_arc_hs) to have proper
memory regions permissions.
Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
Add some changes to ARC linker script. They make correct alignment
for ROMable region. Now regions borders are aligned with respect
to MPU settings.
Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
Update cmake related files that are used by simulators to use
CONFIG_MP_MAX_NUM_CPUS instead of CONFIG_MP_NUM_CPUS as we work to
phase out CONFIG_MP_NUM_CPUS.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
The sys* ops like sys_clear_bit are indirectly included via arch CPU
header. Other stuff like find_msb_set end up included via this header as
well.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Needed for proper filtering based on type in twister.
Sometimes we do not want to run a test in a simulator.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
As we've finally switched to 0.15.0 Zephyr SDK in upstream
verification we can enable zephyr toolchain for all ARC HS5x
targets.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
The boards folder uses ~142.8 MB, being the largest in the repository.
This is due mostly to board images, which are in most cases not
optimized for web content. This patch tries to address this problem by
converting all pictures to JPEG (quality 75) and by adjusting its size
up to 750 px (the width of the documentation content). Images that
specified a fixed width in rst files are converted down to that value
instead.
With this patch, folder goes down to ~53.5 MB from 142.8 MB (-~63%).
Note that this patch introduces a new set of binary files to git
history, though (bad).
The process has been automated using this quickly crafted Python script:
```python
from pathlib import Path
import re
import subprocess
def process(doc, image, image_jpeg, size):
subprocess.run(
(
f"convert {image}"
"-background white -alpha remove -alpha off -quality 75"
f"-resize {size}\> {image_jpeg}"
),
shell=True,
check=True,
cwd=doc.parent,
)
if image != image_jpeg:
(doc.parent / image).unlink()
for doc in Path(".").glob("boards/**/*.rst"):
with open(doc) as f:
content = ""
image = None
for line in f:
m = re.match(r"^(\s*)\.\. (image|figure):: (.*)$", line)
if m:
if image:
process(doc, image, image_jpeg, size)
image = Path(m.group(3))
if image.suffix not in (".jpg", ".jpeg", ".png"):
content += line
image = None
continue
image_jpeg = image.parent / (image.stem + ".jpg")
size = 750
content += (
f"{m.group(1)}.. {m.group(2)}:: {image_jpeg}\n"
)
elif image:
m = re.match(r"\s*:height:\s*[0-9]+.*$", line)
if m:
continue
m = re.match(r"\s*:width:\s*([0-9]+).*$", line)
if m:
size = min(int(m.group(1)), size)
continue
content += line
if line == "\n":
process(doc, image, image_jpeg, size)
image = None
else:
content += line
with open(doc, "w") as f:
f.write(content)
```
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Some board pictures contain text that is difficult to read with current
width. Increase it to 650px.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Non-functional polish of Kconfig symbol description and
QEMU_CPU_TYPE_${ARCH} variable (used only for verbose cmake comments)
for HS6x QEMU.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Update nsim / mdb options of nsim_hs6x and nsim_hs6x_smp
to be closer to default hs68 templates.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
tests/drivers/build_all/led/drivers.led.build fails to build
since the GPIO driver for the cypress,cy8c95xx-gpio is not
enabled. This is because the I2C bus is not enabled. Add
enabling the I2C bus if GPIO is enabled to address the issue.
Signed-off-by: Kumar Gala <galak@kernel.org>
According to the board porting guidelines, boards should "leave
peripherals and their drivers disabled by default". In Zephyr we
tipically enable GPIO and SERIAL, as they are virtually required by all
samples/tests in tree. However, for the rest of peripherals it is up to
the application/test to enable the necessary driver classes. It is also
useful that board's Kconfig.defconfig enables certain driver peripherals
based on a condition, e.g. enable I2C if SENSOR=y.
Ref. https://docs.zephyrproject.org/latest/hardware/porting/
board_porting.html#general-recommendations
This patch removes the following driver classes from defconfig files:
- CONFIG_ADC
- CONFIG_COUNTER
- CONFIG_EEPROM
- CONFIG_ENTROPY
- CONFIG_ESPI
- CONFIG_HWINFO
- CONFIG_I2C
- CONFIG_LED
- CONFIG_NETWORKING
- CONFIG_PS2
- CONFIG_PWM
- CONFIG_SENSOR
- CONFIG_SPI
- CONFIG_SPI_SLAVE
- CONFIG_WATCHDOG
Note that a previous attempt was done in #38510.
Fixes#30694
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Header was not used, so remove it. Add other necessary includes as part
of the removal.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
ICI (Inter-Core Interrupt Unit) interrupts and priorities were hardcoded
in C files. This patch moves this information to Devicetree and updates
code to make use of it.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use Devicetree to describe secure timer0 instead of hardcoding values in
<soc.h>.
DT files have been structured to match the following requirements: In
case of sectimer0 - it's should be only enabled for:
- emsdp_em7d_esp.dts
- em_starterkit_em7d.dts
- nsim_sem_mpu_stack_guard.dts
- nsim_sem.dts
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Now that I2C drivers are enabled based on devicetree
we need to remove any cases of them getting enabled by
Kconfig.defconfig* files as this can lead to errors.
Typically the Kconfig.defconfig* will blindly enable a
sensor and not respect the devicetree state of the I2C.
Additionally we can get problems with prj.conf/defconfig
getting incorrectly overridden.
Signed-off-by: Kumar Gala <galak@kernel.org>
Now that SPI drivers are enabled based on devicetree
we need to remove any cases of them getting enabled by
Kconfig.defconfig* files as this can lead to errors.
Typically the Kconfig.defconfig* will blindly enable a
sensor and not respect the devicetree state of the SPI.
Additionally we can get problems with prj.conf/defconfig
getting incorrectly overridden.
Signed-off-by: Kumar Gala <galak@kernel.org>
Now that serial drivers are enabled based on devicetree
we need to remove any cases of them getting enabled by
Kconfig.defconfig* files as this can lead to errors.
Typically the Kconfig.defconfig* will blindly enable a
sensor and not respect the devicetree state of the serial.
Additionally we can get problems with prj.conf/defconfig
getting incorrectly overridden.
Signed-off-by: Kumar Gala <galak@kernel.org>
Now that serial drivers are enabled based on devicetree we can remove
any cases of them getting enabled by *defconfig and proj.conf files.
Signed-off-by: Kumar Gala <galak@kernel.org>
Now that gpio drivers are enabled based on devicetree we can remove
any cases of them getting enabled by *defconfig and proj.conf files.
Signed-off-by: Kumar Gala <galak@kernel.org>
Now that gpio drivers are enabled based on devicetree
we need to remove any cases of them getting enabled by
Kconfig.defconfig* files as this can lead to errors.
Typically the Kconfig.defconfig* will blindly enable a
sensor and not respect the devicetree state of the GPIO.
Additionally we can get problems with prj.conf/defconfig
getting incorrectly overridden.
Signed-off-by: Kumar Gala <galak@kernel.org>
Use DT_INST_FOREACH_STATUS_OKAY to reduce duplicated code for each
instance.
We make interrupts optional since they aren't always available.
Signed-off-by: Kumar Gala <galak@kernel.org>