0

I am making a project which send out 40khz signal from antenna. I have found the signal is not too accurate so I have decided to try a real-time kernel.

I run Raspbian Jessie on my Raspberry-Pi 2B. After clean install, the script run without any problem. bcm2835_delayMicroseconds could be run.

I follow this tutorial http://www.frank-durr.de/?p=203 compiled and installed the RT kernal. However, the script could no longer be run successfully. After showing "HIGH SLEEP", and it is held up.

This is the code snippet:

fprintf(stdout , "HIGH\n");
bcm2835_gpio_write(PIN, HIGH);
fprintf(stdout , "SLEEP\n");
bcm2835_delayMicroseconds(12);
fprintf(stdout , "LOW\n");
bcm2835_gpio_write(PIN, LOW);
fprintf(stdout , "SLEEP\n");
bcm2835_delayMicroseconds(12);

Do I miss anything when compiling the kernel?

jopasserat
  • 5,721
  • 4
  • 31
  • 50
ロジャー
  • 347
  • 1
  • 6
  • 16
  • Can you try writing a program that does nothing other than delayMicroseconds and debug it? – John Zwinck Dec 16 '15 at 11:15
  • Here is someone else reporting almost the same problem (but then it went away on its own): https://groups.google.com/forum/#!topic/bcm2835/ys4aWbllqjo – John Zwinck Dec 16 '15 at 11:16
  • @JohnZwinck I am not familiar with C. How to debug it? Is there any error-log for runtime error? Thanks. – ロジャー Dec 16 '15 at 14:02
  • #include #include #include #include #define PIN RPI_V2_GPIO_P1_07 int main(int argc, char *argv[]){ fprintf(stdout , "START\n"); if( bcm2835_init() < 0 ) { fprintf( stderr, "could not initialize bcm2835\n" ); } fprintf(stdout , "HIGH\n"); bcm2835_gpio_write(PIN, HIGH); fprintf(stdout , "SLEEP\n"); bcm2835_delayMicroseconds(12); fprintf(stdout , "LOW\n"); bcm2835_gpio_write(PIN, LOW); fprintf(stdout , "SLEEP\n"); bcm2835_delayMicroseconds(12); fprintf(stdout , "END\n"); } – ロジャー Dec 17 '15 at 04:56
  • I have just written a little script, and it is held up after the first "SLEEP"... – ロジャー Dec 17 '15 at 04:57
  • I have the same problem. However, my LED does blink 4-5 times but then it stops. No error. I wonder if you found a solution? I'm using Rasbian Jessie Lite as well. – KenGey Jan 06 '16 at 21:21
  • In my case the issue was that I was using the same port in my c-code to blink the LED as I setup for the one-wire protocol. Both were using GPIO4. – KenGey Jan 07 '16 at 18:32

2 Answers2

1

To use PREEMPT_RT you just have to:

  • retrieve the configuration of your current kernel
  • retrieve the kernel sources
  • patch the kernel sources with the PREEMPT_RT patch (or obtain an already patched kernel)
  • configure the new kernel as the current kernel (i.e., using make oldconfig)
  • enable full preemtability in kernel config (e.g., by running make menuconfig).
  • compile the kernel in the standard way
  • install the new kernel

Therefore, no particular action is needed.

Then, if performance is still not sufficient, you may want to tune priorities of specific IRQ threads.

From your specific error, it seems that the new kernel has been conpiled with a different configuration than the current kernel (e.g., GPIOs not enabled).

Claudio
  • 10,614
  • 4
  • 31
  • 71
  • Sorry I have forgotten to post the link of the tutorial I am referring to. This is the link http://www.frank-durr.de/?p=203 Do these the steps "make menuconfig zcat config.gz > .config" identical to "make oldconfig"? Thanks for answering. – ロジャー Dec 16 '15 at 14:00
1

I have just seen and remembered this thread. About half year ago, I want to generate 40khz from a Raspberry. But finally I found I am using the wrong tool. I believe Raspberry cannot handle such a task, since it is running an OS. I switched to Arduino, and the problem is solved immediately without any problem. Using the right tool for your task is very important!

ロジャー
  • 347
  • 1
  • 6
  • 16