Writing bootloader failed

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Writing bootloader failed

跳至解决方案
5,923 次查看
AlekseyM
Contributor III

Hi! I make a custom board with iMX8MM and compile u-boot. But I can't understand what I do wrong. Could somebody tip me?
I use uuu under Windows 10, for compiling images I use imx-boot under WSL2 ubuntu 20.04.
Log by board:

 

MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... MMC: no card present
*** Warning - No block device, using default environment

MMC: no card present
Detect USB boot. Will enter fastboot mode!
Net:   Could not get PHY for FEC0: addr 0
Could not get PHY for FEC0: addr 0
No ethernet found.

Fastboot: Normal
Boot from USB for mfgtools
*** Warning - Use default environment for                                mfgtools
, using default environment

Run bootcmd_mfg: run mfgtool_args;if iminfo ${initrd_addr}; then if test ${tee} = yes; then bootm ${tee_addr} ${initrd_addr} ${fdt_addr}; else booti ${loadaddr} ${initrd_addr} ${fdt_addr}; fi; else echo "Run fastboot ..."; fastboot 0; fi;
Hit any key to stop autoboot:  0

## Checking Image at 43800000 ...
Unknown image format!
Run fastboot ...
Detect USB boot. Will enter fastboot mode!
flash target is MMC:1
MMC: no card present
MMC card init failed!
MMC: no card present
** Block device MMC 1 not supported
Detect USB boot. Will enter fastboot mode!
flash target is MMC:2
switch to partitions #0, OK
mmc2(part 0) is current device
Detect USB boot. Will enter fastboot mode!
Starting download of 2091712 bytes
...............
downloading of 2091712 bytes finished
writing to partition 'bootloader'
Initializing 'bootloader'
switch to partitions #1, OK
mmc2(part 1) is current device
Writing 'bootloader'

MMC write: dev # 2, block # 66, count 4086 ... MMC: block number 0x1038 exceeds max(0x1000)
0 blocks written: ERROR
Writing 'bootloader' FAILED!

 

 Log by uuu

 

FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev ${emmc_dev}
FB: ucmd mmc dev ${emmc_dev}
FB: flash bootloader flash.bin
FB: ucmd if env exists emmc_ack; then ; else setenv emmc_ack 0; fi;
FB: ucmd mmc partconf ${emmc_dev} ${emmc_ack} 1 0
FB: Done


Wait for Known USB Device Appear...
New USB Device Attached at 1:2
1:2>Start Cmd:SDP: boot -f flash.bin
100%1:2>Okay (0.452s)
New USB Device Attached at 1:2
1:2>Start Cmd:SDPV: delay 1000
1:2>Okay (1.013s)
1:2>Start Cmd:SDPV: write -f flash.bin -skipspl
100%1:2>Okay (2.913s)
1:2>Start Cmd:SDPV: jump
100%1:2>Okay (0.244s)
New USB Device Attached at 1:2
1:2>Start Cmd:FB: ucmd setenv fastboot_dev mmc
1:2>Okay (0.016s)
1:2>Start Cmd:FB: ucmd setenv mmcdev ${emmc_dev}
1:2>Okay (0.049s)
1:2>Start Cmd:FB: ucmd mmc dev ${emmc_dev}
1:2>Okay (0.054s)
1:2>Start Cmd:FB: flash bootloader flash.bin
0x40000000Write partition failed1:2>Fail Write partition failed(0.13s)

 

0 项奖励
回复
1 解答
5,706 次查看
smithcoba
Contributor III

Here is your log.

Detect USB boot. Will enter fastboot mode!
Starting download of 2091712 bytes
...............
downloading of 2091712 bytes finished


MMC write: dev # 2, block # 66, count 4086 ... MMC: block number 0x1038 exceeds max(0x1000)

The space you must have on boot1: 

66 x 512 +  2091712  = 2,125,504

The space on the emmc boot1:

4096 x 512 = 2,097,152

2,097,152 -  2,125,504  =  -28,352

The emmc is 32G, it is user partition. not boot partition. 

The log shows the boot partition is 2M big. That I have told you before.

If you use scard, the flash.bin can flash into it. 

 

Usually, the NXP binary demo image flash.bin is bigger than 2M.

If you want use the emmc currently on your board, you must change the uboot configuration to make it smaller.

 

 

image.png

在原帖中查看解决方案

23 回复数
5,499 次查看
smithcoba
Contributor III

 

 

It seems the flash.bin size + boot offset is bigger than the emmc boot partition size 2M 

 

