Page 1 of 1

CSI demo app with SC3336

Posted: 2025-03-15 11:06
by steko
Hi, examining thru the wiki tutorial I have few questions. Any help is appreciated.

1) Since pico ultra boards require luckfox-config > enable csi procedure, how can I enable it within buildroot firmware for production environment?

2) The overlay date&time on RTSP stream is not in sync with local NTP server.
2.a) I added local server ip in /etc/ntp.conf as "server 192.168.100.100 version 3" and reboot but date -R show a date from 2021. I also enabled ntp logs and perform UDP cap trace using wireshark. I can confirm server-client communication is in place. Note that nap services is provided by windows 10 machine in local network.
ntp-pcap.png

Code: Select all

[root@luckfox root]# grep ntpd /var/log/messages                                                                        
Jan  1 14:58:59 luckfox daemon.notice ntpd[222]: ntpd 4.2.8p15@1.3728-o Sun Mar  9 14:56:43 UTC 2025 (1): Starting      
Jan  1 14:58:59 luckfox daemon.notice ntpd[222]: Command line: /usr/sbin/ntpd -g -p /var/run/ntpd.pid                   
Jan  1 14:58:59 luckfox daemon.notice ntpd[222]: ----------------------------------------------------                   
Jan  1 14:58:59 luckfox daemon.notice ntpd[222]: ntp-4 is maintained by Network Time Foundation,                        
Jan  1 14:58:59 luckfox daemon.notice ntpd[222]: Inc. (NTF), a non-profit 501(c)(3) public-benefit                      
Jan  1 14:58:59 luckfox daemon.notice ntpd[222]: corporation.  Support and training for ntp-4 are                       
Jan  1 14:58:59 luckfox daemon.notice ntpd[222]: available at https://www.nwtime.org/support                            
Jan  1 14:58:59 luckfox daemon.notice ntpd[222]: ----------------------------------------------------                   
Jan  1 14:58:59 luckfox daemon.info ntpd[245]: proto: precision = 1.167 usec (-20)                                      
Jan  1 14:58:59 luckfox daemon.info ntpd[245]: basedate set to 2025-02-25                                               
Jan  1 14:58:59 luckfox daemon.info ntpd[245]: gps base set to 2025-03-02 (week 2356)                                   
Jan  1 14:58:59 luckfox daemon.notice ntpd[245]: switching logging to file /var/log/ntpd.log  

[root@luckfox root]# tail -f /var/log/ntpd.log                                                                          
 1 Jan 14:58:59 ntpd[245]: Listen and drop on 0 v4wildcard 0.0.0.0:123                                                  
 1 Jan 14:58:59 ntpd[245]: Listen normally on 1 lo 127.0.0.1:123                                                        
 1 Jan 14:58:59 ntpd[245]: Listening on routing socket on fd #18 for interface updates                                  
 1 Jan 14:58:59 ntpd[245]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized                                        
 1 Jan 14:58:59 ntpd[245]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized                                        
 1 Jan 14:59:05 ntpd[245]: Listen normally on 2 eth0 192.168.100.197:123   

[root@luckfox root]# date -R                                                                                            
Sat, 09 Jan 2021 07:22:26 +0000 
2.b) I noticed that RKIPC is looking for another IP address for time sync. I updated it from the source code and rebuild the firmware. But nothing is changed.

Code: Select all

luckfox@luckfox:~/luckfox-pico/project/app/rkipc/rkipc/common/network$ cat network.c  | grep ntp_server
	const char *ntp_server = rk_param_get_string("network:ntp.ntp_server", "127.0.0.1");
2.c) I also replaced the ntp addresses in /oem/usr/share/rkipc*.ini files without success..

3) occasionally I received debug messages as follows. Is this expected?

[video.c][rkipc_ivs_get_results]:MD: md_area is 167936, md_area_threshold is 155520

Re: CSI demo app with SC3336

Posted: 2025-03-17 2:18
by Crocodile
Hello
1 Let the image start CSI by default Add it to the dts file

Code: Select all

 
&i2c4 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&i2c4m2_xfer>;
}
2 Refer to network calibration https://wiki.luckfox.com/Luckfox-Pico/L ... 1%E6%97%B6, ensure that the luckfox pico ultra can ping the Internet
3 MD is a printed result of the mobile test

