nvm command

nvm command

To save user data to the flash memory, save the data with a "nvm write" command after getting a key with a "nvm wkey" command.

After generating a key to be used for the "nvm write" command as a parameter, returns it.

Parameter Description
$target the area to save into
(envs: system data area, envu: user data area)

Saving the data to the flash area with the key which was generated with "nvm wkey".

Parameter Description
envs/envu envs - system data area
envu - user data area
wkey the key which was returned from the "nvm wkey" command
env data to be saved

After user have saved data to the flash memory user cannot save data in the same area within 2 seconds. And the number of saving operation is limited because of hardware limitation so this function should be carefully used.

The following is an example which saves "abcdefghij" to the user data area.

$str = "abcdefghij";

echo "setup /mmap/envu (user non-volatile meory)\r\n";
$wkey = system("nvm wkey envu");
echo "write \$str to /mmap/envu\r\n";
system("nvm write envu $wkey %1", $str);  // write $str  to /mmap/envu (flash)

echo "open /mmap/envu and read it\r\n";
$pid_envu = pid_open("/mmap/envu");  // open /mmap/envu
$buf = "";
pid_read($pid_envu, $buf, 10);  // read /mmap/envu
echo "/mmap/envu : $buf\r\n";