MMC write: dev # 2, block # 66, count 4086 ... MMC: block number 0x1038 exceeds max(0x1000)

 

0 项奖励
回复
5,472 次查看
Chavira
NXP TechSupport
NXP TechSupport

Hi @smithcoba@AlekseyM!

Can you share with me the steps that are you are following to create the flash.bin, and what commands are using under uuu?

0 项奖励
回复
5,471 次查看
AlekseyM
Contributor III

I use uuu -v -b emmc flash.bin
also I try use sd-card
uuu -v -b sd flash.bin
emmc 32Gbit
SD-card 8GB

0 项奖励
回复
5,707 次查看
smithcoba
Contributor III

Here is your log.

Detect USB boot. Will enter fastboot mode!
Starting download of 2091712 bytes
...............
downloading of 2091712 bytes finished


MMC write: dev # 2, block # 66, count 4086 ... MMC: block number 0x1038 exceeds max(0x1000)

The space you must have on boot1: 

66 x 512 +  2091712  = 2,125,504

The space on the emmc boot1:

4096 x 512 = 2,097,152

2,097,152 -  2,125,504  =  -28,352

The emmc is 32G, it is user partition. not boot partition. 

The log shows the boot partition is 2M big. That I have told you before.

If you use scard, the flash.bin can flash into it. 

 

Usually, the NXP binary demo image flash.bin is bigger than 2M.

If you want use the emmc currently on your board, you must change the uboot configuration to make it smaller.

 

 

image.png

5,335 次查看
AlekseyM
Contributor III

Sorry, could you tip me, where I can change boot partition on emmc? in defconfig or another place?

0 项奖励
回复
5,286 次查看
smithcoba
Contributor III

uboot has command "mmc dev [dev] [part]"

From your log, MMC: FSL_SDHC: 1, FSL_SDHC: 2

mmc dev 1 switches to SDHC 1  

mmc dev 2 switches to SDHC 2  

Because   SDHC2 is emmc, you can 

 

mmc dev 2  1  switches to emmc boot partition 1 

mmc dev 2  3 switches to emmc boot partition 2   

mmc dev 3 3 switches to emmc use partition. 

Because the emmc boot partition is small you need to switch to use partition and flash the image. 

But in the binary demo image, NXP doesn't provide the script to flash image to the emmc use partition. You need to write down by yourself, using such as  uuu download command..., etc. Manually flash the image to use partition.

But after that, you also need to switch to boot from use patition, using mmc partconf

mmc partconf 2 0 7 0. Note 7 is enable use partition to boot. 

 

Another way, you can change the uboot configuration. Remove some no necessary module/configuration for your project to make the flash.bin smaller can fit the 2M emmc boot partition. 

Maybe remove  the spi, ethernet ..., etc. 

 

 

5,346 次查看
AlekseyM
Contributor III

Thanks for your help! 

5,467 次查看
Chavira
NXP TechSupport
NXP TechSupport

what are the steps that are you are following to create the flash.bin?

0 项奖励
回复
5,383 次查看
smithcoba
Contributor III

.

0 项奖励
回复
5,365 次查看
Chavira
NXP TechSupport
NXP TechSupport

HI @smithcoba!

The problem is not the size of the image, as I mention before the problem is the DDR initialization.
Those binaries were created for our evk you have to create your custom fhash.bin according to the manual that I attached previously.

After that, you should flash your board and boot your board.

Best Regards!

Chavira

0 项奖励
回复
5,057 次查看
AlekseyM
Contributor III

That is not a solution.
The problem was solved with a decreased size of flash.bin
My DDR4 is configured fine and the log shows what ddr init and training were done.
I have had ddr4 trouble in the past and the board doesn't load to u-boot with the wrong timings for ddr4.

0 项奖励
回复
5,359 次查看
AlekseyM
Contributor III

I think that part of the log should be shown that DDR4 works fine

