0

I'm attempting to save the uboot environment to the FAT partition of an mmc device on a CM3 rpi module. The OS has been built in buildroot I can printenv and this shows the inbuilt env in the binary. The saveenv command is recognised, firstly states it's saving to fat and the filename is uboot-env.bin. The file exists and is found but the function bcm2835_transfer_block_pio seems to write nothing and repeatedly spits out fsm 1, hsts 000001. The mmc is selected as dev0 partition1 (0:1) in buildroot. Anyone come across this error and know how to fix it?

Source for mmc driver:

static int bcm2835_transfer_block_pio(struct bcm2835_host *host, bool is_read)
{
    struct mmc_data *data = host->data;
    size_t blksize = data->blocksize;
    int copy_words;
    u32 hsts = 0;
    u32 *buf;

    if (blksize % sizeof(u32))
        return -EINVAL;

    buf = is_read ? (u32 *)data->dest : (u32 *)data->src;

    if (is_read)
        data->dest += blksize;
    else
        data->src += blksize;

    copy_words = blksize / sizeof(u32);

    /*
     * Copy all contents from/to the FIFO as far as it reaches,
     * then wait for it to fill/empty again and rewind.
     */
    while (copy_words) {
        int burst_words, words;
        u32 edm;

        burst_words = min(SDDATA_FIFO_PIO_BURST, copy_words);
        edm = readl(host->ioaddr + SDEDM);
        if (is_read)
            words = edm_fifo_fill(edm);
        else
            words = SDDATA_FIFO_WORDS - edm_fifo_fill(edm);

        if (words < burst_words) {
            int fsm_state = (edm & SDEDM_FSM_MASK);

            if ((is_read &&
                 (fsm_state != SDEDM_FSM_READDATA &&
                  fsm_state != SDEDM_FSM_READWAIT &&
                  fsm_state != SDEDM_FSM_READCRC)) ||
                (!is_read &&
                 (fsm_state != SDEDM_FSM_WRITEDATA &&
                  fsm_state != SDEDM_FSM_WRITESTART1 &&
                  fsm_state != SDEDM_FSM_WRITESTART2))) {
                hsts = readl(host->ioaddr + SDHSTS);
                printf("fsm %x, hsts %08x\n", fsm_state, hsts);

                if (hsts & SDHSTS_ERROR_MASK)
                    break;
            }

            continue;
        } else if (words > copy_words) {
            words = copy_words;
        }

        copy_words -= words;

        /* Copy current chunk to/from the FIFO */
        while (words) {
            if (is_read)
                *(buf++) = readl(host->ioaddr + SDDATA);
            else
                writel(*(buf++), host->ioaddr + SDDATA);
            words--;
        }
    }

    return 0;
}
Chris
  • 367
  • 4
  • 13
  • did you enable driver, CONFIG_MMC_BCM2835=y ? – ntshetty Dec 10 '18 at 03:58
  • The buildroot version is 2018.05 and doesn't have the config you show, however these configs are selected: MMC_BCM2835=y CONFIG_MMC_SDHCI_BCM2835=y mmc list in u-boot shows: mmc@7e202000: 0 (eMMC) sdhci@7e300000: 1 So the interface is working. I can ls when I have selected the dev mmc 0 partition 1/2 e.g.
    ls mmc 0:1 Sorry about the formatting of this comment, it's not playing ball for some reason.
    – Chris Dec 10 '18 at 11:55

0 Answers0