Jump to content

Recommended Posts

Posted

Hello everyone,

 

since i couldn't find a section for the NanoPi Neo/M1 (or maybe i just overlooked it), and the OrangePi One is rather close to it anyways, i'll post it here.

 

Would there be interrest in a 3.4.112 kernel tree with the preempt_rt patches (rt143) added? I got myself said NanoPi's some days ago, and started to patch my way up from the original sunxi kernel 3.4.39 to the 3.4.112 version, then added the preempt_rt patches, and finally added (most?) patches from the Armbian build. Obviously manually adding the rejects. I'm also having a U-Boot 2016.09-rc1 that i have slightly patched to have it use uEnv.txt instead of boot.scr, because i got too annoyed to edit a text file, then male a binary version of it...

 

So far the kernel seems to wok fine, although i have only tested it with the stuff i need for my project (a controller for 3D printing).

 

I needed the preempt_rt patches to get some half-decent chance to actually control steppers directly from Linux (i'm writing my own driver for that currently), since there is no usable FIQ support in the 3.4 kernel (and all the patches to add such a thing are usually for newer kernels), but they also generally improve the responsiveness of the system. So it may be useful for others as well. I'm rather new to Github (and git in general), will create an account there soon and hopefully get the source trees checked in there.

 

This is a bottlog, from power up until the point systemd is started. U-Boot basically falls through (i have network and USB disabled in my own U-Boot config) and almost immediately loads the kernel.

 

 

  Reveal hidden contents

 

So, if there is interrest i will let you know once i got it stuffed onto Github. In case anyone wants it before that i can just bzip it up and put it on my server.

 

Greetings,

 

Chris

Posted
  On 8/21/2016 at 11:39 PM, ChrisK said:

since i couldn't find a section for the NanoPi Neo/M1 (or maybe i just overlooked it), and the OrangePi One is rather close to it anyways, i'll post it here.

 

First: great to see you appearing here :)

 

Then I don't think this thread is the best point for stuff like that since it's outdated and both NanoPi are 'just another H3 board' (really nothing special). But at least it's in development forum.

 

I believe realtime patches would be nice to be able to provide. But since we would need patches anyway and your development approach sounds a little bit time consuming may I suggest adopting Armbian's build system? Especially FEL booting might be nice for you since you save the SD card entirely and time between build and boot is less than 1 second. Also you can supply your own u-boot parameters as userpatches/fel-boot.cmd (see docs above) and benefit from patch handling in Armbian. Also you can deal with different branches easily (just add 'BOOTBRANCH=tag:v2016.09-rc1' to userpatches/lib.config and you're testing out new u-boot version and so on)

 

It might take you some time in the beginning but the savings when you're familiar with the build system are enormous. On my build host subsequent image buildings take 5 min on average (from scratch including u-boot and kernel compilation and creating a whole FEL boot ready image). As an example a quick build with 2016-09-r1 below (just to see which of our u-boot patches will fail):

 

  Reveal hidden contents

 

Posted

Hello,

 

thnaks for the welcome.

 

Yea, i wasn't sure wether to open a new thread or just add to this. If this isn't the right pülace, maybe a mod can move these parts to a new thread? Or i open a new one?

 

The method i used for patching the original kernel was indeed time consuming, but i did it that way on purpose. Great way to get a rough idea of what changed, plus, my last kernel hacking was way over 10 years ago, so it was also a great way to get back into that stuff. Also, i learned about Armbian only later, when it was already "too late", so to say.

 

I guess i could try to create a diff between the Armbian kernel and the rt kernel. After all, the only difference between the two now should be just the rt patches (unless i somehow forgot to apply one/some of the Armbian patches from lib/patch/kernel for the 3.4.112 version). Alternatively i could apply the rt patches to the "final" Armbian kernel, manually adding the failed hunks (as i did with my version of it). Now that i know  what to look for that should be done rather quickly.

 

