Is it possible to increase RTC supercapacitor charging current?

I have Jetson Nano 4GB B01, I have added supercapacitor for RTC (by following this guide). It charges very slowly, it would take more than a day to fully charge with default charging current. I found some examples how to increase RTC battery charging current in some other Jetson boards by editing dtsi, and for example this topic mentions it is possible to configure charging current in Jetson Nano too but does not says how and the link in the original post is broken. This is what I would like to know how to do (quote from Trumany post, the moderator, so I assume this should be accurate information):

These will be charged with a constant current (CC), constant voltage (CV) charger that can be configured between 2.5V and 3.5V CV output and 50uA to 800uA CC

I tried to google this phrase but found nothing. I want to max out RTC voltage and current to 3.5V 800µA. My supercapacitor is 5.5V so it should be safe.

Have reference to below topic to add it to the dts.

I found Jetson Nano Datasheet: https://www.realtimes.cn/Uploads/download/JetsonNano_DataSheet.pdf and it indeed mentions that “charger that can be configured between 2.5V and 3.5V CV output and 50uA to 800uA CC”. Unfortunattely, it does not mention how.

I found the following devices:

% cat /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-current | xxd -p
00000064

0x64 = 100, this means currently it is limited to 100µA instead of 800uA (which equals to 0x320).

cat /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-voltage | xxd -p  
002dc6c0

0x2dc6c0 = 3000000µV = 3V but I would like to set it to 3.5V. Unfortunatelly, I cannot do this directly:

echo "0000 0320" | xxd -r -p - > /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-current
zsh: permission denied: /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-current

I found that /boot/tegra210-p3448-0000-p3449-0000-b00.dtb mentions backup-battery but it is a binary file. I searched the source code and found Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-pmic-p3448-0000-a00.dtsi, and within it there is the backup-battery subsection I was looking for:

            backup-battery {
                maxim,backup-battery-charging-current = <100>;
                maxim,backup-battery-charging-voltage = <3000000>;
                maxim,backup-battery-output-resistor = <100>;
            };

I replaced it with the values I need to max out voltage and current:

            backup-battery {
                maxim,backup-battery-charging-current = <800>;
                maxim,backup-battery-charging-voltage = <3500000>;
                maxim,backup-battery-output-resistor = <100>;
            };

The last step is to compile the kernel and install it (if you do not how, here is a good guide: https://qengineering.eu/overclocking-the-jetson-nano.html, you may skip overclocking part if you just want to build the kernel). This is how I do it (if using custom .config instead of Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/configs/tegra_defconfig, comment out a section in nvbuild.sh which mentions "${config_file}" or nvbuild.sh will overwrite it):

cd ~/Linux_for_Tegra/source/public && \
sudo ./nvbuild.sh && cd kernel/kernel-4.9 && sudo make modules && \
sudo make modules_install && sudo make && sudo make install && \
sudo cp -av ./arch/arm64/boot/Image /boot/Image && \
sudo cp -av ./arch/arm64/boot/dts/*.dtb* /boot/

Obviously this assumes you already have kernel sources unpacked in the home directory. Refer to the guide mentioned above if you do not know where to get the kernel source code. The above command works directly in Jetson Nano and took less than 1.5h, no need to crosscompile with desktop PC.

Then find out the name of DTS the board is using:

% dmesg | grep -i '\.dts' | head -n1 | perl -pe 's|.*/||'
tegra210-p3448-0000-p3449-0000-b00.dts

Add to extlinux.conf FDT with the path to new DTB (named exactly like DTS):

% sudo nano /boot/extlinux/extlinux.conf

This how edited /boot/extlinux/extlinux.conf looks in my case (I added FDT line at the end):

TIMEOUT 3
DEFAULT primary

MENU TITLE L4T boot options

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
      FDT /boot/tegra210-p3448-0000-p3449-0000-b00.dtb

I rebooted. Let’s check the result:

% cat /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-voltage | xxd -p
003567e0
% cat /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-current | xxd -p 
00000320

0x3567e0 = 3500000µV = 3.5V and 0x320 = 800µA. This is a success!

Information how to do this was hard to figure out and it took hours. The documentation needs to be clearer how to do this, since charging a supercapacitor 8 times faster and to a higher voltage (important to compensate for self-discharge) is a big difference.

Thanks, I saw this topic before, but it was not clear at all what “Modify below in device tree to configure it” actually means: I did not know what file(s) I need to edit, what commands I need to execute and how to check that the result was successful. Figuring out answers to these questions was the hard part. I shared how I finally did this in the post above.