Mediagate MG35

 

NVRAM

Page history last edited by Vasile 7 mos ago

Non Volatile configuration data

 

Non-Volatile storage is in the flash. Flash goes to all bits set (all bytes = 0xFF) when erased. After this, bits can only be cleared. This requires a special NV data storage mechanisms.

 

All the configuration variables (see below) are grouped together in what we call a "configuration block". Whenever a change to one of the variables happens, the whole current block is marked as invalid and the new information is written in the following block. When the configuratio area gets close to be full, the whole of it is erased (reverted to 0xff value) and the process starts anew.

 

Configuration area

The area in flash reserved for configuration blocks is from 0x2-0000 to 0x3-FFFF.  

At address 0x2-0000 is the ascii signature "BOOT"

After this there appears to be a 16-byte bit "block usage" field, in which a bit is cleared down to zero (starting at bit 0) whenever a config block is used.

The config blocks themselves then start at 0x2-0048. They are 1000 decimal bytes each.

When you change some item in the configuration and save the change, a new block is written on the end and another bit in the "block usage" field is cleared down, until the whole "block usage" field is cleared. At this moment, the configuration area is erased and the process start again.

 

Example:

A dumped config area had at address 0x20004 12x 0x00 and then 0xFC - (12*8+2)*1000+0x20048=0x37F18

So, the next free block is at 0x37F18 and the current config data starts 1000 bytes before this.

 

Configuration block

Each configuration block consists of 1000 (decimal) bytes, but is seems that only 848 are really used, so we may have some spare space for our own data.

 

Offset (decimal) Description Length Values
64 Audio Output 4 0 = digital, 1 = analog
68 Video HD Component State 4  
72 Video Composite state 4  
84 Screen size state 4  
92 Jpeg Preview state 4  
168 Language State 4  
172 Power LED state 4  
176 NDAS state 4  
196 "CONF" - start of bootloader section? 4  
200 MAC address (to offset 205) 6  
208 IP address 4  
212 net mask 4  
216 gateway 4  
220 server IP (tftp?) 4  
228 Name of domain 24  
252 Name of loader.bin file 64 (This is also where we are storing the SETNAS Variable)
316 TFTP path to romfs (kernel + cramfs) 64  
380 Name of linux.bin file 64  
444 TFTP path to test image (bootloader+config+kernel+camfs) 64  
508 End of bootloader section 4  
516 DHCP state 4  
520 DHCP Set IP address 4  
524 DHCP Set net mask 4  
528 Serial console state 4  
532 Resume file playing name hash 16  
548 Resume file playing start (seconds) 4  
552 Resume handling flag 4  
844 "FINE" canary 4  
848 0xFF filler 152  

 

Booleans (states) are stored as either 0 or 1 in the first (least signficant) byte of the field.

Network addresses are stored in little-endian byte order, not network byte order. e.g. for 192.168.1.2  we have [208]=2, [209]=1, [210]=168, [211]=192 

MAC address is stored in network/standard byte order. e.g. for 00:02:A8:0D:11:1B we have [200]=0x00, [201]=0x02, [202]=0xa8, [203]=0x0d, [204]=0x11, [205]=0x1B

 

Tools for accessing configuration data

You can dump config data with the mg35config utility. This utility writes configs into the current directory.

The mgnv utility allows reading and writing of the configuration data. BEWARE!! Do not write to the configuration area unless you know what you're doing!

 

Example:

You can read the power LED with - mgnv "%d" b:172

and write it with - mgnv b:172=1

read the loader file name with - mgnv "%s" s:252

and write it with - mgnv s:252="/bin/test"

 

 

Comments (0)

You don't have permission to comment on this page.