On Tue, 25 May 2021 12:55:32 -0700, in gmane.comp.hardware.beagleboard.user
"John Dammeyer" <johnd-5o6ditlojsohvde0pjs...@public.gmane.org> wrote:


>My understanding is both systems place the variables on the heap.  Only the 
>small micro-controllers with limited stack space (recall some of the PIC16 
>series had a 2 word call stack).  Other systems in the micro-controller area 
>might limit the stack to 256  bytes due to paging schema.

        Unless things have changed in the last decade or two, the normal
behavior of variables defined within a C function is that they were
allocated on the stack. I believe to get them into the heap or BSS space
required them to be declared "static"... Or to use malloc() (and kin) to
allocate the structure space from the heap (I think C++ "new" is equivalent
to a heap allocation).

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwi_n8HplubwAhUEH80KHTvaDnMQFnoECCgQAA&url=https%3A%2F%2Fwww.seas.upenn.edu%2F~cit593%2Fcit593f09%2Flectures%2Fstructs.pdf&usg=AOvVaw1TWuW67QkVCNXBNHnhbVan
"""
We define a variable using our new data type as follows:

struct w_type day;

Memory is now allocated (on stack), and we can access
individual fields of this variable
"""

Or http://www.avabodh.com/cin/structure.html which has a sample of assembly
output, which sure looks like stack-relative access to me...

> 
>The record (struct) is essentially the same in C or Pascal.
>  spi_ioc_transfer = record
>    tx_buf: UInt64;
>    rx_buf: UInt64;
>    len: LongWord;
>    speed_hz: LongWord;
>    delay_usecs: Word;
>    bits_per_word: Byte;
>    cs_change: Byte;
>    pad: LongWord;
>  end;

        Something else to consider -- alignment. C compilers may add padding
between elements to match some architecture idea of ease-of-access (on a
four-byte alignment, a single byte/char field will have three bytes of
padding added to put following data on a 4-byte increment). cf the avabodh
page.


>BTW.  For the Pi to make this work I have to either run it with sudo from the 
>command line or run Lazarus with sudo.  The help everyone provided on the 
>Beagle  to make my user part of the gpio group means the code can run and be 
>debugged from within the IDE.

        Sounds like the R-Pi may not have set the same group memberships.
Though mine seems to have gpio and spi set...

pi@rpi3bplus-1:~$ groups
pi adm dialout cdrom sudo audio video plugdev games users input netdev
lpadmin gpio i2c spi
pi@rpi3bplus-1:~$



-- 
Dennis L Bieber

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/ra9rag5p83r4p3kgl8bmt19u9asiipd5b9%404ax.com.

Reply via email to