U-Boot SPL 2022.04-dirty (Jul 13 2023 - 14:12:30 +0000)
I2C init go
I2C init done
Power init go
PMIC power init
setup for DDR4
PMIC init finished successfully
Power init done
DRAM init continuing..
DDRINFO: start DRAM init
DDRINFO: DRAM rate 2400MTS
DDRINFO:ddrphy calibration done
DDRINFO: ddrmix config done
DRAM init done
SEC0:  RNG instantiated
Normal Boot
Trying to boot from USB SDP
SDP: initialize...
SDP: handle requests...
Downloading file of size 1901104 to 0x40400000... done
Jumping to header at 0x40400000
Header Tag is not an IMX image
Found header at 0x404293a0
NOTICE:  BL31: v2.6(release):lf-6.1.1-1.0.0-0-g616a4588f
NOTICE:  BL31: Built : 10:31:38, Mar  1 2023U-Boot 2022.04-dirty (Jul 13 2023 - 14:12:30 +0000)CPU:   i.MX8MMSL rev1.0 1800 MHz (running at 1200 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 45C
Reset cause: POR
Model: NXP i.MX8MM DDR4 DMC with CYW43455 WIFI/BT board
DRAM:  2 GiB
tcpc_init: Can't find device id=0x52
setup_typec: tcpc port2 init failed, err=-19
tcpc_init: Can't find device id=0x50
setup_typec: tcpc port1 init failed, err=-19
Core:  161 devices, 25 uclasses, devicetree: separate
NAND:  0 MiB
MMC:   FSL_SDHC: 1, FSL_SDHC: 2

0 项奖励
回复
5,456 次查看
AlekseyM
Contributor III

1. I make changes in spl.c and dts files for imx8mm-ddr4-evk, and added timing.c from ddr-tool, according to my board.

2. https://community.nxp.com/t5/i-MX-Processors/build-imx-boot-image-in-Yocto/m-p/1679794/highlight/tru...
I go to this steps, but I use command for imx8mm-ddr4-evk
here:

 

$ cd uboot-imx
$ make clean
$ make imx8mm_ddr4_evk_defconfig
$ make

 

and here: 

 

make SOC=iMX8MM flash_ddr4_evk

 



0 项奖励
回复
5,447 次查看
Chavira
NXP TechSupport
NXP TechSupport

How are you putting the processor in download mode?

Are you using lpddr4 or ddr4?

If you are using lpddr4 in your board the problem could be that.

If you follow the instructions of the post that are you mentioning is for lpddr4 and you are compiling for ddr4.

In general, I don't see a bad step in all your process but is important to clarify the memory that you are using and compile the correct one.

0 项奖励
回复
5,382 次查看
smithcoba
Contributor III

If the memory(ddr4/lpddr4) type is wrong.

It could flash or not? The flash.bin could run correctly or not?

NXP  "expert" answer my question!!! 

0 项奖励
回复
5,368 次查看
Chavira
NXP TechSupport
NXP TechSupport

Hi @smithcoba  !

You should not boot or flash the firmware.

The defconfig that are you compiling is for our evk board and has different hardware than your board.

That is the reason that you have to adjust the DDR timings according to your board.

The guide that I attached previously is very helpful and shows how to do all the processes, after that should flash the firmware to your board and boot your board correctly.

Best Regards!

Chavira

0 项奖励
回复
5,319 次查看
rudi_cyber
Contributor III

I have the same question.

If the memory type(ddr4/lpddr4) is wrong. It doesn't match the hardware. 

The flash.bin can run correctly and run till uboot stage? it stops at ddr training stage or not? 

From AlekseyM's log, it runs to u-boot stage. Even starts to flash image. 

 

Here is the log.

Detect USB boot. Will enter fastboot mode!
Starting download of 2091712 bytes
...............
downloading of 2091712 bytes finished


MMC write: dev # 2, block # 66, count 4086 ... MMC: block number 0x1038 exceeds max(0x1000)

 

MMC write: dev # 2, block # 66, count 4086 ... MMC: block number 0x1038 exceeds max(0x1000)
0 blocks written: ERROR
Writing 'bootloader' FAILED

 

0 项奖励
回复
5,295 次查看
smithcoba
Contributor III

rudi_cyber.

Thanks a lot. 

.

0 项奖励
回复
5,088 次查看
rudi_cyber
Contributor III

It is disappointing that NXP insists on their wrong even it is very simple and basic problem just one line showing in the log.

0 项奖励
回复
5,348 次查看
AlekseyM
Contributor III

1. I switch the boot mode to sequential boot using the boot0 and boot1 pins.
2. DDR4.
3 What needs to be changed in the instructions for creating flash.bin for ddr4? I changed "make defconfig for ddr4" and imx-boot flash_ddr4_evk.
As far as I can see, the initialization, training, etc. associated with ddr4 or lpddr were successful.

I think the problem is that I didn't change the emmc config in spl, but I don't know where I can change that.
Also, u-boot after the "mmc dev 2" command shows me the correct emmc info.

标记 (1)
0 项奖励
回复