Re: CSI demo app with SC3336

Posted: 2025-03-17 14:35
by steko
Thank You @Crocodile for your help so far.

Related to the incorrect time, I made a workaround and solved the issue.

original S99rtcinit script always returns "RTC does not require time calibration" due to if condition comparing the date with 1996, event the condition could met it set 2024...

Code: Select all

	if [ "$(hwclock | grep "1969")" ]; then
		echo "RTC time calibration"
		date -s 2024-01-01
		hwclock -w
	else
		echo "RTC does not require time calibration"
	fi


I modified the script to the following and hwclock is set accordingly.

Code: Select all

#!/bin/sh

case $1 in
start)
    myIPaddress=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
    echo $myIPaddress
    # Wait for network
    sleep 5
    # Get RTC time, reformat for BusyBox
    RTC_TIME=$(hwclock --show | sed 's/  *[0-9]\.[0-9]* seconds//' | awk '{print $3 " " $2 " " $6 " " $4}')
    RTC_EPOCH=$(date -d "$RTC_TIME" +%s 2>/dev/null || echo "0")
    BASELINE_EPOCH=$(date -d "2025-01-01" +%s)

    if [ "$RTC_EPOCH" -lt "$BASELINE_EPOCH" ] || [ "$RTC_EPOCH" = "0" ]; then
        echo "RTC time calibration needed"
        # Stop ntpd to free port 123
        killall ntpd 2>/dev/null
        sleep 1
        if command -v ntpdate >/dev/null 2>&1; then
            ntpdate -b 192.168.1.1 || date -s "2025-01-01"
        else
            echo "ntpdate not found, setting fallback time"
            date -s "2025-01-01"
        fi
        # Write to RTC
        hwclock -w
        # Restart ntpd
        ntpd -g -c /etc/ntp.conf &
    else
        echo "RTC does not require time calibration"
    fi
    # Sync RTC to system time (redundant but safe)
    hwclock --systohc
    ;;
*)
    exit 1
    ;;
esac

However I noticed that even I set ntpdate in buildrootconfig, the firmware does not include the executable. I had to copy it to the overlay directory to get it included in the firmware. Perhaps it is due to ntp.mk file?

Code: Select all


NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_NTP_KEYGEN) += util/ntp-keygen
NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_NTP_WAIT) += scripts/ntp-wait/ntp-wait
NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_NTPDATE) += ntpdate/ntpdate
NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_NTPDC) += ntpdc/ntpdc
NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_NTPQ) += ntpq/ntpq
NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_NTPSNMPD) += ntpsnmpd/ntpsnmpd
NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_NTPTIME) += util/ntptime
NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_NTPTRACE) += scripts/ntptrace/ntptrace
NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_SNTP) += sntp/sntp
NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_TICKADJ) += util/tickadj

define NTP_INSTALL_TARGET_CMDS
        $(if $(BR2_PACKAGE_NTP_NTPD), install -m 755 $(@D)/ntpd/ntpd $(TARGET_DI>
        test -z "$(NTP_INSTALL_FILES_y)" || install -m 755 $(addprefix $(@D)/,$(>
        $(INSTALL) -m 644 package/ntp/ntpd.etc.conf $(TARGET_DIR)/etc/ntp.conf
endef



Re: CSI demo app with SC3336

Posted: 2025-03-18 1:08
by pimouren
Hello, it may be the problem of ntp.mk. If the rules for installing ntpdate are missing in ntp.mk, or the rules are incorrect, ntpdate may not be correctly installed in the target file system.
Solution:
Check the ntp.mk file to make sure it contains an installation rule similar to the following:
Makefile:

Code: Select all

$(INSTALL) -D -m 0755 $(@D)/ntpdate $(TARGET_DIR)/usr/sbin/ntpdate
2. Check buildrootconfig and make sure the following options are enabled:

Code: Select all

BR2_PACKAGE_NTP=y
BR2_PACKAGE_NTP_NTPDATE=y
Make sure all dependencies (such as toolchains, libraries, etc.) are configured correctly.