Skip to content

Commit

Permalink
Add autodetect for rootfs size
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorxda committed Mar 28, 2024
1 parent 05f0cca commit 90873ad
Show file tree
Hide file tree
Showing 19 changed files with 163 additions and 159 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.bin
output
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# u-boot-ingenic
U-Boot for Ingenic Xburst T10-T31 SoC's
U-Boot for Ingenic Xburst T10-T31 chipsets.

```
bash build.sh
```
8 changes: 3 additions & 5 deletions arch/mips/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# MA 02111-1307 USA
#

CROSS_COMPILE ?= mips-linux-gnu-
CROSS_COMPILE ?= mipsel-linux-gnu-

# Handle special prefix in ELDK 4.0 toolchain
ifneq (,$(findstring 4KCle,$(CROSS_COMPILE)))
Expand All @@ -39,9 +39,6 @@ endif
# Default to EB if no endianess is configured
ENDIANNESS ?= -EB

PLATFORM_CPPFLAGS += -msoft-float -std=gnu89
PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__

#
# From Linux arch/mips/Makefile
#
Expand All @@ -63,8 +60,9 @@ PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
# to RAM, unless we're building SPL which doesn't relocate. $28 is always
# used as gp.
#

PLATFORM_CPPFLAGS += -std=gnu89 -DCONFIG_MIPS -D__MIPS__
PLATFORM_CPPFLAGS += -G 0 $(ENDIANNESS)
PLATFORM_CPPFLAGS += -msoft-float
PLATFORM_LDFLAGS += -G 0 -static -n -nostdlib $(ENDIANNESS)
PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
LDFLAGS_FINAL += --gc-sections
Expand Down
49 changes: 14 additions & 35 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,30 @@
#!/bin/sh -e

export ARCH=mips
export CROSS_PATH="../../../../pc/tools/toolchain/gcc_540/mips-gcc540-glibc222-32bit-r3.3.0/bin"
export CROSS_COMPILE="$(readlink -f $CROSS_PATH)/mips-linux-gnu-"

# NOR
# T31N make isvp_t31_sfcnor
# T31L make isvp_t31_sfcnor_lite
# T31X make isvp_t31_sfcnor_ddr128M
# T31A make isvp_t31a_sfcnor_ddr128M
# T31AL make isvp_t31al_sfcnor_ddr128M
# MMC
# T31N make isvp_t31_msc0
# T31L make isvp_t31_msc0_lite
# T31X make isvp_t31_msc0_ddr128M
# T31A make isvp_t31a_msc0_ddr128M
# T31AL make isvp_t31al_msc0_ddr128M
#!/bin/bash
output=output

declare -A cfg
cfg[t10]="isvp_t10_sfcnor"
cfg[t10l]="isvp_t10_sfcnor_lite"
cfg[t20]="isvp_t20_sfcnor"
cfg[t20l]="isvp_t20_sfcnor_lite"
cfg[t20x]="isvp_t20_sfcnor_ddr128M"
cfg[t31n]="isvp_t31_sfcnor"
cfg[t31l]="isvp_t31_sfcnor_lite"
cfg[t31x]="isvp_t31_sfcnor_ddr128M"
cfg[t31a]="isvp_t31a_sfcnor_ddr128M"
cfg[t31al]="isvp_t31al_sfcnor_ddr128M"
cfg[t31lc]="isvp_t31lc_sfcnor"
cfg[t21n]="isvp_t21_sfcnor"
cfg[t30n]="isvp_t30_sfcnor"
cfg[t30l]="isvp_t30_sfcnor_lite"
cfg[t30x]="isvp_t30_sfcnor_ddr128M"
cfg[t30a]="isvp_t30a_sfcnor_ddr128M"
cfg[t30a1]="isvp_t30a1_sfcnor_ddr128M"
cfg[t31n]="isvp_t31_sfcnor"
cfg[t31l]="isvp_t31_sfcnor_lite"
cfg[t31x]="isvp_t31_sfcnor_ddr128M"
cfg[t31a]="isvp_t31a_sfcnor_ddr128M"
cfg[t31al]="isvp_t31al_sfcnor_ddr128M"
cfg[t31lc]="isvp_t31lc_sfcnor"

rm -rf $output
mkdir -p $output

OUTPUTDIR="${HOME}/uboot"
mkdir -p ${OUTPUTDIR} 2>&1 > /dev/null

for soc in "${!cfg[@]}" ;do

make distclean
make ${cfg[$soc]}
make -j`nproc`

cp u-boot-with-spl.bin ${OUTPUTDIR}/u-boot-${soc}-universal.bin

for soc in ${!cfg[@]}; do
make ${cfg[$soc]} -j8
cp u-boot-lzo-with-spl.bin $output/u-boot-${soc}-nor.bin
make distclean
done
6 changes: 1 addition & 5 deletions common/cmd_sdupdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ static int au_check_header_valid(int idx, long nbytes)
unsigned long checksum;