What kind of patch-set would you guys prefer? The way i applied the rt stuff was by using the patch-set patches-3.4.112-rt143.tar.gz, instead of the single big patch file. So there are two options, i can either create basically the same patch set, just for the Armbian kernel, or make a single big rt patch that could be optionally applied to it after all the other patches from Armbian have been applied.

 

Regarding the Armbian build script, for what i am doing right now it is rather bulky. I'm writing a kernel driver/module, so all i ever need is to recompile that, copy over the uImage, and boot it. Building a whole new image all the time is just too much.

 

So, let me know how you guys would prefer the rt patch, small patches or a single big patch, and i try to get it done by the weekend.

 

Greetings,

 

Chris

Posted

 (moved this to a new thread now)

  On 8/22/2016 at 11:56 AM, ChrisK said:

So, let me know how you guys would prefer the rt patch, small patches or a single big patch, and i try to get it done by the weekend.

 

Up to @Igor, @Zador -- they are into kernel development. For me a huge patch that applies cleanly against Armbian's 3.4.112 would be great since then we could provide kernel .debs for testers interested in this stuff.

Posted

Hi,

 

first of all, thanks for moving this part into a separate thread.

 

Attached is .tar.gz with the patches. While the RT patches themselves are in a single patch file, there are 4 more patches.

 

I created them by first running the compile.sh script. I selected the legacy kernel, and Nanopi M1, then had it unpack the kernel patch it and then compile it. Once that was done i copied over the sources/linux-sun8i/sun8i dierectory to apply the patches. In fact i copied it twice, to be able to get a patchset consistin of single patch files for the RT stuff as well. I then fixed up a few other issues /thus the extra patches), and added a patch to allow setting priority levels on IRQ's.

 

After all that i copied the clean sun8i directory again and applied the just created patches, to verify the result applies cleanly to the 3.4.112 sunxi kernel in Armbian. Which they do.

 

The patches are as follows:

 

0000-... : The lib/patch/kernel/sun8i-default/02-0005... patch has a small bug. The patched result makes use of kobj_to_dev(), but it can't find that because genhd.h is missing from the includes in firmware_class.c. This patch fixes that.

 

0001-... : The full preempt_rt patch. Most of the patches of the original rt143 apply just fine. A few have only line offsets, even fewer have failed hunks or errors. The latter ones are where i manually added the rejected parts into their proper places.

 

0002-... : Afte the RT patches are applied, when one want to use PREEMPT_RT_FULL, the use of highmem is no longer possible (in the 2.6 kernel patches it is possible again, though...). The SUNXI SS hardware crypto driver makes use of kmap/kunmap, which are provided by highmem functions. This patch disables that driver if no CONFIG_HIGHMEM is possible. No idea in what places the SUNXI SS is used anyways. By default it builds as a module, and i never saw it loaded.

 

0003-... : There is a small bug in the RT patches in rimerfd.c, where in one places it tries to access ctx->tmr, whereas it should be ctx->t.tmr. This patch fixes that.

 

0004-... : This adds the ability to set priorities for IRQ's on the GIC. Normally all IRQ's have the same priority, 0xa0. This patch allows three levels, and high priority can be selected for an IRQ by adding IRQF_HIGH_PRIORITY to its flags.

 

About the issue with no highmem available when PREEMPT_RT_FULL is used, i will dive into that once i have more time. Maybe i can backport some stuff from newer RT patches, who knows. Other than that the kernel runs fine, at least i didn't encounter any issues yet.

 

As usual, the RT patches add two extra choices to Kernel Features -> Preemption Model, Preemtible Kernel (Basic RT) and Fully Preemptible Kernel (RT). Also as usual, using those patches makes the kernel slightly less performant when it comes to things like raw I/O stuff. It simply improves the response time to events, decreases latency, etc., which is very useful in certain applications.

 

Anyways, i hope that this is helpful for you folks.

 

Greetings,

 

Chris

 

