I'm looking for the best Hard RealTime solution to install on my mini2440. I'm working on a project that will process input signals from various sensors (analog and digital) and output few digital signals based on some calculations. I also want to write some data to the sd card. I need to do it at rates >= 50hz. Of course I can buffer the data and save it to the SD in chunks, but the sensors readings must occur regularly 50 (or better if possible) times per second and also the output must be set @ the same rate. I was looking @ xenomai as it seemed quite best documented but now I'm having doubts. Has anyone succeeded in installing xenomai on mini2440? Is so, please share the knowledge - I don't know where to start. Or maybe you can suggest a better solution for me. Maybe my rates are low enough for the soft RT? However stable latency is cruitial! Let me know what you think, please! regards, -- Luke
Hard RT on mini2440
Hi Luke, please look at there http://www.friendlyarm.net/forum/topic/3299#15471 regards, Sergey
100us - that is 10000 times per second, wow! And you had all the inputs/outputs/sd card working? Could you help me a bit in the installation process? Small list of general points to do would be great. Like: 1. download the 2.6.35.9 kernel 2. patch the kernel 3. ? It all seems incosistend to me reading xenomai howtos and mini2440 howtos. If I had a general guidelines then I could dig furter :) Thanks, -- Luke
dragzilla, latency != period. If you need realtime the max. latency is an important value. Not the period.
Hm, We're talking interrupt latency here, right? I thought, that latency = 100us means that I can get an interrupt 10000 times per second. How is it then? Forgive me if I'm writing nonsense here - I'm new to arm and RT. thanks, -- Luke
10000 times per second? Think about it: in this case your machine only runs your interrupt handler. *Nothing else* any more! "real time" does *not* mean "as fast as possible"! And it also does not mean "as early as possible". It just means "as fast or early as you specify in your requirement". And if the max. latency achieves your requirements, a real time operating system will guarantee this max latency. Fact is, Linux with RT Preempt will slow down your machine a little bit (compared to the non RT Preempt kernel). But it guarantees you the max latency whatever happens in your system (regarding to system load and hardware activity). Without RT Preempt a plain kernel is most of the time faster than the max latency of the RT Preempt one. But there is no guarantee any more about the max latency. In case of a high system load or some other corner cases, the plain kernel can also generate latencies of dozens of milliseconds. This will never happen in a real time operating system (modulo bugs in the application).
Ok. Let me fully understand. Is the max latency dependent on the function I wand to perform? Or is it just dependent on the system configuration? If the max latency is 100us what does it mean in practice? How do I know what max latency I get on my mini2440? regards, -- Luke
No, the max latency should be independent of anything what happens in your system and whatever you (or your application does). In practice the 100 us mean, if you are running a high priority task and it is ready to run after waiting for an event after 100 us this high priority task get the CPU. Anything other (lower priority) will be preempted. It is not easy to get an answer for the max latency question. All you can do is, to let your system do things it will later on do, when it runs in production. Or create various synthetic load and measure the result (refer 'cyclictest').
So I can do a cyclic test and measure my max latency, make assumptions and design my application accordingly and then it may happen that the max latency is higher in some circumstance? That does not make sense to me :) I will have to do more reading in the subject. Any good sources of knowledge on the internet? Anyways: what kind of solution would you recomend to my problem (post 1)? xenomai is ok? But xenomai on what? busybox? I don't need the screen so qtopia is pointless... thanks,
"That does not make sense to me :)" But there is no other way. Do you want to check every path the software can take in a complex operating system like Linux is? You never can't. What you have to do is to create a system load that compares to your production scenario. This load should run to all pathes the software can take. In RT Preempt are some helpers included. For example a "latency hunter". It will log in a circular buffer what functions the system takes the last few milliseconds back. And it will trigger if a latency violates your settings. In this case it gives you a stack trace where the system wastes time. Sometimes real time behaviour is lost due to an ugly application design. In this case, any real time operating system cannot help (think about bad locking). Also on modern x86 systems there is something called "system management mode" that steals CPU cycles from the system. In this case the real time operating system also cannot help. RT Preempt does not work on the S3C2440 due to its ugly hardware timer design. I didn't try it yet, but Xenomai should do the job. And Xenomai is an operating system. I guess you should be able to run any available userland.
Hi I had the same sort of requirement where i needed to fire a triac within 1ms of zero crossing along with a QT user interface. No way a mini2440 + linux could do this even with a RT patch applied so what I did was I outsourced the control loop to a PIC controller , which I programmed as a I2C slave. The PIC controlled the control loop and the mini2440 the QT user interface. This divide and rule strategy works effectively in terms of coding/testing of the UI and the control loop, must faster development cycle now. try it out. thanks --fatbrain
Hi serg_io. I'm trying to compile 2.6.35.9 with your patch. It patched fine but then I couldn't find the config you mentioned here http://code.google.com/p/miniemc2/downloads/detail?name=linux-2.6.35.9-s...= (make mini2440_xeno_defconfig). There is mini2440_defconfig which I used instead. Then I made make menuconfig and then make ARCH=arm -j4 I get following errors: arch/arm/mach-s3c2440/mach-mini2440.c:621: error: 'sc32440_fiq_device' undeclared here (not in a function) make[1]: *** [arch/arm/mach-s3c2440/mach-mini2440.o] Error 1 make: *** [arch/arm/mach-s3c2440] Error 2 make: *** Waiting for unfinished jobs.... I guess there's something wrong with the config? Please help me out. regards, -- LS
Ok. I found it. Your patch assumes the CONFIG_S3C2440_C_FIQ is set to compile the kernel. If it's not set then struct platform_device sc32440_fiq_device is not defined (it's inside #ifdef CONFIG_S3C2440_C_FIQ) but it is used further in the arch/arm/mach-s3c2440/mach-mini2440.c file (line 621). The mini2440_defconfig does not turn it on, so the kernel doesn't compile. I will try to turn it on manually and it should compile. It's something related to NAND so it's needed anyways, right?
I changed "# CONFIG_S3C2440_C_FIQ is not set" to "CONFIG_S3C2440_C_FIQ=y" and the error is gone. However it's strange because the menuconfig for this section (System type->Arm system type) is not readable... Anyways, your mini2440_xeno_defconfig would be really appreciated :)
Damn it, now I get other errors... Does it have to be sooo hard? arch/arm/mach-s3c2440/built-in.o: In function `fiq_init_irq_source': /home/luke/Desktop/moje/mini2440/linux-2.6.35.9/arch/arm/mach-s3c2440/fiq_c_isr. c:134: undefined reference to `s3c2410_pwm_init' /home/luke/Desktop/moje/mini2440/linux-2.6.35.9/arch/arm/mach-s3c2440/fiq_c_isr. c:150: undefined reference to `s3c2410_pwm_enable' /home/luke/Desktop/moje/mini2440/linux-2.6.35.9/arch/arm/mach-s3c2440/fiq_c_isr. c:154: undefined reference to `s3c2410_pwm_start' /home/luke/Desktop/moje/mini2440/linux-2.6.35.9/arch/arm/mach-s3c2440/fiq_c_isr. c:159: undefined reference to `s3c2410_pwm_enable' /home/luke/Desktop/moje/mini2440/linux-2.6.35.9/arch/arm/mach-s3c2440/fiq_c_isr. c:162: undefined reference to `s3c2410_pwm_start' /home/luke/Desktop/moje/mini2440/linux-2.6.35.9/arch/arm/mach-s3c2440/fiq_c_isr. c:164: undefined reference to `s3c2410_pwm_enable' /home/luke/Desktop/moje/mini2440/linux-2.6.35.9/arch/arm/mach-s3c2440/fiq_c_isr. c:167: undefined reference to `s3c2410_pwm_start' make: *** [.tmp_vmlinux1] Error 1 The file fiq_c_isr includes mach/pwm.h which hold the declaration of s3c2410_pwm_init for example. The definition is in pwm.c. It should be ok? HELP!!!
Wow - it compiles! But I'm having some serious doubts if it's going to work - I need a proper config.
Hi dragilla, thanks for your tests and sorry if you had some problems. There is a mistake - you can try with miniemc_defconfig. And you are right, there are some errors when FIQ ISR and PWM is not enabled. If you don't like this patch, then you can use i-pipe patch from http://git.xenomai.org/?p=ipipe-gch.git;a=commit;h=d1680ec95b648058f7067... and Xenomai 2.5.6 from the same site. It should work too.
Thanks, I will try that becasuse the kernel compiled but modules didn't - I got modules section mismatch. Hm, And how about a kerrnel from this thread and a patch from Xenomai. I could use 2.6.38.8 and patch it with adeos patch for this kernel - it's available in xenomai 2.6.0. Theoretically it should work, right? regards,
this thread... I mean this thred: http://friendlyarm.net/forum/topic/2737
You can try to use 2.6.0, there is right i-pipe patch, which works well with Adeos patch from 2.5.6. But with Adeos patch from 2.6.0 kernel doesn't compiled. I don't remember exactly why. Try yourself and then tell us about results.
Hehe, Guess what. 2.6.0 has adeos patches for 2.6.35.9, 2.6.37.6, 2.6.38.8 and older kernels. None of the above kernels has patch for mini2440. If I understand correctly I need a kernel patched for mini2440 as a base for patching with xenomai patches, right?
With miniemc_defconfig and your patch I get following kernel compilation error: /home/luke/Desktop/moje/mini2440/linux-2.6.35.9/scripts/gen_initramfs_list.sh: Cannot open '/home/ksu/projects/miniemc/images/initramfs_test' make[1]: *** [usr/initramfs_data.cpio] Error 1 make: *** [usr] Error 2 a hardcoded /home/ksu... path?
linux-2.6.35.9-s3c24xx-i-pipe-xenomai-fiq-isr-aufs2.patch:56502:+CONFIG_INITRAMF S_SOURCE="/home/ksu/projects/miniemc/images/initramfs_test" This file is not within the kernel source - so for now I'm stuck. You said I could use a patch from http://git.xenomai.org/?p=ipipe-gch.git;a=commit;h=d1680ec95b648058f7067... But what kernel do I apply it to? I know it's 2.6.35.9, but doesn't standard 2.6.35.9 require patching for mini2440 first?
You are right, there is error again. You have to open menuconfig and remove flag General setup->Initial RAM filesystem and RAM disks...->Initramfs source file. These days I will refactor my patch to be more usable. I-pipe patch from Xenomai I talked about was applied to that kernel ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.35.9.tar.bz2 without any additional patches. It already has support for mini2440.
Already when compiling the kernel I get: MODPOST vmlinux.o WARNING: modpost: Found 5 section mismatch(es). To see full details build your kernel with: 'make CONFIG_DEBUG_SECTION_MISMATCH=y' With the previous confing I got a similar error when building modules. Now, with the new config (miniemc_defconfig) I only get a warning when building kernel, no error building modules... I'm attaching log with the output from compilation with CONFIG_DEBUG_SECTION_MISMATCH=y
I've decided to go with the 2.6.38.8 kernel and xenomai 2.6. I successfully built the kernel, module and xenomai user-space. I ended up with compiled modules, uImage of the kernel and two user-space directotires "dev" and "usr". Will I need something more? Busybox maybe? Or maybe this is enough for xenomai? How do I add the skin (api)? regards,
My congragulation with your success. Did you test it on mini2440? I hope it will work. There are some tests, please perform their on HW. Especially I would like to see latency test results without any loads and when mini busy with some IO tasks, like data copying over FTP to SD or USB flash. To build rootfs I use buildroot. To build Xenomai-based appication you have to use one of Xenomai's API, it comes with good documantation. Personaly I use native API.
So I don't need anything else but the files I have now? As I said I'm totally new, so I need a hint. No busybox? Just /dev /lib and /usr directories? no /etc, /bin, /sbin, ... ?
Of course you need filesystem, for example based on busybox. But I told about buidroot. It's filesystem build util which includes busybox and many other applications. As a result you will have full rootfs in format that you prefer. After you have to copy your Xenomai's libraries to right place.
Ok, finally a solid answer :) So I need a standard file system structure after all - good I'm not crazy :) I'm gonna try to put all the stuff on my mini today/tomorrow and launch the latency test (they provide a bin file latency which i think is the latency test). Thanks for help.
Sergey, was the Nand working with you kernel patch? I was just told by Juergen Beisert that NAND is not working in his patched 2.6.28.8 kernel. I must have a working nand :( Anyways I'm struggling like hell to do ANYTHING with my mini :( I accidentally replaced vivi by u-boot in NOR flash instead of NAND. Then I cleared the NAND and I'm left with u-boot only in NOR. How can I put anything in NAND now? I think there's no option to tranfer it by usb like in vivi... Tried sd card and usb but it gives me errors... (http://www.friendlyarm.net/forum/topic/3389). FFS nothing works - this is irritating... ;)
Yes, NAND flash works fine with 2.6.35.9 and Xenomai. Unfortunately I don't have time now to test 2.6.38.8. With u-boot you can do anything with NAND: erase, write, read. There are dedicated commands, try help on u-boot command prompt. Then you can upload images, like uLinux.bin and filesystem image ( I use jffs2 and ubifs filesystems ) to memory and write it to NAND. To do this you need setup TFTP server on your PC and download images with u-boot's command tftpboot. Pay attention, NAND flash has some partition, whose size defined in arc/arm/mach-s3c2440/mach-mini2440.c You can create you own partition table there for kernel, rootfs and etc. You should consider NAND's partiotons location and size when writing filesystem image to NAND. After that you have to setup right kernel boot arguments in the u-boot's bootargs variable: specify console name, root patrition device, rootfs type. For more details refer to kernel documantation.
Juergen corrected himself and said that nand works on 2440 but not on 6440. So it's ok (theoretically) to use 2.6.38.8. Anyway... I download kernel image and jffs to ram and did nand write accordingly (as in http://narnia.cs.ttu.edu/drupal/node/131). It all loaded but then it won't boot of the new settings. My guess is the problem is that it doesn't want to save env to nand. I will describe it in a new thread as this becomes offtopic.
Where do I check what partition device names I have? mtdparts prints partition names, but I need /dev/something to set env vars for boot. My root defaults to /dev/mtdblock3, but I get kernel panic as no init is found, so maybe this is wrong...
I've rewritten the mach-mini2440.c - it was way different than my partition table. Thanks for the tip.
I no longer have the "empty flash" messages when booting the kernel. But now it won't mount the root fs: s3c-rtc s3c2410-rtc: setting system clock to 2000-05-01 23:56:24 UTC (957225384) VFS: Cannot open root device "mtdblock3" or unknown-block(31,3) Please append a correct "root=" boot option; here are the available partitions: 1f00 256 mtdblock0 (driver?) 1f01 128 mtdblock1 (driver?) 1f02 5120 mtdblock2 (driver?) 1f03 1043072 mtdblock3 (driver?) Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3) [<c002f2e4>] (unwind_backtrace+0x0/0xf8) from [<c03942d4>] (panic+0x60/0xf0) [<c03942d4>] (panic+0x60/0xf0) from [<c0008eb4>] (mount_block_root+0x180/0x2c0) [<c0008eb4>] (mount_block_root+0x180/0x2c0) from [<c0009158>] (prepare_namespace+0x100/0x1c0) [<c0009158>] (prepare_namespace+0x100/0x1c0) from [<c0008498>] (kernel_init+0x12c/0x184) [<c0008498>] (kernel_init+0x12c/0x184) from [<c002ac18>] (kernel_thread_exit+0x0/0x8) My env is set like this: MINI2440 # printenv bootargs=root=/dev/mtdblock3 rootfstype=jffs2 console=ttySAC0,115200 bootdelay=3 baudrate=115200 ethaddr=08:08:11:18:12:27 usbtty=cdc_acm mini2440=mini2440=0tb bootargs_base=console=ttySAC0,115200 noinitrd bootargs_init=init=/sbin/init root_nand=root=/dev/mtdblock3 rootfstype=jffs2 root_mmc=root=/dev/mmcblk0p2 rootdelay=2 root_nfs=/mnt/nfs set_root_nfs=setenv root_nfs root=/dev/nfs rw nfsroot=${serverip}:${root_nfs} ifconfig_static=run setenv ifconfig ip=${ipaddr}:${serverip}::${netmask}:mini2440:eth0 ifconfig_dhcp=run setenv ifconfig ip=dhcp ifconfig=ip=dhcp set_bootargs_mmc=setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_mmc} set_bootargs_nand=setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_nand} set_bootargs_nfs=run set_root_nfs; setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_nfs} ${ifconfig} mtdids=nand0=mini2440-nand bootfile=u-boot.bin loadaddr=0x31000000 filesize=3A814 fileaddr=31000000 netmask=255.255.255.0 ipaddr=10.0.0.111 serverip=10.0.0.4 mtdparts=mtdparts=mini2440-nand:0x00040000(u-boot),0x00020000(u-boot_env),0x0050 0000(kernel),0x3faa0000(rootfs) bootcmd=nboot.e kernel ; bootm partition=nand0,0 mtddevnum=0 mtddevname=u-boot Environment size: 1220/131068 bytes MINI2440 # Kernel is missing a driver or what?
Hi dragilla, seems you never sleep :) It's hard to say exactly what is wrong in your case. Try to check if JFFS2 ernabled in the kernel. Bootargs seems are right
Sometimes I do sleep, but not much recently. I actually didn't have jffs2 turned on... again this config sux :P When I turned it on, the kernel again started printing : .... Empty flash at 0x00f0fffc ends at 0x00f10000 Empty flash at 0x00f1bffc ends at 0x00f1c000 Empty flash at 0x00f2fffc ends at 0x00f30000 ..... VFS: Mounted root (jffs2 filesystem) on device 31:3. Freeing init memory: 132K Kernel panic - not syncing: No init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance. [<c002eef4>] (unwind_backtrace+0x0/0xec) from [<c0312654>] (panic+0x5c/0xe4) [<c0312654>] (panic+0x5c/0xe4) from [<c0029684>] (init_post+0xac/0xd8) [<c0029684>] (init_post+0xac/0xd8) from [<c0008488>] (kernel_init+0x124/0x16c) [<c0008488>] (kernel_init+0x124/0x16c) from [<c002ab24>] (kernel_thread_exit+0x0/0x8) But at least it seems it mounted to rootfs.
Why you don't start with NFS root? You are doing the hard way. As long you are in the development phase you should use NFS root, make everything work in a way you need it, and in the last step you make the result persistent into the NAND, to be able to boot the Mini2440 stand alone.
When I finally manage to boot linux then I will probably do it - it's a good idea. But at first I want to learn how to boot from nand :)
But it is much easier to get the kernel talking to the NAND from a NFS root. And if you are sure this kernel (with some patches and your kernel config) can handle the NAND its time to try booting from NAND. You problem could also be a broken userland. "Kernel panic - not syncing: No init found" is also the message, when userland cannot start due to missing libraries and so on. Maybe you are hunting phantoms and not the NAND is your problem...
finally ported xenomai kernel and usespace application to board, now how can i modified my c prog with xenomai api, my c prog. read and write value to gpio register from usr space prog. i need to modified with xenomai api, can you please tell me where to do modification to the prog. Regards
Hi drag_gila, congratulation, i try todo this 2 weeks, no success. I have always boot problem! Please post the steps how do you ported Xenomai and Kernel and getting boot.
Hi, I left my mini project almost a year ago so I don't remember much, but I can paste here my todo file, where I kept all the steps I used to build and run xenomai. Maybe you can get something out of it. There are 2 versions: for two versions of xenomai. Now you probably get a newer xenoami for which my steps could not work. Good luck! --- cut here --- ###################################################### ############ XENOMAI ################################# ###################################################### export PATH=/home/luke/Desktop/moje/mini2440/arm-2011.03/bin:$PATH export ARCH=arm unset CC unset CROSS_COMPILE cd ~/Desktop/moje/mini2440/xenoami-2.5.6 ./configure CFLAGS="-march=armv4t" LDFLAGS="-march=armv4t" --build=i686-pc-linux-gnu --host=arm-none-linux-gnueabi --enable-arm-mach=s3c2410 --enable-arm-tsc --enable-arm-eabi make DESTDIR=/home/luke/Desktop/moje/mini2440/xenomai-2.5.6-target install cd ~/Desktop/moje/mini2440/xenomai-2.6.0-rc5 ./configure CFLAGS="-march=armv4t" LDFLAGS="-march=armv4t" --build=i686-pc-linux-gnu --host=arm-none-linux-gnueabi make DESTDIR=/home/luke/Desktop/moje/mini2440/xenomai-2.6.0-rc5-target install ###################################################### ############# KERNEL ################################# ###################################################### export PATH=/home/luke/Desktop/moje/mini2440/arm-2011.03/bin:$PATH export ARCH=arm export CROSS_COMPILE=arm-none-linux-gnueabi- export CC=arm-none-linux-gnueabi-gcc –march=armv4t –mtune=arm920t cd ~/Desktop/moje/mini2440/linux-2.6.35.9 rm ../linux-2.6.35.9-target/lib/* -fR vi arch/arm/mach-s3c2440/mach-mini2440.c make clean make ARCH=arm -j4 make ARCH=arm -j4 modules make INSTALL_MOD_PATH=/home/luke/Desktop/moje/mini2440/linux-2.6.35.9-target -j4 modules_install cd ~/Desktop/moje/mini2440 uboot/mini2440/tools/mkimage -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d linux-2.6.35.9/arch/arm/boot/zImage linux-2.6.35.9-target/uImage sudo cp linux-2.6.35.9-target/uImage /tftpboot cp -a linux-2.6.35.9-target/lib xenoami-2.5.6-target cd ~/Desktop/moje/mini2440/linux-2.6.38.8 vi arch/arm/mach-s3c2440/mach-mini2440.c rm ../linux-2.6.38.8-target/lib/* -fR make clean make ARCH=arm -j4 make ARCH=arm -j4 modules make INSTALL_MOD_PATH=/home/luke/Desktop/moje/mini2440/linux-2.6.38.8-target -j4 modules_install cd ~/Desktop/moje/mini2440 uboot/mini2440/tools/mkimage -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d linux-2.6.38.8/arch/arm/boot/zImage linux-2.6.38.8-target/uImage sudo cp linux-2.6.38.8-target/uImage /tftpboot cp -a linux-2.6.38.8-target/lib xenomai-2.6.0-rc5-target ###################################################### ############# BUSYBOX ################################ ###################################################### cd ~/Desktop/moje/mini2440/buildroot-2011.08 make cp -a output/target/* ../xenomai-2.5.6-target cp -a output/target/* ../xenomai-2.6.0-rc5-target ###################################################### ############# ROOTFS ################################# ###################################################### cd ~/Desktop/moje/mini2440 mkfs.jffs2 -lqnp -e 128 -r xenomai-2.5.6-target -o my_rootfs.jffs2 mkfs.jffs2 -lqnp -e 128 -r xenomai-2.6.0-rc5-target -o my_rootfs.jffs2 sudo mv my_rootfs.jffs2 /tftpboot sudo chown nobody /tftpboot/ -R ; sudo chmod 777 /tftpboot/ -R ###################################################### ############# ON MINI2440 ############################ ###################################################### nand bad nand scrub nand createbbt dynpart dynenv set u-boot_env saveenv setenv bootfile u-boot.bin tftp nand write 0x31000000 u-boot setenv bootfile uImage tftp nand write 0x31000000 kernel setenv bootfile my_rootfs.jffs2 tftp nand erase rootfs nand write.jffs2 0x31000000 rootfs ${filesize} reset --- cut here --- cheers, -- LS