GPIO base address and GPIO_SET_OFFSET

hi
I am writing assembler code on JETSON NANO that needs to use 40 PINS (for example pin 12)
I tried to search in the documents about GPIO base address and GPIO_SET_OFFSET
But I didn’t find it
Is there a document ?

Example code:
.section .data
gpio_base: .word 0x6000D000 // Replace with the actual base address
gpio_dir_offset: .word 0x00 // Offset for direction register
gpio_set_offset: .word 0x1C // Offset for set register
gpio_clr_offset: .word 0x28 // Offset for clear register

.section .text
.global_start

_start:
// Load base address of GPIO (0x6000D000)
ldr x0, =gpio_base // Load GPIO base address
ldr x1, [x0] // x1 = GPIO base address

// Configure GPIO pin 11 as output
ldr x2, =gpio_dir_offset // Load offset for direction register
add x2, x1, x2 // x2 = address of direction register
ldr x3, [x2] // Load current value of direction register
orr x3, x3, #(1 << 11) // Set bit 11 to configure GPIO pin 11 as output
str x3, [x2] // Store updated value back to direction register

// Set GPIO pin 11 high
ldr x2, =gpio_set_offset // Load offset for set register
add x2, x1, x2 // x2 = address of set register
mov x3, #(1 << 11) // Prepare value to set GPIO pin 11 high
str x3, [x2] // Store value to set register

// Infinite loop to avoid exiting
loops:
wfi // Wait for interrupt
b loop // Branch to loop

When I run the code I get the following error: “Segmentation fault”
From an investigation on the Internet, apparently I get the error because I am trying to access a memory component that I am not authorized to access (even when using SUDO)
I tried to look for the JETSON NANO base address in the documents but without success.

Hi guy.ford.green2pass,

Are you using the devkit or custom board for Jetson Nano?
What’s your Jetpack version in use?

Are you trying to control GPIO through DRA?
Which GPIO would you like to control?

hii
Are you using the devkit or custom board for Jetson Nano? - devkit
What’s your Jetpack version in use? - jetpack - 4.6.5
Are you trying to control GPIO through DRA? - yes
Which GPIO would you like to control? - 40pins - pin number 11

Please refer to Jetson Nano Fast GPIO C++ Example with Direct Memory Access (DMA) - #11 by shgarg for this use case.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.