mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2025-04-21 12:27:27 +03:00
Merge jzboot as xburst-tools subdirectory
This commit is contained in:
28
jzboot/include/app_config.h
Normal file
28
jzboot/include/app_config.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* JzBoot: an USB bootloader for JZ series of Ingenic(R) microprocessors.
|
||||
* Copyright (C) 2010 Sergey Gridassov <grindars@gmail.com>
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CONFIG__H__
|
||||
#define __CONFIG__H__
|
||||
|
||||
char *cfg_getenv(const char *variable);
|
||||
void cfg_setenv(const char *variable, const char *newval);
|
||||
void cfg_unsetenv(const char *variable);
|
||||
|
||||
extern char **cfg_environ;
|
||||
|
||||
#endif
|
||||
34
jzboot/include/debug.h
Normal file
34
jzboot/include/debug.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* JzBoot: an USB bootloader for JZ series of Ingenic(R) microprocessors.
|
||||
* Copyright (C) 2010 Sergey Gridassov <grindars@gmail.com>
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __DEBUG__H__
|
||||
#define __DEBUG__H__
|
||||
|
||||
void set_debug_level(int level);
|
||||
int get_debug_level();
|
||||
void hexdump(const void *data, size_t size);
|
||||
|
||||
void debug(int level, const char *fmt, ...);
|
||||
|
||||
#define LEVEL_SILENT 0
|
||||
#define LEVEL_ERROR 1
|
||||
#define LEVEL_WARNING 2
|
||||
#define LEVEL_INFO 3
|
||||
#define LEVEL_DEBUG 4
|
||||
|
||||
#endif
|
||||
34
jzboot/include/devmgr.h
Normal file
34
jzboot/include/devmgr.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* JzBoot: an USB bootloader for JZ series of Ingenic(R) microprocessors.
|
||||
* Copyright (C) 2010 Sergey Gridassov <grindars@gmail.com>
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __DEVMGR__H__
|
||||
#define __DEVMGR__H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define INTERFACE_BOOT 0
|
||||
#define ENDPOINT_OUT 0x01
|
||||
#define ENDPOINT_IN 0x81
|
||||
|
||||
int is_ingenic(uint16_t vid, uint16_t pid);
|
||||
|
||||
void add_device(uint16_t vid, uint16_t pid, void *data);
|
||||
void enum_devices(void (*handler)(int idx, uint16_t vid, uint16_t pid, void *data));
|
||||
void *get_device(int idx);
|
||||
|
||||
#endif
|
||||
78
jzboot/include/elf.h
Normal file
78
jzboot/include/elf.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#ifndef __ELF__H__
|
||||
#define __ELF__H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint16_t Elf32_Half;
|
||||
typedef uint32_t Elf32_Word;
|
||||
typedef uint32_t Elf32_Addr;
|
||||
typedef uint32_t Elf32_Off;
|
||||
typedef int32_t Elf32_Sword;
|
||||
|
||||
#define EI_NIDENT 16
|
||||
#define EI_MAG0 0
|
||||
#define EI_MAG1 1
|
||||
#define EI_MAG2 2
|
||||
#define EI_MAG3 3
|
||||
#define EI_CLASS 4
|
||||
#define EI_DATA 5
|
||||
#define EI_VERSION 6
|
||||
#define EI_PAD 7
|
||||
|
||||
#define ELFMAG0 0x7F
|
||||
#define ELFMAG1 'E'
|
||||
#define ELFMAG2 'L'
|
||||
#define ELFMAG3 'F'
|
||||
|
||||
#define ELFCLASSNONE 0
|
||||
#define ELFCLASS32 1
|
||||
#define ELFCLASS64 2
|
||||
|
||||
#define ELFDATANONE 0
|
||||
#define ELFDATA2LSB 1
|
||||
#define ELFDATA2MSB 2
|
||||
|
||||
#define ET_NONE 0
|
||||
#define ET_REL 1
|
||||
#define ET_EXEC 2
|
||||
#define ET_DYN 3
|
||||
#define ET_CORE 4
|
||||
|
||||
#define EM_MIPS 8
|
||||
|
||||
#define EV_NONE 0
|
||||
#define EV_CURRENT 1
|
||||
|
||||
#define PT_NULL 0
|
||||
#define PT_LOAD 1
|
||||
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT];
|
||||
Elf32_Half e_type;
|
||||
Elf32_Half e_machine;
|
||||
Elf32_Word e_version;
|
||||
Elf32_Addr e_entry;
|
||||
Elf32_Off e_phoff;
|
||||
Elf32_Off e_shoff;
|
||||
Elf32_Word e_flags;
|
||||
Elf32_Half e_ehsize;
|
||||
Elf32_Half e_phentsize;
|
||||
Elf32_Half e_phnum;
|
||||
Elf32_Half e_shentsize;
|
||||
Elf32_Half e_shnum;
|
||||
Elf32_Half e_shstrndx;
|
||||
} Elf32_Ehdr;
|
||||
|
||||
typedef struct {
|
||||
Elf32_Word p_type;
|
||||
Elf32_Off p_offset;
|
||||
Elf32_Addr p_vaddr;
|
||||
Elf32_Addr p_paddr;
|
||||
Elf32_Word p_filesz;
|
||||
Elf32_Word p_memsz;
|
||||
Elf32_Word p_flags;
|
||||
Elf32_Word p_align;
|
||||
} Elf32_Phdr;
|
||||
|
||||
#endif
|
||||
|
||||
10
jzboot/include/elfldr.h
Normal file
10
jzboot/include/elfldr.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __ELFLDR__H__
|
||||
#define __ELFLDR__H__
|
||||
|
||||
int load_elf(void *ingenic,
|
||||
const char *filename,
|
||||
const char *args,
|
||||
const char *initrd);
|
||||
|
||||
#endif
|
||||
|
||||
149
jzboot/include/ingenic.h
Normal file
149
jzboot/include/ingenic.h
Normal file
@@ -0,0 +1,149 @@
|
||||
/* This file is based on code by Ingenic Semiconductor Co., Ltd. */
|
||||
|
||||
#ifndef __INGENIC__H__
|
||||
#define __INGENIC__H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define VR_GET_CPU_INFO 0x00
|
||||
#define VR_SET_DATA_ADDRESS 0x01
|
||||
#define VR_SET_DATA_LENGTH 0x02
|
||||
#define VR_FLUSH_CACHES 0x03
|
||||
#define VR_PROGRAM_START1 0x04
|
||||
#define VR_PROGRAM_START2 0x05
|
||||
#define VR_NOR_OPS 0x06
|
||||
#define VR_NAND_OPS 0x07
|
||||
#define VR_SDRAM_OPS 0x08
|
||||
#define VR_CONFIGRATION 0x09
|
||||
#define VR_GET_NUM 0x0a
|
||||
|
||||
#define CMDSET_SPL 1
|
||||
#define CMDSET_USBBOOT 2
|
||||
|
||||
#define INGENIC_STAGE1 1
|
||||
#define INGENIC_STAGE2 2
|
||||
|
||||
#define STAGE1_DEBUG_BOOT 0
|
||||
#define STAGE1_DEBUG_MEMTEST 1
|
||||
#define STAGE1_DEBUG_GPIO_SET 2
|
||||
#define STAGE1_DEBUG_GPIO_CLEAR 3
|
||||
|
||||
#define STAGE1_BASE 0x2000
|
||||
#define STAGE2_CODESIZE 0x400000
|
||||
#define SDRAM_BASE 0x80000000
|
||||
|
||||
#define STAGE2_IOBUF (2048 * 128)
|
||||
|
||||
#define DS_flash_info 0
|
||||
#define DS_hand 1
|
||||
|
||||
#define SDRAM_LOAD 0
|
||||
|
||||
#define NAND_QUERY 0
|
||||
#define NAND_INIT 1
|
||||
#define NAND_MARK_BAD 2
|
||||
#define NAND_READ_OOB 3
|
||||
#define NAND_READ_RAW 4
|
||||
#define NAND_ERASE 5
|
||||
#define NAND_READ 6
|
||||
#define NAND_PROGRAM 7
|
||||
#define NAND_READ_TO_RAM 8
|
||||
|
||||
#define OOB_ECC 0
|
||||
#define OOB_NO_ECC 1
|
||||
#define NO_OOB 2
|
||||
#define NAND_RAW (1 << 7)
|
||||
|
||||
#define PROGRESS_INIT 0
|
||||
#define PROGRESS_UPDATE 1
|
||||
#define PROGRESS_FINI 2
|
||||
|
||||
typedef struct {
|
||||
/* debug args */
|
||||
uint8_t debug_ops;
|
||||
uint8_t pin_num;
|
||||
uint32_t start;
|
||||
uint32_t size;
|
||||
} __attribute__((packed)) ingenic_stage1_debug_t;
|
||||
|
||||
typedef struct {
|
||||
/* CPU ID */
|
||||
uint32_t cpu_id;
|
||||
|
||||
/* PLL args */
|
||||
uint8_t ext_clk;
|
||||
uint8_t cpu_speed;
|
||||
uint8_t phm_div;
|
||||
uint8_t use_uart;
|
||||
uint32_t baudrate;
|
||||
|
||||
/* SDRAM args */
|
||||
uint8_t bus_width;
|
||||
uint8_t bank_num;
|
||||
uint8_t row_addr;
|
||||
uint8_t col_addr;
|
||||
uint8_t is_mobile;
|
||||
uint8_t is_busshare;
|
||||
|
||||
ingenic_stage1_debug_t debug;
|
||||
} __attribute__((packed)) firmware_config_t;
|
||||
|
||||
typedef struct {
|
||||
/* nand flash info */
|
||||
uint32_t cpuid; /* cpu type */
|
||||
uint32_t nand_bw; /* bus width */
|
||||
uint32_t nand_rc; /* row cycle */
|
||||
uint32_t nand_ps; /* page size */
|
||||
uint32_t nand_ppb; /* page number per block */
|
||||
uint32_t nand_force_erase;
|
||||
uint32_t nand_pn; /* page number in total */
|
||||
uint32_t nand_os; /* oob size */
|
||||
uint32_t nand_eccpos;
|
||||
uint32_t nand_bbpage;
|
||||
uint32_t nand_bbpos;
|
||||
uint32_t nand_plane;
|
||||
uint32_t nand_bchbit;
|
||||
uint32_t nand_wppin;
|
||||
uint32_t nand_bpc; /* block number per chip */
|
||||
} nand_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t vid;
|
||||
uint8_t pid;
|
||||
uint8_t chip;
|
||||
uint8_t page;
|
||||
uint8_t plane;
|
||||
} nand_info_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
void (*cmdset_change)(uint32_t cmdset, void *arg);
|
||||
void (*progress)(int action, int value, int max, void *arg);
|
||||
} ingenic_callbacks_t;
|
||||
|
||||
void *ingenic_open(void *usb_hndl);
|
||||
void ingenic_close(void *hndl);
|
||||
void ingenic_set_callbacks(void *hndl, const ingenic_callbacks_t *callbacks, void *arg);
|
||||
|
||||
int ingenic_redetect(void *hndl);
|
||||
int ingenic_cmdset(void *hndl);
|
||||
int ingenic_type(void *hndl);
|
||||
uint32_t ingenic_sdram_size(void *hndl);
|
||||
|
||||
int ingenic_rebuild(void *hndl);
|
||||
int ingenic_loadstage(void *hndl, int id, const char *filename);
|
||||
int ingenic_stage1_debugop(void *device, const char *filename, uint32_t op, uint32_t pin, uint32_t base, uint32_t size);
|
||||
int ingenic_memtest(void *hndl, const char *filename, uint32_t base, uint32_t size, uint32_t *fail);
|
||||
|
||||
int ingenic_configure_stage2(void *hndl);
|
||||
int ingenic_load_sdram(void *hndl, void *data, uint32_t base, uint32_t size);
|
||||
int ingenic_load_sdram_file(void *hndl, uint32_t base, const char *filename);
|
||||
int ingenic_go(void *hndl, uint32_t address);
|
||||
|
||||
int ingenic_query_nand(void *hndl, int cs, nand_info_t *info);
|
||||
int ingenic_dump_nand(void *hndl, int cs, int start, int pages, int type, const char *filename);
|
||||
int ingenic_program_nand(void *hndl, int cs, int start, int type, const char *filename);
|
||||
int ingenic_erase_nand(void *hndl, int cs, int start, int blocks);
|
||||
int ingenic_load_nand(void *hndl, int cs, int start, int pages, uint32_t base);
|
||||
|
||||
#endif
|
||||
49
jzboot/include/shell.h
Normal file
49
jzboot/include/shell.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* JzBoot: an USB bootloader for JZ series of Ingenic(R) microprocessors.
|
||||
* Copyright (C) 2010 Sergey Gridassov <grindars@gmail.com>
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SHELL__H__
|
||||
#define __SHELL__H__
|
||||
|
||||
#ifndef SHELL_INTERNALS
|
||||
typedef void shell_context_t;
|
||||
#endif
|
||||
|
||||
typedef struct shell_command {
|
||||
const char *cmd;
|
||||
const char *description;
|
||||
int (*handler)(shell_context_t *ctx, int argc, char *argv[]);
|
||||
const char *args;
|
||||
} shell_command_t;
|
||||
|
||||
shell_context_t *shell_init(void *ingenic);
|
||||
void shell_fini(shell_context_t *context);
|
||||
|
||||
void shell_interactive(shell_context_t *ctx);
|
||||
int shell_source(shell_context_t *ctx, const char *filename);
|
||||
int shell_execute(shell_context_t *ctx, const char *input);
|
||||
void *shell_device(shell_context_t *ctx);
|
||||
int shell_run(shell_context_t *ctx, int argc, char *argv[]);
|
||||
|
||||
void shell_exit(shell_context_t *ctx, int val);
|
||||
int shell_enumerate_commands(shell_context_t *ctx, int (*callback)(shell_context_t *ctx, const shell_command_t *cmd, void *arg), void *arg);
|
||||
|
||||
extern const shell_command_t spl_cmdset[];
|
||||
extern const shell_command_t usbboot_cmdset[];
|
||||
extern const shell_command_t builtin_cmdset[];
|
||||
|
||||
#endif
|
||||
63
jzboot/include/shell_internal.h
Normal file
63
jzboot/include/shell_internal.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* JzBoot: an USB bootloader for JZ series of Ingenic(R) microprocessors.
|
||||
* Copyright (C) 2010 Sergey Gridassov <grindars@gmail.com>
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SHELL_INTERNAL__H__
|
||||
#define __SHELL_INTERNAL__H__
|
||||
|
||||
#define SHELL_INTERNALS
|
||||
#define STATE_WANTSTR 0
|
||||
#define STATE_WANTSPACE 1
|
||||
|
||||
#define TOK_SEPARATOR 1
|
||||
#define TOK_STRING 2
|
||||
#define TOK_SPACE 3
|
||||
#define TOK_COMMENT 4
|
||||
|
||||
typedef struct {
|
||||
void *device;
|
||||
char linebuf[512];
|
||||
char *strval;
|
||||
char *line;
|
||||
const struct shell_command *set_cmds;
|
||||
int shell_exit;
|
||||
int prev_progress;
|
||||
} shell_context_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
int argc;
|
||||
char **argv;
|
||||
} shell_run_data_t;
|
||||
|
||||
int shell_pull(shell_context_t *ctx, char *buf, int maxlen);
|
||||
|
||||
#ifndef FLEX_SCANNER
|
||||
typedef void *yyscan_t;
|
||||
int yylex_init(yyscan_t *ptr_yy_globals);
|
||||
int yylex_init_extra(shell_context_t *user_defined, yyscan_t *ptr_yy_globals);
|
||||
int yylex(yyscan_t yyscanner) ;
|
||||
int yylex_destroy (yyscan_t yyscanner) ;
|
||||
#else
|
||||
#define YY_EXTRA_TYPE shell_context_t *
|
||||
#define YY_INPUT(buf, result, max_size) result = shell_pull(yyextra, buf, max_size);
|
||||
#endif
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
#endif
|
||||
|
||||
38
jzboot/include/usbdev.h
Normal file
38
jzboot/include/usbdev.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* JzBoot: an USB bootloader for JZ series of Ingenic(R) microprocessors.
|
||||
* Copyright (C) 2010 Sergey Gridassov <grindars@gmail.com>,
|
||||
* Peter Zotov <whitequark@whitequark.org>
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __USBDEV__H__
|
||||
#define __USBDEV__H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int usbdev_init();
|
||||
void usbdev_fini();
|
||||
|
||||
#define USBDEV_FROMDEV 0
|
||||
#define USBDEV_TODEV 1
|
||||
|
||||
int usbdev_enumerate();
|
||||
void *usbdev_open(void *dev);
|
||||
void usbdev_close(void *hndl);
|
||||
int usbdev_vendor(void *hndl, int direction, uint8_t req, uint16_t value, uint16_t index, void *data, uint16_t size);
|
||||
int usbdev_sendbulk(void *hndl, void *data, int size);
|
||||
int usbdev_recvbulk(void *hndl, void *data, int size);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user