patches.tar.gzFetching info...

 

Posted

That reminds me, i forgot to include another patch. That one makes irq_set_affinity_hint() work properly. The interrupt controller allows IRQ's to be tied to specific cores, by setting the cpu affinity of the IRQ. While irq_set_affinity_hint() is already there and exported, it fails to actually put the IRQ on the selected CPU(s).

 

It can be quite useful to be able to tie an IRQ to a specific CPU/core, especially in conjunction with the RT patches. You can, for example, simply exclude one core from being used by the kernel, using the isolcpus= boot arg for the kernel. Like, isolcpus=3 will exclude the fourth core from being used by the kernel. If you then install your interrupt and call irq_set_affinity_hint(IRQNUM, cpumask_of(3)) (with IRQNUM being the number of the IRQ in question), that IRQ will then handled exclusively on the fourth core. This greatly reduces latency and jitter.

 

Greetings,

 

Chris

 

0005-make-irq-set-affinity-hint-work-properly.patch.gzFetching info...

Posted
  On 8/23/2016 at 12:14 PM, Igor said:

https://github.com/igorpecovnik/lib/commit/b1c387cec595ab956c38fc4c75f0f3b4a2d15cb7

 

We usually left out the main patch as .disabled so one can enable and build if needed. Other patches, except disabled one, should not break current kernel, right? I only made a brief look into code and try building.

 

Thanks!

 

The other patches don't break or modify the default behaviour of the kernel. However, you should also disable 0003 if 0001 is not used. That one only fixes an issue that shows up when the RT patches are applied, and will fail if they are not applied first. 0000 is a general fix for an issue that exists in the 3.4.112 armbian kernel, 0002 just excludes SUNXI SS if highmem is not enabled, 0004 and 0005 are just additions to the IRQ handling/config that does not affect regular operation, but is handy to have in case one wants/needs these functionalities in their own drivers.

 

Greetings,

 

Chris

Posted

Hi,

 

and here is another patch that should be added if the RT patch is applied.

 

This one fixes BUG's that are triggered when using the interactive cpufreq governor. The probelm is that spin_lock_irqsave and spin_lock_irqrestore are used there, which leads to:

 

BUG: scheduling while atomic: swapper/0/0/0x00000002

 

This patch makes it use the raw_ versions of those in case the PREEMPT_RT_FULL patch is applied.

 

I wasn't aware of the issue until now, since i usually use the "userpsace" governor.

 

Greetings,

 

Chris

0006-cpufreq_interactive-spin_lock_for_rt.patch.gzFetching info...

Posted

Hi,

 

Igor asked me if i could consolidate the RT patches into a single one, and only doing the extra patches seperately, so here they are.

 

First, i added the fix for firmware_class.c in the 02-0005-backport-firmware-loader.patch, because that is what introduces the issue in the first place. So, that patch can be replaced by this file:

 

02-0005-backport-firmware-loader.patch.gzFetching info...

 

Then i took the liberty to consolidate all the patches that brings the kernel from 2.4.39 to 2.4.112 into a single one. I did so by first disabling all the patches from 02-0001-patch... down to z-0003... (leaving those before 02-0001 enabled), having the compile script apply the patches. Then i saved the kernel source tree, enabled these 39-112 patches:

 

 

  Reveal hidden contents

 

 

and ran compile.sh again to have all those applied. Then i saved that source tree, and made single patch file. This one brings the kernel from 2.4.39 up to 2.4.112 in one patch:

 

02-0001-patch-3.4.39-112.patch.gzFetching info...

 

That means that in the lib/patch/kernel/sun8i-default directory all the patches in the above list can be removed and the single patch file be used instead.

 

Here is the consolidated RT patch, which now includes the RT itself plus the fixes for it:

 

0000-rt143-full-plus-rt-fixes.patch.gzFetching info...

 

