Skip to content

Sysview fixes#399

Open
jlaitine wants to merge 225 commits intomasterfrom
sysview_fixes
Open

Sysview fixes#399
jlaitine wants to merge 225 commits intomasterfrom
sysview_fixes

Conversation

@jlaitine
Copy link
Copy Markdown

This is a collection of patches to enable segger sysview tool on mpfs. All but the last two patches are also in upstream, I opened upstream PRs for those 2 as well

jlaitine and others added 30 commits March 14, 2025 08:18
- Use LPWORK by default if CONFIG_MPFS_ETHMAC_HPWORK is not defined
- Always use LPWORK for timeouts; this makes very lengthy operations such as re-initializing PHY.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
…roken PHYs

If the interface is UP, and no packets are received in 30s, re-initialize the interface by calling the
already implemented mpfs_txtimeout_expiry.

This is a workaround for a bug where IF might be UP and working but packets can only
be transmitted. Receive side just doesn't work at all. The bug manifests at least in
older LAN8742A (rev A and B), for which also a silicon errata exists.

The original issue can be re-produced easily by disconnecting and reconnecting the ethernet cable while
the IF is up.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
…UG_NET

- Fix compilation failure "error: 'mpfs_phydump' defined but not used [-Werror=unused-function]"
- Add debug dump of phy registers.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
mpfs_phyinit() was called twice during ifup().

Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
Verify that GMAC RX/TX buffers are 64 byte aligned
- boots from eNVM
- uses lim memory for RAM
- has console on uart 0
- has procfs enabled
- has most of nsh commands enabled

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
- Change git repository urls to point to our tiiuae repos for nuttx & nuttx apps
- Remove most of the the build steps, leave just arm-12 and riscv;
	arm-12 has a build for stm32f7, and riscv for mpfs

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
SD-card clock speed is just forced to 50MHz. Note that to be correct, one should first set the SD-card
into high-speed mode, but currently NuttX doesn't support this.

With our cards, just setting the interface to 50MHz seems to work fine, and it removes the issue with
25MHZ clock causing disturbance on GPS bands. Typically cards which support high-speed mode just work with
50MHz interface clock.

This patch should be reverted when the NuttX supports high-speed mode, and we can properly set it.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
…ootloader

This removes the need to have all the DDR/clock configuration related
"LIBERODEFS" flags defined, when not building a standalone/coldboot
configuration

All of this code is unused when not building with CONFIG_MPFS_BOOTLOADER

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Disable macOS builds for now.
All other commands are disabled in send_recv().

Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
…ef and forward declare devif_loopback

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Enable LINUX_ON_HART4 in rpmsg-ch2 defconfig of ICICLE board.
Remove LINUX_ON_HART4 config from rpmsg-ch1 defconfig of ICICLE board.
Fix build warning when CONFIG_STM32F7_AUTONEG is not set

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
…ved IO area in protected build

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Just a temporary patch, need to implement some kind of scalable solution
for this. It might be a good idea to map something else for the user
to avoid using ecall to enter the kernel for simple reads ?

Also, increase the L3 table size
There is no make step executed for this directory before the Kconfigure,
so all Kconfig's just need to be in-tree

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
The user i/o area goes over 4MB, so need more page tables
Add FPGA serial support, including console capabilities.
FPGA has UARTs from 0-7, so all UARTs starting from 5
depend on FPGA.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
Fix-Point and others added 28 commits August 21, 2025 08:38
This commit resolves a timing error caused by the round-up behavior in clock_time2ticks. In rare cases, this could lead to a two-tick increment within a single tick interval. To fix this, we introduced clock_time2ticks_floor, which guarantees the correct semantics for obtaining current system ticks.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
When exiting schedlock, that task should first take the critical section and
only after that decrease the lockcount to 0. Otherwise an interrupt might
cause a re-schedule before the task enters the critical section, which makes
the following code meaningless.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
…tch_context to this_task()

Change every occurence of up_switch_context to use this_task() as the first parameter.

