Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BeaglePlay] Wrong hostname on beagleplay #6

Open
microhobby opened this issue Aug 11, 2023 · 4 comments
Open

[BeaglePlay] Wrong hostname on beagleplay #6

microhobby opened this issue Aug 11, 2023 · 4 comments
Assignees
Labels
beagleplay bug Something isn't working
Milestone

Comments

@microhobby
Copy link
Contributor

image_720

This beagleplay-recovery-mode does not sounds correct. We need to investigate and get the actual serial number instead, as all the other models.

@microhobby microhobby added bug Something isn't working beagleplay labels Aug 11, 2023
@charles2910
Copy link

I'll leave things here as an investigation log :-)

Things related to hostname happens in meta-toradex-bsp-common/recipes-core/set-hostname. There we have the sethostname file with the following contents:

#!/bin/sh
if [ ! -f /proc/device-tree/serial-number ]; then
    serial="recovery-mode"
else
    serial=$(tr -d '\0' </proc/device-tree/serial-number)

    #if serial number is empty we append no-serial-number string
    if [ -z "$serial" -a "$serial" != " "  ]; then
        serial="no-serial-number"
    fi
fi

hostname=@@MACHINE@@"-"${serial}

if [ -f /usr/bin/hostnamectl ]; then
    /usr/bin/hostnamectl set-hostname ${hostname}
else
    hostname ${hostname}
fi

So, we need to get the correct serial number for it wherever beagleplay make it available for us

@charles2910
Copy link

There is a project whose goal is to get the serial of various boards. It's called boardid. It supports reading beagleplay serial and also gives us a hint on how to get it:

static void extract_beagleplay_serial(const unsigned char *data, char *buffer)
{
    // BeaglePlay EEPROM Layout
    // See https://git.beagleboard.org/beagleplay/beagleplay/-/blob/main/EEPROM.md
    //
    // Multibyte integers are little endian
    //
    // Offset Size Contents
    // 0      4    Header (AA,55,33,EE)
    // 4      1    Type (1)
    // 5      2    Payload size (0x37)
    // 7      1    BRD_INFO (0x10)
    // 8      2    0x2e
    // 10     16   Board_Name (BEAGLEPLAY-A0-\0\0)
    // 26     2    Design_Rev (0x02)
    // 28     4    PROC_Nbr
    // ...
    // 40     2    VendorID (ASCII "64")
    // 42     2    Build_Week (ASCII)
    // 44     2    Build_Year (ASCII)
    // 46     6    Board_ID (ASCII)
    // 52     4    Serial_Nbr (ASCII "SSSS")
    //
    // The serial number is set to all S's, so use the Board_ID.
    // The Board_ID is the last 6 digits on the QRCode sticker.
    // E.g., BPVA2022510000123 where 2022 is the Build_Year and 51 is the
    // Build_Week.

    const int digits = 6;
    memcpy(buffer, &data[46], digits);
    buffer[digits] = 0;
}

// Read the serial number from the Beaglebone's EEPROM
bool beagleboneblack_id(const struct boardid_options *options, char *buffer)
{
    // Try both the Linux 3.8 and 4.1 EEPROM locations
    FILE *fp = fopen_helper("/sys/bus/i2c/devices/0-0050/eeprom", "r");
    if (!fp)
        fp = fopen_helper("/sys/bus/i2c/devices/0-0050/at24-0/nvmem", "r");

    if (!fp)
        return 0;

    unsigned char data[56];
    if (fread(data, 1, sizeof(data), fp) != sizeof(data)) {
        fclose(fp);
        return false;
    }

    fclose(fp);

    // Verify that the EEPROM was programmed
    if (data[0] != 0xaa ||
            data[1] != 0x55 ||
            data[2] != 0x33 ||
            data[3] != 0xee)
        return false;

    // BeaglePlay has a non-ASCII 1 at offset 4 and follow it with the data
    // size. Beagleboards should have ASCII letters there.
    if (data[4] == 0x01 && data[5] == 0x37 && data[6] == 0)
        extract_beagleplay_serial(data, buffer);
    else
        extract_bbb_serial(data, buffer);

    return true;
}

We can't even get from uboot env, it's all set to SSSS

@charles2910
Copy link

This command does the trick, but it's a pretty poor solution in my opinion:

tail -c +47 /sys/bus/i2c/devices/0-0050/eeprom | head -c 6

@microhobby do you have any recommendations on how to proceed at this point?

@microhobby
Copy link
Contributor Author

@charles2910 did you think that there is some issue on u-boot side? I mean, u-boot should fill the env with the serial, or no?

@microhobby microhobby changed the title Wrong hostname on beagleplay [BeaglePlay] Wrong hostname on beagleplay Oct 27, 2023
@microhobby microhobby added this to the v6.4.0 milestone Oct 27, 2023
leonheldattoradex pushed a commit to leonheldattoradex/meta-common-torizon that referenced this issue Feb 5, 2024
…-support

kernel-devsrc.bbappend: support arm64 kernel 5.19+ on Kirkstone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beagleplay bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants