Erase U-Boot Environment Settings
TracNav menu
-
User Guide
- Copyright Information
- Acknowledgements
- Terminology
- Introduction
-
PetaLinux Overview...
-
Working with PetaLinux - The Basics...
-
Customising PetaLinux...
-
Advanced Topics...
-
Debugging...
-
PetaLinux Bootloader Solutions
-
First Stage Boot (FS-Boot)...
-
U-Boot
- Overview
- Adding U-Boot
- Building U-Boot
- Customizing U-Boot
-
Using U-Boot
- Booting U-Boot
- Downloading Files
- Programming Flash
- Platform Initialisation
- Erase U-Boot Environment
- Updating Ethernet MAC Address in U-Boot
-
Supported Reference Designs...
- PetaLinux Tools Reference
- Getting Help
U-Boot store its environment settings in Flash and these values are loaded into RAM memory on every bootup. In most occasion the user can use the setenv and saveenv command to update the environment variables. However, when the user need to completely erase the environment sector for reprogramming or updating the locked variables like the Ethernet MAC address, a full erase is required.
This section provides details on the 2 methods of erasing the U-Boot environment sector in Flash.
Automatic Erase
PetaLinux includes a U-Boot command eraseenv in the U-Boot environment. This command can be used to erase the U-Boot environment sector in Flash.
Note that this command will only be available if the target device has been configured using the PetaLinux ub.config.img environment setup file. Refer to the U-Boot Platform Initialisation Chapter of the User Guide for more information.
The eraseenv command will automatically detect the U-Boot environment partition in Flash and will handle the unlocking and erasing of that partition.
The example below shows how to run the eraseenv command in U-Boot.
U-Boot> run eraseenv Un-Protected 1 sectors . done Erased 1 sectors U-Boot>
Manual Erase
1. Find the address and ID of the U-Boot environment flash sector
In the PetaLinux System Configuration Menu, check the address of the bootenv sector.
Then, in U-Boot, use the flinfo command to identify the flash sector ID of this address:
U-Boot> flinfo
Bank # 1: CFI conformant FLASH (32 x 16) Size: 8 MB in 32 Sectors
Erase timeout 16384 ms, write timeout 3 ms, buffer write timeout 3 ms, buffer size 32
Sector Start Addresses:
28000000 28040000 (RO) 28080000 280C0000 28100000
28140000 28180000 281C0000 28200000 28240000
28280000 282C0000 28300000 28340000 28380000
283C0000 28400000 28440000 28480000 284C0000
28500000 28540000 28580000 285C0000 28600000
28640000 28680000 286C0000 28700000 28740000
28780000 287C0000
U-Boot>
For example, if the bootenv address was 0x28040000, this would be sector 1 (sector IDs start from zero).
2. Unlock the bootenv Flash sector.
U-Boot> protect off 1:1 Un-Protect Flash Sectors 1-1 in Bank # 1
In this example the bootenv is in sector 1 (sector numbers start from 0). The 1:1 command argument refers to <bank number>:<sector number> . There is only 1 Flash bank configured for the default PetaLinux environment, hence the bank number is set to 1. Refer to U-Boot User Guide for more information on the protect command.
3. Erase the bootenv partition
U-Boot> erase 1:1 Erase Flash Sectors 1-1 in Bank # 1 . done U-Boot>
