summaryrefslogtreecommitdiff
path: root/recipes-bsp/u-boot
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-bsp/u-boot')
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/config.patch42
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/fix_2_6.patch40
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/fix_net.patch136
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/hide_uboot_version.patch11
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/i2c.patch114
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/kconfig_common.patch65
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/macb.patch54
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt.patch292
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt_flush_console_autoboot.patch43
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/mtpwd.patch300
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/mtr.patch272
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/mtrv1.patch261
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/printeepromcrc.patch56
-rw-r--r--recipes-bsp/u-boot/u-boot-2016.09.01/tftpput.patch28
-rw-r--r--recipes-bsp/u-boot/u-boot.inc316
-rw-r--r--recipes-bsp/u-boot/u-boot_2016.09.01.bb34
16 files changed, 2064 insertions, 0 deletions
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/config.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/config.patch
new file mode 100644
index 0000000..658fdec
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/config.patch
@@ -0,0 +1,42 @@
+diff -Naru old/configs/at91sam9x5ek_nandflash_defconfig new/configs/at91sam9x5ek_nandflash_defconfig
+--- old/configs/at91sam9x5ek_nandflash_defconfig 2019-04-09 18:00:13.342337484 -0500
++++ new/configs/at91sam9x5ek_nandflash_defconfig 2019-04-15 12:06:49.171618119 -0500
+@@ -1,9 +1,9 @@
+ CONFIG_ARM=y
+ CONFIG_ARCH_AT91=y
+ CONFIG_TARGET_AT91SAM9X5EK=y
+-CONFIG_SPL=y
++CONFIG_SPL=n
+ CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9X5,SYS_USE_NANDFLASH"
+-CONFIG_BOOTDELAY=3
++CONFIG_BOOTDELAY=0
+ CONFIG_HUSH_PARSER=y
+ CONFIG_SYS_PROMPT="U-Boot> "
+ CONFIG_CMD_BOOTZ=y
+@@ -12,7 +12,7 @@
+ # CONFIG_CMD_FLASH is not set
+ CONFIG_CMD_MMC=y
+ CONFIG_CMD_SF=y
+-CONFIG_CMD_USB=y
++CONFIG_CMD_USB=n
+ # CONFIG_CMD_FPGA is not set
+ # CONFIG_CMD_SETEXPR is not set
+ CONFIG_CMD_DHCP=y
+@@ -23,3 +23,17 @@
+ CONFIG_USB=y
+ CONFIG_USB_STORAGE=y
+ CONFIG_OF_LIBFDT=y
++
++CONFIG_OF_CONTROL=n
++CONFIG_CMD_TFTPPUT=y
++CONFIG_CMD_FAT=y
++CONFIG_CMD_NAND=y
++CONFIG_CMD_BOOTZ=y
++CONFIG_CMD_MII=y
++CONFIG_CMD_I2C=y
++
++# The config option CONFIG_SILENT_CONSOLE can be used to quiet messages
++# on the console. If the option has been enabled, the output can be
++# silenced by setting the environment variable "silent"
++CONFIG_SILENT_CONSOLE=y
++CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC=y
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/fix_2_6.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/fix_2_6.patch
new file mode 100644
index 0000000..43ca78f
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/fix_2_6.patch
@@ -0,0 +1,40 @@
+From 91314dd05aa6848049501a10266f2cf4e530f904 Mon Sep 17 00:00:00 2001
+From: Serhii Voloshynov <serhii.voloshynov@globallogic.com>
+Date: Fri, 17 Jan 2020 16:47:26 +0200
+Subject: [PATCH] fix compile error in Yocto-2.6
+
+---
+ include/libfdt.h | 4 ++--
+ include/libfdt_env.h | 4 ++--
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/include/libfdt.h b/include/libfdt.h
+index b6a400a..310d571 100644
+--- a/include/libfdt.h
++++ b/include/libfdt.h
+@@ -1,5 +1,5 @@
+-#ifndef _LIBFDT_H
+-#define _LIBFDT_H
++#ifndef LIBFDT_H
++#define LIBFDT_H
+ /*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+diff --git a/include/libfdt_env.h b/include/libfdt_env.h
+index 6c6845f..638ea69 100644
+--- a/include/libfdt_env.h
++++ b/include/libfdt_env.h
+@@ -6,8 +6,8 @@
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
+
+-#ifndef _LIBFDT_ENV_H
+-#define _LIBFDT_ENV_H
++#ifndef LIBFDT_ENV_H
++#define LIBFDT_ENV_H
+
+ #include "compiler.h"
+ #include "linux/types.h"
+--
+2.7.4
+
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/fix_net.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/fix_net.patch
new file mode 100644
index 0000000..3d9a986
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/fix_net.patch
@@ -0,0 +1,136 @@
+From 9436a1e4dfcc7d6f0cbf9511f84c8164e49f23c6 Mon Sep 17 00:00:00 2001
+From: Serhii Voloshynov <serhii.voloshynov@globallogic.com>
+Date: Mon, 10 Feb 2020 13:10:58 +0200
+Subject: [PATCH] based on https://patchwork.ozlabs.org/patch/792238/ Core
+ reason is usage of structures for network headers without packed attribute.
+
+---
+ include/net.h | 14 +++++++-------
+ net/bootp.h | 2 +-
+ net/dns.h | 2 +-
+ net/nfs.h | 2 +-
+ net/sntp.h | 2 +-
+ 5 files changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/include/net.h b/include/net.h
+index 06320c6..60baf6b 100644
+--- a/include/net.h
++++ b/include/net.h
+@@ -296,7 +296,7 @@ struct ethernet_hdr {
+ u8 et_dest[6]; /* Destination node */
+ u8 et_src[6]; /* Source node */
+ u16 et_protlen; /* Protocol or length */
+-};
++} __attribute__((packed));
+
+ /* Ethernet header size */
+ #define ETHER_HDR_SIZE (sizeof(struct ethernet_hdr))
+@@ -314,7 +314,7 @@ struct e802_hdr {
+ u8 et_snap2;
+ u8 et_snap3;
+ u16 et_prot; /* 802 protocol */
+-};
++} __attribute__((packed));
+
+ /* 802 + SNAP + ethernet header size */
+ #define E802_HDR_SIZE (sizeof(struct e802_hdr))
+@@ -328,7 +328,7 @@ struct vlan_ethernet_hdr {
+ u16 vet_vlan_type; /* PROT_VLAN */
+ u16 vet_tag; /* TAG of VLAN */
+ u16 vet_type; /* protocol type */
+-};
++} __attribute__((packed));
+
+ /* VLAN Ethernet header size */
+ #define VLAN_ETHER_HDR_SIZE (sizeof(struct vlan_ethernet_hdr))
+@@ -357,7 +357,7 @@ struct ip_hdr {
+ u16 ip_sum; /* checksum */
+ struct in_addr ip_src; /* Source IP address */
+ struct in_addr ip_dst; /* Destination IP address */
+-};
++} __attribute__((packed));
+
+ #define IP_OFFS 0x1fff /* ip offset *= 8 */
+ #define IP_FLAGS 0xe000 /* first 3 bits */
+@@ -385,7 +385,7 @@ struct ip_udp_hdr {
+ u16 udp_dst; /* UDP destination port */
+ u16 udp_len; /* Length of UDP packet */
+ u16 udp_xsum; /* Checksum */
+-};
++} __attribute__((packed));
+
+ #define IP_UDP_HDR_SIZE (sizeof(struct ip_udp_hdr))
+ #define UDP_HDR_SIZE (IP_UDP_HDR_SIZE - IP_HDR_SIZE)
+@@ -424,7 +424,7 @@ struct arp_hdr {
+ u8 ar_tha[]; /* Target hardware address */
+ u8 ar_tpa[]; /* Target protocol address */
+ #endif /* 0 */
+-};
++} __attribute__((packed));
+
+ #define ARP_HDR_SIZE (8+20) /* Size assuming ethernet */
+
+@@ -459,7 +459,7 @@ struct icmp_hdr {
+ } frag;
+ u8 data[0];
+ } un;
+-};
++} __attribute__((packed));
+
+ #define ICMP_HDR_SIZE (sizeof(struct icmp_hdr))
+ #define IP_ICMP_HDR_SIZE (IP_HDR_SIZE + ICMP_HDR_SIZE)
+diff --git a/net/bootp.h b/net/bootp.h
+index fcb0a64..567340e 100644
+--- a/net/bootp.h
++++ b/net/bootp.h
+@@ -49,7 +49,7 @@ struct bootp_hdr {
+ char bp_sname[64]; /* Server host name */
+ char bp_file[128]; /* Boot file name */
+ char bp_vend[OPT_FIELD_SIZE]; /* Vendor information */
+-};
++} __attribute__((packed));
+
+ #define BOOTP_HDR_SIZE sizeof(struct bootp_hdr)
+
+diff --git a/net/dns.h b/net/dns.h
+index c4e96af..c55a5c1 100644
+--- a/net/dns.h
++++ b/net/dns.h
+@@ -29,7 +29,7 @@ struct header {
+ uint16_t nauth; /* Authority PRs */
+ uint16_t nother; /* Other PRs */
+ unsigned char data[1]; /* Data, variable length */
+-};
++} __attribute__((packed));
+
+ void dns_start(void); /* Begin DNS */
+
+diff --git a/net/nfs.h b/net/nfs.h
+index 45da246..70a1a6d 100644
+--- a/net/nfs.h
++++ b/net/nfs.h
+@@ -79,7 +79,7 @@ struct rpc_t {
+ uint32_t data[NFS_READ_SIZE];
+ } reply;
+ } u;
+-};
++} __attribute__((packed));
+ void nfs_start(void); /* Begin NFS */
+
+
+diff --git a/net/sntp.h b/net/sntp.h
+index 6a9c6bb..c38bcee 100644
+--- a/net/sntp.h
++++ b/net/sntp.h
+@@ -51,7 +51,7 @@ struct sntp_pkt_t {
+ unsigned long long originate_timestamp;
+ unsigned long long receive_timestamp;
+ unsigned long long transmit_timestamp;
+-};
++} __attribute__((packed));
+
+ void sntp_start(void); /* Begin SNTP */
+
+--
+2.7.4
+
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/hide_uboot_version.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/hide_uboot_version.patch
new file mode 100644
index 0000000..a59dcc1
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/hide_uboot_version.patch
@@ -0,0 +1,11 @@
+diff -raNu old/lib/display_options.c new/lib/display_options.c
+--- old/lib/display_options.c 2016-09-19 17:45:12.000000000 +0300
++++ new/lib/display_options.c 2019-02-08 15:40:16.566717983 +0200
+@@ -15,6 +15,7 @@
+
+ int display_options (void)
+ {
++ return 0;
+ #if defined(BUILD_TAG)
+ printf ("\n\n%s, Build: %s\n\n", version_string, BUILD_TAG);
+ #else
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/i2c.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/i2c.patch
new file mode 100644
index 0000000..a5087ea
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/i2c.patch
@@ -0,0 +1,114 @@
+diff -raNu old/include/i2c.h new/include/i2c.h
+--- old/include/i2c.h 2017-04-28 17:26:27.854898005 -0500
++++ new/include/i2c.h 2017-05-01 17:27:32.673437788 -0500
+@@ -17,6 +17,27 @@
+ #ifndef _I2C_H_
+ #define _I2C_H_
+
++#define U_BOOT_I2C_MKENT_COMPLETE(_init, _probe, _read, _write, \
++ _set_speed, _speed, _slaveaddr, _hwadapnr, _name) \
++ { \
++ .init = _init, \
++ .probe = _probe, \
++ .read = _read, \
++ .write = _write, \
++ .set_bus_speed = _set_speed, \
++ .speed = _speed, \
++ .slaveaddr = _slaveaddr, \
++ .init_done = 0, \
++ .hwadapnr = _hwadapnr, \
++ .name = #_name \
++};
++
++#define U_BOOT_I2C_ADAP_COMPLETE(_name, _init, _probe, _read, _write, \
++ _set_speed, _speed, _slaveaddr, _hwadapnr) \
++ ll_entry_declare(struct i2c_adapter, _name, i2c) = \
++ U_BOOT_I2C_MKENT_COMPLETE(_init, _probe, _read, _write, \
++ _set_speed, _speed, _slaveaddr, _hwadapnr, _name);
++
+ /*
+ * For now there are essentially two parts to this file - driver model
+ * here at the top, and the older code below (with CONFIG_SYS_I2C being
+@@ -538,6 +559,26 @@
+ */
+ void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs);
+
++
++struct i2c_adapter {
++ void (*init)(struct i2c_adapter *adap, int speed,
++ int slaveaddr);
++ int (*probe)(struct i2c_adapter *adap, uint8_t chip);
++ int (*read)(struct i2c_adapter *adap, uint8_t chip,
++ uint addr, int alen, uint8_t *buffer,
++ int len);
++ int (*write)(struct i2c_adapter *adap, uint8_t chip,
++ uint addr, int alen, uint8_t *buffer,
++ int len);
++ uint (*set_bus_speed)(struct i2c_adapter *adap,
++ uint speed);
++ int speed;
++ int waitdelay;
++ int slaveaddr;
++ int init_done;
++ int hwadapnr;
++ char *name;
++};
+ #ifndef CONFIG_DM_I2C
+
+ /*
+@@ -578,46 +619,6 @@
+ #define CONFIG_SYS_SPD_BUS_NUM 0
+ #endif
+
+-struct i2c_adapter {
+- void (*init)(struct i2c_adapter *adap, int speed,
+- int slaveaddr);
+- int (*probe)(struct i2c_adapter *adap, uint8_t chip);
+- int (*read)(struct i2c_adapter *adap, uint8_t chip,
+- uint addr, int alen, uint8_t *buffer,
+- int len);
+- int (*write)(struct i2c_adapter *adap, uint8_t chip,
+- uint addr, int alen, uint8_t *buffer,
+- int len);
+- uint (*set_bus_speed)(struct i2c_adapter *adap,
+- uint speed);
+- int speed;
+- int waitdelay;
+- int slaveaddr;
+- int init_done;
+- int hwadapnr;
+- char *name;
+-};
+-
+-#define U_BOOT_I2C_MKENT_COMPLETE(_init, _probe, _read, _write, \
+- _set_speed, _speed, _slaveaddr, _hwadapnr, _name) \
+- { \
+- .init = _init, \
+- .probe = _probe, \
+- .read = _read, \
+- .write = _write, \
+- .set_bus_speed = _set_speed, \
+- .speed = _speed, \
+- .slaveaddr = _slaveaddr, \
+- .init_done = 0, \
+- .hwadapnr = _hwadapnr, \
+- .name = #_name \
+-};
+-
+-#define U_BOOT_I2C_ADAP_COMPLETE(_name, _init, _probe, _read, _write, \
+- _set_speed, _speed, _slaveaddr, _hwadapnr) \
+- ll_entry_declare(struct i2c_adapter, _name, i2c) = \
+- U_BOOT_I2C_MKENT_COMPLETE(_init, _probe, _read, _write, \
+- _set_speed, _speed, _slaveaddr, _hwadapnr, _name);
+
+ struct i2c_adapter *i2c_get_adapter(int index);
+
+@@ -803,7 +804,7 @@
+ void i2c_soft_scl(int bit);
+ void i2c_soft_delay(void);
+ #endif
+-#else
++#elif !defined(CONFIG_DM_I2C_COMPAT)
+
+ /*
+ * Probe the given I2C chip address. Returns 0 if a chip responded,
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/kconfig_common.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/kconfig_common.patch
new file mode 100644
index 0000000..db6773a
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/kconfig_common.patch
@@ -0,0 +1,65 @@
+#
+# MD: based on the following change:
+#
+# http://git.denx.de/?p=u-boot.git;a=commit;h=98af87997670af840ef178f76b4d6888534a6700
+# author Simon Glass <sjg@chromium.org>
+# Tue, 18 Oct 2016 04:12:35 +0200 (20:12 -0600)
+# committer Tom Rini <trini@konsulko.com>
+# Mon, 24 Oct 2016 00:33:18 +0200 (18:33 -0400)
+#
+# Convert SILENT_CONSOLE options to Kconfig
+#
+# Move these option to Kconfig and tidy up existing uses.
+#
+# The Power PC boards don't have a suitable common element: the common header
+# files don't appear to line up with the Kconfig files as far as I can tell.
+# This results in a lot of defconfig changes.
+#
+diff -raNu old/common/Kconfig new/common/Kconfig
+--- old/common/Kconfig 2016-09-19 17:45:12.000000000 +0300
++++ new/common/Kconfig 2019-02-08 13:41:54.925466228 +0200
+@@ -213,3 +213,44 @@
+ version as printed by the "version" command.
+ Any change to this variable will be reverted at the
+ next reset.
++
++config SILENT_CONSOLE
++ bool "Support a silent console"
++ help
++ This option allows the console to be silenced, meaning that no
++ output will appear on the console devices. This is controlled by
++ setting the environment variable 'silent' to a non-empty value.
++ Note this also silences the console when booting Linux.
++
++ When the console is set up, the variable is checked, and the
++ GD_FLG_SILENT flag is set. Changing the environment variable later
++ will update the flag.
++
++config SILENT_U_BOOT_ONLY
++ bool "Only silence the U-Boot console"
++ depends on SILENT_CONSOLE
++ help
++ Normally when the U-Boot console is silenced, Linux's console is
++ also silenced (assuming the board boots into Linux). This option
++ allows the linux console to operate normally, even if U-Boot's
++ is silenced.
++
++config SILENT_CONSOLE_UPDATE_ON_SET
++ bool "Changes to the 'silent' environment variable update immediately"
++ depends on SILENT_CONSOLE
++ default y if SILENT_CONSOLE
++ help
++ When the 'silent' environment variable is changed, update the
++ console silence flag immediately. This allows 'setenv' to be used
++ to silence or un-silence the console.
++
++ The effect is that any change to the variable will affect the
++ GD_FLG_SILENT flag.
++
++config SILENT_CONSOLE_UPDATE_ON_RELOC
++ bool "Allow flags to take effect on relocation"
++ depends on SILENT_CONSOLE
++ help
++ In some cases the environment is not available until relocation
++ (e.g. NAND). This option makes the value of the 'silent'
++ environment variable take effect at relocation.
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/macb.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/macb.patch
new file mode 100644
index 0000000..5869628
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/macb.patch
@@ -0,0 +1,54 @@
+diff -raNu old/drivers/net/macb.c new/drivers/net/macb.c
+--- old/drivers/net/macb.c 2017-05-11 16:08:48.747255895 -0500
++++ new/drivers/net/macb.c 2017-05-12 09:55:17.331129433 -0500
+@@ -49,7 +49,7 @@
+ #define MACB_RX_RING_SIZE (MACB_RX_BUFFER_SIZE / 128)
+ #define MACB_TX_RING_SIZE 16
+ #define MACB_TX_TIMEOUT 1000
+-#define MACB_AUTONEG_TIMEOUT 5000000
++#define MACB_AUTONEG_TIMEOUT 3000000
+
+ struct macb_dma_desc {
+ u32 addr;
+@@ -419,7 +419,8 @@
+ static void macb_phy_reset(struct macb_device *macb, const char *name)
+ {
+ int i;
+- u16 status, adv;
++ u16 status = 0;
++ u16 adv;
+
+ adv = ADVERTISE_CSMA | ADVERTISE_ALL;
+ macb_mdio_write(macb, MII_ADVERTISE, adv);
+@@ -439,6 +440,7 @@
+ else
+ printf("%s: Autonegotiation timed out (status=0x%04x)\n",
+ name, status);
++
+ }
+
+ #ifdef CONFIG_MACB_SEARCH_PHY
+@@ -479,7 +481,6 @@
+ u32 ncfgr;
+ u16 phy_id, status, adv, lpa;
+ int media, speed, duplex;
+- int i;
+
+ arch_get_mdio_control(name);
+ #ifdef CONFIG_MACB_SEARCH_PHY
+@@ -515,14 +516,7 @@
+ status = macb_mdio_read(macb, MII_BMSR);
+ if (!(status & BMSR_LSTATUS)) {
+ /* Try to re-negotiate if we don't have link already. */
+- macb_phy_reset(macb, name);
+-
+- for (i = 0; i < MACB_AUTONEG_TIMEOUT / 100; i++) {
+- status = macb_mdio_read(macb, MII_BMSR);
+- if (status & BMSR_LSTATUS)
+- break;
+- udelay(100);
+- }
++ macb_phy_reset(macb,name);
+ }
+
+ if (!(status & BMSR_LSTATUS)) {
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt.patch
new file mode 100644
index 0000000..4f265df
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt.patch
@@ -0,0 +1,292 @@
+diff -raNu old/include/configs/at91sam9x5ek.h new/include/configs/at91sam9x5ek.h
+--- old/include/configs/at91sam9x5ek.h 2017-05-04 13:59:37.381346896 -0500
++++ new/include/configs/at91sam9x5ek.h 2017-05-11 08:31:30.258358272 -0500
+@@ -9,9 +9,11 @@
+ #ifndef __CONFIG_H__
+ #define __CONFIG_H__
+
++#include <linux/kconfig.h>
+ #include <asm/hardware.h>
+
+-#define CONFIG_SYS_TEXT_BASE 0x26f00000
++#define USE_MTCDT
++#define CONFIG_SYS_TEXT_BASE 0x2ef00000
+
+ /* ARM asynchronous clock */
+ #define CONFIG_SYS_AT91_SLOW_CLOCK 32768
+@@ -26,6 +28,8 @@
+ #define CONFIG_BOARD_EARLY_INIT_F
+ #define CONFIG_DISPLAY_CPUINFO
+
++#define CONFIG_MISC_INIT_R /* enable platform-dependent misc_init_r() */
++
+ /* general purpose I/O */
+ #define CONFIG_ATMEL_LEGACY /* required until (g)pio is fixed */
+ #define CONFIG_AT91_GPIO
+@@ -36,6 +40,8 @@
+ #define CONFIG_USART_ID ATMEL_ID_SYS
+
+ /* LCD */
++/* MTCDT has no LCD */
++#if !defined(MTCDT)
+ #define CONFIG_LCD
+ #define LCD_BPP LCD_COLOR16
+ #define LCD_OUTPUT_BPP 24
+@@ -46,7 +52,13 @@
+ #define CONFIG_ATMEL_HLCD
+ #define CONFIG_ATMEL_LCD_RGB565
+ #define CONFIG_SYS_CONSOLE_IS_IN_ENV
++#endif /* !defined(MTCDT) */
++
++/* check for keypress even if bootdelay is 0 */
++#define CONFIG_ZERO_BOOTDELAY_CHECK
+
++/*STATUS LED*/
++#define BOOT_STATUS_LED AT91_PIN_PA24
+
+ /*
+ * BOOTP options
+@@ -60,10 +72,10 @@
+ #define CONFIG_SYS_NO_FLASH
+
+ /*
+- * Command line configuration.
++ * Defined by .config (configs/at91sam9x5ek)
++ * #define CONFIG_CMD_I2C
+ */
+-#define CONFIG_CMD_NAND
+-
++#define CONFIG_SYS_I2C
+ /*
+ * define CONFIG_USB_EHCI to enable USB Hi-Speed (aka 2.0)
+ * NB: in this case, USB 1.1 devices won't be recognized.
+@@ -72,7 +84,7 @@
+ /* SDRAM */
+ #define CONFIG_NR_DRAM_BANKS 1
+ #define CONFIG_SYS_SDRAM_BASE 0x20000000
+-#define CONFIG_SYS_SDRAM_SIZE 0x08000000 /* 128 megs */
++#define CONFIG_SYS_SDRAM_SIZE 0x10000000 /* 256 megs */
+
+ #define CONFIG_SYS_INIT_SP_ADDR \
+ (CONFIG_SYS_SDRAM_BASE + 4 * 1024 - GENERATED_GBL_DATA_SIZE)
+@@ -94,13 +106,30 @@
+ /* our CLE is AD22 */
+ #define CONFIG_SYS_NAND_MASK_CLE (1 << 22)
+ #define CONFIG_SYS_NAND_ENABLE_PIN AT91_PIN_PD4
+-#define CONFIG_SYS_NAND_READY_PIN AT91_PIN_PD5
++/* MTCDT nand ready is PC31 */
++#define CONFIG_SYS_NAND_READY_PIN AT91_PIN_PC31
+
+ /* PMECC & PMERRLOC */
+ #define CONFIG_ATMEL_NAND_HWECC 1
+ #define CONFIG_ATMEL_NAND_HW_PMECC 1
+-#define CONFIG_PMECC_CAP 2
++
++/* MTCDT: 4-bit PMECC */
++#define CONFIG_PMECC_CAP 4
+ #define CONFIG_PMECC_SECTOR_SIZE 512
++/*
++ * CONFIG_PMECC_INDEX_TABLE_OFFSET has been replaced by:
++ * ATMEL_PMECC_INDEX_OFFSET_512 and
++ * ATMEL_PMECC_INDEX_OFFSET_1024
++ *
++ * Which as used depends on:
++ * host->pmecc_sector_size == 512
++ *
++ * 2012.10:
++ * #define CONFIG_PMECC_INDEX_TABLE_OFFSET 0x8000
++ * 2016.03 (at91sam9x5.h):
++ * 182:#define ATMEL_PMECC_INDEX_OFFSET_512 0x8000
++ */
++
+
+ #define CONFIG_CMD_NAND_TRIMFFS
+
+@@ -147,20 +176,36 @@
+ #endif
+ #endif
+
++#define CONFIG_SYS_I2C_SOFT
++#define CONFIG_SOFT_I2C
++#define CONFIG_SOFT_I2C_GPIO_SCL AT91_PIN_PA31
++#define CONFIG_SOFT_I2C_GPIO_SDA AT91_PIN_PA30
++#define CONFIG_SYS_I2C_SOFT_SPEED 50000
++#define CONFIG_SYS_I2C_SPEED CONFIG_SYS_I2C_SOFT_SPEED
++/* Values from previous levels of Conduit U-Boot */
++#define CONFIG_SYS_I2C_SLAVE 0xfe
++#define I2C_RXTX_LEN 128
++
++/* I2C eeprom support */
++#define CONFIG_CMD_EEPROM
++#define CONFIG_SYS_I2C_EEPROM_ADDR 0x56 /* at24c04 */
++#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1 /* Bytes of address */
++#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
++
+ #define CONFIG_SYS_LOAD_ADDR 0x22000000 /* load address */
+
+ #define CONFIG_SYS_MEMTEST_START CONFIG_SYS_SDRAM_BASE
+-#define CONFIG_SYS_MEMTEST_END 0x26e00000
++#define CONFIG_SYS_MEMTEST_END 0x2ee00000
+
+ #ifdef CONFIG_SYS_USE_NANDFLASH
+ /* bootstrap + u-boot + env + linux in nandflash */
+ #define CONFIG_ENV_IS_IN_NAND
+ #define CONFIG_ENV_OFFSET 0xc0000
+-#define CONFIG_ENV_OFFSET_REDUND 0x100000
++#define CONFIG_ENV_OFFSET_REDUND 0x160000
+ #define CONFIG_ENV_SIZE 0x20000 /* 1 sector = 128 kB */
+-#define CONFIG_BOOTCOMMAND "nand read " \
+- "0x22000000 0x200000 0x300000; " \
+- "bootm 0x22000000"
++/* MTCDT: read from env variables for boot */
++#define CONFIG_BOOTCOMMAND "nboot.jffs2 ${loadaddr} 0 ${kernel_addr}; bootm ${loadaddr}"
++
+ #elif defined(CONFIG_SYS_USE_SPIFLASH)
+ /* bootstrap + u-boot + env + linux in spi flash */
+ #define CONFIG_ENV_IS_IN_SPI_FLASH
+@@ -197,6 +242,9 @@
+ "8M(bootstrap/uboot/kernel)ro,-(rootfs) " \
+ "root=/dev/mmcblk0p2 " \
+ "rw rootfstype=ext4 rootwait"
++#elif defined(USE_MTCDT)
++/* MTCDT uses jffs2 */
++#define CONFIG_BOOTARGS "mem=256M console=ttyS0,115200 root=/dev/mtdblock8 ro rootfstype=jffs2"
+ #else
+ #define CONFIG_BOOTARGS \
+ "console=ttyS0,115200 earlyprintk " \
+@@ -274,4 +322,21 @@
+
+ #endif
+
++/* MTCDT defaults */
++#define CONFIG_ENV_OVERWRITE 1 /* Allow Overwrite of serial# & ethaddr */
++#define CONFIG_ETHADDR 00:08:00:87:00:02
++#define CONFIG_IPADDR 192.168.2.1
++#define CONFIG_NETMASK 255.255.255.0
++#define CONFIG_SERVERIP 192.168.2.2
++#define CONFIG_HOSTNAME AT91SAM9G25
++#define CONFIG_LOADADDR 0x22000000
++
++/* MTCDT - enable watchdog */
++#define CONFIG_AT91SAM9_WATCHDOG 1
++#define CONFIG_HW_WATCHDOG 1
++#define CONFIG_AT91_HW_WDT_TIMEOUT 16
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ "kernel_addr=0x200000\0" \
++ ""
++
+ #endif
+diff -raNu old/board/atmel/at91sam9x5ek/at91sam9x5ek.c new/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+--- old/board/atmel/at91sam9x5ek/at91sam9x5ek.c 2017-05-05 11:09:53.668926301 -0500
++++ new/board/atmel/at91sam9x5ek/at91sam9x5ek.c 2017-05-05 17:35:53.342774065 -0500
+@@ -44,7 +44,8 @@
+ csa = readl(&matrix->ebicsa);
+ csa |= AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA;
+ /* NAND flash on D16 */
+- csa |= AT91_MATRIX_NFD0_ON_D16;
++ /* MTCDT: nand flash is set up by bootstrap, so leave it alone here */
++ /* csa |= AT91_MATRIX_NFD0_ON_D16; */
+
+ /* Configure IO drive */
+ csa &= ~AT91_MATRIX_EBI_EBI_IOSR_NORMAL;
+@@ -256,6 +257,9 @@
+
+ int board_init(void)
+ {
++ /* Set Status LED High */
++ at91_set_gpio_output(BOOT_STATUS_LED, 0);
++
+ /* arch number of AT91SAM9X5EK-Board */
+ gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9X5EK;
+
+@@ -267,6 +271,7 @@
+ #endif
+
+ #ifdef CONFIG_ATMEL_SPI
++ at91_spi0_hw_init(1 << 0);
+ at91_spi0_hw_init(1 << 4);
+ #endif
+
+@@ -283,12 +288,6 @@
+ return 0;
+ }
+
+-int dram_init(void)
+-{
+- gd->ram_size = get_ram_size((void *) CONFIG_SYS_SDRAM_BASE,
+- CONFIG_SYS_SDRAM_SIZE);
+- return 0;
+-}
+
+ #if defined(CONFIG_SPL_BUILD)
+ #include <spl.h>
+@@ -362,4 +361,69 @@
+ /* DDRAM2 Controller initialize */
+ ddr2_init(ATMEL_BASE_DDRSDRC, ATMEL_BASE_CS1, &ddr2);
+ }
++
+ #endif
++
++/* on-board EEPROM */
++struct mts_id_eeprom_layout {
++ char vendor_id[32];
++ char product_id[32];
++ char device_id[32];
++ char hw_version[32];
++ uint8_t mac_addr[6];
++ char imei[32];
++ uint8_t capa[32];
++ uint8_t mac_bluetooth[6];
++ uint8_t mac_wifi[6];
++ uint8_t reserved[302];
++};
++
++int board_get_enetaddr(uchar *enetaddr)
++{
++ struct mts_id_eeprom_layout eeprom_buffer = {0};
++
++ if (eeprom_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, &eeprom_buffer, sizeof(eeprom_buffer))) {
++ printf("EEPROM: read error\n");
++ return 0;
++ }
++
++ if (eeprom_buffer.vendor_id[0] == 0x00 || eeprom_buffer.vendor_id[0] == 0xFF) {
++ printf("EEPROM: uninitialized\n");
++ return 0;
++ }
++
++ printf("vendor-id: %s\n", eeprom_buffer.vendor_id);
++ printf("product-id: %s\n", eeprom_buffer.product_id);
++ printf("device-id: %s\n", eeprom_buffer.device_id);
++ printf("hw-version: %s\n", eeprom_buffer.hw_version);
++ printf("mac-addr: %02x:%02x:%02x:%02x:%02x:%02x\n", eeprom_buffer.mac_addr[0],
++ eeprom_buffer.mac_addr[1],
++ eeprom_buffer.mac_addr[2],
++ eeprom_buffer.mac_addr[3],
++ eeprom_buffer.mac_addr[4],
++ eeprom_buffer.mac_addr[5]);
++
++ memcpy(enetaddr, eeprom_buffer.mac_addr, 6);
++
++ return 1;
++}
++
++int misc_init_r(void)
++{
++ uchar enetaddr[6];
++
++ /* set MAC address from EEPROM if read successful */
++ if (board_get_enetaddr(enetaddr)) {
++ eth_setenv_enetaddr("ethaddr", enetaddr);
++ }
++
++ return 0;
++}
++
++int dram_init(void)
++{
++ gd->ram_size = get_ram_size((void *) CONFIG_SYS_SDRAM_BASE,
++ CONFIG_SYS_SDRAM_SIZE);
++ return 0;
++}
++
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt_flush_console_autoboot.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt_flush_console_autoboot.patch
new file mode 100644
index 0000000..d08843a
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt_flush_console_autoboot.patch
@@ -0,0 +1,43 @@
+# This change sets the bootdelay to 2 seconds. On old devices
+# the bootdelay may be in the environment variable partitions.
+# When updating a system, u-boot setenv command must be used
+# to set the bootdelay to 2 in the environment. A bootdelay
+# of zero will make it nearly impossible to enter U-Boot,
+# and zero is the old default, and may be in the environment.
+# For MTCDT only the unpowered EXAR serial to USB convertor
+# leaks the output of the console back to the input in some
+# cases. Therefore it is necessary to flush the UART before
+# attempting to monitor keystrokes. The output of the
+# console must be quiet, or in the case of the normal
+# boot where the EXAR part is unpowered, the read of the
+# keyboard may be reading output to the console screen.
+# This problem never occurs if the EXAR part is connected
+# to a PC, and is powered.
+diff -Naru orig/common/autoboot.c new/common/autoboot.c
+--- orig/common/autoboot.c 2019-08-15 10:56:58.183468370 -0500
++++ new/common/autoboot.c 2019-08-15 10:30:11.363515940 -0500
+@@ -219,6 +219,12 @@
+ printf("Hit any key to stop autoboot: %2d ", bootdelay);
+ #endif
+
++ /* Flush input -- must be done because of loopback
++ * issue on MTCDT models with unpowered EXAR part
++ * which do loopback unintentionally by default.
++ */
++ while (tstc())
++ getc();
+ /*
+ * Check if key already pressed
+ */
+diff -Naru orig/configs/at91sam9x5ek_nandflash_defconfig new/configs/at91sam9x5ek_nandflash_defconfig
+--- orig/configs/at91sam9x5ek_nandflash_defconfig 2019-08-15 10:49:30.223481632 -0500
++++ new/configs/at91sam9x5ek_nandflash_defconfig 2019-08-15 10:50:10.703480433 -0500
+@@ -3,7 +3,7 @@
+ CONFIG_TARGET_AT91SAM9X5EK=y
+ CONFIG_SPL=n
+ CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9X5,SYS_USE_NANDFLASH"
+-CONFIG_BOOTDELAY=0
++CONFIG_BOOTDELAY=2
+ CONFIG_HUSH_PARSER=y
+ CONFIG_SYS_PROMPT="U-Boot> "
+ CONFIG_CMD_BOOTZ=y
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/mtpwd.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtpwd.patch
new file mode 100644
index 0000000..fb07372
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/mtpwd.patch
@@ -0,0 +1,300 @@
+diff -raNu old/common/autoboot.c new/common/autoboot.c
+--- old/common/autoboot.c 2017-05-19 10:43:49.378496833 -0500
++++ new/common/autoboot.c 2017-05-19 10:52:10.561509423 -0500
+@@ -362,4 +362,5 @@
+ run_command_list(s, -1, 0);
+ }
+ #endif /* CONFIG_MENUKEY */
++ mts_run_passwd_loop();
+ }
+diff -raNu old/common/Makefile new/common/Makefile
+--- old/common/Makefile 2017-05-11 18:07:26.904563771 -0500
++++ new/common/Makefile 2017-05-11 18:09:05.514736126 -0500
+@@ -164,5 +164,6 @@
+ obj-y += command.o
+ obj-y += s_record.o
+ obj-y += xyzModem.o
++obj-$(CONFIG_MTS_PASSWD) += mts_passwd.o
+
+ CFLAGS_env_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2>/dev/null)
+diff -raNu old/common/mts_passwd.c new/common/mts_passwd.c
+--- old/common/mts_passwd.c 1969-12-31 18:00:00.000000000 -0600
++++ new/common/mts_passwd.c 2017-05-12 13:15:54.928180929 -0500
+@@ -0,0 +1,248 @@
++#include <common.h>
++#include <linux/ctype.h>
++#include <watchdog.h>
++#include <u-boot/sha256.h>
++#include <mts_passwd.h>
++
++#define MTS_PASSWD_ATTEMPTS (3)
++#define MTS_PASSWD_MAX_LEN (30)
++#define MTS_PASSWD_HASH_VAR "mtsp"
++#define MTS_PASSWD_SALT_VAR "mtss"
++#define MTS_PASSWD_PROMPT "Enter password : "
++
++static
++void mts_do_reset(unsigned long delay)
++{
++ mdelay(delay);
++ do_reset(NULL, 0, 0, NULL);
++}
++
++/*
++ *
++ * Figure out if device is locked or not
++ *
++ */
++static
++int mts_get_protection_status(void)
++{
++ int rc = 0; /* UNLOCKED */
++ char *var = NULL;
++ int len;
++
++ var = getenv(MTS_PASSWD_HASH_VAR);
++
++ do {
++ /* Variable is not set */
++ if (!var) break;
++
++ len = strlen(var);
++
++ /* Variable is empty */
++ if (len == 0) break;
++
++ /*
++ * Length should be correct. Otherwise, do not unlock the device, just show the message and reset.
++ */
++ if (len != 2*SHA256_SUM_LEN) {
++ puts("WARNING: password is corrupted\n");
++ mts_do_reset(1000);
++ }
++
++ /* LOCKED */
++ rc = 1;
++
++ } while (0);
++
++ return rc;
++}
++
++
++/*
++ *
++ * Helper function for the password reading
++ *
++ */
++static
++char *mts_password_delete_char(char *buffer, char *p, int *colp, int *np, int plen)
++{
++ static char erase_seq[] = "\b \b";
++
++ if (*np == 0) {
++ return (p);
++ }
++
++ --p;
++ puts(erase_seq);
++ (*colp)--;
++
++ (*np)--;
++ return (p);
++}
++
++/*
++ *
++ * Read password helper
++ *
++ */
++static
++int mts_password_into_buffer(const char *const prompt, char *buf, size_t buflen)
++{
++ char *p = buf;
++ char *p_buf = p;
++ int n = 0; /* buffer index */
++ int plen = 0; /* prompt length */
++ int col; /* output column cnt */
++ char c;
++
++ /* print prompt */
++ if (prompt) {
++ plen = strlen(prompt);
++ puts (prompt);
++ }
++
++ col = plen;
++
++ for (;;) {
++
++ WATCHDOG_RESET();
++
++ c = getc();
++
++ /*
++ * Special character handling
++ */
++ switch (c) {
++ case '\r': /* Enter */
++ case '\n':
++ *p = '\0';
++ puts("\r\n");
++ return (p - p_buf);
++
++ case '\0': /* nul */
++ case '\t':
++ continue;
++
++ case 0x03: /* ^C - break */
++ p_buf[0] = '\0'; /* discard input */
++ puts("\r\n");
++ return (-1);
++
++ case 0x08: /* ^H - backspace */
++ case 0x7F: /* DEL - backspace */
++ p = mts_password_delete_char(p_buf, p, &col, &n, plen);
++ continue;
++
++ default:
++ /*
++ * Must be a normal character then
++ */
++ if (n < buflen - 2) {
++ ++col; /* echo input */
++ *p++ = c;
++ ++n;
++ }
++ putc('*');
++ }
++ }
++}
++
++/*
++ *
++ * Read the password from input
++ *
++ */
++static
++int read_password(char *buf, size_t buflen)
++{
++ return mts_password_into_buffer(MTS_PASSWD_PROMPT, buf, buflen);
++}
++
++/*
++ *
++ * Verify if the entered password is correct.
++ *
++ */
++static
++int verify_password(char *pwd, size_t pwdlen)
++{
++ char *hash_env = getenv(MTS_PASSWD_HASH_VAR);;
++ char *salt_env = getenv(MTS_PASSWD_SALT_VAR);
++
++ if (pwd && pwdlen > 0 && hash_env && (strlen(hash_env) == 2*SHA256_SUM_LEN)) {
++ uint8_t hash[SHA256_SUM_LEN];
++ uint8_t prefix[]={'0','3','e','3'};
++ sha256_context ctx;
++ char tmp[3];
++ int i;
++
++ sha256_starts(&ctx);
++ sha256_update(&ctx, prefix, 4);
++ sha256_update(&ctx, (uint8_t *) pwd, pwdlen);
++ if (salt_env) {
++ size_t saltlen = strlen(salt_env);
++ sha256_update(&ctx, (uint8_t *) salt_env, saltlen);
++ }
++ sha256_finish(&ctx, hash);
++ memset(&ctx, 0, sizeof(sha256_context));
++
++ for (i = 0; i < SHA256_SUM_LEN; i++) {
++ snprintf(tmp, sizeof tmp, "%02x", hash[i]);
++ if (tolower(tmp[0]) != tolower(hash_env[2*i]) ||
++ tolower(tmp[1]) != tolower(hash_env[2*i + 1])) {
++ break;
++ }
++ }
++
++ if (i == SHA256_SUM_LEN) {
++ return 1;
++ }
++ }
++
++ return 0;
++}
++
++/*
++ *
++ * Check is the device is locked and ask the password.
++ *
++ */
++void mts_run_passwd_loop(void)
++{
++ char buf[MTS_PASSWD_MAX_LEN] = "\0";
++ unsigned long delay = 1000; /* 1 second initially */
++ int len;
++ int trynr = 0;
++
++ /* Do not delete */
++ printf("", "mts password protected");
++
++ if (mts_get_protection_status() == 0) {
++ return;
++ }
++
++ while (1) {
++ if (trynr == MTS_PASSWD_ATTEMPTS) {
++ mts_do_reset(1000);
++ }
++
++ len = read_password(buf, MTS_PASSWD_MAX_LEN);
++ if (len > 0) {
++ if (verify_password(buf, len)) {
++ /* zero out */
++ memset(buf, 0, sizeof(buf));
++ return;
++ }
++ puts("Permission denied\n");
++ }
++
++ trynr++;
++
++ /* progressive delay */
++ mdelay(delay);
++ delay *= 2;
++ if (delay > 4000) delay = 4000;
++ }
++ /* zero out */
++ memset(buf, 0, sizeof(buf));
++ return;
++}
+diff -raNu old/include/common.h new/include/common.h
+--- old/include/common.h 2017-05-12 10:49:29.391203966 -0500
++++ new/include/common.h 2017-05-12 10:49:13.170842438 -0500
+@@ -25,6 +25,7 @@
+ #include <asm/ptrace.h>
+ #include <stdarg.h>
+ #include <linux/kernel.h>
++#include <mts_passwd.h>
+ #if defined(CONFIG_PCI) && defined(CONFIG_4xx)
+ #include <pci.h>
+ #endif
+diff -raNu old/include/mts_passwd.h new/include/mts_passwd.h
+--- old/include/mts_passwd.h 1969-12-31 18:00:00.000000000 -0600
++++ new/include/mts_passwd.h 2017-05-12 10:46:40.459437214 -0500
+@@ -0,0 +1,13 @@
++#ifndef _MTS_PASSWD_H
++#define _MTS_PASSWD_H
++
++#define CONFIG_MTS_PASSWD
++
++#if defined(CONFIG_MTS_PASSWD)
++#define CONFIG_SHA256
++void mts_run_passwd_loop(void);
++#else
++#define mts_run_passwd_loop() {}
++#endif
++
++#endif
+\ No newline at end of file
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/mtr.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtr.patch
new file mode 100644
index 0000000..176e590
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/mtr.patch
@@ -0,0 +1,272 @@
+diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+index b0d440d..13cc9a3 100644
+--- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
++++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+@@ -44,7 +44,8 @@ static void at91sam9x5ek_nand_hw_init(void)
+ csa = readl(&matrix->ebicsa);
+ csa |= AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA;
+ /* NAND flash on D16 */
+- csa |= AT91_MATRIX_NFD0_ON_D16;
++ /* MTR: nand flash is set up by bootstrap, so leave it alone here */
++ /* csa |= AT91_MATRIX_NFD0_ON_D16; */
+
+ /* Configure IO drive */
+ csa &= ~AT91_MATRIX_EBI_EBI_IOSR_NORMAL;
+@@ -256,6 +257,9 @@ int board_early_init_f(void)
+
+ int board_init(void)
+ {
++ /* Set Status LED High */
++ at91_set_gpio_output(BOOT_STATUS_LED, 0);
++
+ /* arch number of AT91SAM9X5EK-Board */
+ gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9X5EK;
+
+@@ -363,3 +367,60 @@ void mem_init(void)
+ ddr2_init(ATMEL_BASE_DDRSDRC, ATMEL_BASE_CS1, &ddr2);
+ }
+ #endif
++
++/* on-board EEPROM */
++struct mts_id_eeprom_layout {
++ char vendor_id[32];
++ char product_id[32];
++ char device_id[32];
++ char hw_version[32];
++ uint8_t mac_addr[6];
++ char imei[32];
++ uint8_t capa[32];
++ uint8_t mac_bluetooth[6];
++ uint8_t mac_wifi[6];
++ uint8_t reserved[302];
++};
++
++int board_get_enetaddr(uchar *enetaddr)
++{
++ struct mts_id_eeprom_layout eeprom_buffer = {0};
++
++ if (eeprom_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, &eeprom_buffer, sizeof(eeprom_buffer))) {
++ printf("EEPROM: read error\n");
++ return 0;
++ }
++
++ if (eeprom_buffer.vendor_id[0] == 0x00 || eeprom_buffer.vendor_id[0] == 0xFF) {
++ printf("EEPROM: uninitialized\n");
++ return 0;
++ }
++
++ printf("vendor-id: %s\n", eeprom_buffer.vendor_id);
++ printf("product-id: %s\n", eeprom_buffer.product_id);
++ printf("device-id: %s\n", eeprom_buffer.device_id);
++ printf("hw-version: %s\n", eeprom_buffer.hw_version);
++ printf("mac-addr: %02x:%02x:%02x:%02x:%02x:%02x\n", eeprom_buffer.mac_addr[0],
++ eeprom_buffer.mac_addr[1],
++ eeprom_buffer.mac_addr[2],
++ eeprom_buffer.mac_addr[3],
++ eeprom_buffer.mac_addr[4],
++ eeprom_buffer.mac_addr[5]);
++
++ memcpy(enetaddr, eeprom_buffer.mac_addr, 6);
++
++ return 1;
++}
++
++int misc_init_r(void)
++{
++ uchar enetaddr[6];
++
++ /* set MAC address from EEPROM if read successful */
++ if (board_get_enetaddr(enetaddr)) {
++ eth_setenv_enetaddr("ethaddr", enetaddr);
++ }
++
++ return 0;
++}
++
+diff -Naru a/configs/at91sam9x5ek_nandflash_defconfig b/configs/at91sam9x5ek_nandflash_defconfig
+--- a/configs/at91sam9x5ek_nandflash_defconfig 2019-02-13 11:21:57.000000000 -0600
++++ b/configs/at91sam9x5ek_nandflash_defconfig 2019-02-13 11:27:11.463114488 -0600
+@@ -31,7 +31,6 @@
+ CONFIG_CMD_NAND=y
+ CONFIG_CMD_BOOTZ=y
+ CONFIG_CMD_MII=y
+-CONFIG_CMD_I2C=y
+
+ # The config option CONFIG_SILENT_CONSOLE can be used to quiet messages
+ # on the console. If the option has been enabled, the output can be
+diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
+index 637c403..693feee 100644
+--- a/include/configs/at91sam9x5ek.h
++++ b/include/configs/at91sam9x5ek.h
+@@ -9,8 +9,10 @@
+ #ifndef __CONFIG_H__
+ #define __CONFIG_H__
+
++#include <linux/kconfig.h>
+ #include <asm/hardware.h>
+
++#define USE_MTR
+ #define CONFIG_SYS_TEXT_BASE 0x26f00000
+
+ /* ARM asynchronous clock */
+@@ -26,6 +28,8 @@
+ #define CONFIG_BOARD_EARLY_INIT_F
+ #define CONFIG_DISPLAY_CPUINFO
+
++#define CONFIG_MISC_INIT_R /* enable platform-dependent misc_init_r() */
++
+ /* general purpose I/O */
+ #define CONFIG_ATMEL_LEGACY /* required until (g)pio is fixed */
+ #define CONFIG_AT91_GPIO
+@@ -36,6 +40,8 @@
+ #define CONFIG_USART_ID ATMEL_ID_SYS
+
+ /* LCD */
++/* MTR has no LCD */
++#if !defined(MTR)
+ #define CONFIG_LCD
+ #define LCD_BPP LCD_COLOR16
+ #define LCD_OUTPUT_BPP 24
+@@ -46,7 +52,13 @@
+ #define CONFIG_ATMEL_HLCD
+ #define CONFIG_ATMEL_LCD_RGB565
+ #define CONFIG_SYS_CONSOLE_IS_IN_ENV
++#endif /* !defined(MTR) */
++
++/* check for keypress even if bootdelay is 0 */
++#define CONFIG_ZERO_BOOTDELAY_CHECK
+
++/*STATUS LED*/
++#define BOOT_STATUS_LED AT91_PIN_PC21
+
+ /*
+ * BOOTP options
+@@ -59,10 +71,7 @@
+ /* no NOR flash */
+ #define CONFIG_SYS_NO_FLASH
+
+-/*
+- * Command line configuration.
+- */
+-#define CONFIG_CMD_NAND
++#define CONFIG_SYS_I2C
+
+ /*
+ * define CONFIG_USB_EHCI to enable USB Hi-Speed (aka 2.0)
+@@ -94,13 +103,30 @@
+ /* our CLE is AD22 */
+ #define CONFIG_SYS_NAND_MASK_CLE (1 << 22)
+ #define CONFIG_SYS_NAND_ENABLE_PIN AT91_PIN_PD4
+-#define CONFIG_SYS_NAND_READY_PIN AT91_PIN_PD5
++/* MTR nand ready is PC31 */
++#define CONFIG_SYS_NAND_READY_PIN AT91_PIN_PC31
+
+ /* PMECC & PMERRLOC */
+ #define CONFIG_ATMEL_NAND_HWECC 1
+ #define CONFIG_ATMEL_NAND_HW_PMECC 1
+-#define CONFIG_PMECC_CAP 2
++
++/* MTR: 4-bit PMECC */
++#define CONFIG_PMECC_CAP 4
+ #define CONFIG_PMECC_SECTOR_SIZE 512
++/*
++ * CONFIG_PMECC_INDEX_TABLE_OFFSET has been replaced by:
++ * ATMEL_PMECC_INDEX_OFFSET_512 and
++ * ATMEL_PMECC_INDEX_OFFSET_1024
++ *
++ * Which as used depends on:
++ * host->pmecc_sector_size == 512
++ *
++ * 2012.10:
++ * #define CONFIG_PMECC_INDEX_TABLE_OFFSET 0x8000
++ * 2016.03 (at91sam9x5.h):
++ * 182:#define ATMEL_PMECC_INDEX_OFFSET_512 0x8000
++ */
++
+
+ #define CONFIG_CMD_NAND_TRIMFFS
+
+@@ -127,9 +153,11 @@
+
+ /* Ethernet */
+ #define CONFIG_MACB
+-#define CONFIG_RMII
++#undef CONFIG_RMII
+ #define CONFIG_NET_RETRY_COUNT 20
+ #define CONFIG_MACB_SEARCH_PHY
++/* enable MII command */
++#define CONFIG_CMD_MII 1
+
+ /* USB */
+ #ifdef CONFIG_CMD_USB
+@@ -147,6 +175,22 @@
+ #endif
+ #endif
+
++#define CONFIG_SYS_I2C_SOFT
++#define CONFIG_SOFT_I2C
++#define CONFIG_SOFT_I2C_GPIO_SCL AT91_PIN_PA31
++#define CONFIG_SOFT_I2C_GPIO_SDA AT91_PIN_PA30
++#define CONFIG_SYS_I2C_SOFT_SPEED 50000
++#define CONFIG_SYS_I2C_SPEED CONFIG_SYS_I2C_SOFT_SPEED
++/* Values from previous levels of Conduit U-Boot */
++#define CONFIG_SYS_I2C_SLAVE 0xfe
++#define I2C_RXTX_LEN 128
++
++/* I2C eeprom support */
++#define CONFIG_CMD_EEPROM
++#define CONFIG_SYS_I2C_EEPROM_ADDR 0x56 /* at24c04 */
++#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1 /* Bytes of address<---><------>*/
++#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
++
+ #define CONFIG_SYS_LOAD_ADDR 0x22000000 /* load address */
+
+ #define CONFIG_SYS_MEMTEST_START CONFIG_SYS_SDRAM_BASE
+@@ -156,11 +200,11 @@
+ /* bootstrap + u-boot + env + linux in nandflash */
+ #define CONFIG_ENV_IS_IN_NAND
+ #define CONFIG_ENV_OFFSET 0xc0000
+-#define CONFIG_ENV_OFFSET_REDUND 0x100000
++#define CONFIG_ENV_OFFSET_REDUND 0x160000
+ #define CONFIG_ENV_SIZE 0x20000 /* 1 sector = 128 kB */
+-#define CONFIG_BOOTCOMMAND "nand read " \
+- "0x22000000 0x200000 0x300000; " \
+- "bootm 0x22000000"
++/* MTR: read from env variables for boot */
++#define CONFIG_BOOTCOMMAND "nboot.jffs2 ${loadaddr} 0 ${kernel_addr}; bootm ${loadaddr}"
++
+ #elif defined(CONFIG_SYS_USE_SPIFLASH)
+ /* bootstrap + u-boot + env + linux in spi flash */
+ #define CONFIG_ENV_IS_IN_SPI_FLASH
+@@ -197,6 +241,9 @@
+ "8M(bootstrap/uboot/kernel)ro,-(rootfs) " \
+ "root=/dev/mmcblk0p2 " \
+ "rw rootfstype=ext4 rootwait"
++#elif defined(USE_MTR)
++/* MTR uses jffs2 */
++#define CONFIG_BOOTARGS "mem=128M console=ttyS0,115200 root=/dev/mtdblock8 ro rootfstype=jffs2"
+ #else
+ #define CONFIG_BOOTARGS \
+ "console=ttyS0,115200 earlyprintk " \
+@@ -274,4 +321,21 @@
+
+ #endif
+
++/* MTR defaults */
++#define CONFIG_ENV_OVERWRITE 1 /* Allow Overwrite of serial# & ethaddr */
++#define CONFIG_ETHADDR 00:08:00:87:00:02
++#define CONFIG_IPADDR 192.168.2.1
++#define CONFIG_NETMASK 255.255.255.0
++#define CONFIG_SERVERIP 192.168.2.2
++#define CONFIG_HOSTNAME AT91SAM9G25
++#define CONFIG_LOADADDR 0x22000000
++
++/* MTR - enable watchdog */
++#define CONFIG_AT91SAM9_WATCHDOG 1
++#define CONFIG_HW_WATCHDOG 1
++#define CONFIG_AT91_HW_WDT_TIMEOUT 16
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ "kernel_addr=0x200000\0" \
++ ""
++
+ #endif
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/mtrv1.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtrv1.patch
new file mode 100644
index 0000000..49cb435
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/mtrv1.patch
@@ -0,0 +1,261 @@
+diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+index b0d440d..5640cef 100644
+--- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
++++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+@@ -44,7 +44,8 @@ static void at91sam9x5ek_nand_hw_init(void)
+ csa = readl(&matrix->ebicsa);
+ csa |= AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA;
+ /* NAND flash on D16 */
+- csa |= AT91_MATRIX_NFD0_ON_D16;
++ /* MTR: nand flash is set up by bootstrap, so leave it alone here */
++ /* csa |= AT91_MATRIX_NFD0_ON_D16; */
+
+ /* Configure IO drive */
+ csa &= ~AT91_MATRIX_EBI_EBI_IOSR_NORMAL;
+@@ -256,6 +257,9 @@ int board_early_init_f(void)
+
+ int board_init(void)
+ {
++ /* Set Status LED High */
++ at91_set_gpio_output(BOOT_STATUS_LED, 0);
++
+ /* arch number of AT91SAM9X5EK-Board */
+ gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9X5EK;
+
+@@ -362,4 +366,61 @@ void mem_init(void)
+ /* DDRAM2 Controller initialize */
+ ddr2_init(ATMEL_BASE_DDRSDRC, ATMEL_BASE_CS1, &ddr2);
+ }
++
+ #endif
++
++/* on-board EEPROM */
++struct mts_id_eeprom_layout {
++ char vendor_id[32];
++ char product_id[32];
++ char device_id[32];
++ char hw_version[32];
++ uint8_t mac_addr[6];
++ char imei[32];
++ uint8_t capa[32];
++ uint8_t mac_bluetooth[6];
++ uint8_t mac_wifi[6];
++ uint8_t reserved[302];
++};
++
++int board_get_enetaddr(uchar *enetaddr)
++{
++ struct mts_id_eeprom_layout eeprom_buffer = {0};
++
++ if (eeprom_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, &eeprom_buffer, sizeof(eeprom_buffer))) {
++ printf("EEPROM: read error\n");
++ return 0;
++ }
++
++ if (eeprom_buffer.vendor_id[0] == 0x00 || eeprom_buffer.vendor_id[0] == 0xFF) {
++ printf("EEPROM: uninitialized\n");
++ return 0;
++ }
++
++ printf("vendor-id: %s\n", eeprom_buffer.vendor_id);
++ printf("product-id: %s\n", eeprom_buffer.product_id);
++ printf("device-id: %s\n", eeprom_buffer.device_id);
++ printf("hw-version: %s\n", eeprom_buffer.hw_version);
++ printf("mac-addr: %02x:%02x:%02x:%02x:%02x:%02x\n", eeprom_buffer.mac_addr[0],
++ eeprom_buffer.mac_addr[1],
++ eeprom_buffer.mac_addr[2],
++ eeprom_buffer.mac_addr[3],
++ eeprom_buffer.mac_addr[4],
++ eeprom_buffer.mac_addr[5]);
++
++ memcpy(enetaddr, eeprom_buffer.mac_addr, 6);
++
++ return 1;
++}
++
++int misc_init_r(void)
++{
++ uchar enetaddr[6];
++
++ /* set MAC address from EEPROM if read successful */
++ if (board_get_enetaddr(enetaddr)) {
++ eth_setenv_enetaddr("ethaddr", enetaddr);
++ }
++
++ return 0;
++}
+diff -Naru a/configs/at91sam9x5ek_nandflash_defconfig b/configs/at91sam9x5ek_nandflash_defconfig
+--- a/configs/at91sam9x5ek_nandflash_defconfig 2019-02-13 11:21:57.000000000 -0600
++++ b/configs/at91sam9x5ek_nandflash_defconfig 2019-02-13 11:27:11.463114488 -0600
+@@ -31,7 +31,6 @@
+ CONFIG_CMD_NAND=y
+ CONFIG_CMD_BOOTZ=y
+ CONFIG_CMD_MII=y
+-CONFIG_CMD_I2C=y
+
+ # The config option CONFIG_SILENT_CONSOLE can be used to quiet messages
+ # on the console. If the option has been enabled, the output can be
+diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
+index 637c403..eff48d6 100644
+--- a/include/configs/at91sam9x5ek.h
++++ b/include/configs/at91sam9x5ek.h
+@@ -9,8 +9,10 @@
+ #ifndef __CONFIG_H__
+ #define __CONFIG_H__
+
++#include <linux/kconfig.h>
+ #include <asm/hardware.h>
+
++#define USE_MTR
+ #define CONFIG_SYS_TEXT_BASE 0x26f00000
+
+ /* ARM asynchronous clock */
+@@ -26,6 +28,8 @@
+ #define CONFIG_BOARD_EARLY_INIT_F
+ #define CONFIG_DISPLAY_CPUINFO
+
++#define CONFIG_MISC_INIT_R /* enable platform-dependent misc_init_r() */
++
+ /* general purpose I/O */
+ #define CONFIG_ATMEL_LEGACY /* required until (g)pio is fixed */
+ #define CONFIG_AT91_GPIO
+@@ -36,6 +40,8 @@
+ #define CONFIG_USART_ID ATMEL_ID_SYS
+
+ /* LCD */
++/* MTR has no LCD */
++#if !defined(MTR)
+ #define CONFIG_LCD
+ #define LCD_BPP LCD_COLOR16
+ #define LCD_OUTPUT_BPP 24
+@@ -46,7 +52,13 @@
+ #define CONFIG_ATMEL_HLCD
+ #define CONFIG_ATMEL_LCD_RGB565
+ #define CONFIG_SYS_CONSOLE_IS_IN_ENV
++#endif /* !defined(MTR) */
++
++/* check for keypress even if bootdelay is 0 */
++#define CONFIG_ZERO_BOOTDELAY_CHECK
+
++/*STATUS LED*/
++#define BOOT_STATUS_LED AT91_PIN_PC21
+
+ /*
+ * BOOTP options
+@@ -59,10 +71,7 @@
+ /* no NOR flash */
+ #define CONFIG_SYS_NO_FLASH
+
+-/*
+- * Command line configuration.
+- */
+-#define CONFIG_CMD_NAND
++#define CONFIG_SYS_I2C
+
+ /*
+ * define CONFIG_USB_EHCI to enable USB Hi-Speed (aka 2.0)
+@@ -94,13 +103,30 @@
+ /* our CLE is AD22 */
+ #define CONFIG_SYS_NAND_MASK_CLE (1 << 22)
+ #define CONFIG_SYS_NAND_ENABLE_PIN AT91_PIN_PD4
+-#define CONFIG_SYS_NAND_READY_PIN AT91_PIN_PD5
++/* MTR nand ready is PC31 */
++#define CONFIG_SYS_NAND_READY_PIN AT91_PIN_PC31
+
+ /* PMECC & PMERRLOC */
+ #define CONFIG_ATMEL_NAND_HWECC 1
+ #define CONFIG_ATMEL_NAND_HW_PMECC 1
+-#define CONFIG_PMECC_CAP 2
++
++/* MTR: 4-bit PMECC */
++#define CONFIG_PMECC_CAP 4
+ #define CONFIG_PMECC_SECTOR_SIZE 512
++/*
++ * CONFIG_PMECC_INDEX_TABLE_OFFSET has been replaced by:
++ * ATMEL_PMECC_INDEX_OFFSET_512 and
++ * ATMEL_PMECC_INDEX_OFFSET_1024
++ *
++ * Which as used depends on:
++ * host->pmecc_sector_size == 512
++ *
++ * 2012.10:
++ * #define CONFIG_PMECC_INDEX_TABLE_OFFSET 0x8000
++ * 2016.03 (at91sam9x5.h):
++ * 182:#define ATMEL_PMECC_INDEX_OFFSET_512 0x8000
++ */
++
+
+ #define CONFIG_CMD_NAND_TRIMFFS
+
+@@ -147,6 +173,23 @@
+ #endif
+ #endif
+
++#define CONFIG_SYS_I2C_SOFT
++#define CONFIG_SOFT_I2C
++#define CONFIG_SOFT_I2C_GPIO_SCL AT91_PIN_PA31
++#define CONFIG_SOFT_I2C_GPIO_SDA AT91_PIN_PA30
++#define CONFIG_SYS_I2C_SOFT_SPEED 50000
++#define CONFIG_SYS_I2C_SPEED CONFIG_SYS_I2C_SOFT_SPEED
++/* Values from previous levels of Conduit U-Boot */
++#define CONFIG_SYS_I2C_SLAVE 0xfe
++#define I2C_RXTX_LEN 128
++
++/* I2C eeprom support */
++#define CONFIG_CMD_EEPROM
++#define CONFIG_SYS_I2C_EEPROM_ADDR 0x56 /* at24c04 */
++#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1 /* Bytes of address<---><------>*/
++#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
++
++
+ #define CONFIG_SYS_LOAD_ADDR 0x22000000 /* load address */
+
+ #define CONFIG_SYS_MEMTEST_START CONFIG_SYS_SDRAM_BASE
+@@ -156,11 +199,11 @@
+ /* bootstrap + u-boot + env + linux in nandflash */
+ #define CONFIG_ENV_IS_IN_NAND
+ #define CONFIG_ENV_OFFSET 0xc0000
+-#define CONFIG_ENV_OFFSET_REDUND 0x100000
++#define CONFIG_ENV_OFFSET_REDUND 0x160000
+ #define CONFIG_ENV_SIZE 0x20000 /* 1 sector = 128 kB */
+-#define CONFIG_BOOTCOMMAND "nand read " \
+- "0x22000000 0x200000 0x300000; " \
+- "bootm 0x22000000"
++/* MTR: read from env variables for boot */
++#define CONFIG_BOOTCOMMAND "nboot.jffs2 ${loadaddr} 0 ${kernel_addr}; bootm ${loadaddr}"
++
+ #elif defined(CONFIG_SYS_USE_SPIFLASH)
+ /* bootstrap + u-boot + env + linux in spi flash */
+ #define CONFIG_ENV_IS_IN_SPI_FLASH
+@@ -197,6 +240,9 @@
+ "8M(bootstrap/uboot/kernel)ro,-(rootfs) " \
+ "root=/dev/mmcblk0p2 " \
+ "rw rootfstype=ext4 rootwait"
++#elif defined(USE_MTR)
++/* MTR uses jffs2 */
++#define CONFIG_BOOTARGS "mem=128M console=ttyS0,115200 root=/dev/mtdblock8 ro rootfstype=jffs2"
+ #else
+ #define CONFIG_BOOTARGS \
+ "console=ttyS0,115200 earlyprintk " \
+@@ -274,4 +320,21 @@
+
+ #endif
+
++/* MTR defaults */
++#define CONFIG_ENV_OVERWRITE 1 /* Allow Overwrite of serial# & ethaddr */
++#define CONFIG_ETHADDR 00:08:00:87:00:02
++#define CONFIG_IPADDR 192.168.2.1
++#define CONFIG_NETMASK 255.255.255.0
++#define CONFIG_SERVERIP 192.168.2.2
++#define CONFIG_HOSTNAME AT91SAM9G25
++#define CONFIG_LOADADDR 0x22000000
++
++/* MTR - enable watchdog */
++#define CONFIG_AT91SAM9_WATCHDOG 1
++#define CONFIG_HW_WATCHDOG 1
++#define CONFIG_AT91_HW_WDT_TIMEOUT 16
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ "kernel_addr=0x200000\0" \
++ ""
++
+ #endif
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/printeepromcrc.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/printeepromcrc.patch
new file mode 100644
index 0000000..19fca02
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/printeepromcrc.patch
@@ -0,0 +1,56 @@
+diff -raNu old/common/env_nand.c new/common/env_nand.c
+--- old/common/env_nand.c 2017-05-11 16:27:26.160067136 -0500
++++ new/common/env_nand.c 2017-05-11 16:44:12.134434145 -0500
+@@ -68,15 +68,22 @@
+ #if defined(ENV_IS_EMBEDDED) || defined(CONFIG_NAND_ENV_DST)
+ int crc1_ok = 0, crc2_ok = 0;
+ env_t *tmp_env1;
++ uint32_t calc_crc;
+
+ #ifdef CONFIG_ENV_OFFSET_REDUND
+ env_t *tmp_env2;
+
+ tmp_env2 = (env_t *)((ulong)env_ptr + CONFIG_ENV_SIZE);
+- crc2_ok = crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc;
++ calc_crc = crc32(0, tmp_env2->data, ENV_SIZE);
++ crc2_ok = (calc_crc == tmp_env2->crc);
++ printf("env_relocate_spec: crc2_ok=%d saved crc=0x%x calculated crc=0x%x flags=%d\n",
++ crc2_ok,tmp_env2->crc,calc_crc,tmp_env2->flags);
+ #endif
+ tmp_env1 = env_ptr;
+- crc1_ok = crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc;
++ calc_crc = crc32(0, tmp_env1->data, ENV_SIZE);
++ crc1_ok = (calc_crc == tmp_env1->crc);
++ printf("env_relocate_spec: crc1_ok=%d saved crc=0x%x calculated crc=0x%x flags=%d\n",
++ crc1_ok,tmp_env1->crc,calc_crc,tmp_env1->flags);
+
+ if (!crc1_ok && !crc2_ok) {
+ gd->env_addr = 0;
+@@ -317,6 +324,7 @@
+ int read1_fail = 0, read2_fail = 0;
+ int crc1_ok = 0, crc2_ok = 0;
+ env_t *ep, *tmp_env1, *tmp_env2;
++ uint32_t calc_crc;
+
+ tmp_env1 = (env_t *)malloc(CONFIG_ENV_SIZE);
+ tmp_env2 = (env_t *)malloc(CONFIG_ENV_SIZE);
+@@ -334,11 +342,16 @@
+ else if (read1_fail || read2_fail)
+ puts("*** Warning - some problems detected "
+ "reading environment; recovered successfully\n");
+-
++ calc_crc = crc32(0, tmp_env1->data, ENV_SIZE);
+ crc1_ok = !read1_fail &&
+- (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc);
++ (calc_crc == tmp_env1->crc);
++ printf("env_relocate_spec: crc1_ok=%d saved crc=0x%x calculated crc=0x%x flags=%d\n",
++ crc1_ok,tmp_env1->crc,calc_crc,tmp_env1->flags);
++ calc_crc = crc32(0, tmp_env2->data, ENV_SIZE);
+ crc2_ok = !read2_fail &&
+- (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc);
++ (calc_crc == tmp_env2->crc);
++ printf("env_relocate_spec: crc2_ok=%d saved crc=0x%x calculated crc=0x%x flags=%d\n",
++ crc2_ok,tmp_env2->crc,calc_crc,tmp_env2->flags);
+
+ if (!crc1_ok && !crc2_ok) {
+ set_default_env("!bad CRC");
diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/tftpput.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/tftpput.patch
new file mode 100644
index 0000000..b5e419f
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-2016.09.01/tftpput.patch
@@ -0,0 +1,28 @@
+/*
+ * tftpput in u-boot has two issues. It never resets the timeout, so
+ * tftpput must complete within the timeout perious (by defaut 5 seconds)
+ * and it does not properly handle the block wrap at 65535 back to zero,
+ * so it will transmit data forever, or at least a very long time, if
+ * the timeout is set long enough, or the timeout issue is patched by
+ * itself.
+ */
+diff -Naru old/net/tftp.c new/net/tftp.c
+--- old/net/tftp.c 2017-07-05 15:52:28.865818329 -0500
++++ new/net/tftp.c 2017-07-11 16:15:27.870430395 -0500
+@@ -499,10 +499,15 @@
+ int block = ntohs(*s);
+ int ack_ok = (tftp_cur_block == block);
+
++ /* update_block_number needs tftp_prev_block */
++ tftp_prev_block = tftp_cur_block;
+ tftp_cur_block = (unsigned short)(block + 1);
+ update_block_number();
+- if (ack_ok)
++ if (ack_ok) {
++ /* We got the ACK, so reset the timeout */
++ net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
+ tftp_send(); /* Send next data block */
++ }
+ }
+ }
+ #endif
diff --git a/recipes-bsp/u-boot/u-boot.inc b/recipes-bsp/u-boot/u-boot.inc
new file mode 100644
index 0000000..8854181
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot.inc
@@ -0,0 +1,316 @@
+SUMMARY = "Universal Boot Loader for embedded devices"
+HOMEPAGE = "http://www.denx.de/wiki/U-Boot/WebHome"
+SECTION = "bootloaders"
+PROVIDES = "virtual/bootloader"
+
+# New U-Boot with suppressed version.
+PR="m3"
+
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6"
+
+SRC_URI = "git://git.denx.de/u-boot.git;branch=master"
+
+S = "${WORKDIR}/git"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+inherit uboot-config deploy
+
+EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" V=1'
+EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"'
+
+PACKAGECONFIG ??= "openssl"
+# u-boot will compile its own tools during the build, with specific
+# configurations (aka when CONFIG_FIT_SIGNATURE is enabled) openssl is needed as
+# a host build dependency.
+PACKAGECONFIG[openssl] = ",,openssl-native"
+
+# Allow setting an additional version string that will be picked up by the
+# u-boot build system and appended to the u-boot version. If the .scmversion
+# file already exists it will not be overwritten.
+UBOOT_LOCALVERSION ?= ""
+
+# Some versions of u-boot use .bin and others use .img. By default use .bin
+# but enable individual recipes to change this value.
+UBOOT_SUFFIX ??= "bin"
+UBOOT_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_SUFFIX}"
+UBOOT_BINARY ?= "u-boot.${UBOOT_SUFFIX}"
+UBOOT_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_SUFFIX}"
+UBOOT_MAKE_TARGET ?= "all"
+
+# Output the ELF generated. Some platforms can use the ELF file and directly
+# load it (JTAG booting, QEMU) additionally the ELF can be used for debugging
+# purposes.
+UBOOT_ELF ?= ""
+UBOOT_ELF_SUFFIX ?= "elf"
+UBOOT_ELF_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_ELF_SUFFIX}"
+UBOOT_ELF_BINARY ?= "u-boot.${UBOOT_ELF_SUFFIX}"
+UBOOT_ELF_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_ELF_SUFFIX}"
+
+# Some versions of u-boot build an SPL (Second Program Loader) image that
+# should be packaged along with the u-boot binary as well as placed in the
+# deploy directory. For those versions they can set the following variables
+# to allow packaging the SPL.
+#SPL_BINARY ?= ""
+#SPL_BINARYNAME ?= "${@os.path.basename(d.getVar("SPL_BINARY", True))}"
+#SPL_IMAGE ?= "${SPL_BINARYNAME}-${MACHINE}-${PV}-${PR}"
+#SPL_SYMLINK ?= "${SPL_BINARYNAME}-${MACHINE}"
+
+# Additional environment variables or a script can be installed alongside
+# u-boot to be used automatically on boot. This file, typically 'uEnv.txt'
+# or 'boot.scr', should be packaged along with u-boot as well as placed in the
+# deploy directory. Machine configurations needing one of these files should
+# include it in the SRC_URI and set the UBOOT_ENV parameter.
+UBOOT_ENV_SUFFIX ?= "txt"
+UBOOT_ENV ?= ""
+UBOOT_ENV_BINARY ?= "${UBOOT_ENV}.${UBOOT_ENV_SUFFIX}"
+UBOOT_ENV_IMAGE ?= "${UBOOT_ENV}-${MACHINE}-${PV}-${PR}.${UBOOT_ENV_SUFFIX}"
+UBOOT_ENV_SYMLINK ?= "${UBOOT_ENV}-${MACHINE}.${UBOOT_ENV_SUFFIX}"
+FILES_${PN}-dev += "${includedir}/u-boot/* ${includedir}/u-boot/configs/* ${includedir}/u-boot/asm/*"
+
+# Put the PR into the U-Boot image. u-boot allows a local
+# version in a file called localversion.*
+# For some reason, this must be written in python.
+do_patch_append () {
+ try:
+ S = d.getVar("S",True)
+ except TypeError:
+ bb.fatal("S is missing from recipe")
+
+ f = open(S + "/localversion.mt","w")
+
+ try:
+ PR = d.getVar("PR",True)
+ except TypeError:
+ bb.fatal("PR is missing from recipe")
+ f.write(PR + os.linesep)
+}
+
+
+do_compile () {
+ if [ "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld-is-gold', '', d)}" = "ld-is-gold" ] ; then
+ sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' config.mk
+ fi
+
+ unset LDFLAGS
+ unset CFLAGS
+ unset CPPFLAGS
+
+ if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ]
+ then
+ echo ${UBOOT_LOCALVERSION} > ${B}/.scmversion
+ echo ${UBOOT_LOCALVERSION} > ${S}/.scmversion
+ fi
+
+ if [ "x${UBOOT_CONFIG}" != "x" ]
+ then
+ for config in ${UBOOT_MACHINE}; do
+ i=`expr $i + 1`;
+ for type in ${UBOOT_CONFIG}; do
+ j=`expr $j + 1`;
+ if [ $j -eq $i ]
+ then
+ oe_runmake O=${config} ${config} --defconfig mtconfig
+ oe_runmake O=${config} ${UBOOT_MAKE_TARGET}
+ cp ${S}/${config}/${UBOOT_BINARY} ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX}
+ fi
+ done
+ unset j
+ done
+ unset i
+ else
+ oe_runmake ${UBOOT_MACHINE}
+ oe_runmake ${UBOOT_MAKE_TARGET}
+ fi
+
+}
+
+do_install () {
+ if [ "x${UBOOT_CONFIG}" != "x" ]
+ then
+ for config in ${UBOOT_MACHINE}; do
+ i=`expr $i + 1`;
+ for type in ${UBOOT_CONFIG}; do
+ j=`expr $j + 1`;
+ if [ $j -eq $i ]
+ then
+ install -d ${D}/boot
+ install ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}
+ fi
+ done
+ unset j
+ done
+ unset i
+ else
+ install -d ${D}/boot
+ install ${S}/${UBOOT_BINARY} ${D}/boot/${UBOOT_IMAGE}
+ ln -sf ${UBOOT_IMAGE} ${D}/boot/${UBOOT_BINARY}
+ fi
+
+ if [ "x${UBOOT_ELF}" != "x" ]
+ then
+ if [ "x${UBOOT_CONFIG}" != "x" ]
+ then
+ for config in ${UBOOT_MACHINE}; do
+ i=`expr $i + 1`;
+ for type in ${UBOOT_CONFIG}; do
+ j=`expr $j + 1`;
+ if [ $j -eq $i ]
+ then
+ install ${S}/${config}/${UBOOT_ELF} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}
+ fi
+ done
+ unset j
+ done
+ unset i
+ else
+ install ${S}/${UBOOT_ELF} ${D}/boot/${UBOOT_ELF_IMAGE}
+ ln -sf ${UBOOT_ELF_IMAGE} ${D}/boot/${UBOOT_ELF_BINARY}
+ fi
+ fi
+
+ if [ -e ${WORKDIR}/fw_env.config ] ; then
+ install -d ${D}${sysconfdir}
+ install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config
+ fi
+
+ if [ "x${SPL_BINARY}" != "x" ]
+ then
+ if [ "x${UBOOT_CONFIG}" != "x" ]
+ then
+ for config in ${UBOOT_MACHINE}; do
+ i=`expr $i + 1`;
+ for type in ${UBOOT_CONFIG}; do
+ j=`expr $j + 1`;
+ if [ $j -eq $i ]
+ then
+ install ${S}/${config}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}-${type}-${PV}-${PR}
+ ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME}-${type}
+ ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME}
+ fi
+ done
+ unset j
+ done
+ unset i
+ else
+ install ${S}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}
+ ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARYNAME}
+ fi
+ fi
+
+ if [ "x${UBOOT_ENV}" != "x" ]
+ then
+ install ${WORKDIR}/${UBOOT_ENV_BINARY} ${D}/boot/${UBOOT_ENV_IMAGE}
+ ln -sf ${UBOOT_ENV_IMAGE} ${D}/boot/${UBOOT_ENV_BINARY}
+ fi
+ mkdir -p ${D}/usr/include/u-boot || true
+ (cd ${S}/include;find . | cpio -pdum ${D}/usr/include/u-boot)
+ (cd ${S}/arch/arm;rm -f ${D}/usr/include/mach-at91;find mach-at91 | cpio -pdum ${D}/usr/include/)
+ (cd ${S} ; rm -f ${D}/usr/include/u-boot/asm ; cd arch/arm/include ; find asm | cpio -pdum ${D}/usr/include/u-boot)
+}
+
+FILES_${PN} = "/boot ${sysconfdir}"
+
+do_deploy () {
+ if [ "x${UBOOT_CONFIG}" != "x" ]
+ then
+ for config in ${UBOOT_MACHINE}; do
+ i=`expr $i + 1`;
+ for type in ${UBOOT_CONFIG}; do
+ j=`expr $j + 1`;
+ if [ $j -eq $i ]
+ then
+ install -d ${DEPLOYDIR}
+ install ${S}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX}
+ cd ${DEPLOYDIR}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}-${type}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}-${type}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}
+ fi
+ done
+ unset j
+ done
+ unset i
+ else
+ install -d ${DEPLOYDIR}
+ install ${S}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE}
+ cd ${DEPLOYDIR}
+ rm -f ${UBOOT_BINARY} ${UBOOT_SYMLINK}
+ ln -sf ${UBOOT_IMAGE} ${UBOOT_SYMLINK}
+ ln -sf ${UBOOT_IMAGE} ${UBOOT_BINARY}
+ fi
+
+ if [ "x${UBOOT_ELF}" != "x" ]
+ then
+ if [ "x${UBOOT_CONFIG}" != "x" ]
+ then
+ for config in ${UBOOT_MACHINE}; do
+ i=`expr $i + 1`;
+ for type in ${UBOOT_CONFIG}; do
+ j=`expr $j + 1`;
+ if [ $j -eq $i ]
+ then
+ install ${S}/${config}/${UBOOT_ELF} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}-${type}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}-${type}
+ ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}
+ fi
+ done
+ unset j
+ done
+ unset i
+ else
+ install ${S}/${UBOOT_ELF} ${DEPLOYDIR}/${UBOOT_ELF_IMAGE}
+ ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}
+ ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}
+ fi
+ fi
+
+
+ if [ "x${SPL_BINARY}" != "x" ]
+ then
+ if [ "x${UBOOT_CONFIG}" != "x" ]
+ then
+ for config in ${UBOOT_MACHINE}; do
+ i=`expr $i + 1`;
+ for type in ${UBOOT_CONFIG}; do
+ j=`expr $j + 1`;
+ if [ $j -eq $i ]
+ then
+ install ${S}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}-${type}-${PV}-${PR}
+ rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
+ ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}-${type}
+ ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}
+ ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
+ ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}
+ fi
+ done
+ unset j
+ done
+ unset i
+ else
+ install ${S}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}
+ rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}
+ ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARYNAME}
+ ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK}
+ fi
+ fi
+
+
+ if [ "x${UBOOT_ENV}" != "x" ]
+ then
+ install ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE}
+ rm -f ${DEPLOYDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
+ ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY}
+ ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
+ fi
+}
+
+addtask deploy before do_build after do_compile
diff --git a/recipes-bsp/u-boot/u-boot_2016.09.01.bb b/recipes-bsp/u-boot/u-boot_2016.09.01.bb
new file mode 100644
index 0000000..59b3c4c
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot_2016.09.01.bb
@@ -0,0 +1,34 @@
+require u-boot.inc
+
+DEPENDS += "dtc-native"
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-2016.09.01:"
+
+SRC_URI = "ftp://ftp.denx.de/pub/u-boot/u-boot-${PV}.tar.bz2 \
+ file://kconfig_common.patch \
+ file://config.patch \
+ file://i2c.patch \
+ file://printeepromcrc.patch \
+ file://mtpwd.patch \
+ file://tftpput.patch \
+ file://hide_uboot_version.patch \
+ file://fix_2_6.patch \
+ file://fix_net.patch"
+
+SRC_URI_append_mtcdt = " \
+ file://mtcdt.patch \
+ file://mtcdt_flush_console_autoboot.patch"
+
+SRC_URI_append_mtcap = " \
+ file://mtcdt.patch"
+
+SRC_URI_append_mtr = "\
+ file://mtr.patch \
+"
+SRC_URI_append_mtrv1 = "\
+ file://mtrv1.patch \
+"
+
+SRC_URI[md5sum] = "61c628f8034477c946e173ed174efeb4"
+SRC_URI[sha256sum] = "95728e89dd476d17428f94080752ab48884be477b6a678941582aeef618b70bb"
+
+S = "${WORKDIR}/${PN}-${PV}"