# Accesing a memory direction using a pointer

**URL:** <https://forums.freertos.org/t/accesing-a-memory-direction-using-a-pointer/22425>\
**Category:** Kernel\
**Tags:** tutorial\
**Created:** [January 26, 2025, 11:18am UTC](https://forums.freertos.org/t/accesing-a-memory-direction-using-a-pointer/22425 "2025-01-26T11:18:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iren](https://avatars.discourse-cdn.com/v4/letter/i/ac91a4/32.png) [@Iren](https://forums.freertos.org/u/Iren)\
**Post date:** [January 26, 2025, 11:18am UTC](https://forums.freertos.org/t/accesing-a-memory-direction-using-a-pointer/22425/1 "2025-01-26T11:18:21Z")

</div>

Hello! I am beginning my first FreeRTOS project, and I have a problem accesing a memory direction.  
I have defined this pointer to a GPIO\_regs struct:

```auto
struct GPIO_regs
{
    volatile uint32_t Data;   
    volatile uint32_t Output;   
    volatile uint32_t Direction;  
};

volatile struct GPIO_regs * const pGPIO_REGS =
        (struct GPIO_regs *)0xFC083000;

```

And I try to access the content of the Direction field:

```auto
pGPIO_REGS->Direction = pGPIO_REGS->Direction |(GPIO_LED0_MASK | GPIO_LED1_MASK |GPIO_LED2_MASK | GPIO_LED3_MASK);

```

But, when executing that code line, the program is terminated and shows this message:

```auto
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.

```

Is there anything wrong in this code? Do I have to change anything in the FreeRTOSConfig.h file to access the memory direction 0xFC083000?

Thank you so much!

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [January 26, 2025, 11:21am UTC](https://forums.freertos.org/t/accesing-a-memory-direction-using-a-pointer/22425/2 "2025-01-26T11:21:16Z")

</div>

Which platform / CPU do you use ?  
SIGSEGV sounds like running the code as Linux application 🤔

---

<div class="post-metadata">

**Author:** ![Iren](https://avatars.discourse-cdn.com/v4/letter/i/ac91a4/32.png) [@Iren](https://forums.freertos.org/u/Iren)\
**Post date:** [January 26, 2025, 11:25am UTC](https://forums.freertos.org/t/accesing-a-memory-direction-using-a-pointer/22425/3 "2025-01-26T11:25:38Z")

</div>

Yes indeed, I am using Eclipse on Ubuntu.

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [January 26, 2025, 11:48am UTC](https://forums.freertos.org/t/accesing-a-memory-direction-using-a-pointer/22425/4 "2025-01-26T11:48:49Z")

</div>

Well, then you can’t simulate accessing a GPIO controller of a very different MCU this way. At least you can’t use/access physical addresses not existing on your Ubuntu box.  
In addition Linux itself doesn’t allow direct access to physical addresses because it uses virtual memory/MMU and kernel/userspace address space split.  
I don’t know what you’re trying to do, but you could use e.g.  
pGPIO\_REGS = (GPIO\_regs \*)malloc( sizeof(GPIO\_regs) );  
to get some accessible memory and initialize the structure accordingly to test/simulate your code up to a certain degree.

---

<div class="post-metadata">

**Author:** ![Iren](https://avatars.discourse-cdn.com/v4/letter/i/ac91a4/32.png) [@Iren](https://forums.freertos.org/u/Iren)\
**Post date:** [January 26, 2025, 7:19pm UTC](https://forums.freertos.org/t/accesing-a-memory-direction-using-a-pointer/22425/5 "2025-01-26T19:19:07Z")

</div>

I understand what the problem is! I will do it the way you suggested, thank you so much!!!
