Solved How to patch some parts of the source code using a RK356X-diff file...

Hello to everyone.

I need to apply a lot of fixes that are enterely written inside a single file called RK356X-diff,that sounds like this :

Code:
--- trunk/stable-14/sys/arm/arm/generic_timer.c    2025-03-19 20:49:43.139887000 +0100
+++ branches/stable-14-deepcore/sys/arm/arm/generic_timer.c    2025-03-19 20:22:23.334267000 +0100
@@ -185,6 +185,7 @@
     return (get_el0(cntfrq));
 }
 
+#ifdef FDT
 static uint64_t
 get_cntxct_a64_unstable(bool physical)
 {
@@ -206,6 +207,7 @@
 
     return (val);
 }
+#endif
 
 static uint64_t
 get_cntxct(bool physical)

--- trunk/stable-14/sys/arm/arm/pmu.c    2025-03-19 20:49:43.176176000 +0100
+++ branches/stable-14-deepcore/sys/arm/arm/pmu.c    2025-03-19 20:22:23.363676000 +0100
@@ -67,7 +67,6 @@
 {

and so on...

I want to apply all these patches to "FreeBSD 14.3-RELEASE". This is what I did :

Code:
# git clone https://git.FreeBSD.org/src.git ./src
# cd src
# git checkout origin/releng/14.3

and now ? I would like to learn how to apply all those patches automatically with a single command. Is this possible to achieve ?
Anyway,what's the faster method to use here ?
 
Click the link and read the funny letters in that link.

Sorry. I'm not able to understand pratically something of useful using that kind of information processing method. What I see is just a big pile of strange symbols for which I don't understand the connections because there aren't enough practical examples. If I was able to do what you suggest,I would have avoided to ask here.
 
eternal_noob :

I would like that you understand that I do not want that you do the work for me, but if you can give me some indications that will help me to do it by myself. Unfortunately, the ones that have been given to me are insufficient. I am sorry that you do not have a good relationship with those users who do not understand things on the fly. Nope,not everyone understand fast as you. Furthermore,using a different kind of method of explaining is enough for me to reach the final result.
 
Missing of examples in man pages makes it many times hard for absolute beginners to understand. In this case make a web search, keywords i.e. "freebsd linux how to apply a patch(1) examples". One of the search results (depending of the search engine) is https://forums.freebsd.org/threads/solved-how-to-apply-a-patch.47304/

To give an example in your case, the patch has non standard, custom FreeBSD source directories. Change on your system to the "/usr/src/sys/arm/arm" directory and apply patch:
Code:
# cd /usr/src/sys/arm/arm

dry-run
# patch -C  < /path/to/patch

apply for real
# patch  <  /path/to/patch

reverse to the original state
# patch  -R  <  /path/to/patch
 
Thanks for your help,but I'm a little bit ignorant. Your suggestion is not enough for me to be able to do something. Can you elaborate more ?
Well, if you really lucky (meaning there won't be any conflicts), all you have to do is patch -p2 < patchfile.diff in /usr/src/ directory. If there are conflicts though, you'll have to ask the patch author, not here.
 
Missing of examples in man pages makes it many times hard for absolute beginners to understand. In this case make a web search, keywords i.e. "freebsd linux how to apply a patch(1) examples". One of the search results (depending of the search engine) is https://forums.freebsd.org/threads/solved-how-to-apply-a-patch.47304/

To give an example in your case, the patch has non standard, custom FreeBSD source directories. Change on your system to the "/usr/src/sys/arm/arm" directory and apply patch:
Code:
# cd /usr/src/sys/arm/arm

dry-run
# patch -C  < /path/to/patch

apply for real
# patch  <  /path/to/patch

reverse to the original state
# patch  -R  <  /path/to/patch

In your opinion is a good idea to separate all the patches that now are written in one only file,into a lot of smaller files ?
 
In your opinion is a good idea to separate all the patches that now are written in one only file,into a lot of smaller files ?
That will not make any difference (or sense), patch can use the headers (it's all described in the man page) that your diff file contains.
 
Won't all the patches be applied to arm/arm? What does
Code:
 /usr/src  #  patch -C -p2 < patch
show?

Code:
marietto# pwd
/mnt/zroot2/zroot2/OS/BSD/FreeBSD/arm64/img/Radxa-3W/Stuff/covacat/usr/src/patches

marietto# ls

RADXA3W                random.h.diff            rk817.c.diff
RK356X                random_harvestq.c.diff        rk817reg.h.diff
acpi.c.diff            rk3399-pinebook-pro.dts.diff    rk8xx.c.diff
clk.c.diff            rk3566-quartz64-a-sata.dts.diff    rk8xx_clocks.c.diff
clk.h.diff            rk3566-quartz64-a-usb3.dts.diff    rk8xx_rtc.c.diff
cpu.h.diff            rk3566-radxa-cm3-io.dts.diff    rk_clk_composite.c.diff
cpufreq_dt.c.diff        rk3566-radxa-cm3.dtsi.diff    rk_clk_mux.c.diff
dwc3.c.diff            rk3566-radxa-zero-3.dtsi.diff    rk_clk_pll.c.diff
dwmmc.c.diff            rk3566-radxa-zero-3e.dts.diff    rk_clk_pll.h.2.diff
dwmmc_acpi.c.diff        rk3566-radxa-zero-3w.dts.diff    rk_clk_pll.h.diff
dwmmc_var.h.diff        rk3566-roc-pc.dts.diff        rk_cru.c.diff
files.arm64.diff        rk3568-nanopi-r5c.dts.diff    rk_cru.h.diff
files.diff            rk3568-nanopi-r5s.dts.diff    rk_fspi.c.diff
generic_timer.c.diff        rk3568-nanopi-r5s.dtsi.diff    rk_gpio.c.diff
if_eqos.c.diff            rk3568.dtsi.diff        rk_otp.c.diff
if_eqos_acpi.c.diff        rk3568_combphy.c.diff        rk_otp.h.diff
if_eqos_fdt.c.diff        rk3568_pcie.c.diff        rk_otp_if.m.diff
if_eqos_if.m.diff        rk3568_pciephy.c.diff        rk_rng.c.diff
if_eqos_var.h.diff        rk3568_pmucru.c.diff        rk_tsadc.c.diff
k3568-roc-pc.dts.diff        rk356x.dtsi.diff        scmi.c.diff
machdep.c.diff            rk3588-orangepi-5-plus.dts.diff    sdhci.c.diff
mcommphy.c.diff            rk3588.dtsi.diff        sdhci_acpi.c.diff
pci_dw.c.diff            rk3588s-nanopi-r6c.dts.diff    sdhci_fdt.c.diff
pci_pci.c.diff            rk3588s-nanopi-r6s.dts.diff    undefined.c.diff
pmu.c.diff            rk3588s.dtsi.diff        vga_pci.c.diff

marietto# patch -C -p2 < acpi.c.diff
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- trunk/stable-14/sys/dev/acpica/acpi.c    2025-04-06 19:40:37.360335000 +0200
|+++ branches/stable-14-deepcore/sys/dev/acpica/acpi.c    2025-03-19 20:23:47.458894000 +0100
--------------------------
File to patch:
 
Sorry. I'm not able to understand pratically something of useful using that kind of information processing method. What I see is just a big pile of strange symbols for which I don't understand the connections
This has been going on for years.
Nobody grew up being able to read man pages. Yet, somehow, almost everybody figures it out eventually because they put in the time to learn.
Meanwhile, for years, you categorically refuse to even put a little bit of effort into it and instead expect other people to do the work for you.
If you want to improve your skills and become more proficient, learn to read man pages. It's really not that hard. Otherwise you're just increasing the list of people which no longer bother trying to help you.

There's nothing wrong with asking for help - also not if it's in the context of "hey, I read this man page, I get most of it, but I don't understand how to apply it in this particular use case".
People will be happy to help (including myself) and you'll walk away with a better understanding of how things work and next time around you'll get a little further on your own.

For example, nobody in primary school understood the connections of mathematics when learning basic arithmetic and nobody understood the connections of grammar while learning the first few words when they studied a language. But you keep going. And the more you learn, the easier it becomes.
The same applies to reading man pages. Just do it - and then ask questions specifically about what you learned there.

Again: Nobody grew up as a pro. We all had to learn everything. Everybody is better at something different and that is fine. That is why we build communities to help each other. But outright refusing to read man pages when dealing with something like FreeBSD is not helping you and you're certainly not making any friends along the way.
 
Code:
marietto# cd /mnt/zroot2/zroot2/OS/BSD/FreeBSD/arm64/img/Radxa-3W/Stuff/covacat/usr/src/patches

marietto# cp acpi.c.diff /mnt/zroot2/zroot2/OS/BSD/FreeBSD/arm64/img/Radxa-3W/Stuff/covacat/usr/src/sys/dev/acpica/

marietto# ls
Osd            acpi_dock.c        acpi_pcib.c        acpi_smbat.c
acpi.c            acpi_ec.c        acpi_pcib_acpi.c    acpi_smbus.h
acpi.c.diff        acpi_ged.c        acpi_pcib_pci.c        acpi_thermal.c
acpi_acad.c        acpi_hpet.c        acpi_pcibvar.h        acpi_throttle.c
acpi_apei.c        acpi_hpet.h        acpi_pcivar.h        acpi_timer.c
acpi_battery.c        acpi_if.m        acpi_perf.c        acpi_video.c
acpi_bus_if.m        acpi_isab.c        acpi_powerres.c        acpiio.h
acpi_button.c        acpi_lid.c        acpi_pxm.c        acpivar.h
acpi_cmbat.c        acpi_package.c        acpi_quirk.c
acpi_container.c    acpi_pci.c        acpi_quirks
acpi_cpu.c        acpi_pci_link.c        acpi_resource.c

marietto# patch -C < acpi.c.diff
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- trunk/stable-14/sys/dev/acpica/acpi.c    2025-04-06 19:40:37.360335000 +0200
|+++ branches/stable-14-deepcore/sys/dev/acpica/acpi.c    2025-03-19 20:23:47.458894000 +0100
--------------------------
Patching file acpi.c using Plan A...
Hunk #1 succeeded at 3477.
done
 
This has been going on for years.
Nobody grew up being able to read man pages. Yet, somehow, almost everybody figures it out eventually because they put in the time to learn.
Meanwhile, for years, you categorically refuse to even put a little bit of effort into it and instead expect other people to do the work for you.
If you want to improve your skills and become more proficient, learn to read man pages. It's really not that hard. Otherwise you're just increasing the list of people which no longer bother trying to help you.

There's nothing wrong with asking for help - also not if it's in the context of "hey, I read this man page, I get most of it, but I don't understand how to apply it in this particular use case".
People will be happy to help (including myself) and you'll walk away with a better understanding of how things work and next time around you'll get a little further on your own.

For example, nobody in primary school understood the connections of mathematics when learning basic arithmetic and nobody understood the connections of grammar while learning the first few words when they studied a language. But you keep going. And the more you learn, the easier it becomes.
The same applies to reading man pages. Just do it - and then ask questions specifically about what you learned there.

Again: Nobody grew up as a pro. We all had to learn everything. Everybody is better at something different and that is fine. That is why we build communities to help each other. But outright refusing to read man pages when dealing with something like FreeBSD is not helping you and you're certainly not making any friends along the way.

Wrong. I only refuse to read the man pages because I don't understand them at all. But I read from different sources and I ask help here and there. Please don't distort reality. Everyone has his own methods of learning. This happens because the human brain processes the input informations differently. So,please respect the diversity,the human differences. It's a nice approach to don't think that because many learn in one way then the rest of the people can / must do it the same way. Thanks.

As you can see,even this time,with some help from you,I have been able to find the solution.

Usually I need a little push. Luckily this forum is full of generous and understanding people. Thanks to everyone from the day one.
 
Meanwhile, for years, you categorically refuse to even put a little bit of effort into it and instead expect other people to do the work for you.

Screenshot_2025-06-20_18-14-04.jpg


jbo@ : Please don't read only what confirms your theory. There is no enjoy for me if someone do all the work for me. But it also true that I feel too much frustrated when I don't understand even where to start. A good compromise is the key.
 
You do this for years now. "Please read that man page for me and tell me exactly what to type".

At least, try to read and understand it. There is nothing wrong to ask for help afterwards. But you didn't even try.

This is valid only for the man pages. It's not my fault if I don't understand them. Unfortunately sometime happens that when someone helps me,he gave to me the man pages. What should I do if I'm not able to understand them ? I'm not sure if it's a good idea to ignore who gave them to me. I think it's not polite,so I ask more elaboration. Anyway,I read from different sources,where concepts are explained differently. And when I come here,I ask only a little introduction to the topic. Sorry if you understand that I want the job done. It's not true. Because this is an hobby for me. Usually hobbies are chosen. Maybe it could be more valid if it was for school or for the job....for sure I don't want to be too much frustrated when I don't understand something.
 
What should I do if I'm not able to understand them ?
Learn.
Just like with literally everything else you're able to do today that you didn't understand when you were born.

Please don't distort reality.
I believe I don't - I specifically addressed some of that in my post.

This happens because the human brain processes the input informations differently. So,please respect the diversity,the human differences.
I absolutely 100% do that.
If you like different formats that's fine. There are plenty of blogs, tutorial, videos and probably other media that talks about how to learn to read man pages.

The difference is that you think because you don't understand something it's fine to just categorically ignore/deny it.
If you don't understand math, you can learn it from a textbook, or you can learn it from a video, or you can learn it form a lecture - all valid ways. But at the end of the day you understand math.

Whatever medium you like to learn how to work with man pages is fine. Just saying "no" to man pages is the real problem.
Man pages are a tool - not a skill. You can learn the skill of welding however you like - but you cannot reject the welder as a tool.
Stop rejecting the tool.
 
What should I do if I'm not able to understand them ?
Ask ChatGPT for a summary of that man page.
Tell ChatGPT what you want to do and ask if it can create a command for your task.

Think about that command ChatGPT gave to you. Look at the man page and try to understand why the command looks like it does.
 
I copied all the diffs to the directories where there are the files to patch :

Code:
./sys/sys/random.h.diff
./sys/arm64/rockchip/clk/rk_fspi.c.diff
./sys/arm64/rockchip/clk/rk_otp.h.diff
./sys/arm64/rockchip/clk/rk_clk_pll.h.diff
./sys/arm64/rockchip/clk/rk_cru.c.diff
./sys/arm64/rockchip/clk/rk_otp_if.m.diff
./sys/arm64/rockchip/clk/rk_tsadc.c.diff
./sys/arm64/rockchip/clk/rk_clk_mux.c.diff
./sys/arm64/rockchip/clk/rk_clk_composite.c.diff
./sys/arm64/rockchip/clk/rk_otp.c.diff
./sys/arm64/rockchip/clk/rk_clk_pll.c.diff
./sys/arm64/rockchip/clk/rk_cru.h.diff
./sys/arm64/rockchip/clk/rk_rng.c.diff
./sys/arm64/rockchip/clk/rk_gpio.c.diff
./sys/arm64/include/cpu.h.diff
./sys/arm64/arm64/machdep.c.diff
./sys/arm64/arm64/undefined.c.diff
./sys/dev/firmware/arm/scmi.c.diff
./sys/dev/mii/mcommphy.c.diff
./sys/dev/eqos/if_eqos_if.m.diff
./sys/dev/eqos/if_eqos_var.h.diff
./sys/dev/eqos/if_eqos_fdt.c.diff
./sys/dev/eqos/if_eqos_acpi.c.diff
./sys/dev/eqos/if_eqos.c.diff
./sys/dev/acpica/acpi.c.diff
./sys/dev/extres/clk/clk.c.diff
./sys/dev/extres/clk/clk.h.diff
./sys/dev/sdhci/sdhci_fdt.c.diff
./sys/dev/sdhci/sdhci.c.diff
./sys/dev/sdhci/sdhci_acpi.c.diff
./sys/dev/iicbus/pmic/rockchip/rk8xx_rtc.c.diff
./sys/dev/iicbus/pmic/rockchip/rk8xx.c.diff
./sys/dev/iicbus/pmic/rockchip/rk8xx_clocks.c.diff
./sys/dev/iicbus/pmic/rockchip/rk817reg.h.diff
./sys/dev/random/random_harvestq.c.diff
./sys/dev/cpufreq/cpufreq_dt.c.diff
./sys/dev/usb/controller/dwc3.c.diff
./sys/dev/pci/vga_pci.c.diff
./sys/dev/pci/pci_dw.c.diff
./sys/dev/pci/pci_pci.c.diff
./sys/dev/mmc/host/dwmmc_var.h.diff
./sys/dev/mmc/host/dwmmc.c.diff
./sys/conf/files.arm64.diff
./sys/conf/files.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3399-pinebook-pro.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3568.dtsi.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3566-quartz64-a-sata.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3588s-nanopi-r6c.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3588s-nanopi-r6s.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3568_pcie.c.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3566-quartz64-a-usb3.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3568_combphy.c.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3588.dtsi.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3566-radxa-zero-3w.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3566-roc-pc.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk817.c.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3568_pmucru.c.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3566-radxa-zero-3.dtsi.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3568-roc-pc.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3588-orangepi-5-plus.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3566-radxa-cm3-io.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3566-radxa-zero-3e.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3566-radxa-cm3.dtsi.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3568-nanopi-r5s.dts.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3568_pciephy.c.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk356x.dtsi.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3588s.dtsi.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3568-nanopi-r5s.dtsi.diff
./sys/contrib/device-tree/src/arm64/rockchip/rk3568-nanopi-r5c.dts.diff
./sys/arm/arm/pmu.c.diff
./sys/arm/arm/generic_timer.c.diff

Now I will patch them one by one. I haven't found a faster method. But I have a lot of patience and I'm stubborn,so I will patch everything without getting bored.
 
Ask ChatGPT to write a script that automatically applies all the diffs in a certain directory.

Seriously, ChatGPT is very capable of helping with such tasks.
 
Back
Top