mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
update nand mbr and libnand
This commit is contained in:
@ -20,7 +20,8 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
# MA 02111-1307 USA
|
||||
#
|
||||
CROSS_COMPILE ?= arm-linux-gnueabi-
|
||||
|
||||
CROSS_COMPILE ?= arm-none-linux-gnueabi-
|
||||
|
||||
ifndef CONFIG_STANDALONE_LOAD_ADDR
|
||||
ifeq ($(SOC),omap3)
|
||||
|
@ -47,3 +47,25 @@ lowlevel_init:
|
||||
|
||||
SRAM_STACK:
|
||||
.word LOW_LEVEL_SRAM_STACK
|
||||
|
||||
.global sunxi_pre_clean
|
||||
sunxi_pre_clean:
|
||||
#if defined(CONFIG_SUN7I_FPGA)
|
||||
/* clear all registers for simulation */
|
||||
mov r0, #0
|
||||
mov r1, #0
|
||||
mov r2, #0
|
||||
mov r3, #0
|
||||
mov r4, #0
|
||||
mov r5, #0
|
||||
mov r6, #0
|
||||
mov r7, #0
|
||||
mov r8, #0
|
||||
mov r9, #0
|
||||
mov r10, #0
|
||||
mov r11, #0
|
||||
mov r12, #0
|
||||
|
||||
/* back to arch calling code */
|
||||
mov pc, lr
|
||||
#endif
|
||||
|
@ -178,11 +178,11 @@ int sunxi_partition_init(void)
|
||||
crc = calc_crc32(&mbr->version, MBR_SIZE-4);
|
||||
if(crc == mbr->crc32)
|
||||
{
|
||||
if(mbr->PartCount < 32)
|
||||
if(mbr->PartCount < MBR_MAX_PART_COUNT)
|
||||
{
|
||||
PARTITION* pe = mbr->array;
|
||||
|
||||
for(i=0; i<mbr->PartCount && i < MBR_MAX_PART_COUNT; i++, pe++)
|
||||
for(i=0; i<mbr->PartCount; i++, pe++)
|
||||
{
|
||||
unsigned long long len, addr;
|
||||
|
||||
|
@ -18,12 +18,13 @@
|
||||
|
||||
#define DOWNLOAD_MAP_NAME "dlinfo.fex"
|
||||
/* MBR */
|
||||
#define MBR_SIZE 1024
|
||||
#define MBR_MAGIC "softw311"
|
||||
#define MBR_SIZE (16*1024)
|
||||
#define MBR_MAGIC "softw411"
|
||||
#define MBR_START_ADDRESS 0x00000000
|
||||
#define MBR_MAX_PART_COUNT 15
|
||||
#define MBR_MAX_PART_COUNT 120
|
||||
#define MBR_COPY_NUM 4 //mbr<62>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define MBR_RESERVED (MBR_SIZE - 20 - (MBR_MAX_PART_COUNT * sizeof(PARTITION))) //mbr<62><72><EFBFBD><EFBFBD><EFBFBD>Ŀռ<C4BF>
|
||||
#define MBR_RESERVED (MBR_SIZE - 32 - (MBR_MAX_PART_COUNT * sizeof(PARTITION))) //mbr<62><72><EFBFBD><EFBFBD><EFBFBD>Ŀռ<C4BF>
|
||||
#define DL_RESERVED (DL_SIZE - 32 - (MBR_MAX_PART_COUNT * sizeof(dl_one_part_info)))
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ, 64byte
|
||||
typedef struct tag_PARTITION
|
||||
@ -32,47 +33,50 @@ typedef struct tag_PARTITION
|
||||
unsigned int addrlo; //
|
||||
unsigned int lenhi; //<2F><><EFBFBD><EFBFBD>
|
||||
unsigned int lenlo; //
|
||||
unsigned char classname[12]; //<2F><><EFBFBD>豸<EFBFBD><E8B1B8>
|
||||
unsigned char name[12]; //<2F><><EFBFBD>豸<EFBFBD><E8B1B8>
|
||||
unsigned char classname[16]; //<2F><><EFBFBD>豸<EFBFBD><E8B1B8>
|
||||
unsigned char name[16]; //<2F><><EFBFBD>豸<EFBFBD><E8B1B8>
|
||||
unsigned int user_type; //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
unsigned int keydata; //<2F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD>ݣ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ
|
||||
unsigned int ro; //<2F><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||
unsigned char res[16]; //<2F><><EFBFBD><EFBFBD>
|
||||
unsigned char reserved[68]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ128<EFBFBD>ֽ<EFBFBD>
|
||||
} __attribute__ ((packed))PARTITION;
|
||||
//MBR<42><52>Ϣ
|
||||
typedef struct tag_MBR
|
||||
{
|
||||
unsigned int crc32; // crc 1k - 4
|
||||
unsigned int version; // <20>汾<EFBFBD><E6B1BE>Ϣ<EFBFBD><CFA2> 0x00000100
|
||||
unsigned char magic[8]; //"softw311"
|
||||
unsigned char copy; //<2F><><EFBFBD><EFBFBD>
|
||||
unsigned char index; //<2F>ڼ<EFBFBD><DABC><EFBFBD>MBR<42><52><EFBFBD><EFBFBD>
|
||||
unsigned short PartCount; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
unsigned char magic[8]; //"softw411"
|
||||
unsigned int copy; //<2F><><EFBFBD><EFBFBD>
|
||||
unsigned int index; //<2F>ڼ<EFBFBD><DABC><EFBFBD>MBR<42><52><EFBFBD><EFBFBD>
|
||||
unsigned int PartCount; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
unsigned int stamp[1]; //<2F><><EFBFBD><EFBFBD>
|
||||
PARTITION array[MBR_MAX_PART_COUNT]; //
|
||||
unsigned char res[MBR_RESERVED];
|
||||
}__attribute__ ((packed)) MBR;
|
||||
|
||||
typedef struct tag_one_part_info
|
||||
{
|
||||
unsigned char classname[12]; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD>豸<EFBFBD><EFBFBD>
|
||||
unsigned char name[12]; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>
|
||||
unsigned char name[16]; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><EFBFBD>
|
||||
unsigned int addrhi; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ĸߵ<C4B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
unsigned int addrlo; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ĵ͵<C4B5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
unsigned int lenhi; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>ȣ<EFBFBD><C8A3><EFBFBD>32λ<32><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
unsigned int lenlo; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>ȣ<EFBFBD><C8A3><EFBFBD>32λ<32><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
unsigned char part_name[12]; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>MBR<42>еķ<D0B5><C4B7><EFBFBD> classname <20><>Ӧ
|
||||
unsigned char dl_filename[16]; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD>ȹ̶<C8B9>16<31>ֽ<EFBFBD>
|
||||
unsigned char vf_filename[16]; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD>ȹ̶<C8B9>16<31>ֽ<EFBFBD>
|
||||
unsigned int encrypt; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD> 0:<3A><><EFBFBD><EFBFBD> 1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
unsigned int verify; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3> 0:<3A><>У<EFBFBD><D0A3> 1<><31>У<EFBFBD><D0A3>
|
||||
}
|
||||
dl_one_part_info;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>Ϣ
|
||||
typedef struct tag_download_info
|
||||
{
|
||||
unsigned int crc32; //crc
|
||||
unsigned int version; //<2F>汾<EFBFBD><E6B1BE> 0x00000101
|
||||
unsigned char magic[8]; //"softw311"
|
||||
unsigned int download_count; //<2F><>Ҫ<EFBFBD><D2AA>д<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
unsigned int crc32; //crc
|
||||
unsigned int version; //<2F>汾<EFBFBD><E6B1BE> 0x00000101
|
||||
unsigned char magic[8]; //"softw311"
|
||||
unsigned int download_count; //<2F><>Ҫ<EFBFBD><D2AA>д<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
unsigned int stamp[3]; //<2F><><EFBFBD><EFBFBD>
|
||||
dl_one_part_info one_part_info[MBR_MAX_PART_COUNT]; //<2F><>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
unsigned char res[DL_RESERVED];
|
||||
}
|
||||
download_info;
|
||||
|
||||
|
@ -464,7 +464,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
|
||||
// debug("monitor flash len: %08lX\n", monitor_flash_len);
|
||||
#ifdef CONFIG_ALLWINNER
|
||||
#ifdef DEBUG
|
||||
// printf("sunxi script init\n");
|
||||
printf("sunxi script init\n");
|
||||
#endif
|
||||
sw_gpio_init();
|
||||
if(script_parser_fetch("target", "storage_type", &storage_type, sizeof(int)))
|
||||
|
@ -215,6 +215,7 @@ int do_boota_linux (struct fastboot_boot_img_hdr *hdr)
|
||||
sunxi_flash_exit();
|
||||
/* we assume that the kernel is in place */
|
||||
announce_and_cleanup();
|
||||
sr32(SUNXI_CCM_APB1_GATING, 16, 2, 0);
|
||||
sr32(SUNXI_CCM_APB1_GATING, 16, 1, 0);
|
||||
|
||||
kernel_entry(0, bd->bi_arch_number, bd->bi_boot_params);
|
||||
|
@ -42,8 +42,8 @@ void fastboot_flash_partition_init(void)
|
||||
{
|
||||
fastboot_ptentry fb_part;
|
||||
int index, part_total;
|
||||
char partition_sets[256];
|
||||
char part_name[16];
|
||||
char partition_sets[512];
|
||||
char part_name[32];
|
||||
char *pa_index;
|
||||
int part_name_count;
|
||||
|
||||
@ -57,9 +57,9 @@ void fastboot_flash_partition_init(void)
|
||||
}
|
||||
printf("-total partitions:%d-\n", part_total);
|
||||
printf("%-12s %-12s %-12s\n", "-name-", "-start-", "-size-");
|
||||
memset(partition_sets, ' ', 256);
|
||||
memset(partition_sets, ' ', sizeof(partition_sets));
|
||||
|
||||
memset(part_name, 0, 16);
|
||||
memset(part_name, 0, sizeof(part_name));
|
||||
if(!storage_type)
|
||||
{
|
||||
memcpy(part_name, "nanda", 5);
|
||||
|
@ -96,7 +96,7 @@ int do_sunxi_flash(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||
|
||||
if((!strncmp(part_name, "boot", 4)) || (!strncmp(part_name, "recovery", 4)))
|
||||
{
|
||||
readall_flag = 1;
|
||||
// readall_flag = 1;
|
||||
}
|
||||
start_block = sunxi_partition_get_offset_byname((const char *)part_name);
|
||||
if(start_block == (u64)(-1))
|
||||
|
@ -115,7 +115,7 @@
|
||||
* Size of malloc() pool
|
||||
* 1MB = 0x100000, 0x100000 = 1024 * 1024
|
||||
*/
|
||||
#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (1 << 20))
|
||||
#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (4 << 20))
|
||||
|
||||
#define CONFIG_FASTBOOT
|
||||
#define CONFIG_STORAGE_NAND
|
||||
|
2
include/fastboot.h
Normal file → Executable file
2
include/fastboot.h
Normal file → Executable file
@ -158,7 +158,7 @@ typedef struct fastboot_ptentry fastboot_ptentry;
|
||||
struct fastboot_ptentry
|
||||
{
|
||||
/* The logical name for this partition, null terminated */
|
||||
char name[16];
|
||||
char name[32];
|
||||
/* 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 */
|
||||
|
@ -25,7 +25,8 @@ include $(TOPDIR)/config.mk
|
||||
|
||||
all:
|
||||
ifeq ($(notdir $(shell find ./ -name lib)), lib)
|
||||
|
||||
|
||||
@echo "make lib-nand from source"
|
||||
make -C lib
|
||||
|
||||
else
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user