Seeed-Studio / wiki-documents

https://wiki.seeedstudio.com/Getting_Started Seeed Studio Wiki source code
https://wiki.seeedstudio.com/Getting_Started
GNU General Public License v3.0
111 stars 130 forks source link

ReComputer & ReServer Industrial GPIO Instruction [Jetpack 6] #1348

Closed sniper7kills closed 1 month ago

sniper7kills commented 3 months ago

I am currently attempting to get a 5G card working in the ReComputer Industrial 4012 using Jetpack 6.0

The provided commands in the wiki are:

sudo su 
cd /sys/class/gpio
echo 309 > export 
cd gpio309
echo out > direction
echo 0 > value

cd..
echo 341 > export 
cd PEE.02
echo out > direction
echo 1 > value

cd..
echo 330 > export 
cd PCC.02
echo out > direction
echo 0 > value

It appears that in Jetpack 6.0 the use of /sys/class/gpio is depreciated; and one must use libgpio.

I tried to duplicate the instructions using the following commands:

sudo gpioset gpiochip2 9=0
sudo gpioset gpiochip1 25=1
sudo gpioset gpiochip1 14=0

However after running these commands / a reboot I can not see the 5G card when running lspci or lsusb.

I would appreciate any guidance that can be provided; and would love to open a PR to reflect any progress I am able to make.

github-actions[bot] commented 3 months ago

👋 @sniper7kills

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.

yuyoujiang commented 2 months ago

Hi sniper7kills, The new jp6 image has been updated during the wiki. You can try again with new jp6 image.

sniper7kills commented 2 months ago

Hi sniper7kills, The new jp6 image has been updated during the wiki. You can try again with new jp6 image.

Can you confirm? I still only see the JP6 Image from 2024-06-14.

Additionally; the same thing exists in the JP6 ReServer Industrial image dated 2024-07-03.

sniper7kills commented 2 months ago

Doing additional testing on my ReServer Industrial; I was able to compile the following C program.

#include <stdio.h>
#include <stdlib.h>
#include <gpiod.h>
#include <unistd.h>
#include <signal.h>

#define CONSUMER "gpio-control"

struct gpiod_chip *chip0, *chip1, *chip2;
struct gpiod_line *line309, *line315, *line329, *line330, *line341;

volatile sig_atomic_t stop = 0;

void inthand(int signum) {
    stop = 1;
}

void setup_gpio() {
    chip0 = gpiod_chip_open("/dev/gpiochip0");
    chip1 = gpiod_chip_open("/dev/gpiochip1");
    chip2 = gpiod_chip_open("/dev/gpiochip2");

    if (!chip0 || !chip1 || !chip2) {
        perror("Open chip failed");
        exit(1);
    }

    line309 = gpiod_chip_get_line(chip2, 9); // M2B_PCI2_rst
    line315 = gpiod_chip_get_line(chip2, 15); // PSE_PWR_EN
    line329 = gpiod_chip_get_line(chip1, 13); // PCC.01 (LED)
    line330 = gpiod_chip_get_line(chip1, 14); // PCC.02
    line341 = gpiod_chip_get_line(chip1, 25); // PEE.02

    if (!line309 || !line315 || !line329 || !line330 || !line341) {
        perror("Get line failed");
        exit(1);
    }

    gpiod_line_request_output(line309, CONSUMER, 0);
    gpiod_line_request_output(line315, CONSUMER, 0);
    gpiod_line_request_output(line329, CONSUMER, 0);
    gpiod_line_request_output(line330, CONSUMER, 0);
    gpiod_line_request_output(line341, CONSUMER, 0);
}

void enable_m2_slot() {
    gpiod_line_set_value(line309, 0);
    gpiod_line_set_value(line341, 1);
    gpiod_line_set_value(line330, 0);
    printf("M2 slot enabled for 5G card\n");
}

void enable_poe() {
    gpiod_line_set_value(line315, 1);
    printf("PoE enabled on eth1-4\n");
}

void flash_led() {
    printf("Flashing LED on front panel. Press Ctrl+C to stop.\n");
    while (!stop) {
        gpiod_line_set_value(line329, 1);
        usleep(500000);
        gpiod_line_set_value(line329, 0);
        usleep(500000);
    }
    printf("LED flashing stopped\n");
}

