From 4865efd9ceaa0296b03e4aa02dc9af0e59a6d716 Mon Sep 17 00:00:00 2001 From: John Klug Date: Wed, 17 May 2017 08:31:01 -0500 Subject: Put patches in the same location as prior u-boot recipes. --- recipes-bsp/u-boot/u-boot-2016.09.01/config.patch | 28 ++ recipes-bsp/u-boot/u-boot-2016.09.01/i2c.patch | 114 ++++++++ recipes-bsp/u-boot/u-boot-2016.09.01/macb.patch | 54 ++++ recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt.patch | 292 ++++++++++++++++++++ .../u-boot/u-boot-2016.09.01/mtcdt/config.patch | 28 -- .../u-boot/u-boot-2016.09.01/mtcdt/i2c.patch | 114 -------- .../u-boot/u-boot-2016.09.01/mtcdt/macb.patch | 54 ---- .../u-boot/u-boot-2016.09.01/mtcdt/mtcdt.patch | 292 -------------------- .../u-boot/u-boot-2016.09.01/mtcdt/mtpwd.patch | 302 --------------------- .../u-boot-2016.09.01/mtcdt/printeepromcrc.patch | 56 ---- recipes-bsp/u-boot/u-boot-2016.09.01/mtpwd.patch | 302 +++++++++++++++++++++ .../u-boot/u-boot-2016.09.01/printeepromcrc.patch | 56 ++++ 12 files changed, 846 insertions(+), 846 deletions(-) create mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/config.patch create mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/i2c.patch create mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/macb.patch create mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt.patch delete mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/config.patch delete mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/i2c.patch delete mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/macb.patch delete mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/mtcdt.patch delete mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/mtpwd.patch delete mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/printeepromcrc.patch create mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/mtpwd.patch create mode 100644 recipes-bsp/u-boot/u-boot-2016.09.01/printeepromcrc.patch (limited to 'recipes-bsp/u-boot') 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..726b9bf --- /dev/null +++ b/recipes-bsp/u-boot/u-boot-2016.09.01/config.patch @@ -0,0 +1,28 @@ +diff -raNu old/configs/at91sam9x5ek_nandflash_defconfig new/configs/at91sam9x5ek_nandflash_defconfig +--- old/configs/at91sam9x5ek_nandflash_defconfig 2017-05-04 14:33:41.143172324 -0500 ++++ new/configs/at91sam9x5ek_nandflash_defconfig 2017-05-04 17:54:27.132377607 -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 +@@ -23,3 +23,12 @@ + 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_USB=y ++CONFIG_CMD_NAND=y ++CONFIG_CMD_BOOTZ=y ++CONFIG_CMD_MII=y ++CONFIG_CMD_I2C=y 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/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 + #include + +-#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 +@@ -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/config.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/config.patch deleted file mode 100644 index 726b9bf..0000000 --- a/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/config.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff -raNu old/configs/at91sam9x5ek_nandflash_defconfig new/configs/at91sam9x5ek_nandflash_defconfig ---- old/configs/at91sam9x5ek_nandflash_defconfig 2017-05-04 14:33:41.143172324 -0500 -+++ new/configs/at91sam9x5ek_nandflash_defconfig 2017-05-04 17:54:27.132377607 -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 -@@ -23,3 +23,12 @@ - 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_USB=y -+CONFIG_CMD_NAND=y -+CONFIG_CMD_BOOTZ=y -+CONFIG_CMD_MII=y -+CONFIG_CMD_I2C=y diff --git a/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/i2c.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/i2c.patch deleted file mode 100644 index a5087ea..0000000 --- a/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/i2c.patch +++ /dev/null @@ -1,114 +0,0 @@ -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/mtcdt/macb.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/macb.patch deleted file mode 100644 index 5869628..0000000 --- a/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/macb.patch +++ /dev/null @@ -1,54 +0,0 @@ -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/mtcdt.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/mtcdt.patch deleted file mode 100644 index 4f265df..0000000 --- a/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/mtcdt.patch +++ /dev/null @@ -1,292 +0,0 @@ -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 - #include - --#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 -@@ -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/mtpwd.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/mtpwd.patch deleted file mode 100644 index a97b976..0000000 --- a/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/mtpwd.patch +++ /dev/null @@ -1,302 +0,0 @@ -diff -raNu old/common/cli.c new/common/cli.c ---- old/common/cli.c 2017-05-11 17:59:53.806580961 -0500 -+++ new/common/cli.c 2017-05-11 18:06:16.575014377 -0500 -@@ -227,6 +227,7 @@ - - void cli_init(void) - { -+ mts_run_passwd_loop(); - #ifdef CONFIG_HUSH_PARSER - u_boot_hush_start(); - #endif -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 -+#include -+#include -+#include -+#include -+ -+#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 - #include - #include -+#include - #if defined(CONFIG_PCI) && defined(CONFIG_4xx) - #include - #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/mtcdt/printeepromcrc.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/printeepromcrc.patch deleted file mode 100644 index 19fca02..0000000 --- a/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdt/printeepromcrc.patch +++ /dev/null @@ -1,56 +0,0 @@ -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/mtpwd.patch b/recipes-bsp/u-boot/u-boot-2016.09.01/mtpwd.patch new file mode 100644 index 0000000..a97b976 --- /dev/null +++ b/recipes-bsp/u-boot/u-boot-2016.09.01/mtpwd.patch @@ -0,0 +1,302 @@ +diff -raNu old/common/cli.c new/common/cli.c +--- old/common/cli.c 2017-05-11 17:59:53.806580961 -0500 ++++ new/common/cli.c 2017-05-11 18:06:16.575014377 -0500 +@@ -227,6 +227,7 @@ + + void cli_init(void) + { ++ mts_run_passwd_loop(); + #ifdef CONFIG_HUSH_PARSER + u_boot_hush_start(); + #endif +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 ++#include ++#include ++#include ++#include ++ ++#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 + #include + #include ++#include + #if defined(CONFIG_PCI) && defined(CONFIG_4xx) + #include + #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/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"); -- cgit v1.2.3