Compilation of u-boot with increased CONFIG_ENV_SIZE

When increasing #define CONFIG_ENV_SIZE 0x2000 to #define CONFIG_ENV_SIZE 0x20000 and updating u-boot in the eMMC using run setupdate + run update_uboot and poweroff/on it hangs up right after boot:

U-Boot 2016.11-00006-gfc72714-dirty (Jan 31 2017 - 13:01:55 +0100)              
DRAM:  2 GiB                                                                    
MMC:   Tegra SD/MMC: 0, Tegra SD/MMC: 1, Tegra SD/MMC: 2                        
*** Warning - bad CRC, using default environment                                
In:    serial                                                                   
Out:   serial                                                                   
Err:   serial                                                                   

When u-boot is run in the recovery mode from RAM it runs properly and boots into Ubuntu.

When the same u-boot configuration is build with #define CONFIG_ENV_SIZE 0x2000 it does also boot properly into Ubuntu from eMMC (not RAM):

U-Boot 2016.11-00006-gfc72714-dirty (Jan 31 2017 - 15:31:15 +0100)              
DRAM:  2 GiB                                                                    
MMC:   Tegra SD/MMC: 0, Tegra SD/MMC: 1, Tegra SD/MMC: 2                        
In:    serial                                                                   
Out:   serial                                                                   
Err:   serial                                                                   
Model: Toradex Apalis TK1 2GB V1.1A, Serial# 02864547                           
Net:   No ethernet found.                                                       
Hit any key to stop autoboot:  0                                                
Booting from internal eMMC chip...                                              
Unknown command 'dtbparam' - try 'help'                                         
49735 bytes read in 155 ms (312.5 KiB/s)                                        
5471848 bytes read in 387 ms (13.5 MiB/s)                                       
## Booting kernel from Legacy Image at 81000000 ...                             
   Image Name:   Linux-3.10.40-v2.7b1+g19722d4                                  
   Image Type:   ARM Linux Kernel Image (uncompressed)                          
   Data Size:    5471784 Bytes = 5.2 MiB                                        
   Load Address: 80008000                                                       
   Entry Point:  80008000                                                       
   Verifying Checksum ... OK                                                    
## Flattened Device Tree blob at 82000000                                       
   Booting using the fdt blob at 0x82000000                                     
   Loading Kernel Image ... OK                                                  
   Using Device Tree in place at 82000000, end 8200f246                         
Starting kernel ...                                                             
[    0.000000] Booting Linux on physical CPU 0x0                                
[    0.000000] Initializing cgroup subsys cpu                                   
[    0.000000] Initializing cgroup subsys cpuacct                               
[    0.000000] Linux version 3.10.40-v2.7b1+g19722d4 (linuxdev@linuxdev.toradex7
[    0.000000] ...

Where did I missed to consider the increased environment size? (I did not change the partitioning until and inclusive the vfat partition. I appended 2 other partitions after the rootfs partition of the original apalis image.)
BTW: How do I get rid of this ugly -00006-gfc72714-dirty appended to the u-boot identification?

The dirty in “U-Boot 2016.11-00006-gfc72714-dirty” indicates changes in the local u-boot sources which have not been commited (is only allowed during development). fc72714 links the u-boot build to a version control commit fc72714….

In the Apalis Linux Image the u-boot environment is located in the “primary eMMC boot sector” (mmcblk0boot0) after the cbootimage and in front of the configblock. Do I need to adjust the flashing of the configblock e.g. the startblock ( update_configblock in apalis-tk1_bin/flash_eth.scr) due to the increase of the u-boot environment from 0x2000 to 0x20000?

I would assume so, yes.

The cbootimage apalis-tk1.img is flashed into mmcblk0boot0 with setenv update_uboot 'tftpboot ${loadaddr} ${board_name}/${board_name}.img && run set_blkcnt && mmc dev 0 1 && mmc write ${loadaddr} 0x0 ${blkcnt}' to start block 0x0.

The configblock configblock.bin is flashed into mmcblk0boot0 with setenv update_configblock 'run check_configblock; tftpboot ${loadaddr} ${board_name}/configblock.bin && mmc dev 0 1 && mmc write ${loadaddr} ${conf_blk_offset} 1' to start block 0x2000. The maximal conf_blk_offset is set to 0x1fff with setenv check_1 'setenv conf_blk_offset 0x1fff; mmc read ${loadaddr} ${conf_blk_offset} 1' in setenv check_configblock 'setexpr toradex_oui_addr ${loadaddr} + 8; mmc dev 0 1; run check_1 || run check_2 || run check_3; crc32 -v ${toradex_oui_addr} 3 94305232'. I should probably extend the checking with e.g. check_0 until 0x1ffff ( 0x20000 - 1 )…

I did not find the explicit flashing of the u-boot environment. A comment in states that it is appended at the end of apalis-tk1.img. In apalis-tk1.img.cfg I found just a reference to the BCT file and u-boot. (The BCT file has a size of 8192 bytes and the u-boot binary of 582206 bytes.) Do I have to consider the size of BCT and u-boot in the cbootimage in front of the u-boot environment somehow in addition?