diff options
| author | mattis fjallstrom <mattis@acm.org> | 2015-09-06 11:09:39 -0700 |
|---|---|---|
| committer | mattis fjallstrom <mattis@acm.org> | 2015-09-06 11:09:39 -0700 |
| commit | ee87ec4d2c955c929a4c27ce8a56f918444cf955 (patch) | |
| tree | c18141755ad893eddd5b504e4cf096ad4e7062b9 /include | |
| parent | 2c25de1ed5c6f8f6bba3b5ec506f430d8a883a83 (diff) | |
| download | olio-uboot-2014.01-ee87ec4d2c955c929a4c27ce8a56f918444cf955.tar.xz olio-uboot-2014.01-ee87ec4d2c955c929a4c27ce8a56f918444cf955.zip | |
First fastboot commit, MLO built here wont work so be careful.
Change-Id: Ic8d65a92da82896282eee71cf0d0515f64c939bc
Diffstat (limited to 'include')
| -rw-r--r-- | include/configs/omap3_h1.h | 100 | ||||
| -rw-r--r-- | include/olioh1_reboot.h | 32 | ||||
| -rw-r--r-- | include/sparse_format.h | 50 | ||||
| -rw-r--r-- | include/usb/fastboot.h | 213 |
4 files changed, 394 insertions, 1 deletions
diff --git a/include/configs/omap3_h1.h b/include/configs/omap3_h1.h index b406bde99..ebb71ffad 100644 --- a/include/configs/omap3_h1.h +++ b/include/configs/omap3_h1.h @@ -20,6 +20,31 @@ #define CONFIG_OMAP_GPIO #define CONFIG_OMAP_COMMON + +/* USB UHH support options */ +#define CONFIG_CMD_USB +#define CONFIG_USB_HOST +#define CONFIG_USB_EHCI +#define CONFIG_USB_EHCI_OMAP +#define CONFIG_USB_STORAGE +#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3 +#define CONFIG_EHCI_HCD_INIT_AFTER_RESET + +/* #define CONFIG_USB_MUSB_AM35X */ +#define CONFIG_USB_MUSB_OMAP2PLUS + +/* USB Composite download gadget - g_dnl */ +#define CONFIG_USB_GADGET +#define CONFIG_USBDOWNLOAD_GADGET + + +/* USB TI's IDs */ +#define CONFIG_USBD_HS +#define CONFIG_G_DNL_VENDOR_NUM 0x0403 +#define CONFIG_G_DNL_PRODUCT_NUM 0xBD00 +#define CONFIG_G_DNL_MANUFACTURER "Texas Instruments" + + #define CONFIG_SDRC /* The chip has SDRC controller */ #include <asm/arch/cpu.h> /* get chip and board defs */ @@ -261,6 +286,79 @@ * FLASH and environment organization */ +#define CONFIG_MMC +#define CONFIG_GENERIC_MMC +#define CONFIG_OMAP_HSMMC +#define CONFIG_CMD_MMC +#define CONFIG_DOS_PARTITION +#define CONFIG_CMD_FAT +#define CONFIG_FAT_WRITE +#define CONFIG_CMD_EXT2 + +#define CONFIG_SPI +#define CONFIG_OMAP3_SPI +#define CONFIG_MTD_DEVICE +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_WINBOND +#define CONFIG_CMD_SF +#define CONFIG_SF_DEFAULT_SPEED (24000000) + + +/* + * USB configuration + */ +#define CONFIG_USB_MUSB_DSPS +/* #define CONFIG_ARCH_MISC_INIT */ + +#define CONFIG_CMD_SAVEENV +#define CONFIG_MUSB_GADGET +#define CONFIG_MUSB_PIO_ONLY +#define CONFIG_USB_GADGET_DUALSPEED +#define CONFIG_USB_GADGET_VBUS_DRAW 2 + + +#ifdef CONFIG_MUSB_GADGET +/* Android fastboot support over USB */ +#define CONFIG_CMD_FASTBOOT +#define FASTBOOT_DEVICE_VENDOR_ID 0x0451 +#define FASTBOOT_DEVICE_PRODUCT_ID 0xd00e /* TI fastboot PID */ +#define FASTBOOT_DEVICE_BCD 0x0100 + +#define FASTBOOT_BLKDEV "nand0" +/* + * BeagleBone white, AM335x-SK and old AM335xEVMs have only 256MB RAM + * To be compatible with all devices, assume 256MB max RAM. + * + * The current fastboot implementation assumes maximum 16MB of RAM + * will be used by u-boot itself. So the fastboot transfer buffer + * becomes (256-16)=240MB + */ + +/* #define CONFIG_FASTBOOT_MAX_TRANSFER_SIZE (SZ_256M - SZ_16M) */ +/* If using BeagleBone Black you can use the full RAM and so + flash larger images */ +#define CONFIG_FASTBOOT_MAX_TRANSFER_SIZE (SZ_512M - SZ_16M) + +#define FASTBOOT_NAND_BLOCK_SIZE 2048 +#define FASTBOOT_NAND_OOB_SIZE 64 + +#define CONFIG_MMC_FASTBOOT_DEV 1 + +/*Uncomment this to enable NAND fastboot*/ +#define CONFIG_FASTBOOT_NAND + +/*Uncomment this to support eMMC booting*/ +/* #define CONFIG_STORAGE_EMMC */ + +#define NAND_ENV_OFFSET 0x260000 /* environment starts here */ + +/* ethernet gadget conflicts with fastboot, so disabled */ +/* +#define CONFIG_USB_ETHER +#define CONFIG_USB_ETH_RNDIS +#define CONFIG_USBNET_HOST_ADDR "de:ad:be:af:00:00"*/ +#endif /* CONFIG_MUSB_GADGET */ + /* **** PISMO SUPPORT *** */ /* Configure the PISMO */ @@ -350,7 +448,7 @@ #define CONFIG_SYS_NAND_ECCPOS {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} #define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_SW #endif /* BCH8_ECC */ diff --git a/include/olioh1_reboot.h b/include/olioh1_reboot.h new file mode 100644 index 000000000..1fbea3e74 --- /dev/null +++ b/include/olioh1_reboot.h @@ -0,0 +1,32 @@ +/* + * (C) Copyright 2014 + * Chris Simmonds, 2net Ltd. chris@2net.co.uk + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* Here we define an address in SRAM that can contain a flag to indicate + the reason for a reboot. + + I chose an address 16 bytes from the end of SRAM in the hope that + nobody will clobber it between Linux reboot and U-Boot starting */ +#define REBOOT_REASON_PA 0x4030fff0 + +#define REBOOT_FLAG_RECOVERY 0x52564352 +#define REBOOT_FLAG_FASTBOOT 0x54534146 +#define REBOOT_FLAG_NORMAL 0x4D524F4E +#define REBOOT_FLAG_POWER_OFF 0x46464F50 + diff --git a/include/sparse_format.h b/include/sparse_format.h new file mode 100644 index 000000000..6c62c34c7 --- /dev/null +++ b/include/sparse_format.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +typedef struct sparse_header { + __le32 magic; /* 0xed26ff3a */ + __le16 major_version; /* (0x1) - reject images with higher major versions */ + __le16 minor_version; /* (0x0) - allow images with higer minor versions */ + __le16 file_hdr_sz; /* 28 bytes for first revision of the file format */ + __le16 chunk_hdr_sz; /* 12 bytes for first revision of the file format */ + __le32 blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */ + __le32 total_blks; /* total blocks in the non-sparse output image */ + __le32 total_chunks; /* total chunks in the sparse input image */ + __le32 image_checksum; /* CRC32 checksum of the original data, counting "don't care" */ + /* as 0. Standard 802.3 polynomial, use a Public Domain */ + /* table implementation */ +} sparse_header_t; + +#define SPARSE_HEADER_MAGIC 0xed26ff3a + +#define CHUNK_TYPE_RAW 0xCAC1 +#define CHUNK_TYPE_FILL 0xCAC2 +#define CHUNK_TYPE_DONT_CARE 0xCAC3 +#define CHUNK_TYPE_CRC32 0xCAC4 + +typedef struct chunk_header { + __le16 chunk_type; /* 0xCAC1 -> raw; 0xCAC2 -> fill; 0xCAC3 -> don't care */ + __le16 reserved1; + __le32 chunk_sz; /* in blocks in output image */ + __le32 total_sz; /* in bytes of chunk input file including chunk header and data */ +} chunk_header_t; + +/* Following a Raw or Fill or CRC32 chunk is data. + * For a Raw chunk, it's the data in chunk_sz * blk_sz. + * For a Fill chunk, it's 4 bytes of the fill data. + * For a CRC32 chunk, it's 4 bytes of CRC32 + */ + diff --git a/include/usb/fastboot.h b/include/usb/fastboot.h new file mode 100644 index 000000000..9525454bc --- /dev/null +++ b/include/usb/fastboot.h @@ -0,0 +1,213 @@ +/* + * (C) Copyright 2008 - 2009 + * Windriver, <www.windriver.com> + * Tom Rix <Tom.Rix at windriver.com> + * + * Copyright (c) 2011 Sebastian Andrzej Siewior <bigeasy at linutronix.de> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * The logical naming of flash comes from the Android project + * Thse structures and functions that look like fastboot_flash_* + * They come from bootloader/legacy/include/boot/flash.h + * + * The boot_img_hdr structure and associated magic numbers also + * come from the Android project. They are from + * bootloader/legacy/include/boot/bootimg.h + * + * Here are their copyrights + * + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#ifndef FASTBOOT_H +#define FASTBOOT_H + +#include <common.h> +#include <command.h> +#include <linux/usb/ch9.h> +#include <linux/usb/gadget.h> + +#ifdef DEBUG +#define FBTDBG(fmt,args...)\ + printf("DEBUG: [%s]: %d: \n"fmt, __FUNCTION__, __LINE__,##args) +#else +#define FBTDBG(fmt,args...) do{}while(0) +#endif + +#ifdef INFO +#define FBTINFO(fmt,args...)\ + printf("INFO: [%s]: "fmt, __FUNCTION__, ##args) +#else +#define FBTINFO(fmt,args...) do{}while(0) +#endif + +#ifdef WARN +#define FBTWARN(fmt,args...)\ + printf("WARNING: [%s]: "fmt, __FUNCTION__, ##args) +#else +#define FBTWARN(fmt,args...) do{}while(0) +#endif + +#ifdef ERR +#define FBTERR(fmt,args...)\ + printf("ERROR: [%s]: "fmt, __FUNCTION__, ##args) +#else +#define FBTERR(fmt,args...) do{}while(0) +#endif + +struct fastboot_config { + + /* + * Transfer buffer for storing data sent by the client. It should be + * able to hold a kernel image and flash partitions. Care should be + * take so it does not overrun bootloader memory + */ + unsigned char *transfer_buffer; + + /* Size of the buffer mentioned above */ + unsigned int transfer_buffer_size; + + /* Total data to be downloaded */ + unsigned int download_size; + + /* Data downloaded so far */ + unsigned int download_bytes; + + unsigned int nand_block_size; + + unsigned int nand_oob_size; + + unsigned int download_bytes_unpadded; +}; + +#define FB_STR_PRODUCT_IDX 1 +#define FB_STR_SERIAL_IDX 2 +#define FB_STR_CONFIG_IDX 3 +#define FB_STR_INTERFACE_IDX 4 +#define FB_STR_MANUFACTURER_IDX 5 +#define FB_STR_PROC_REV_IDX 6 +#define FB_STR_PROC_TYPE_IDX 7 + +#ifdef CONFIG_CMD_FASTBOOT + +int fastboot_init(void); +void fastboot_shutdown(void); +int fastboot_poll(void); + +int fastboot_board_init(struct fastboot_config *interface, + struct usb_gadget_strings **str); + + +/* Android-style flash naming */ +typedef struct fastboot_ptentry fastboot_ptentry; + +/* flash partitions are defined in terms of blocks + ** (flash erase units) + */ +struct fastboot_ptentry{ + + /* The logical name for this partition, null terminated */ + char name[16]; + /* The start wrt the nand part, must be multiple of nand block size */ + unsigned int start; + /* The length of the partition, must be multiple of nand block size */ + unsigned int length; + /* Controls the details of how operations are done on the partition + See the FASTBOOT_PTENTRY_FLAGS_*'s defined below */ + unsigned int flags; +}; + +/* Lower byte shows if the read/write/erase operation in + repeated. The base address is incremented. + Either 0 or 1 is ok for a default */ + +#define FASTBOOT_PTENTRY_FLAGS_REPEAT_MASK(n) (n & 0x0f) +#define FASTBOOT_PTENTRY_FLAGS_REPEAT_4 0x00000004 + +/* Writes happen a block at a time. + If the write fails, go to next block + NEXT_GOOD_BLOCK and CONTIGOUS_BLOCK can not both be set */ +#define FASTBOOT_PTENTRY_FLAGS_WRITE_NEXT_GOOD_BLOCK 0x00000010 + +/* Find a contiguous block big enough for a the whole file + NEXT_GOOD_BLOCK and CONTIGOUS_BLOCK can not both be set */ +#define FASTBOOT_PTENTRY_FLAGS_WRITE_CONTIGUOUS_BLOCK 0x00000020 + +/* Sets the ECC to software before writing + HW and SW ECC should not both be set. */ +#define FASTBOOT_PTENTRY_FLAGS_WRITE_SW_ECC 0x00000040 + +/* Sets the ECC to hardware before writing + HW and SW ECC should not both be set. */ +#define FASTBOOT_PTENTRY_FLAGS_WRITE_HW_ECC 0x00000080 + +/* Sets the ECC to hardware before writing + HW and SW ECC should not both be set. */ +#define FASTBOOT_PTENTRY_FLAGS_WRITE_HW_BCH4_ECC 0x00000100 + +/* Sets the ECC to hardware before writing + HW and SW ECC should not both be set. */ +#define FASTBOOT_PTENTRY_FLAGS_WRITE_HW_BCH8_ECC 0x00000200 + +/* Sets the ECC to hardware before writing + HW and SW ECC should not both be set. */ +#define FASTBOOT_PTENTRY_FLAGS_WRITE_HW_BCH16_ECC 0x00000400 + +/* Write the file with write.i */ +#define FASTBOOT_PTENTRY_FLAGS_WRITE_I 0x00000800 + +/* Write the file with write.jffs2 */ +#define FASTBOOT_PTENTRY_FLAGS_WRITE_JFFS2 0x00001000 + +/* Write the file as a series of variable/value pairs + using the setenv and saveenv commands */ +#define FASTBOOT_PTENTRY_FLAGS_WRITE_ENV 0x00002000 + + +/* The Android-style flash handling */ + +/* tools to populate and query the partition table */ +extern void fastboot_flash_add_ptn(fastboot_ptentry *ptn); +extern fastboot_ptentry *fastboot_flash_find_ptn(const char *name); +extern fastboot_ptentry *fastboot_flash_get_ptn(unsigned n); +extern unsigned int fastboot_flash_get_ptn_count(void); +extern void fastboot_flash_dump_ptn(void); +extern int fastboot_oem(const char *cmd); + + +#endif +#endif |