"nxsched_add_readytorun" returns "true" if context switch is required. "nxsched_add_readytorun"
typically could only switch the assigned/running task to the one which is passed in as parameter.
But this is not strictly guaranteed in SMP; if other CPUs tweak with affinities or priorities,
it may be possible that the running task after the call is changed, but is some other
task from the readytorun list (and it should be, if there is higher priority one available or the
affinity of the added task prevents it to be scheduled in, but the previous head of the readytorun
list should run.

this_task() is always the correct one to switch to, since it always points to the tcb which was
just switched in by the nxsched_add_readytorun.

This is also a precursor to re-writing the SMP queue logic to remove pending lists for SMP.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This fixes several places, where the sched erroneously checks if the scheduling
is locked on current cpu/task, when it should check if the scheduling is locked
on the target cpu/task.

The original code randomly caused a task to be added to the pending list, and never
taken out from there, leading to system halt.

For SMP, there is no need for the pending list. Each CPU has got it's own
running list (assigned tasks list), and pending tasks can just be kept in
the unassigned (readytorun) list.

In addition, the smp scheduling is changed in a way that every CPU just picks
up the tasks from the ready-to-run list themselves. Which task to pick is
not tried to be dictated by another CPU.

This also allows using up_send_smp_sched for asynchronously
- re-prioritizing a running task
- triggering round robin scheduling switch

Iow, no separate smp call mechanism is needed for those and the code can be simplified.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Since g_assignedtasks only holds the running task for each CPU, it can
be just a vector. Idle tasks are already preserved in statically allocated
structures "g_idletcb", and can be used from there.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
… calls

When the task has TCB_FLAG_CPU_LOCKED it is locked to the CPU regardless
of the affinity. There is no need to switch the affinity back and forth.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
- In case of warm reboot, clear active and pending interrupts from GICv3
and also from the CPU interface.
- Fix default IGROUPMODR to the reset value (0)
- Move gic_wait_rwp calls to after modifying ICENABLER
- Improve some comments

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
The search table of ccitt should describe more algorithm details:

- CRC-16/CCITT, CRC-16/CCITT-TRUE, CRC-16/KERMIT
initial seed: 0x0000, xor output: 0x0000

: width=16
: poly=0x1021
: init=0x0000
: refin=true
: refout=true
: xorout=0x0000
: check=0x2189
: residue=0x0000
: name="CRC-16/KERMIT"

https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-kermit

Signed-off-by: chao an <anchao.archer@bytedance.com>
Compatible CRC16 with Linux Kernel:
https://github.com/torvalds/linux/blob/master/lib/crc16.c

- CRC-16/CCITT, CRC-16/CCITT-TRUE, CRC-16/KERMIT
poly: 0x8005 (0xA001) initial seed: 0x0000, xor output: 0x0000

: width=16
: poly=0x8005
: init=0x0000
: refin=true
: refout=true
: xorout=0x0000
: check=0xbb3d
: residue=0x0000
: name="CRC-16/ARC"

https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-arc

Signed-off-by: chao an <anchao.archer@bytedance.com>
move crc16 table from data to rodata

Signed-off-by: chao an <anchao.archer@bytedance.com>
keep default crc16 catalogue for CRC-16/XMODEM

Mapping crc16 implement to crc16xmodem

crc16     -> crc16xmodem
crc16part -> crc16xmodempart

- CRC-16/ACORN, CRC-16/LTE, CRC-16/V-41-MSB, XMODEM, ZMODEM
poly: 0x1021 initial seed: 0x0000, xor output: 0x0000

: width=16
: poly=0x1021
: init=0x0000
: refin=false
: refout=false
: xorout=0x0000
: check=0x31c3
: residue=0x0000
: name="CRC-16/XMODEM"

https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-xmodem

Signed-off-by: chao an <anchao.archer@bytedance.com>
Check that the provided stream pointer is really opened for the group before
closing & freeing it.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This enables compiling fully linked apps for imx9 in CONFIG_BUILD_KERNEL

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This enables compiling fully linked apps for mpfs in CONFIG_BUILD_KERNEL

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
…tem path

Add a function to find any driver's registered pointer by the filesystem path.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Add a function to search the cdcacm instance by the devnode
minor number to unregister it

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
…ointer

When uninitializing cdcacm via a boardctl ioctl, use the instance number
instead of direct pointer to the driver. The reason for this is, that in
CONFIG_BUILD_KERNEL the applications sercon and serdis can't store the pointer;
they are separate processes which get killed.

The cdcacm driver will search up the driver from the file system when the direct
pointer is not given.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
…alize

This protects the driver in case multiple threads are trying to initialize
or uninitialize the cdcacm concurrently.

Note that this only protects the case when the private pointer is not managed
outside the kernel. If someone has acquired the pointer to the driver and uses
that, it also needs to manage the protection itself if needed.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This adds the I2C extension support to the CoreI2C, enabling smart
FIFO reads & writes

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
- Fix void * arithmetic warning
- Fix unused variable warning without CONFIG_SCHED_INSTRUMENTATION_FILTER

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Don't assume that perf_getfreq returns nanoseconds, define the
SEGGER_SYSVIEW_TIMESTAMP_FREQ instead.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Add a configuration option CONFIG_SEGGER_SYSVIEW_POST_MORTEM to enable
logging continuously into a circular buffer

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
For drivers implement those possible recusive, native spinlock
will cause deadlock directly, critial_section is use globally,
will make lock parallel to serial, add API to keep recursive
support but isolate each other.

For race condition, we may get cpuid in stack and then thread moved
to other cpu. So we have to get cpuid with irq disabled.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
So that the same code can be used with and without spinlocks.

Signed-off-by: Ville Juven <ville.juven@unikie.com>
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
The lock is needed always with RTT, not just with note_sysview.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
The SEGGER_RTT_LOCK needs to be recursive, otherwise system will
deadlock in SMP

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.