Dennboy

  • Content Count

    31
  • Joined

  • Last visited

Posts posted by Dennboy

  1. Hi tparys,

     

    Thanks for your reply pointing to the upstream debian repo's, and sorry for posting an upstream bug here. I just looked up the dtc package in debian, and they appear to have it fixed in their newest update 1.4.7-4 from 27 january 2021 (see DTC debian changelog), it is now available in Armbian too, and seems to be working. Apparently it took some time to travel to the repo/mirrors, it wasn't yet available when I posted here.

     

    Kind regards,

    Dennis

  2. Dear all,

     

    My system logs: http://ix.io/2Pgj

     

    I consistency get a crash with dtc on both orangepi, nanopi neo+2, nanopi neo3 when I try to see the current devicetree via the filesystem, e.g.:
     

    $ dtc -I fs /sys/firmware/devicetree/base/
    <stdout>: Warning (unit_address_vs_reg): /memory: node has a reg or ranges property, but no unit name
    <stdout>: Warning (clocks_property): /soc/spdif@1c21000:clocks: cell 0 is not a phandle reference
    <stdout>: Warning (clocks_property): /soc/spdif@1c21000:clocks: cell 2 is not a phandle reference
    ....
    /dts-v1/;
    / {
    [1]    16929 segmentation fault  dtc -I fs /sys/firmware/devicetree/base/

     

    My current work-around is to install the kernel headers and start dtc from there, but headers takes quite long to install:

    $ sudo apt install linux-headers-current-sunxi
    $ /lib/modules/5.10.12-sunxi/build/scripts/dtc/dtc -I fs /sys/firmware/devicetree/base/
    /dts-v1/;
    
    / {
            compatible = "xunlong,orangepi-zero\0allwinner,sun8i-h2-plus";
            serial-number = "02c000421661c2d2";
            model = "Xunlong Orange Pi Zero";
            interrupt-parent = <0x01>;
            #address-cells = <0x01>;
            #size-cells = <0x01>;
    ...
    };

     

    I could also try to install an upstream version of dtc, but it would be great if the supplied dtc doesn't crash.

     

    Kind regards,

    Dennis

  3. I tried to override the interrupt affinity using a devicetree overlay, but also this seems to be ignored on sunxi. Anybody knows why?

    Is the affinity simply not implemented by sunxi?

     

    Below is the overlay to change the interrupt affinity. Devicetree before modification shows interrupt-affinity=<&cpu0>,<&cpu1>,<&cpu2>,<&cpu3>;

     

    /dts-v1/;
    /plugin/;
    / {
            compatible = "allwinner,sun8i-h3","allwinner,sun50i-h5","friendlyarm,nanopi-neo2";
    
            fragment@1 {
                    target-path = "/pmu";
    
                    __overlay__ {
                            interrupt-affinity = <&cpu0>;
                    };
            };
    };

     

    After boot only using cpu0 is reflected in the runtime devicetree on opi0:
     

    $ /lib/modules/5.10.12-sunxi/build/scripts/dtc/dtc -I fs /sys/firmware/devicetree/base|less
    
            pmu {
                    compatible = "arm,cortex-a7-pmu";
                    interrupts = <0x00 0x78 0x04 0x00 0x79 0x04 0x00 0x7a 0x04 0x00 0x7b 0x04>;
                    interrupt-affinity = <0x30>;
            };
            cpus {
                    cpu@0 {
                            compatible = "arm,cortex-a7";
                            phandle = <0x30>;
                            ...
                    };
                    ...
            };

     

    Here is the /proc/interrupt table again:

    HomeCT2:~:% grep ads /proc/interrupts 
     66:       1043          0          0          0  sunxi_pio_edge   1 Edge      ads131a04
    162:         68        255    1040571          1  ads131a04-dev0     Edge      ads131a04_consumer0

    So the affinity has been changed but seems to be ignored.

     

    p.s. Sorry for talking to myself;-)

  4. Hi,

    I experimented some further and set /proc/irq/default_smp_affinity to 1 for the first core, and it looks good on paper, but in practice most interrupts still go to the second core.

     

    echo 1 > /proc/irq/default_smp_affinity
    
    # dynamically load ADC kernel driver
    
    HomeCT2:~:% cat /proc/irq/162/smp_affinity
    1
    HomeCT2:~:% cat /proc/irq/162/effective_affinity
    0
    HomeCT2:~:% grep ads /proc/interrupts 
     66:       1397          0          0          0  sunxi_pio_edge   1 Edge      ads131a04
    162:        557    1394461         27          0  ads131a04-dev0     Edge      ads131a04_consumer0

     

  5. Dear all,


    I'm frequently losing GPIO interrupts on various boards, which seem to be caused by bursty processes.

     

    When I shield the cores that have those interrupts according to /proc/interrupts with e..g. "cset shield --cpu=0,1" , way less interrupts are lost (e.g. for 4kHz interrupts one in hours instead of once per minute). Most of these (ADC) interrupts are handled by my own kernel module, but couldn't find how to restrict them to e.g. CPU0, and they are not movable using /proc/irq/*/smp_affinity.


     

    HomeCT1:~:% grep ads /proc/interrupts
     66:     166559          0          0          0  sunxi_pio_edge   1 Edge      ads131a04
    162:        273  152692648   13858531         17  ads131a04-dev0     Edge      ads131a04_consumer0
    
    
    HomeCT1:~:% cat /proc/irq/162/smp_affinity
    f

     

    I noticed that on allwinner (opi0, nanopi neo+2), the ADC interrupts are on different CPU cores. On the neo3 they always seem to go to the 1st CPU core.

     

    Is there any way to force the interrupts to 1st core on the allwinner as well (e.g. in kernel module c-code or via devicetree)? This would make it easier to shield the first core and reduce the lost interrupts.

    Or is there another way to give more priority to the GPIO interrupts? Making the kernel thread realtime with chrt is apparently not enough.


     

      PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
    
     2407 root      rt   0       0      0      0 S   4.6   0.0 116:06.38 [irq/162-ads131a]  

     

    Kind regards,

    Dennis

  6. Yes Igor, for sure we are thankful for all your help here!
    I'm glad only toys got broken:) Hope you can teach your kid to repair toys some day;)

    I tried with the nanopineo2 (Armbian 20.11.6 Buster), the modules build fine but the installation reports SSL errors during installation of the module, that didn't appear on the orangepizero. The module(s) can be loaded and run after depmod -a.

      INSTALL pps_timer.ko
    At main.c:160:
    - SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:69
    - SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:76
    sign-file: certs/signing_key.pem: No such file or directory
      DEPMOD  5.10.4-sunxi64

     

    Kind regards,

    Dennis

     

  7. 1 hour ago, hjoe said:

    Hi, have the same problem with compiling the can4linux driver.
    Why does someone suggest to remove the last line of the linker script module.lds ?

      sudo sh -c "sed '$ d' 

     

    it should include something for sure, may be the .plt section.

    #include does not work, so I added the content of  ./linux-headers-5.10.4-sunxi/arch/arm/include/asm/module.lds.h

     


    now I can load the module, but is may be not correct

    Hi @hjoe,

     

    Your fix seems to work beautifully on the orangepizero, thanks! My kernel module loads and runs beautifully. Tomorrow I'll try on nanopi neo2+ and neo3.

     

    @Igor Good luck with the family in these strange times. I hope things change for the best in the next months as more people get vacinated.


    Kind regards,

    Dennis

  8. Just retried with a very simple kernel module (added license in second attempt to get rid of kernel taint), with the same result.

     

    $ sudo modprobe ktest_module
    modprobe: ERROR: could not insert 'ktest_module': Exec format error

     

    $ dmesg|tail
    [   24.151391] pps_timer: module PLT section(s) missing
    [   33.784067] vcc3v0: disabling
    [   33.784092] vcc5v0: disabling
    [   33.784099] vcc-wifi: disabling
    [ 1413.944125] pps_timer: module PLT section(s) missing
    [ 7157.483985] ktest_module: module license 'unspecified' taints kernel.
    [ 7157.484004] Disabling lock debugging due to kernel taint
    [ 7157.484019] ktest_module: module PLT section(s) missing
    [ 7357.485416] ktest_module: module PLT section(s) missing
    [ 7465.032086] ktest_module: module PLT section(s) missing

     

     

    #include <linux/module.h>    /* Needed by all modules */
    #include <linux/kernel.h>    /* Needed for KERN_INFO */
    #include <linux/init.h>      /* Needed for the macros */
    #include <linux/version.h>
     
    /* Licensed under the GPL-2 or later. */
    MODULE_LICENSE("GPL v2");
    
    static int __init ktest_module_init(void)
    {
        //printk(KERN_INFO "Driver version %s\n", VERSION);
        printk(KERN_INFO "Buona Sera :)\n");
        return 0;
    }
     
    static void __exit ktest_module_exit(void)
    {
        printk(KERN_INFO "Ciao!\n");
    }
     
    module_init(ktest_module_init);
    module_exit(ktest_module_exit);

     

  9. Armbianmonitor:

    Dear all,


    I can successfully build an out-of-tree module on 5.9 and 5.10.x kernels, but have trouble running them since Armbian 20.11.6. I fixed the module.lds missing problem using the receipt from a bugreport with an extra Makefile target:
     

    PWD=$(shell pwd)
    VER=$(shell uname -r)
    KERNEL_BUILD=/lib/modules/$(VER)/build
    # Later if you want to package the module binary you can provide an INSTALL_ROOT
    # INSTALL_ROOT=/tmp/install-root
    MY_CFLAGS += -g -DDEBUG
    
    # for newer 5.10.x kernels with x<=4
    $(KERNEL_BUILD)/scripts/module.lds: $(KERNEL_BUILD)/scripts/module.lds.S
            sudo sh -c "sed '$ d' $(KERNEL_BUILD)/scripts/module.lds.S > $(KERNEL_BUILD)/scripts/module.lds"
    
    pps:    pps_timer.c
            $(MAKE) -C $(KERNEL_BUILD) M=$(PWD) modules
                                        
    pps_install: pps
            sudo $(MAKE) -C $(KERNEL_BUILD) M=$(PWD) obj_m=pps_timer.o \
            INSTALL_MOD_PATH=$(INSTALL_ROOT) modules_instal

     

    When trying the module on the 5.10.x kernel, I get an error that the Exec format is not correct:

    $ sudo modprobe pps_timer
    modprobe: ERROR: could not insert 'pps_timer': Exec format error


    And in dmesg, I see the following line:

    [ 1413.944125] pps_timer: module PLT section(s) missing

     

    Did something change in the 5.10.x kernel that needs something extra in the Makefile or source for out-of-tree modules?

    Kind regards,

    Dennis

  10. Armbianmonitor:

    Dear maintainers,

    I have my sensors configured to reboot every night via a user cronjob (0 0 * *  * /sbin/reboot), 14 sensors do this without a problem. I've fixed the nanopi neo+2 reboot from NAND some months ago (by re-using friendlyarm first stage u-boot).

     

    I just stumbled upon a failed reboot with one of my nanopi neo+2 nodes, after two successful reboots. Looking at the /var/log.hdd/syslog, it got stuck in the shutdown procedure when the watchdog reported a failure. The /var/log.hdd/syslog.1 extracts below show the start of the watchdog, and the stop of the watchdog and its failure. After the failure the system doesn't come up anymore, it needed a powercycle, which is quite inconvenient since it is installed at a hard to access remote location.

    Sep 18 00:03:26 EnexisVT2-1 systemd[1]: Starting watchdog daemon...
    Sep 18 00:03:26 EnexisVT2-1 systemd[1]: Reached target Graphical Interface.
    Sep 18 00:03:26 EnexisVT2-1 systemd[1]: Starting Update UTMP about System Runlevel Changes...
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: starting daemon (5.15):
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: int=1s realtime=yes sync=no load=0,0,0 soft=no
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: memory not checked
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: ping: no machine to check
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: file: no file to check
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: pidfile: no server process to check
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: interface: no interface to check
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: temperature: no sensors to check
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: no test binary files
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: no repair binary files
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: error retry time-out = 60 seconds
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: repair attempts = 1
    Sep 18 00:03:26 EnexisVT2-1 watchdog[2212]: alive=[none] heartbeat=[none] to=root no_act=no force=no
    Sep 18 00:03:26 EnexisVT2-1 systemd[1]: Started watchdog daemon.
    ...
    Sep 19 00:00:01 EnexisVT2-1 CRON[6188]: (dennis) CMD (/sbin/reboot)
    ...
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: Stopping Authorization Manager...
    ...
    Sep 19 00:00:02 EnexisVT2-1 watchdog[2212]: stopping daemon (5.15)
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: Stopping watchdog daemon...
    ...
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: watchdog.service: Control process exited, code=exited, status=1/FAILURE
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: watchdog.service: Failed with result 'exit-code'.
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: Stopped watchdog daemon.
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: watchdog.service: Triggering OnFailure= dependencies.
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: Requested transaction contradicts existing jobs: Transaction for wd_keepalive.service/start is destructive (armbian-zram-confi
    g.service has 'stop' job queued, but 'start' is included in transaction).
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: watchdog.service: Failed to enqueue OnFailure= job, ignoring: Transaction for wd_keepalive.service/start is destructive (armbi
    an-zram-config.service has 'stop' job queued, but 'start' is included in transaction).
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: Stopped target Multi-User System.
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: Stopping rng-tools.service...
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: Stopping OpenBSD Secure Shell server...
    Sep 19 00:00:02 EnexisVT2-1 systemd[1]: Stopping LSB: Start or stop stunnel 4.x (TLS tunnel for network daemons)...
    Sep 19 00:00:02 EnexisVT2-1 ntpd[1396]: ntpd exiting on signal 15 (Terminated)
    
    ... cold reboot
    
    Sep 19 00:00:09 EnexisVT2-1 kernel: [    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
    Sep 19 00:00:09 EnexisVT2-1 fake-hwclock[406]: Sat 19 Sep 2020 12:00:03 AM UTC

     

    After this the system didn't boot anymore, and we had to manually cold-boot it. So, I've stopped&disabled the watchdog for now, also had to set run_wd_keepalive=0 in /etc/default/watchdog, since the watchdog also failed to stop from the commandline (also on other systems):

    Sep 23 11:33:59 EnexisVT2-1 systemd[1]: Starting watchdog daemon...
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: starting daemon (5.15):
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: int=1s realtime=yes sync=no load=0,0,0 soft=no
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: memory not checked
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: ping: no machine to check
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: file: no file to check
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: pidfile: no server process to check
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: interface: no interface to check
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: temperature: no sensors to check
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: no test binary files
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: no repair binary files
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: error retry time-out = 60 seconds
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: repair attempts = 1
    Sep 23 11:33:59 EnexisVT2-1 watchdog[3236]: alive=[none] heartbeat=[none] to=root no_act=no force=no
    Sep 23 11:33:59 EnexisVT2-1 systemd[1]: Started watchdog daemon.
    
    ...
    Sep 23 11:34:03 EnexisVT2-1 watchdog[3236]: stopping daemon (5.15)
    Sep 23 11:34:03 EnexisVT2-1 systemd[1]: Stopping watchdog daemon...
    Sep 23 11:34:03 EnexisVT2-1 systemd[1]: watchdog.service: Control process exited, code=exited, status=1/FAILURE
    Sep 23 11:34:03 EnexisVT2-1 systemd[1]: watchdog.service: Failed with result 'exit-code'.
    Sep 23 11:34:03 EnexisVT2-1 systemd[1]: Stopped watchdog daemon.
    Sep 23 11:34:03 EnexisVT2-1 systemd[1]: watchdog.service: Triggering OnFailure= dependencies.

     

    Note that I froze the armbian upgrades on all these sensors on armbian 20.02.7, to avoid having to recompile my kernel modules on every upstream update. I noticed that the systemd package got an update recently, unsure if this update may mitigate the problem.

    systemd-sysv/stable 241-7~deb10u4 arm64 [upgradable from: 241-7~deb10u3]
    systemd/stable 241-7~deb10u4 arm64 [upgradable from: 241-7~deb10u3]
    
    
    dennis@EnexisVT2-1:~$ dpkg -l "*current*"
    Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name                                     Version      Architecture Description
    +++-========================================-============-============-============================================================
    ii  linux-buster-root-current-nanopineoplus2 20.02.1      arm64        Armbian tweaks for buster on nanopineoplus2 (current branch)
    hi  linux-dtb-current-sunxi64                20.02.7      arm64        Linux DTB, version 5.4.28-sunxi64
    hi  linux-headers-current-sunxi64            20.02.7      arm64        Linux kernel headers for 5.4.28-sunxi64 on arm64
    hi  linux-image-current-sunxi64              20.02.7      arm64        Linux kernel, version 5.4.28-sunxi64
    hi  linux-u-boot-nanopineoplus2-current      20.02.1      arm64        Uboot loader 2019.10

     

  11. Hi Quanta,

     

    Depending on the type of serial connector, it may (partly) power the nanopi, I usually only connect the GND, RX and TX with my FT232RL USB to TTL Serial Adapter. I've seen cases where parts of the board didn't fully reset when the serial was still connected. You can of course start a separate thread about serial adaptor power issues, which may be a more general issue.

     

    My reboot problems however also seem to occur without the serial connected, i.e. can can notice it doesn't become reachable again after reboot is invoked remotely.

     

    Kind regards,

    Dennis

  12. 7 minutes ago, Onira said:

    In my case the easiest way is just having empty SD card in slot and it reboots again but I will try Your solution, Dennboy

    I guess the friendyarm image you mention about is the image from FriendlyARM wiki?

    Yes, I use the image from FriendlyArm mentioned on their website (in my case, I booted the image that was on the MMC when it got shipped, which is most likely the same one). To capture their first stage bootloader with dd, I analysed the nand-sata-install script to see what needed to be copied. It may be possible to directly fetch the bootloader part from the sdcard image, with a similar dd with if=sdcard.img when you have a linux PC.

     

    Since u-boot is opensource, we can probably ask FriendlyArm for their software/configuration changes to the first-stage u-boot in order to get this integrated into the Armbian tree as a patch.

  13. 50 minutes ago, Quanta said:

    So, to re-state more clearly the question,  what should I do to get a (more) reliable boot from sd card at this point? I am concerned that while the board is running at the moment, It will choke on some future reboot - perhaps in the process of fixing uboot and I won't know what to do... This isn't something I feel I can 'experiment' with to fix. There are too many unknowns for me.  Dumping a file onto the board or editing via winscp or webmin I can do now but once the board will not boot to SD I am in up a little over my nose...

     

    Hi Quanta,

    Thanks for you reaction. In my case the (re)boot from sdcard do not fail, I only had failing EMMC re-boots. I think the older first stage u-boot from FriendlyArm is running at slower speed so there is less chance of failures. Your u-boot on the sdcard may be fixable with a similar procedure, i.e. by capturing the first stage u-boot bytes from FriendlyArm NEO image and writing it to the sdcard instead of the MMC I guess it would be possible to do this on a linux PC without first booting from the sdcard. Before changing the sdcard, you can of course make a backup on your hard-drive: dd if=/dev/mmcblk0 of=recoveryimage.img bs=8k

     

    Quote

    In my case I don't want to use mmc because I can't replace if I run into a wearout problem. I want to be able to drop in a new card with a reference backup image and have the board back operational. This may not be optimal but at my current level of proficiency and because of the application this seems the most sensible right now.  

    I think the flash wearing on regular sdcards would be similar to EMMC, most mobile phones run from EMMC nowadays and have sdcard as optional storage. Industrial-grade sdcards may be more reliable, but can still have degraded contacts and problems after vibrations. You can also start using sdcards once the EMMC starts failing, that's my plan with our remote Neo2+'s.

     

    Kind regards,

    Dennis

     

  14. For your information, with this work-around, U-boot warns about a SPL version mismatch (DRAM:  sunxi SPL version mismatch: expected 3, got 2), but works nontheless. I wonder what is different in the SPL version that makes the boot possible (maybe the CPU frequency or DRAM frequency?), and if we can transfer this functionality to the newer SPL without breaking the reboot.

    See the serial trace of a successful reboot below for the NanoPi neo plus hardware revision 2.0 (revision 1.2 with 512MB DRAM works as well):

    [  311.266768] reboot: Restarting system                                                                      
                                                                                                                  
    U-Boot SPL 2017.11 (Nov 15 2019 - 05:14:40)                                                                   
    DRAM: 1024 MiB(504MHz)                                                                                        
    CPU Freq: 408MHz                                                                                              
    memory test: 1                                                                                                
    Pattern 55aa  Writing...Reading...OK                                                                          
    Trying to boot from MMC2                                                                                      
    Boot device: emmc                                                                                             
    NOTICE:  BL31: v2.1(debug):bb2d778-dirty                                                                      
    NOTICE:  BL31: Built : 18:34:11, Jul  5 2019                                                                  
    NOTICE:  BL31: Detected Allwinner H5 SoC (1718)                                                               
    NOTICE:  BL31: Found U-Boot DTB at 0x40899d8, model: FriendlyARM NanoPi NEO Plus 2                            
    INFO:    ARM GICv2 driver initialized                                                                         
    INFO:    Configuring SPC Controller                                                                           
    NOTICE:  BL31: PMIC: Defaulting to PortL GPIO according to H5 reference design.                               
    INFO:    BL31: Platform setup done                                                                            
    INFO:    BL31: Initializing runtime services                                                                  
    INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied                                              
    INFO:    BL31: Preparing for EL3 exit to normal world                                                         
    INFO:    Entry point address = 0x4a000000                                                                     
    INFO:    SPSR = 0x3c9                                                                                         
                                                                                                                  
                                                                                                                  
    U-Boot 2019.04-armbian (Jul 06 2019 - 18:02:12 +0200) Allwinner Technology                                    
                                                                                                                  
    CPU:   Allwinner H5 (SUN50I)                                                                                  
    Model: FriendlyARM NanoPi NEO Plus 2                                                                          
    DRAM:  sunxi SPL version mismatch: expected 3, got 2                                                          
    1 GiB                                                                                                         
    MMC:   mmc@1c0f000: 0, mmc@1c11000: 1                    

    An occasional successful boot from NAND without the workaround looks like below. The main difference seems to be the cpu/memory frequency and the memory test.

    [  401.171972] reboot: Restarting system                                                                      
                                                                                                                  
    U-Boot SPL 2019.04-armbian (Jul 06 2019 - 18:02:12 +0200)                                                     
    DRAM: 1024 MiB                                                                                                
    Trying to boot from MMC2                                                                                      
                                                                                                                  
    U-Boot SPL 2019.04-armbian (Jul 06 2019 - 18:02:12 +0200)                                                     
    DRAM: 1024 MiB                                                                                                
    Trying to boot from MMC2                                                                                      
    NOTICE:  BL31: v2.1(debug):bb2d778-dirty                                                                      
    NOTICE:  BL31: Built : 18:34:11, Jul  5 2019                                                                  
    NOTICE:  BL31: Detected Allwinner H5 SoC (1718)                                                               
    NOTICE:  BL31: Found U-Boot DTB at 0x40899d8, model: FriendlyARM NanoPi NEO Plus 2                            
    INFO:    ARM GICv2 driver initialized                                                                         
    INFO:    Configuring SPC Controller                                                                           
    NOTICE:  BL31: PMIC: Defaulting to PortL GPIO according to H5 reference design.                               
    INFO:    BL31: Platform setup done                                                                            
    INFO:    BL31: Initializing runtime services                                                                  
    INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied                                              
    INFO:    BL31: Preparing for EL3 exit to normal world                                                         
    INFO:    Entry point address = 0x4a000000                                                                     
    INFO:    SPSR = 0x3c9                                                                                         
                                                                                                                  
                                                                                                                  
    U-Boot 2019.04-armbian (Jul 06 2019 - 18:02:12 +0200) Allwinner Technology                                    
                                                                                                                  
    CPU:   Allwinner H5 (SUN50I)                                                                                  
    Model: FriendlyARM NanoPi NEO Plus 2                                                                          
    DRAM:  1 GiB                                                                                                  
    MMC:   mmc@1c0f000: 0, mmc@1c11000: 1    

     

  15. Armbianmonitor:

    Dear all,

     

    Starting from NAND memory used to work fine on the nanopi neo plus2, however with the new boards (both v1.2 and v2.0 revision) we just obtained it frequently doesn't want to reboot, while a cold boot works fine (I tried also earlier u-boot versions (2019.04, 2018.11) without much success for the reboot from NAND). The re-boot process stops at this point (from the serial console):

    [  OK  ] Reached target Shutdown.                                                                             
    [  152.452083] reboot: Restarting system  
    
    U-Boot SPL 2019.10-armbian (Jan 25 2020 - 19:56:27 +0100)                                                     
    DRAM: 1024 MiB                                                                                                
    Trying to boot from MMC2

    I suspected the problem to be in the u-boot, since the friendlyarm on NAND reboots without a hitch. I found a work-around for the latest stretch image (Armbian_20.02.0-rc1_Nanopineoplus2_stretch_current_5.4.14.7z), by doing the following:

    • boot friendlyarm image from NAND and copy the sunxi-spl.bin:
      • sudo dd if=/dev/mmcblk2 of=sunxi-spl-friendlyarm.bin count=4 bs=8k skip=1

    • boot armbian from NAND and update u-boot:
      • switched to linux-image-next-sunxi64=5.90 kernel via armbian-config / System / Other / switch

      • dd if=sunxi-spl-friendlyarm.bin of=/dev/mmcblk2 count=4 bs=8k seek=1 conv=fsync

    The atached armbianmonitor -u upload is from after a fresh reboot with the working configuration.

     

    Kind regards,

    Dennis

  16. A way to disable hardware is by setting its status to disabled in the device tree, take a look at " dtc -I fs -O dts /sys/firmware/devicetree/base|less" to see the runtime devicetree. For instance for sound and video this would look like below, which you can convert to dtb with something like "dtc -I dts -O dtb youroverlay.dts > youroverlay.dtb" and add as a user-overlay (place dtb file in /boot/overlay-user) and add "user-overlays=youroverlay" line in /boot/armbianEnv.txt.

     

    /dts-v1/;

    / {
        compatible = "allwinner,sun8i-h3","allwinner,sun50i-h5","friendlyarm,nanopi-neo2";

        fragment@0 {
            target-path = "/soc";

            __overlay__ {

                hdmi@1ee0000 {
                            status = "disabled";
                };
                mixer@1100000 {
                             status = "disabled";
                };
                sound {
                             status = "disabled";
                 };
            };
        };

        fragment@1 {
            target-path = [2f 00];

            __overlay__ {
                  sound {
                             status = "disabled";
                  };
            };
        };
    };

  17. Hi Robert,

     

    I recently looked at the spi controller driver and discovered that the DMA configuration is not used by the SPI controller. It found that dma_set_mask_and_coherent only gives a result until kernel version 4.13.3 (and maybe a bit later), and fails after kernel version 4.14.39 and later).

     

    The result is that the DMA configured for SPI is silently ignored, and regular SPI transfers are done instead.

     

    Can you confirm that you don't see any performance improvement with DMA enabled?
     

    Kind regards,

    Dennis

     

  18. I digged further into the kernel code and had a look at spi.c and spi-sun6i.c. It appears that can_dma is a function pointer that is checked while setting up DMA for a transaction. This function pointer is not assigned in spi-sun6i.c (and spi-sun4i.c for that matter). This would explain why I don't see performance improvements when I try to use DMA for with kernel 4.13.3, since the DMA ignored because can_dma=0x0.

     

    I compared the behavior with the spi-stm32.c in the 4.14.67 kernel, and this driver reads the controller DMA addresses and sets the can_dma function pointer when they are set:

    	spi->dma_tx = dma_request_slave_channel(spi->dev, "tx");
    	if (!spi->dma_tx)
    		dev_warn(&pdev->dev, "failed to request tx dma channel\n");
    	else
    		master->dma_tx = spi->dma_tx;
    
    	spi->dma_rx = dma_request_slave_channel(spi->dev, "rx");
    	if (!spi->dma_rx)
    		dev_warn(&pdev->dev, "failed to request rx dma channel\n");
    	else
    		master->dma_rx = spi->dma_rx;
    
    	if (spi->dma_tx || spi->dma_rx)
    		master->can_dma = stm32_spi_can_dma;

    The assigned function stm32_spi_can_dma mainly checks if it makes sense to do dma, i.e. is the transfer size bigger than the fifo (I believe the fifo is 64 bits for the H3 SPI Controller, so that may pay off for most SPI transactions):

    return (transfer->len > spi->fifo_size);

    Bottom line, the SPI controller does not yet take the configured DMA configuration into account, and it could be fixed using a similar approach to the spi-stm32.c. The

  19. Dear Ohms,

     

    Many thanks for your feedback. Indeed, the dma_set_mask_and_coherent call does no longer work with the same driver code and device tree. Regarding the sunxi modifications, I cannot easily find release notes of the modifications between kernel 4.13.3 and newer. The change could also be in the mainline kernel updates, e.g. stricter checks in the DMA or SPI driver.

    The strange thing is that independent of kernel version spi->controller->can_dma is 0x0, which is supposed to tell whether the controller supports DMA according to spi.h.

    • @can_dma: determine whether this controller supports DMA

    Could it be that the DMA part of the SPI controller is not completely configured from the information in the device tree?

     

    Furthermore, I don't notice any performance gain when I have DMA enabled in the older 4.13.3 kernel and allocate coherent memory for rx_dma and tx_dma in the spi_transfer struct (using dmam_alloc_coherent).

  20. Hi user283746,


    Thanks for your suggestion, it could indeed be better to change the defaults, but then with the userspace governor. I initially placed the my cpufreq command in /etc/rc.local to make it persistent.


    cpufreq-info tells me the available frequencies and governers (e.g. on H5):
     

      available frequency steps: 408 MHz, 648 MHz, 816 MHz, 912 MHz, 960 MHz, 1.01 GHz, 1.06 GHz, 1.10 GHz, 1.15 GHz
      available cpufreq governors: conservative, userspace, powersave, ondemand, performance, schedutil

     

    I have no clue how to underclock RAM, didn't find hints in the devicetree or boot commands.

  21. Dear mainline developers,


    I'm writing a (mainline) SPI driver for de ads131 from TI which I would like to make use of DMA, on the orangePIzero H2, zero+ H3/H5 and nanopi NEO2+. On the 4.13.3-sunxi kernel (armbian 5.33), this works fine, the driver is automatically loaded when the associated devicetree overlay is loaded, and the DMA can be allocated. However, when I compile the same driver for newer kernels (4.14.17-sunxi, 4.14.39-sunxi, 4.14.67-sunxi armbian 5.59), the dma allocation no longer appears to work, while the SPI part of the devicetree is identical except for the phandle (checked with dtc -I fs /sys/firmware/devicetree/base on newest 4.14.67-sunxi kernel, since 4.14.65 headers were not available in newest 5.59 stretch mainline H3 image) and does specify the DMA addresses for the SPI controller:

    spi@01c69000 {                                                                                                               
        compatible = "allwinner,sun8i-h3-spi";                                                                               
        clocks = <0x6 0x1f 0x6 0x53>;                                                                                        
        resets = <0x6 0x10>;                                                                                                 
        clock-names = "ahb", "mod";                                                                                          
        status = "okay";                                                                                                     
        #address-cells = <0x1>;                                                                                              
        interrupts = <0x0 0x42 0x4>;                                                                                         
        #size-cells = <0x0>;                                                                                                 
        dma-names = "rx", "tx";                                                                                              
        phandle = <0x5e>;                                                                                                    
        reg = <0x1c69000 0x1000>;                                                                                            
        pinctrl-0 = <0x21>;                                                                                                  
        dmas = <0x1f 0x18 0x1f 0x18>;                                                                                        
        linux,phandle = <0x5e>;                                                                                              
        pinctrl-names = "default";                                                                                           
    
        ads131a04@0 {                                                                                                        
          compatible = "ti,ads131a04";                                                                                 
          status = "okay";                                                                                             
          reg = <0x0>;                                                                                                 
          spi-max-frequency = <0x1e84800>;                                                                             
        };
    };

    I use the following DMA calls that appear to fail in newer kernels, and the driver reverts to non-DMA spi transfers:

    static int ads131_probe(struct spi_device *spi)
    {
        const struct spi_device_id *id = spi_get_device_id(spi);
        int ret;
    
        ret=spi_setup(spi);
        if (ret!=0) {
            printk("ads131: Problem setting up spi-device, ret=%d",ret);
            return ret;
        }
        printk("ads131: spi->controller->can_dma=0x%lx",(unsigned long)spi->controller->can_dma);
        ...  
        if (!dma_set_mask_and_coherent(&spi->dev, DMA_BIT_MASK(64))) {
            printk("ads131: dma 64 bit");
        } else if (!dma_set_mask_and_coherent(&spi->dev, DMA_BIT_MASK(32))) {
            printk("ads131: dma 32 bit");
        } else if (dma_set_mask_and_coherent(&spi->dev, DMA_BIT_MASK(24))) {
            dev_warn(&spi->dev, "ads131: No suitable DMA available\n");
            goto dma_ignore;
        } else {
            printk("ads131: dma 24 bit");
        }
        ...

    I get the following output from my driver in kernel 4.14.67-sunxi:

    dennis@orangepizeroplus2:~$ dmesg |grep -i dma
    [    0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
    [    0.091893] DMA: preallocated 2048 KiB pool for atomic coherent allocations
    [    5.254126] ads131: spi->controller->can_dma=0x0
    [    5.255134] ads131a04 spi0.0: ads131: No suitable DMA available

    I get the following with the older 4.13.3-sunxi kernel (armbian 5.33):

    [    0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool                                                   
    [   19.848567] ads131: spi->controller->can_dma=0x0                                                                                          
    [   19.849538] ads131: dma 64 bit                                                                                                            
    [   19.849544] ads131: dma_mask=18446744073709551615                                                                                         
    [   19.849564] xfer dma memory allocated with 16 buffers  

     

    Do I need to specify additional information in the devicetree for DMA to work in SPI drivers with newer kernels, or do I need to add something to my driver before trying to use DMA with newer kernels?

    Kind regards,

    Dennis

  22. Dear all,


    I discovered that the leds section is missing in the devicetree of orangepizeroplus2 H5 (at least upto kernel 4.14.39), and had to write an overlay to get them to work. The overlay has been attached. I've added this overlay file to /boot/overlay-user/ and added the overlay in /boot/armbianEnv.txt as follows:

    Quote

    user_overlays=sun50i-h5-orangepi-zeroplus-leds

     


    Kind regards,
    Dennis

    sun50i-h5-orangepi-zeroplus-leds.dts

  23. The frequency scaling seems to be working a bit better on OrangePI zeroplus2 H3 / H5 and NanoPi now (kernel 4.14.39).

     

    We discovered however that the frequency scaling severely impacts the SPI communication, resulting in SPI failures during the frequency change. It could be that SPI communication fails because it uses the same clock as the CPU.

     

    In certain cases you may want to pre-set the frequency to a conservative fixed frequency for better reliability of especially SPI communication ( sudo cpufreq-set -f 816MHz) and add a heat-sink.