char env[20];
char auversion[20];

hdr = (image_header_t *)LOAD_ADDR;
/* check the easy ones first */
Expand Down Expand Up @@ -277,7 +276,6 @@ static int update_to_flash(void)
{
int i = 0;
long sz;
int res, cnt;
int uboot_updated = 0;
int image_found = 0;

Expand Down Expand Up @@ -334,8 +332,7 @@ static int update_to_flash(void)

/* this is really not a good idea, but it's what the */
/* customer wants. */
cnt = 0;
res = au_do_update(i, sz);
au_do_update(i, sz);

if (LOAD_ID != -1)
break;
Expand All @@ -357,7 +354,6 @@ int do_auto_update(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
block_dev_desc_t *stor_dev;
int old_ctrlc;
int j;
int state = -1;
long start = -1, end = 0;

Expand Down
28 changes: 27 additions & 1 deletion common/cmd_sf.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,32 @@ static int do_spi_flash_probe(int argc, char * const argv[])
spi_flash_free(flash);
flash = new;

char buf[64];
unsigned int magic, bytes;

if (spi_flash_read(flash, CONFIG_ENV_ROOTADDR, sizeof(buf), buf)) {
printf("Failed to read from SPI flash\n");
return 1;
}

memcpy(&magic, &buf[0], sizeof(magic));
memcpy(&bytes, &buf[40], sizeof(bytes));

if (magic == 0x73717368) {
if (bytes + 0x1000 < 0x500000) {
setenv("rootmtd", "5120k");
} else {
setenv("rootmtd", "8192k");
}
}

ulong file = getenv_ulong("filesize", 16, 0);
if (file < 0x500000) {
setenv("rootsize", "0x500000");
} else {
setenv("rootsize", "0x800000");
}

return 0;
}

Expand Down Expand Up @@ -515,7 +541,7 @@ static int do_spi_flash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
done:
#ifdef PRINT_TIME
end = get_timer(0);
printf("--->%s spend %d ms\n",cmd,end - start);
printf("---> %s spend %d ms\n",cmd,end - start);
#endif

if (ret != -1)
Expand Down
6 changes: 6 additions & 0 deletions common/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <version.h>
#include <watchdog.h>
#include <linux/ctype.h>
#include <configs/isvp_common.h>

DECLARE_GLOBAL_DATA_PTR;

Expand Down Expand Up @@ -410,6 +411,11 @@ static void process_boot_delay(void)

debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");

if (mmc_get_dev(0) && !run_command(LOAD_SCRIPT0, 0)) {
run_command("source", 0);
return;
}

if (bootdelay != -1 && s && !abortboot(bootdelay)) {
#ifdef CONFIG_AUTOBOOT_KEYED
int prev = disable_ctrlc(1); /* disable Control C checking */
Expand Down
4 changes: 2 additions & 2 deletions common/spl/spl_sfc_nor.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int sfc_read_data(unsigned int *data, unsigned int len)
static int sfc_read(unsigned int addr, unsigned int addr_plus,
unsigned int addr_len, unsigned int *data, unsigned int len)
{
unsigned int cmd, ret, qread[1] = {0}, tmp;
unsigned int cmd, ret;

jz_sfc_writel(STOP, SFC_TRIG);
jz_sfc_writel(FLUSH, SFC_TRIG);
Expand All @@ -123,7 +123,7 @@ static int sfc_read(unsigned int addr, unsigned int addr_plus,
return 0;
}

void sfc_init()
void sfc_init(void)
{
unsigned int tmp;

Expand Down
1 change: 1 addition & 0 deletions drivers/gpio/jz_gpio_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ int gpio_get_value(unsigned gpio)
return pca953x_get_value(gpio);
#endif
}
return 0;
}

int gpio_get_flag(unsigned int gpio)
Expand Down
6 changes: 2 additions & 4 deletions drivers/mtd/spi/spi_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,6 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
if (!flash) {
printf("SF: Unsupported manufacturer %02x\n", *idp);
goto err_manufacturer_probe;
}else{
printf("the manufacturer %02x\n", *idp);
}

#ifdef CONFIG_SPI_FLASH_BAR
Expand Down Expand Up @@ -618,8 +616,8 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
print_size(flash->size, "");
#endif
if (flash->memory_map)
printf(", mapped at %p", flash->memory_map);
puts("\n");
printf(", mapped at %p\n", flash->memory_map);

#ifndef CONFIG_SPI_FLASH_BAR
if (flash->size > SPI_FLASH_16MB_BOUN) {
puts("SF: Warning - Only lower 16MiB accessible,");
Expand Down
5 changes: 4 additions & 1 deletion drivers/net/SynopGMAC_Dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,10 @@ s32 synopGMAC_search_phy (synopGMACdevice * gmacdev) {
status += synopGMAC_read_phy_reg((u32 *)gmacdev->MacBase,phy_id, PHY_ID_HI_REG, &id1);
status += synopGMAC_read_phy_reg((u32 *)gmacdev->MacBase,phy_id, PHY_ID_LOW_REG, &id2);
if ((!status)&&(id2 != 0xffff)) {
printf("====>phy %d:0x%x-0x%x found\n", phy_id, id1, id2);
if ((0x0 == id1) && (0x0 == id2)) {
return -ESYNOPGMACPHYERR;
}
printf("====>phy %d: 0x%x-0x%x found\n", phy_id, id1, id2);
if ((0x0 == id1) && ((0x128 == id2) || (0x118 == id2))) {
status = synopGMAC_write_phy_reg((u32 *)gmacdev->MacBase, 0, 0x1e, 0x50);
status = synopGMAC_read_phy_reg((u32 *)gmacdev->MacBase, 0, 0x1f, &data);
Expand Down
14 changes: 3 additions & 11 deletions drivers/net/jz4775-9161.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,6 @@ static int jz_init(struct eth_device* dev, bd_t * bd)
#endif
synopGMAC_check_phy_init(gmacdev);

u16 data;
s32 status = -ESYNOPGMACNOERR;

jz47xx_mac_configure();
/* setup tx_desc */
for (i = 0; i < NUM_TX_DESCS; i++) {
Expand Down Expand Up @@ -506,9 +503,6 @@ int jz_net_initialize(bd_t *bis)
struct eth_device *dev;
u32 cpm_mphyc = 0;
int phy_id;
u16 data;
s32 status = -ESYNOPGMACNOERR;

clk_set_rate(MACPHY,50000000);
udelay(50000);

Expand Down Expand Up @@ -613,7 +607,7 @@ int jz_net_initialize(bd_t *bis)
if (phy_id >= 0) {
gmacdev->PhyBase = phy_id;
} else {
printf("====>PHY not found!");
printf("====>PHY not found!\n");
}
#endif //CONFIG_NET_PHY_TYPE
udelay(100000);
Expand Down Expand Up @@ -684,8 +678,7 @@ static int do_ethphy(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if(status) {
printf("%s,%d:read mac register error\n", __func__, __LINE__);
}
printf("phy read 0x%x = 0x%x\n",
addr, data);
printf("phy read 0x%lx = 0x%x\n", addr, data);

} else if (strcmp(cmd, "reset") == 0) {
#ifdef CONFIG_GPIO_IP101G_RESET
Expand Down Expand Up @@ -717,8 +710,7 @@ static int do_ethphy(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}

s32 status = -ESYNOPGMACNOERR;
printf("phy write 0x%x = 0x%x\n",
addr, data);
printf("phy write 0x%lx = 0x%x\n", addr, data);
status = synopGMAC_write_phy_reg((u32 *)gmacdev->MacBase, gmacdev->PhyBase, addr, data);
if(status) {
printf("%s,%d:write phy register error\n", __func__, __LINE__);
Expand Down
11 changes: 3 additions & 8 deletions drivers/spi/jz_sfc_nor.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,11 @@ static int sfc_read(unsigned int addr, unsigned int addr_plus,
}
#endif

#undef CPM_SSICDR
#undef CPM_CLKGR0
#define CPM_SSICDR (0xb0000000 + 0x74)
#define CPM_CLKGR0 (0xb0000000 + 0x20)

int sfc_init(void )
{
unsigned int i;
Expand Down Expand Up @@ -978,7 +981,6 @@ void sfc_nor_RDID(unsigned int *idcode)

static void dump_norflash_params(void)
{
int i;
printf(" =================================================\n");
printf(" ====== gparams->name = %s\n",gparams.name);
printf(" ====== gparams->id_manufactory = %x\n",gparams.id_manufactory);
Expand Down Expand Up @@ -1091,10 +1093,7 @@ int sfc_nor_init(unsigned int idcode)

int sfc_nor_read(struct spi_flash *flash, unsigned int src_addr, unsigned int count,unsigned int dst_addr)
{

int i;
int ret = 0;

flag = 0;

#ifdef CONFIG_SPI_QUAD
Expand All @@ -1120,8 +1119,6 @@ int sfc_nor_read(struct spi_flash *flash, unsigned int src_addr, unsigned int co

int sfc_nor_write(struct spi_flash *flash, unsigned int src_addr, unsigned int count,unsigned int dst_addr)
{

int i;
int ret = 0;

#ifdef CONFIG_SPI_QUAD
Expand Down Expand Up @@ -1153,10 +1150,8 @@ int sfc_nor_write(struct spi_flash *flash, unsigned int src_addr, unsigned int c

int sfc_nor_erase(struct spi_flash *flash, unsigned int src_addr, unsigned int count)
{
int i;
int ret = 0;


#ifdef CONFIG_SPI_QUAD
sfc_quad_mode = 1;
#endif
Expand Down
Loading

0 comments on commit 90873ad

Please sign in to comment.