2008-03-17 20:55:04     using L1 scratch memory

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

2008-03-17 20:55:04     using L1 scratch memory

David Rowe (AUSTRALIA)

Message: 52618    Hi,

 

I am using a BF532 with the data cache enabled so the only L1 data memory I have available is the 4k scratch.

 

1/ I was wondering if there is a malloc function to allocate L1 scratch from a kernel module? I have read this page but could only find L1 mallocs for SRAM A + B:

 

http://docs.blackfin.uclinux.org/doku.php?id=using_l1_memory

 

2/ If there is no "nice" way, is it OK for me to DIY a simple malloc?  By OK I mean is any other part of the kernel using any of the scratch L1 by default?

 

Thanks,

 

David

QuoteReplyEditDelete

 

 

2008-03-17 21:29:59     Re: using L1 scratch memory

Robin Getz (UNITED STATES)

Message: 52619    David:

 

Yes - the kernel uses a little bit of the scratch for some internal housekeeping.

 

Have a look at linux-2.6.x/include/asm-blackfin/l1layout.h

 

-Robin

QuoteReplyEditDelete

 

 

2008-03-17 22:10:15     Re: using L1 scratch memory

Mike Frysinger (UNITED STATES)

Message: 52625    from the kernel, just use l1sram_alloc() / l1sram_free() ... there is nothing exposed to userspace for this

QuoteReplyEditDelete

 

 

2008-03-18 01:52:09     Re: using L1 scratch memory

david wang (CHINA)

Message: 52628   

 

what will happen, if I use static allocation of L1 memory in the kernel, say, by defining an array in kernel like below,

 

char mydata[10240] __attribute__((section(l1.data))) ;

 

when I enable D-CACHE at the same time, will the cache and my data confict?

QuoteReplyEditDelete

 

 

2008-03-18 06:54:31     Re: using L1 scratch memory

Mike Frysinger (UNITED STATES)

Message: 52679    that's really unrelated to this thread, but the kernel does things logically.  all things marked with section attributes are taken away from the dynamic memory pool during kernel init.

 

cache doesnt have anything to do with it as you cant use cached L1 as anything other than cache

QuoteReplyEditDelete

 

 

2008-03-18 10:30:45     Re: using L1 scratch memory

Robin Getz (UNITED STATES)

Message: 52704    Mike:

 

There is a kernel option to reduce the amount of cache you have from 32k to 16k (for those parts that support it), and this extra 16k should get mapped into "normal" L1 data SRAM.

 

-Robin

QuoteReplyEditDelete

 

 

2008-03-18 13:04:16     Re: using L1 scratch memory

Mike Frysinger (UNITED STATES)

Message: 52711    i meant once something is configured as cache, it is cache

QuoteReplyEditDelete

 

 

2008-03-19 02:50:57     Re: using L1 scratch memory

david wang (CHINA)

Message: 52731   

 

Yes, I configured the kernel to use only half of l1-data, it is BANK A to be cache. According to Mike, it 'll not allow to be sram.  But it seems the toolchain didnot report warnings and errors when I trying to alloc data in BANK A again, like below

 

char mydata[10240] __attribute__((section(l1.data))) ; /* in BANK A */

 

So, how does this works ?

QuoteReplyEditDelete

 

 

2008-03-19 03:17:44     Re: using L1 scratch memory

Yi Li (CHINA)

Message: 52735    "

But it seems the toolchain didnot report warnings and errors when I trying to alloc data in BANK A again, like below"

 

Do you mean compile time error/warning or runtime?

At compile time, the toolchain will not give any warning on this. But I think when you try to laod/run the app, it would fail, otherwise it is a bug.

QuoteReplyEditDelete

 

 

2008-03-19 03:23:19     Re: using L1 scratch memory

Mike Frysinger (UNITED STATES)

Message: 52737    that is not what i said ... i said you cannot use the same piece of L1 as both cache and SRAM simultaneously

 

if you configured your part to only use have the cache, then sticking things into .l1.data will work (assuming you dont try to stick too much -- but then you'd get an error)

Attachments

    Outcomes