void cleanup() {
    gpiod_line_release(line309);
    gpiod_line_release(line315);
    gpiod_line_release(line329);
    gpiod_line_release(line330);
    gpiod_line_release(line341);

    gpiod_chip_close(chip0);
    gpiod_chip_close(chip1);
    gpiod_chip_close(chip2);
}

int main() {
    signal(SIGINT, inthand);

    setup_gpio();
    enable_m2_slot();
    enable_poe();
    flash_led();
    cleanup();

    return 0;
}

When running on my ReServer Industrial 4012; I don't get any errors; and the green "run" light flashes as expected. But it does not appear that the M.2 slot gets enabled as the LED that is supposed to turn on; doesn't.

yuyoujiang commented 2 months ago

now the download link of reComputer Industrial J4012 should be up to date. 😄 https://github.com/Seeed-Studio/wiki-documents/pull/1437

github-actions[bot] commented 2 months ago

✅ @sniper7kills

This issue is closed, If you have any questions, you can comment and reply.

sniper7kills commented 2 months ago

My apologies for the delay in my response; but I am still facing this issue. (This is a weekend project for me)

/sys/class/gpio still doesn't exist and using GPIOSET or my C program; I am unable to get the M2.B slot to turn on for the 5G card.

Additional research since re-flashing I found the following forum thread: https://forums.developer.nvidia.com/t/how-to-dynamically-set-gpio-in-jetpack-6-0dp/277715/11

Do I need to change any pinmux settings; I just flashed my ReComputer Industrial with the mfi_recomputer-industrial-orin-nx-16g-j201-6.0-36.3.0-2024-07-04.tar.gz file from the WIKI with an md5sum of b20da6a8f6ca1931b00b57f8db229764

bigbearishappy commented 2 months ago

@sniper7kills Hello, Can you check the voltage of those three gpio to find out which gpio is not working properly? I checked the pinctrl code of those three pins. It seems that the pee2 is not configured well. I fixed it and trying to verify if it works fine. I will feedback to you after I finished my test.

bigbearishappy commented 1 month ago

@sniper7kills It's figured out that it's a problem of pinctrl. I have fixed it in ths commit. I tried both JP5 and the latest JP6. It seems that pee2 can't be controlled by gpioset command in both of them. Finally, I can control it with a C program just like you used before.

Here is the details of my program:

#include <gpiod.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
    const char *chipname = "gpiochip1";
    unsigned int line_num = 25;  // GPIO number
    struct gpiod_chip *chip;
    struct gpiod_line *line;
    int ret;

    chip = gpiod_chip_open_by_name(chipname);
    if (!chip) {
        perror("gpiod_chip_open_by_name");
        return -1;
    }

    line = gpiod_chip_get_line(chip, line_num);
    if (!line) {
        perror("gpiod_chip_get_line");
        gpiod_chip_close(chip);
        return -1;
    }

    ret = gpiod_line_request_output(line, "example", 0);
    if (ret < 0) {
        perror("gpiod_line_request_output");
        gpiod_chip_close(chip);
        return -1;
    }

    gpiod_line_set_value(line, 1);
    sleep(2);
    gpiod_line_set_value(line, 0);
    sleep(2);
    gpiod_line_set_value(line, 1);
    sleep(2);

    gpiod_line_release(line);

    gpiod_chip_close(chip);

    return 0;
}

compile details:

sudo apt install libgpiod-dev
gcc pee2_test.c -o pee2_test -lgpiod
./pee2_test

We will release a new version of system image after we tested it. Or you can reflash your device by following the steps in seeed's Llinux_for_Tegra.

I hope this can help you~

sniper7kills commented 1 month ago

@bigbearishappy Thank you; I tried flashing using the instructions in source; but ran into an issue when booting about a partition not being able to be mounted. I'll simply wait for the new official image to be released.

bigbearishappy commented 1 month ago

OK, we will feedback to you after the new image have been uploaded.~

yuyoujiang commented 1 month ago

The new download link of BSP has updated. https://github.com/Seeed-Studio/wiki-documents/pull/1538

github-actions[bot] commented 1 month ago

✅ @sniper7kills

This issue is closed, If you have any questions, you can comment and reply.