So all that is left is the patch for those who want to have irq_set_affinity_hin() work properly. I leave that one extra, because for one it doesn't change anything to the way the kernel operates and sets up IRQ's by default, and it also doesn't have anything to do with the RT patches as such. So, this applies opnly for those who write their own drivers (or want to modify existing ones) that use interrupts, and want to tie said IRQ's to a specific core (or cores):

 

0001-make-irq-set-affinity-hint-work-properly.patch.gzFetching info...

 

Greetings,

 

Chris

 

EDIT: There was a bug in the full RT patch. Fixed it, and replaced the file in this post!

Posted

Just to make sure the edit isn't overlooked:

 

There was a bug in the full RT patch in the post above. Fixed it, and replaced the file in the previous post.

 

Greetings,

 

Chris

Posted

Hi Igor,

 

what exactly is the issue with the 39-112 patch? The overlay-patch (02-0003-linux-sunxi-3.4.108-overlayfs.patch) is included in that one. I have  tested it here, and so far it works.

 

Let me know what the issue is, the i can re-crete it and possibly fix the large patch.

 

Greetings,

 

Chris

Posted

Hi Chris and others

 

I would certainly be interested in a 3.4.112 kernel tree with the preempt_rt patches (rt143) added

 

Regards

 

  On 8/21/2016 at 11:39 PM, ChrisK said:

Hello everyone,

 

since i couldn't find a section for the NanoPi Neo/M1 (or maybe i just overlooked it), and the OrangePi One is rather close to it anyways, i'll post it here.

 

Would there be interrest in a 3.4.112 kernel tree with the preempt_rt patches (rt143) added? I got myself said NanoPi's some days ago, and started to patch my way up from the original sunxi kernel 3.4.39 to the 3.4.112 version, then added the preempt_rt patches, and finally added (most?) patches from the Armbian build. Obviously manually adding the rejects. I'm also having a U-Boot 2016.09-rc1 that i have slightly patched to have it use uEnv.txt instead of boot.scr, because i got too annoyed to edit a text file, then male a binary version of it...

 

So far the kernel seems to wok fine, although i have only tested it with the stuff i need for my project (a controller for 3D printing).

 

I needed the preempt_rt patches to get some half-decent chance to actually control steppers directly from Linux (i'm writing my own driver for that currently), since there is no usable FIQ support in the 3.4 kernel (and all the patches to add such a thing are usually for newer kernels), but they also generally improve the responsiveness of the system. So it may be useful for others as well. I'm rather new to Github (and git in general), will create an account there soon and hopefully get the source trees checked in there.

 

This is a bottlog, from power up until the point systemd is started. U-Boot basically falls through (i have network and USB disabled in my own U-Boot config) and almost immediately loads the kernel.

 

 

  Reveal hidden contents

 

So, if there is interrest i will let you know once i got it stuffed onto Github. In case anyone wants it before that i can just bzip it up and put it on my server.

 

Greetings,

 

Chris

Posted

Hello.

Some questions if you please?

Where do you get all the patches for the Armbian functionalities, from the armbian build??..

Also, the RT patch you (Chrisk) are providing, is one you created, why not use this one

https://rt.wiki.kernel.org/index.php/Main_Page

Also. Igor....where do you remove .disable to use this RT-patch its all ready been tested, and from where does it come from from the page i put above? (I ask this, because I need to patch an Orange pi kernel with this RT patch. So I was thinking in including the preempt-RT patch on the patches folder on the Armbian build (which i have started looking not so long ago. My first strategy was to use buildroot, but have problems with all the patches and now desided to use Armbian and patch it with the preempt-RT patch)).

Thanks in advance.

 

Posted

patch/kernel/sun8i-default

Patch is here: https://github.com/armbian/build/blob/master/patch/kernel/sun8i-default/30-real-time143-full-plus-rt-fixes.patch.disabled 

This patch is here around for some time and also kernel is around for some time. Support is slowly fading out ... but was the only one for those boards until recently.
 

Just remove .disabled in the file name and remember that there are limitations - full preempt is not able to compile. I am monitoring to bring RT to the modern kernel, which would be much better ... latest patches are designed for 4.4, (usable) support for H3 started at (our) 4.13 ... haven't tried if its possible to adopt in some sane time. For some serious patch adjusting, we don't have resources.

Posted

Hello.

Thanks for your answer Igor.

I am trying to patch for RT, to use an Orange pi zero.

In the build folder, in build/patch/kernel/,  there is the sun8i-default, and the sun8i-dev folders..What is the difference between this 2 (I am kind of neewbie in this). also, why is it necessary to u-boot, and the patches I would need for Orange pi zero are u-boot-sunxi (right?)

Thanks a lot in advance.

Posted
  On 10/18/2017 at 2:48 AM, nwk said:

And another thing please...

The kernel used for using this patches is this one (https://github.com/orangepi-xunlong/orangepi_h3_linux) ??

Expand  


Yes, the took it from us and you don't want to use their crappy tools. They are not newbie friendly.

 

  On 10/18/2017 at 2:28 AM, nwk said:

In the build folder, in build/patch/kernel/,  there is the sun8i-default, and the sun8i-dev folders..What is the difference between this 2 (I am kind of neewbie in this)

Expand  


"dev" is development branch which is in the process of deleting since its getting merged into the common sunxi-next kernel. When RT patches are available for 4.13.x this would be the best way to go. Currently, it's n/a.

Posted

Thanks a lot for the reply.

In the page

https://rt.wiki.kernel.org/index.php/Main_Page

There is  3.4-rt patch....

https://www.kernel.org/pub/linux/kernel/projects/rt/3.4/

Isn't that usable with the 3.4.113-sun8i kernel....??

downloading the kernel, using current working armbian .config, putting all the things needed (getting this things from Armbian/build/patch/sun8i-default), then add the RT patch, and compile it.

Would this give an RT OS to use with the orange pi zero?.

Thanks a lot.

 

Posted

Hello Igor.

Thanks for the reply.

Will do..

But, I have read, that this way, Hard RT cannot be done??

Thanks a lot.

 

Posted
  On 10/22/2017 at 9:28 PM, nwk said:

But, I have read, that this way, Hard RT cannot be done??

Expand  


That is the case for old 3.4 kernels. For recent ... I don't know.

Posted

Hello Again.

I am triying to compile the OS with the Armbian compilation tool. I have enabled the RT patch (by errasing .desable), but I gen an error:

          

                               [ error ] ERROR in function compile_kernel [ compilation.sh:339 ]

 

In the compilation.sh, the line 338, is:

if [[ ${PIPESTATUS[0]} -ne 0 || ! -f arch/$ARCHITECTURE/boot/$KERNEL_IMAGE_TYPE ]]; then
        exit_with_error "Kernel was not built" "@host"

 

I dont know what actually this menas.

What could it be done to fix this??

 

 Thanks a lot in advance.

 

Posted

Hi.

I managed to compile it, I did with Buildroot, the sun8i-default, a .config from a previus armbian i was using, and the kernel patches from the build, It has all compile well, but havent tried it yet.

I will post when i try it,, hopefully in some hours.

Thanks a lot for the answers.

nwk

Posted

Hello.

I putted the image I got from buildroot on the orange pi, but doesnt boot.

I atach the files.

any orientation is wellcome.

Thanks a lot.

 

 

images.zip

Posted

If you see, there it says, orange pi pc....I used this defconfig from buildroot, with some changes to meet the parameters i needed.. I attach the defconfig used.

The . config used, is from an armbian which i erased the things i didnt need. also, I used the RT patch provided.

The compilation runs good.

Thaks a lot in advance.

 

** One thing maybe. I did not applied the patches for u-boot...maybe that could be the problem???... I use the moment to ask, why does the u-boot need to be patched??.

 

 

orangepi_pc_defconfigFetching info...

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines