2010-02-10 08:37:09     threads ?

Document created by Aaronwu Employee on Sep 25, 2013
Version 1Show Document
  • View in full screen mode

2010-02-10 08:37:09     threads ?

Filip Vanalme (BELGIUM)

Message: 85913   

 

Hi,

 

I have a simple configuration program that I have to run from U-boot prompt. Just a simple menu-structure that gets console input with getc().

Now, I have to trigger a watchdog from time to time to prevent it from resetting the board. In a normal application I would do that with a separate thread, but is something similar possible in u-boot ? As it is now, my code waits at each getc() for user input, preventing me from triggering the watchdog. What's the best way to tackle this ? (are there other functions to read console input that return immediately if there's no input ?)

TranslateQuoteReplyEditDelete

 

 

2010-02-10 10:00:59     Re: threads ?

Robin Getz (UNITED STATES)

Message: 85914   

 

Filip:

 

What version of U-Boot are you using? newer versions poke the watchdog (via WATCHDOG_RESET()) in serial_tstc(), which is used serial_getc().

 

-Robin

QuoteReplyEditDelete

 

 

2010-02-10 10:11:30     Re: threads ?

Filip Vanalme (BELGIUM)

Message: 85915   

 

I'm using the latest U-boot release.

I'm not using the watchdog timer from the Blackfin. Instead, I have to write to a register that is mapped in async memory bank 2.

TranslateQuoteReplyEditDelete

 

 

2010-02-10 10:24:30     Re: threads ?

Robin Getz (UNITED STATES)

Message: 85916   

 

Filip:

 

So, then make sure that you have CONFIG_HW_WATCHDOG not defined, but CONFIG_WATCHDOG defined, (look in the logic in include/watchdog.h) - and define your own 'void watchdog_reset(void);' somewhere (in your board directory).

 

-Robin

QuoteReplyEditDelete

 

 

2010-02-10 11:18:52     Re: threads ?

Filip Vanalme (BELGIUM)

Message: 85920   

 

In my boards header file, I defined CONFIG_WATCHDOG. In it's source file (in the board directory), I defined a watchdog_reset function. Compilation was OK. In the routine, for now, I just put a printf with some text. I would expect to see the text from time to time on the console, but it doesn't show up.

I assume my watchdog function will be called from time to time. Do I have to define that delay somewhere ?

 

Other issue :

In my config program, the user can set the date/time in an external rtc device via i2c. It worked well with my former version of the U-boot (2008). However, now I see that I don't get the SCL clock anymore. SDA looks OK, but no SCL. SDA is on PF4 of the BF, SCL on PF5. Do I have to config something to make i2c work ? In my boards header file I defined PF_SCL as PF5 and PF_SDA as PF4. I took over the other i2c related things from bf561_ezkit.h.

TranslateQuoteReplyEditDelete

 

 

2010-02-10 16:48:36     Re: threads ?

Mike Frysinger (UNITED STATES)

Message: 85928   

 

did you `make clean` first ?  your watchdog_reset() func should be called everytime you send a char over the serial console.

 

as for watchdog_init(), i guess lib_blackfin/board.c needs to be updated to call it just like the lib_{ppc,m68k,sh}/board.c files are doing now.

QuoteReplyEditDelete

 

 

2010-02-11 04:38:44     Re: threads ?

Filip Vanalme (BELGIUM)

Message: 85975   

 

Any idea why I don't get my i2c SCL ?

TranslateQuoteReplyEditDelete

 

 

2010-02-11 04:46:22     Re: threads ?

Mike Frysinger (UNITED STATES)

Message: 85977   

 

not really.  i cant say i've ever worked with the GPIO bitbanging I2C code in u-boot ... only the Blackfin on-chip TWI code.

 

afaik, none of this code is in the Blackfin-specific part which means i havent looked at or touched it before.

QuoteReplyEditDelete

 

 

2010-02-11 05:06:37     Re: threads ?

Filip Vanalme (BELGIUM)

Message: 85978   

 

found the problem : I had to add the init_func_i2c() to my board.c file. And make the global init function from that file call this i2c init function.

TranslateQuoteReplyEditDelete

 

 

2010-02-11 05:10:26     Re: threads ?

Mike Frysinger (UNITED STATES)

Message: 85979   

 

hmm, perhaps lib_blackfin/board.c should also be calling init_func_i2c like ppc/m68k/arm.  i'll have to ask on the upstream mailing list.

QuoteReplyEditDelete

 

 

2010-02-11 05:16:51     Re: threads ?

Filip Vanalme (BELGIUM)

Message: 85982   

 

Hi Mike,

 

Still a question concerning i2c, but from application point of view. In U-boot it works fine now, but not in my application. I wonder : where do I have to set which PF's will be used for clock and data ? In the Kernel config, I enabled the I2C driver, but as far as I can see, there's no parameter to set this. Does that information has to come from U-boot ?

TranslateQuoteReplyEditDelete

 

 

2010-02-11 05:24:44     Re: threads ?

Mike Frysinger (UNITED STATES)

Message: 85983   

 

i dont know what driver you're talking about.  assuming you mean "GPIO-based bitbanging I2C", then like any normal driver, you express the platform-specific settings in your board resources file.  a cursory check of the bf533-stamp resources as well as busses/i2c-gpio.c seems to indicate this statement is true.

QuoteReplyEditDelete

 

 

2010-02-11 10:28:53     Re: threads ?

Robin Getz (UNITED STATES)

Message: 85987   

 

Filip:

 

This works for me...

 

Index: include/configs/bf537-stamp.h

===================================================================

--- include/configs/bf537-stamp.h       (revision 2234)

+++ include/configs/bf537-stamp.h       (working copy)

@@ -14,6 +14,8 @@

#define CONFIG_BFIN_CPU             bf537-0.2

#define CONFIG_BFIN_BOOT_MODE       BFIN_BOOT_BYPASS

 

+#define CONFIG_WATCHDOG

 

/*

  * Clock Settings

Index: board/bf537-stamp/bf537-stamp.c

===================================================================

--- board/bf537-stamp/bf537-stamp.c     (revision 2234)

+++ board/bf537-stamp/bf537-stamp.c     (working copy)

@@ -36,6 +36,15 @@

 

DECLARE_GLOBAL_DATA_PTR;

 

+void watchdog_reset(void)

+{

+       volatile int *p  = 0;

+       int t;

+       t = *p;

+       t++;

+       *p = t;

+}

+

int checkboard(void)

{

        printf("Board: ADI BF537 stamp board\n");

 

 

You can't use print or serial anything in the watchdog_reset - otherwise things don't boot (or at least it didn't for me) - a relocated function gets called before relocation occurs...

 

but - I can see zero increasing...

 

bfin> md.l 0 1

00000000: 1716e30c    ....

bfin> md.l 0 1

00000000: 177f95a4    ....

bfin> md.l 0 1

00000000: 17e2136e    n...

 

 

So - I think Mike is correct - just a 'make clean' should fix things up.

 

-Robin

QuoteReplyEditDelete

 

 

2010-02-11 20:12:24     Re: threads ?

Mike Frysinger (UNITED STATES)

Message: 85998   

 

on second thought, i dont think the common code should always call i2c_init().  the i2c hardware should only be called when needed.  in the default boot path, it isnt needed, so it shouldnt be called.  if you have code that needs to do i2c stuff, you have to call i2c_init() yourself.

Attachments

    Outcomes