GPIO Read (libtock-rs)

21 views
Skip to first unread message

James H

unread,
Aug 4, 2021, 12:26:48 AM8/4/21
to Tock Embedded OS Development Discussion
I am trying to read a GPIO using the example, gpio_read.rs, from the rust userland library (libtock-rs).   The read always returns low, even when the GPIO bit is set. Is there a way I can read the GPIO bit from the capsule or the the main.rs?  I have verified the bit is set via gdb  but, the application always returns 'Low'.

Configuration:
Tock: Release 1.6 RC1
The platform is based on the Imix board.  I have  limited my platform struct to include only the console, gpio, and kernel drivers.  I copied chips/sam4l/gpio.rs into my platform chips folder.  I modified the BASE_ADDRESS in chips/myboard/gpio.rs to align with the base address of the GPIOs on my platform.  There are no other changes to gpio.rs.  The main.rs was modified to configure Port A bit 0 as a GPIO.
unsafe fn set_pin_primary_functions() {
    //use enclave::gpio::PeripheralFunction::{A, B, C, E};
    use myboard::gpio::PA;

    // Right column: Imix pin name
    // Left  column: SAM4L peripheral function
    PA[00].configure(None); // GPIO pin
}

The gpio was created in the reset_handler().

let gpio = GpioComponent::new(
        board_kernel,
        components::gpio_component_helper!(
            myboard::gpio::GPIOPin,
            0 => &myboard::gpio::PA[0],
        ),
    )
    .finalize(components::gpio_component_buf!(myboard::gpio::GPIOPin));

I enabled the trace_syscalls in kernel/src/config.rs and I can see the gpio driver call is successfully making the kernel call.  I have verified the GPIO bit is set by dumping the memory location in gdb. What am I missing?  Any help or pointers is appreciated.

Regards,
James.

Hudson Randal Ayers

unread,
Aug 22, 2021, 2:26:06 PM8/22/21
to James H, Tock Embedded OS Development Discussion
Hi James,

Sorry this message seems to have fallen through the cracks. Reading through your description of the issue, it is not clear to me what the problem may be -- last I checked, libtock-rs worked fine on the Imix board for reading GPIO pins.

When you say "verified the GPIO bit is set by dumping the memory location in gdb", what do you mean by that? That you verified the actual memory-mapped bit corresponding to that GPIO pin is set? If so, I would recommend adding some debugging to the kernel code -- i.e. check that the chip driver does in fact read the bit as set by printing out the value it passes in the callback.

Best,
Hudson

From: tock...@googlegroups.com <tock...@googlegroups.com> on behalf of James H <vher...@gmail.com>
Sent: Tuesday, August 3, 2021 9:26 PM
To: Tock Embedded OS Development Discussion <tock...@googlegroups.com>
Subject: [tock-dev] GPIO Read (libtock-rs)
 
--
You received this message because you are subscribed to the Google Groups "Tock Embedded OS Development Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tock-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tock-dev/17c6c44a-d9cd-442a-b6a5-bf5ac8c10aecn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages