Config block missing after updating V1.0B modules to V2.6 bootloader

We were previously using 2.4 based BSP with V1.0B modules. Because of the fast boot mode enabled in V1.1A modules, I have updated our u-boot to V2.6 to support this. However when I update the bootloader to the new version, the config block is lost.

I can restore it using cfgblock create in u-boot, but this is not desired for automatic programming in production because of manually entering serial number.

The V1.0B modules have bootloader version U-Boot 2015.04 (May 18 2015 - 14:17:54) installed.

After running setupdate, my environment is as follows:

Colibri iMX6 # run setupdate
MMC: no card present
** Bad device mmc 1 **
starting USB...
USB0:   Port not available.
USB1:   USB EHCI 1.00
scanning bus 1 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found
** Bad device usb 0 **
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'flash_eth.img'.
Load address: 0x10800000
Loading: #
         1.8 MiB/s
done
Bytes transferred = 3720 (e88 hex)
## Executing script at 10800000
enter "run update" to update the entire module
Colibri iMX6 # printenv
arch=arm
baudrate=115200
board=colibri_imx6
board_name=colibri_imx6
board_rev=010b
boot_file=uImage
bootcmd=run emmcboot ; echo ; echo emmcboot failed ; run nfsboot ; echo ; echo nfsboot failed ; usb start ;setenv stdout serial,vga ; setenv stdin serial,usbkbd
bootdelay=1
check_1=setenv conf_blk_offset 0x1fff; mmc read ${loadaddr} ${conf_blk_offset} 1
check_2=setenv conf_blk_offset 0xfff; mmc read ${loadaddr} ${conf_blk_offset} 1
check_3=setenv conf_blk_offset 0x7ff; mmc read ${loadaddr} ${conf_blk_offset} 1
check_configblock=setexpr toradex_oui_addr ${loadaddr} + 8; mw.l ${kernel_addr_r} 0x002d1400; mmc dev 0 1; run check_1 || run check_2 || run check_3; cmp.b ${kernel_addr_r} ${toradex_oui_addr} 3
console=ttymxc0
cp_file_chunk=tftpboot ${loadaddr} ${board_name}/root.ext3-${filenum}; run set_blkcnt; mmc dev 0 0 && mmc write ${loadaddr} ${blkstart} ${blkcnt}
cpu=armv7
defargs=enable_wait_mode=off galcore.contiguousSize=50331648
dfu_alt_info=u-boot.imx raw 0x2 0x3ff mmcpart 0;boot part 0 1;rootfs part 0 2;uImage fat 0 1;imx6q-colibri-eval-v3.dtb fat 0 1;imx6q-colibri-cam-eval-v3.dtb fat 0 1
drive=0
echo_migrate=echo successfully updated U-Boot, power-cycle and enter \\"run setupdate\\; run migrate\\" to complete update
emmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime rootfstype=ext3 rootwait
emmcboot=run setup; setenv bootargs ${defargs} ${emmcargs} ${setupargs} ${vidargs}; echo Booting from internal eMMC chip...; run emmcdtbload; load mmc 0:1 ${kernel_addr_r} ${boot_file} && bootm ${kernel_addr_r} ${dtbparam}
emmcdtbload=setenv dtbparam; load mmc 0:1 ${fdt_addr_r} ${fdt_file} && setenv dtbparam " - ${fdt_addr_r}" && true
ethact=FEC
ethaddr=00:14:2d:4b:75:75
ethprime=FEC
fdt_addr_r=0x12000000
fdt_file=imx6dl-colibri-eval-v3.dtb
fileaddr=10800000
filesize=e88
incr_decimal=setexpr filenum ${filenum} + 1; setexpr filenrlow ${filenum} % 0x10; test ${filenrlow} -eq "a" && setexpr filenum ${filenum} + 0x6; true
interface=usb
ipaddr=192.168.1.51
kernel_addr_r=0x10800000
loadaddr=0x12000000
migrate=run migrate_configblock; run update_latest; reset
migrate_configblock=run check_configblock; mmc dev 0 0 && mmc read ${loadaddr} 0x500 1 && cmp.b ${kernel_addr_r} ${toradex_oui_addr} 3 && mmc dev 0 1 && mmc write ${loadaddr} ${conf_blk_offset} 1
migrate_uboot=tftpboot ${loadaddr} ${board_name}/u-boot.imx && run set_blkcnt && mmc dev 0 1 && mmc write ${loadaddr} 2 ${blkcnt} && patch_ddr_size && mmc bootbus 0 2 1 2 && mmc partconf 0 1 1 0
migrate_uboot_old=tftpboot ${loadaddr} ${board_name}/u-boot.imx && run set_blkcnt && mmc dev 0 0 && mmc write ${loadaddr} 2 ${blkcnt}; patch_ddr_size
netmask=255.255.255.0
nfsargs=ip=:::::eth0:on root=/dev/nfs rw netdevwait
nfsboot=run setup; setenv bootargs ${defargs} ${nfsargs} ${setupargs} ${vidargs}; echo Booting via DHCP/TFTP/NFS...; run nfsdtbload; dhcp ${kernel_addr_r} && bootm ${kernel_addr_r} ${dtbparam}
nfsdtbload=setenv dtbparam; tftp ${fdt_addr_r} ${fdt_file} && setenv dtbparam " - ${fdt_addr_r}" && true
ramdisk_addr_r=0x12100000
sdargs=ip=off root=/dev/mmcblk1p2 rw,noatime rootfstype=ext3 rootwait
sdboot=run setup; setenv bootargs ${defargs} ${sdargs} ${setupargs} ${vidargs}; echo Booting from SD card in 8bit slot...; run sddtbload; load mmc 1:1 ${kernel_addr_r} ${boot_file} && bootm ${kernel_addr_r} ${dtbparam}
sddtbload=setenv dtbparam; load mmc 1:1 ${fdt_addr_r} ${fdt_file} && setenv dtbparam " - ${fdt_addr_r}" && true
serial#=04945269
serverip=192.168.1.61
set_blkcnt=setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200
set_nextnum=run incr_decimal; setexpr blkstart ${blkstart} + ${blkcnt}
setethupdate=tftpboot ${kernel_addr_r} flash_eth.img
setsdupdate=setenv interface mmc; setenv drive 1; mmc rescan; load ${interface} ${drive}:1 ${kernel_addr_r} flash_blk.img
setup=setenv setupargs fec_mac=${ethaddr} consoleblank=0  no_console_suspend=1 console=tty1 console=${console},${baudrate}n8
setupdate=run setsdupdate || run setusbupdate || run setethupdate; source ${kernel_addr_r}
setusbupdate=usb start && setenv interface usb; setenv drive 0; load ${interface} ${drive}:1 ${kernel_addr_r} flash_blk.img
soc=mx6
splashpos=m,m
update=mmc bootbus 0 2 0 1 && run update_new && exit; run update_v2.4b1
update_1=tftpboot ${loadaddr} ${board_name}/mbr.bin && mmc dev 0 0 && mmc write ${loadaddr} 0x0 0x1
update_2=tftpboot ${loadaddr} ${board_name}/boot.vfat && run set_blkcnt && mmc dev 0 0 && mmc write ${loadaddr} 0x2000 ${blkcnt}
update_3=setenv filesize 4000000; setenv filenum 10; setenv blkstart a000; while test ${filesize} -eq "4000000"; do run cp_file_chunk; run set_nextnum; done; true
update_configblock=run check_configblock; tftpboot ${loadaddr} ${board_name}/configblock.bin && mmc dev 0 1 && mmc write ${loadaddr} ${conf_blk_offset} 1
update_fdt=tftpboot ${loadaddr} ${board_name}/${fdt_file} && fatwrite mmc 0:1 ${loadaddr} ${fdt_file} ${filesize}
update_kernel=tftpboot ${loadaddr} ${board_name}/uImage && fatwrite mmc 0:1 ${loadaddr} uImage ${filesize}
update_latest=run update_uboot; run update_1; run update_2; run update_kernel; run update_fdt; run update_3
update_new=updt_fuse -n && run update_latest && reset; run update_v2.5b3
update_uboot=tftpboot ${loadaddr} ${board_name}/u-boot.imx && run set_blkcnt && mmc dev 0 1 && mmc write ${loadaddr} 2 ${blkcnt} && patch_ddr_size && updt_fuse && mmc bootbus 0 2 0 1 && mmc partconf 0 1 1 0 && mmc rst-function 0 1
update_v2.4b1=run check_configblock || run migrate_configblock; run migrate_uboot_old && run echo_migrate
update_v2.5b3=run check_configblock || run migrate_configblock; run migrate_uboot && run echo_migrate
vendor=toradex
ver=U-Boot 2015.04 (May 18 2015 - 14:17:54)
vidargs=video=mxcfb0:dev=lcd,640x480M@60,if=RGB666 video=mxcfb1:off fbmem=8M

