First my Assignment:
I'm a beginner with BSD and low level peripherals like GPIO etc. and I need to toggle Raspberry GPIO Pins from a C programm on BSD.
I am Using this BSD Image
i took from here: FreeBSD - easiest way to install on my RPi?
and try toggling the GPIO Pins, respectively trying to set a Pin to high by calling MMAP to access the Registers directly form C code.
I took the addressesfrom the BCM2835 Datasheet, Cahpter 1.2.3, page 6 "physical Adresses".
Is my assumption right that it does not matter if I use Raspbian or any other OS - these physical addresses will stay the same, as they are given by the Chip?
I tested my Code as root with Raspbian and it worked fine, i also compiled the Code with gcc in BSD, no errors. The Programm is running as root, the System does not crash or freeze.
As getting a place where i can actually test my programm is hard where i study, i just wanted some feedback please. Are my assuptions correct or did i go horribly wrong somewhere? Eg. Does BSD somehow remap physical memory addresses?(is that possible?) If yes, is there a way to find out how this mapping is done?
Or "should" this work alright in theory?
I really appreciate any help, the assignment is vital to my grade and i am affraid i might have overesteemated myself by choosing this assignment^^.
Many thanks in advance for help!
/dev/mem
andmmap()
) to access hardware registers on the raspberry pi, and your code works under linux but fails without error on FreeBSD. Include a cut n' paste of some relevant parts of that code. – goldilocks Jan 23 '14 at 19:00