RK3506 CPU2 is compatible with nuttx#19478
Conversation
Expose a pointer to the console uart_dev_t so board logic can drive the console RX by polling. This is needed on AMP secondary cores where the UART RX interrupt cannot be delivered reliably through a GIC distributor that is shared with another OS (e.g. Linux), so the board polls the LSR and feeds bytes to the upper half via uart_recvchars(). Signed-off-by: likun17 <likun17@xiaomi.com>
Add the RK3506 architecture support for running NuttX as an AMP secondary subsystem on one Cortex-A7 core (CPU2), brought up by U-Boot via PSCI alongside Linux on the other cores. Key points specific to the AMP-shared-GIC environment: - up_irqinitialize() only initializes the GIC CPU interface (GICC) and disables all SPIs, because the GIC distributor (GICD) is owned by Linux. Leftover SPIs targeting CPU2 would otherwise storm the core right after up_irq_enable(). - The generic timer uses the per-CPU PTM path (select ARMV7A_HAVE_PTM), since the per-CPU PPI is private and unaffected by Linux reconfiguring the shared distributor. - Memory map covers DDR (normal) and the 0xff000000 device region; the image runs from the AMP-reserved DRAM window. - rk3506_boot.c includes a raw UART4 breadcrumb for early bring-up debugging, independent of the serial driver. Signed-off-by: likun17 <likun17@xiaomi.com>
Add the Luckfox Lyra (RK3506) board running NuttX as an AMP subsystem on Cortex-A7 CPU2. Boot flow: U-Boot psci_cpu_on() jumps to the image in the AMP-reserved DRAM window, arm_boot() sets up the MMU, and NSH comes up on UART4 (1.5Mbaud). The nsh defconfig enables: - Console on UART4 (16550, MMIO32, REGINCR=1) with the TX driver and a board-side poll thread for RX (the RX interrupt is unreliable on the GIC distributor shared with Linux). - uORB + sensor framework with a CSV-backed fake accelerometer demo on /dev/uorb/sensor_accel0, plus uorb_listener/generator/unit_test. - NSH tab-completion and command history. - RAM disk tooling (mkrd + FAT + mkfatfs) and the ramtest / memtester / fstest utilities. rk3506_bringup.c writes a small CSV to tmpfs and registers the fake sensor, and spawns the console RX poll thread. Signed-off-by: likun17 <likun17@xiaomi.com>
CONFIG_RAM_SIZE 0x02000000 (32MB), RAM_START 0x03f00000. Total NuttX footprint 0x03e00000-0x05f00000 (33MB); the Linux kernel dts amp_reserved node reserves this whole range (no-map). Hard ceiling is 193MB, bounded by the 256MB DDR window mapped in the rk3506 MMU setup. Signed-off-by: likun17 <likun17@xiaomi.com>
| "interval:100\n" /* 10 Hz */ | ||
| "x,y,z\n" | ||
| "0.10,0.00,9.81\n" | ||
| "0.20,0.05,9.79\n" | ||
| "0.05,-0.05,9.82\n" | ||
| "-0.10,0.10,9.80\n"; |
There was a problem hiding this comment.
This is unrelated to this PR, but I think you were the author of uorb_generator. Is this CSV format the same format that's expected by uorb_generator -f? Because it seems to also look for a topic in the first line.
| struct file f; | ||
| int ret; | ||
|
|
||
| ret = file_open(&f, path, O_WRONLY | O_CREAT | O_TRUNC, 0644); |
There was a problem hiding this comment.
I wonder if it would be worthwhile to create a fakesensor interface that allows playback from a string for such a case.
There was a problem hiding this comment.
Exciting port! Could you:
- Add both chip and board documentation files in two separate commits with this PR? There is a board template to make that easier if it helps!
- Include the special build/flash steps in those docs
- Add a configuration for SMP for users to try? It looks from the code that it's implemented.
Is there any way to use this port without depending on your repository?
| * | ||
| ****************************************************************************/ | ||
|
|
||
| FAR uart_dev_t *u16550_consoledev(void) |
There was a problem hiding this comment.
why not disable linux to access it directly?
There was a problem hiding this comment.
let's implement the general rx poll directly
| * interrupt-driven RX is unreliable on the AMP-shared GIC). | ||
| */ | ||
|
|
||
| kthread_create("rxpoll", 100, 2048, rk3506_rxpoll, NULL); |
| #ifdef CONFIG_SENSORS_FAKESENSOR | ||
| /* Register a demo accelerometer (CSV-backed) on /dev/uorb/sensor_accel0. */ | ||
|
|
||
| rk3506_fakesensor_setup(); |
There was a problem hiding this comment.
why use fakesensor on the real device
| CONFIG_NSH_FILEIOSIZE=512 | ||
| CONFIG_NSH_READLINE=y | ||
| CONFIG_RAM_SIZE=15728640 | ||
| CONFIG_RAM_SIZE=33554432 |
There was a problem hiding this comment.
merge with the previous patch
| @@ -0,0 +1,37 @@ | |||
| # ############################################################################## | |||
| # arch/arm/src/qemu/CMakeLists.txt | |||
There was a problem hiding this comment.
fix the path in all file
| @@ -0,0 +1,36 @@ | |||
| ############################################################################ | |||
| # arch/arm/src/qemu/Make.defs | |||
| */ | ||
|
|
||
| void rk3506_rawuart_puts(const char *s); | ||
| void rk3506_dbgmark(const char *tag); |
There was a problem hiding this comment.
why add the unused symbols
| UART4_FCR = 0x07; /* enable+clear FIFOs */ | ||
| } | ||
|
|
||
| void rk3506_rawuart_puts(const char *s) |
There was a problem hiding this comment.
why not implement up_lowputc and up_lowputs
acassis
left a comment
There was a problem hiding this comment.
@Otpvondoiats please add Documentation to explain about this port. Since it runs in an specific CPU, please include this information there. Including all the steps to test it.
|
I'll revise everyone's comments first, test it, and then reply to everyone. |
Summary
This is a patch for the AMP architecture. RK3506 CPU 0 and 1 run Linux, while CPU 2 runs Nuttx.
Impact
uart_recvchars(), which necessitates accessing the driver's internal consoleuart_dev_t. Therefore, this commit specifically added an accessor to expose it. TX and the per-core private PPI timer are unaffected; only the shared SPI RX has this issue.Testing
nsh>
nsh>
nsh>
nsh> ps
TID PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK COMMAND
0 0 0 0 FIFO Kthread - Ready 0000000000000000 0004072 Idle_Task
1 0 0 224 RR Kthread - Waiting Semaphore 0000000000000000 0004024 hpwork 0x3f00000 0x3f00050
3 0 0 100 RR Kthread - Waiting Signal 0000000000000000 0002008 rxpoll
4 0 0 100 RR Kthread - Waiting Semaphore 0000000000000000 0004032 fakesensor_thread 0x3f0a348
6 6 0 100 RR Task - Running 0000000000000000 0004048 nsh_main
7 0 0 224 RR Kthread - Waiting Semaphore 0000000000000000 0004024 rpmsg-virtio linux 0x3f08698
8 8 6 100 RR Task - Waiting Semaphore 0000000000000000 0004032 sh -c cat
nsh> help
help usage: help [-v] []
Builtin Apps:
dd memtester sh uorb_unit_test
fstest nsh uorb_generator
hello ramtest uorb_listener
nsh> free
total used free maxused maxfree nused nfree name
33517568 42448 33475120 42816 33475104 99 2 Umem
nsh> uo
uorb_generator
uorb_listener
uorb_unit_test
nsh> uorb_unit_test
uORB note: try single-topic support
uORB note: PASS single-topic test
uORB note: PASS orb 10-instances
uORB note: try multi-topic support
uORB note: ---------------- LATENCY TEST ------------------
mean: 0 us
std dev: 0 us
min: 0 us
max: 0 us
missed topic updates: 0
uORB note: PASS multi-topic test
uORB note: try multi-topic support subscribing before publishing
uORB note: PASS multi-topic reversed
uORB note: Testing unadvertise
uORB note: Testing multi-topic 2 test (queue simulation)
uORB note: PASS multi-topic 2 test (queue simulation)
uORB note: Testing orb queuing
uORB fail: subscribe failed: 2
FAIL
nsh> uo
uorb_generator
uorb_listener
uorb_unit_test
nsh> uo
uorb_generator
uorb_listener
uorb_unit_test
nsh> uorb_listener -n 5 sensor_accel0
Monitor objects num:1
object_name:sensor_accel, object_instance:0
sensor_accel(now:439274000):0x3f102acB
sensor_accel(now:439375000):0x3f102acB
sensor_accel(now:439476000):0x3f102acB
sensor_accel(now:439577000):0x3f102acB
sensor_accel(now:439678000):0x3f102acB
Object name:sensor_accel0, received:5
Total number of received Message:5/5
nsh>