Environment size: 5882/8188 bytes

I now run update:

Colibri iMX6 # run update
mmc - MMC sub system

Usage:
mmc info - display info of the current MMC device
mmc read addr blk# cnt
mmc write addr blk# cnt
mmc erase blk# cnt
mmc rescan
mmc part - lists available partition on current mmc device
mmc dev [dev] [part] - show or set current mmc device [partition]
mmc list - lists available devices
mmc hwpartition [args...] - does hardware partitioning
  arguments (sizes in 512-byte blocks):
    [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes
    [gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition
    [check|set|complete] - mode, complete set partitioning completed
  WARNING: Partitioning is a write-once setting once it is set to complete.
  Power cycling is required to initialize partitions after set to complete.
mmc setdsr <value> - set DSR register value

switch to partitions #1, OK
mmc0(part 1) is current device

MMC read: dev # 0, block # 8191, count 1 ... MMC: block number 0x2000 exceeds max(0x1000)
0 blocks read: ERROR

MMC read: dev # 0, block # 4095, count 1 ... 1 blocks read: OK
byte at 0x10800001 (0x14) != byte at 0x12000009 (0x0)
Total of 1 byte(s) were the same
switch to partitions #1, OK
mmc0(part 1) is current device

MMC read: dev # 0, block # 8191, count 1 ... MMC: block number 0x2000 exceeds max(0x1000)
0 blocks read: ERROR

MMC read: dev # 0, block # 4095, count 1 ... 1 blocks read: OK
byte at 0x10800001 (0x14) != byte at 0x12000009 (0x0)
Total of 1 byte(s) were the same
switch to partitions #0, OK
mmc0(part 0) is current device

MMC read: dev # 0, block # 1280, count 1 ... 1 blocks read: OK
byte at 0x10800000 (0x0) != byte at 0x12000008 (0x1)
Total of 0 byte(s) were the same
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'colibri_imx6/u-boot.imx'.
Load address: 0x12000000
Loading: ######################
         4.8 MiB/s
done
Bytes transferred = 314368 (4cc00 hex)
switch to partitions #0, OK
mmc0(part 0) is current device

MMC write: dev # 0, block # 2, count 614 ... 614 blocks written: OK
done.
successfully updated U-Boot, power-cycle and enter "run setupdate; run migrate" to complete update
Colibri iMX6 #

As you can see, there is an error when trying to read the MMC.

I power-cycle the target and run setupdate and migrate:

U-Boot 2015.04 (Oct 06 2017 - 11:23:46)

CPU:   Freescale i.MX6SOLO rev1.2 at 792 MHz
CPU:   Temperature 61 C
Reset cause: POR
I2C:   ready
DRAM:  256 MiB
PMIC: device id: 0x10, revision id: 0x21
PMIC: programmed
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
*** Warning - bad CRC, using default environment

auto-detected panel vga-rgb
Display: vga-rgb (640x480)
In:    serial
Out:   serial
Err:   serial
Missing Toradex config block
Model: Toradex Colibri iMX6 256MB
Net:   using PHY at 0
FEC [PRIME]
Error: FEC address not set.

Normal Boot
Hit any key to stop autoboot:  0
Colibri iMX6 # run setupdate
MMC: no card present
** Bad device mmc 1 **
starting USB...
USB0:   Port not available.
USB1:   USB EHCI 1.00
scanning bus 1 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found
** Bad device usb 0 **
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'flash_eth.img'.
Load address: 0x12000000
Loading: ##################################################  3.6 KiB
         605.5 KiB/s
done
Bytes transferred = 3720 (e88 hex)
## Executing script at 12000000
enter "run update" to update the entire module
Colibri iMX6 # run migrate
switch to partitions #1, OK
mmc0(part 1) is current device

MMC read: dev # 0, block # 8191, count 1 ... MMC: block number 0x2000 exceeds max(0x1000)
0 blocks read: ERROR

MMC read: dev # 0, block # 4095, count 1 ... 1 blocks read: OK
byte at 0x11000001 (0x14) != byte at 0x12000009 (0x0)
Total of 1 byte(s) were the same
switch to partitions #0, OK
mmc0(part 0) is current device

MMC read: dev # 0, block # 1280, count 1 ... 1 blocks read: OK
byte at 0x11000000 (0x0) != byte at 0x12000008 (0x1)
Total of 0 byte(s) were the same
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'colibri_imx6/u-boot.imx'.
Load address: 0x12000000
Loading: ##################################################  307 KiB
         8.3 MiB/s
done
Bytes transferred = 314368 (4cc00 hex)
switch to partitions #1, OK
mmc0(part 1) is current device

MMC write: dev # 0, block # 2, count 614 ... 614 blocks written: OK
done.
Fuse 0, 5:     5062
Warning: Programming fuses is an irreversible operation!
         Updating to fast boot mode prevents easy
         downgrading to previous BSP versions.

Really perform this fuse programming? <y/N>
y
Fusing fast boot mode...
done.
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'colibri_imx6/mbr.bin'.
Load address: 0x12000000
Loading: ##################################################  512 Bytes
         83 KiB/s
done
Bytes transferred = 512 (200 hex)
switch to partitions #0, OK
mmc0(part 0) is current device

MMC write: dev # 0, block # 0, count 1 ... 1 blocks written: OK
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'colibri_imx6/boot.vfat'.
Load address: 0x12000000
Loading: ##################################################  16 MiB
         9.6 MiB/s
done
Bytes transferred = 16777216 (1000000 hex)
switch to partitions #0, OK
mmc0(part 0) is current device

MMC write: dev # 0, block # 8192, count 32768 ... 32768 blocks written: OK
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'colibri_imx6/uImage'.
Load address: 0x12000000
Loading: ##################################################  4.2 MiB
         9.6 MiB/s
done
Bytes transferred = 4408160 (434360 hex)
writing uImage
4408160 bytes written
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'colibri_imx6/imx6dl-colibri-eval-v3.dtb'.
Load address: 0x12000000
Loading: ##################################################  50.7 KiB
         4.5 MiB/s
done
Bytes transferred = 51925 (cad5 hex)
writing imx6dl-colibri-eval-v3.dtb
51925 bytes written
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'colibri_imx6/root.ext3-10'.
Load address: 0x12000000
Loading: ##################################################  64 MiB
         9.6 MiB/s
done
Bytes transferred = 67108864 (4000000 hex)
switch to partitions #0, OK
mmc0(part 0) is current device

MMC write: dev # 0, block # 40960, count 131072 ... 131072 blocks written: OK
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'colibri_imx6/root.ext3-11'.
Load address: 0x12000000
Loading: ##################################################  64 MiB
         9.6 MiB/s
done
Bytes transferred = 67108864 (4000000 hex)
switch to partitions #0, OK
mmc0(part 0) is current device

MMC write: dev # 0, block # 172032, count 131072 ... 131072 blocks written: OK
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'colibri_imx6/root.ext3-12'.
Load address: 0x12000000
Loading: ##################################################  64 MiB
         9.6 MiB/s
done
Bytes transferred = 67108864 (4000000 hex)
switch to partitions #0, OK
mmc0(part 0) is current device

MMC write: dev # 0, block # 303104, count 131072 ... 131072 blocks written: OK
Using FEC device
TFTP from server 192.168.1.61; our IP address is 192.168.1.51
Filename 'colibri_imx6/root.ext3-13'.
Load address: 0x12000000
Loading: ##################################################  13 MiB
         9.6 MiB/s
done
Bytes transferred = 13631488 (d00000 hex)
switch to partitions #0, OK
mmc0(part 0) is current device

MMC write: dev # 0, block # 434176, count 26624 ... 26624 blocks written: OK
resetting ...


U-Boot 2015.04 (Oct 06 2017 - 11:23:46)

CPU:   Freescale i.MX6SOLO rev1.2 at 792 MHz
CPU:   Temperature 66 C
Reset cause: WDOG
I2C:   ready
DRAM:  256 MiB
PMIC: device id: 0x10, revision id: 0x21
PMIC: programmed
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
*** Warning - bad CRC, using default environment

auto-detected panel vga-rgb
Display: vga-rgb (640x480)
In:    serial
Out:   serial
Err:   serial
Missing Toradex config block
Model: Toradex Colibri iMX6 256MB
Net:   using PHY at 0
FEC [PRIME]
Error: FEC address not set.

Normal Boot
Hit any key to stop autoboot:  0
Colibri iMX6 #

As you can see, after run migrate, the module is updated. However the config block can no longer be read. What am I doing wrong?

Kind regards, Mark

Hi

Are you sure that on that particular module the config block wasn’t missing in the first place or that you restored it with ‘cfgblock create’ with the V2.4 image? We use a simple test to validate the configblock during the migration.

The config block gets migrated from block 1280 (0x500) in the eMMC user area to the last block in the first boot partition.
Around line 50 the last block gets searched which is found at 4095 (0xfff). Then at line 59 the old config block is read and a not so good test tries to check its validity and finds it being not correct.C

Can you read the data from the old location and post the first 32 bytes here?

mmc dev 0 0
mmc read $loadaddr 500 1
md.b $loadaddr

Max

Hi Max,

The config block was reading properly before updating with all modules. I have tried updating +/- 10 modules, all brand new received from Toradex. The output for the first 32 bytes is as follows:

Colibri iMX6 # mmc dev 0 0
switch to partitions #0, OK
mmc0(part 0) is current device
Colibri iMX6 # mmc read $loadaddr 500 1

MMC read: dev # 0, block # 1280, count 1 ... 1 blocks read: OK
Colibri iMX6 # md.b $loadaddr
12000000: 00 40 01 cf 02 40 08 00 01 00 00 00 01 00 10 00    .@...@..........
12000010: 02 40 00 00 00 14 2d 4b 75 2f 00 00 00 00 00 00    .@....-Ku/......
12000020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
12000030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
Colibri iMX6 #

It looks like the config block is there. Please try running
setenv migrate_configblock ‘run check_configblock; mmc dev 0 0 && mmc read ${fdt_addr_r} 0x500 1 && setexpr toradex_oui_addr ${toradex_oui_addr} + c && cmp.b ${kernel_addr_r} ${toradex_oui_addr} 3 && mmc dev 0 1 && mmc write ${fdt_addr_r} ${conf_blk_offset} 1’

before run migrate

alternatively :
setenv migrate_configblock ‘run check_configblock; mmc dev 0 0 && mmc read ${fdt_addr_r} 0x500 1 && mmc dev 0 1 && mmc write ${fdt_addr_r} ${conf_blk_offset} 1’
This assumes that old config block is valid and moves it without checking.

Hi Dominik,

This does indeed solve the problem! Thank you and Max for your help.

Mark