# Boot from MMC1 on Microchip SAMA5d27-SOM1-EK1

**URL:** https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314
**Category:** General Discussions
**Created:** [October 15, 2019, 3:57pm UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314 "2019-10-15T15:57:22Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![andrewtimoshenko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/andrewtimoshenko/32/406_2.png) [@andrewtimoshenko](https://hub.mender.io/u/andrewtimoshenko)
#### Post date: [October 15, 2019, 3:57pm UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314/1 "2019-10-15T15:57:22Z")

</div>

Hi,

By default an image is built for booting from MMC0 . How can I change boot source to MMC1 (change configuration before compiling for at91bootstrap and u-boot-at91)?

I’ve changed boot source of _at91bootstrap_ in _meta-atmel/conf/machine/sama5d27-som1-ek-sd.conf_ file and it’s ok - device boots from microSD card:

> ```
> AT91Bootstrap 3.8.13 (Tue 15 Oct 2019 01:58:37 PM UTC)
> 
> SDHC: fix in place for SAMA5D2 SoM VDDSDMMC over-consumption errata
> SD/MMC: Image: Read file u-boot.bin to 0x23f00000
> MMC: ADMA supported
> SD: Card Capacity: High or Extended
> SD: Specification Version 3.0X
> SD/MMC: Done to load image
> <debug_uart>
> 
> U-Boot 2019.04-linux4sam_6.1 (Sep 24 2019 - 17:09:53 +0000)
> 
> CPU: SAMA5D27 1G bits DDR2 SDRAM
> Crystal frequency: 24 MHz
> CPU clock : 492 MHz
> Master clock : 164 MHz
> DRAM: 128 MiB
> MMC: sdio-host@a0000000: 0, sdio-host@b0000000: 1
> Loading Environment from MMC... *** Warning - No block device, using default environment
> 
> ```

But u-boot still tries to load the environment from MMC0. If I change u-boot configuration in the sama5d27-som1-ek-sd.conf for loading from MMC1 I get the next error (attached log file).

Did the right way I choose for solving this problem (I want to boot the system from MMC1 micro SD card instead MMC0 by default)?  
Could you help me with it?

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [October 15, 2019, 4:01pm UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314/2 "2019-10-15T16:01:01Z")

</div>

You need to update the device that the Mender integration will use. e.g

```auto
MENDER_STORAGE_DEVICE = "/dev/mmcblk1"

```

This should update all the relevant locations, but further integration effort might be necessary but this will get you on the right track.

---

<div class="post-metadata">

### Author: ![andrewtimoshenko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/andrewtimoshenko/32/406_2.png) [@andrewtimoshenko](https://hub.mender.io/u/andrewtimoshenko)
#### Post date: [October 15, 2019, 4:27pm UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314/3 "2019-10-15T16:27:59Z")

</div>

Thanks a lot for a quick reply.

> [@mirzak](#):
>
> MENDER\_STORAGE\_DEVICE = “/dev/mmcblk1”

got it.

But then there is an error:

> include/config\_mender.h:73:5: error: #error CONFIG\_SYS\_MMC\_ENV\_DEV is not the same as MENDER\_UBOOT\_STORAGE\_DEVICE

After changing CONFIG\_SYS\_MMC\_ENV\_DEV there is the same error.

I update these variables in the local.conf file:

> MENDER\_STORAGE\_DEVICE = “/dev/mmcblk1”  
> CONFIG\_SYS\_MMC\_ENV\_DEV = “/dev/mmcblk1”

Any ideas? 🙂

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [October 15, 2019, 4:52pm UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314/4 "2019-10-15T16:52:43Z")

</div>

> [@andrewtimoshenko](#):
>
> CONFIG\_SYS\_MMC\_ENV\_DEV

This is an U-Boot variable and this should automatically be set based on value in `MENDER_STORAGE_DEVICE`. But I am not familiar in this specific board integration and maybe @jorisoffouga might have some additional insights as he has done the integration and might have a board 🙂

---

<div class="post-metadata">

### Author: ![texierp](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/texierp/32/45_2.png) [@texierp](https://hub.mender.io/u/texierp)
#### Post date: [October 15, 2019, 5:24pm UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314/5 "2019-10-15T17:24:53Z")

</div>

> [@mirzak](#):
>
> But I am not familiar in this specific board integration and maybe @jorisoffouga might have some additional insights as he has done the integration and might have a board 🙂

In fact this is my integration 😉, @jorisoffouga duplicated this integration for the sama5d3.

@andrewtimoshenko, it seems you have to `undef`` CONFIG\_SYS\_MMC\_ENV\_DEV:

> <https://github.com/linux4sam/u-boot-at91/blob/master/include/configs/at91-sama5_common.h#L43>

You can check here for an example:

> <https://github.com/mendersoftware/meta-mender-community/blob/warrior/meta-mender-atmel/recipes-bsp/u-boot/files/0001-ARM-sama5d27_som1_ek-Add-support-to-mender.patch#L51>

In any case, it seems we have to create a specific patch for this ‘configuration’ with the right defconfig:

> <https://github.com/linux4sam/u-boot-at91/blob/cabd17a06e9ab95fe58e6366b1865ee0bed62dbe/configs/sama5d27_som1_ek_mmc1_defconfig#L1>

---

<div class="post-metadata">

### Author: ![andrewtimoshenko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/andrewtimoshenko/32/406_2.png) [@andrewtimoshenko](https://hub.mender.io/u/andrewtimoshenko)
#### Post date: [October 16, 2019, 12:46pm UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314/6 "2019-10-16T12:46:20Z")

</div>

Hey guys,

@texierp @mirzak

Thanks a lot for your help.

If someone wants to boot sama5d27 and Mender from microSD, here is a brief manual:

1. Add to your local.conf file the line:

```auto
MENDER_STORAGE_DEVICE = "/dev/mmcblk1"

```

1. Add to meta-atmel/conf/machine/sama5d27-som1-ek-sd.conf for a at91bootstrap booting from MMC1:

```auto
AT91BOOTSTRAP_TARGET ?= "${AT91BOOTSTRAP_MACHINE}sd1_uboot_defconfig"

```

If you do not, at91bootstrap will still boot from MMC0.

1. Undefine CONFIG\_SYS\_MMC\_ENV\_DEV in the include/configs/at91-sama5\_common.h file of the u-boot-at91:

```auto
From b51c78c57b95d3074c819ab2257f16dafddaec8c Mon Sep 17 00:00:00 2001
From: andrewtimoshenko <andrewtimoshenko@klika-tech.com>
Date: Wed, 16 Oct 2019 14:34:27 +0300
Subject: [PATCH] Booting from MMC1 microSD

---
 include/configs/at91-sama5_common.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/at91-sama5_common.h b/include/configs/at91-sama5_common.h
index fc46540a10..1af5dbc02d 100644
--- a/include/configs/at91-sama5_common.h
+++ b/include/configs/at91-sama5_common.h
@@ -41,6 +41,7 @@
 #define CONFIG_ENV_OFFSET 0x2000
 #define CONFIG_ENV_SIZE 0x1000
 #define CONFIG_SYS_MMC_ENV_DEV 0
+#undef CONFIG_SYS_MMC_ENV_DEV
 #else
 /* u-boot env in sd/mmc card */
 #define CONFIG_ENV_SIZE 0x4000

```

1. And keep on rocking 🙂

My build configuration:

```auto
BB_VERSION = "1.40.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "arm-poky-linux-gnueabi"
MACHINE = "sama5d27-som1-ek-sd"
DISTRO = "poky-atmel"
DISTRO_VERSION = "2.6.3"
TUNE_FEATURES = "arm armv7a vfp thumb neon callconvention-hard cortexa5"
TARGET_FPU = "hard"
meta                 
meta-poky            
meta-yocto-bsp = "HEAD:e6949336479e611a142834b6d9241514cbaeaf80"
meta-oe              
meta-python          
meta-networking = "thud:9b3b907f30b0d5b92d58c7e68289184fda733d3e"
meta-mender-atmel = "HEAD:c2f777bdccba7e8c281fdb520cde98b301ac7acd"
meta-mender-core     
meta-mender-demo = "thud:352cd81fe4dd6e44ba0819da1d8e189109e805e6"
meta-iot-cloud = "feature/bsp_porting_RLPR-64:c4b12f6ca0ca5a5aa144c543a7464c921fb49efb"
meta-atmel = "thud:d6773b92ae0805d941493a2950fd167d7bdfff1b"
meta-qt5 = "thud:1520d5b2b2beec5e1c3209d3178219e93ef08bca"

```

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [October 17, 2019, 6:19am UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314/7 "2019-10-17T06:19:24Z")

</div>

Thanks for sharing @andrewtimoshenko. Maybe this is something that can be integrated in to [https://github.com/mendersoftware/meta-mender-community/tree/thud/meta-mender-atmel](https://github.com/mendersoftware/meta-mender-community/tree/thud/meta-mender-atmel)

---

<div class="post-metadata">

### Author: ![andrewtimoshenko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/andrewtimoshenko/32/406_2.png) [@andrewtimoshenko](https://hub.mender.io/u/andrewtimoshenko)
#### Post date: [October 23, 2019, 8:59am UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314/8 "2019-10-23T08:59:38Z")

</div>

Hi guys,  
I want to add a new flexcom0 node for UART supporting to the device tree of at91-sama5d27\_som1\_ek board. I’ve described this node in the arch/arm/boot/dts/at91-sama5d27\_som1\_ek.dts file, but my changes are not included in the sdimage.

My flexcome0 UART node:

```auto
flx0: flexcom@f8034000 {
    compatible = "atmel,sama5d2-flexcom";
    reg = < 0xf8034000 0x200 >;
    clocks = < 0x51 >;
    #address-cells = < 0x01 >;
    #size-cells = < 0x01 >;
    ranges = < 0x00 0xf8034000 0x800 >;
    status = "okay";
    atmel,flexcom-mode = < 0x01 >;
    phandle = < 0xaa >;

    serial@200 {
        compatible = "atmel,at91sam9260-usart";
        reg = < 0x200 0x200 >;
        interrupts = < 0x13 0x04 0x07 >;
        clocks = < 0x51 >;
        clock-names = "usart";
        atmel,use-dma-rx;
        atmel,use-dma-tx;
        dmas = < 0x39 0xb004000 0x39 0xc004000 >;
        dma-names = "tx\0rx";
        pinctrl-names = "default";
        pinctrl-0 = < 0x52 >;
        atmel,fifo-size = < 0x20 >;
        status = "okay";
        phandle = < 0xab >;
    };

```

Is there another way how to include new nodes to the device tree? Could you provide some examples for adding nodes with dt-overlay, perhaps it can be an alternative way for device tree editing?

---

<div class="post-metadata">

### Author: ![texierp](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/texierp/32/45_2.png) [@texierp](https://hub.mender.io/u/texierp)
#### Post date: [October 24, 2019, 9:35am UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314/9 "2019-10-24T09:35:12Z")

</div>

Hi @andrewtimoshenko,

It is not related to Mender, but anyway, in fact you have to create a patch into your meta layer to include this specific node in your DTS file.

It means a specific ‘bbappend’ of linux-at91 (like [this](https://github.com/MOVE-II/meta-cdh/commit/1553841126f0b4be8c838a76baeca6dc0346b029))

---

<div class="post-metadata">

### Author: ![andrewtimoshenko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/andrewtimoshenko/32/406_2.png) [@andrewtimoshenko](https://hub.mender.io/u/andrewtimoshenko)
#### Post date: [October 24, 2019, 3:37pm UTC](https://hub.mender.io/t/boot-from-mmc1-on-microchip-sama5d27-som1-ek1/2314/10 "2019-10-24T15:37:24Z")

</div>

Thank you anyway @texierp .  
Just needs to remember about the cleaning of kernel build directory periodically 🙂
