In this blog, the eBoot menu is modified to to allow user selection of Clearing of the Hive or not. This is implemented by adding a further parameter to the BOOT_CG and BSP_ARGS structures to handle the boolean selection. The eBoot code is then extended to pass the selection up to the OS args driver. The OS args driver then is modified to get the value when requested by getting it from the structure passed to it through shared memory. This replaces the use of the dummy variable s_bClearHive as used in args.c in the previous blog.
Context: This discussion is with respect to the Texas Instruments AM335X MPU as used with BeagleBone Black (BBB) and the Variscite VAR-SOM-AM33. This material was developed mainly with the latter but the BBB was also used in parts.
Previous Blog: TI AM335X Windows Embedded Compact Bootloader Args and Clearing Hive Registry
1. Add an arg to be passed between eboot and the OS, and stored in flash when configuration is saved.
in boot_args.h at the bottom of BOOT_CFG structure add the bClearHive entry:
2. Similarly in BSP_ARGS structure in args.h insert the bCrearHive entry
Adding two items to main menu. Could do a submenu .. ToDo
In menu.c: 3. List the functions that implement the code for for each new menu item. Add the highlighted change:
//Added DJ 29/05/15: static VOID SetClearHive(OAL_BLMENU_ITEM *pMenu); static VOID UnSetClearHive(OAL_BLMENU_ITEM *pMenu);
In menu.c 4. Add the menu items. There are two menus. One for Nand and one for SD boots:
// {L'a', L"Select Display Resolution", SetDisplayResolution,NULL, NULL, NULL}, {L'b', L"Select OPP Mode", SetOPPmode,NULL, NULL, NULL}, {L'h', L"HIVE -- Keep Hive (Default)", UnSetClearHive,NULL, NULL, NULL}, {L'H', L" -- Clear Hive", SetClearHive,NULL, NULL, NULL}, {L'0', L"Exit and Continue", NULL,NULL, NULL, NULL}, {0, NULL, NULL,NULL, NULL, NULL} }; #else static OAL_BLMENU_ITEM g_menuMain = { {L'1', L"Show Current Settings", ShowSettings,NULL, NULL, NULL}, {L'2', L"Select Boot Device", OALBLMenuSelectDevice,L"Boot", &g_bootCfg.bootDevLoc, g_bootDevices}, {L'3', L"Select KITL (Debug) Device", OALBLMenuSelectDevice,L"Debug", &g_bootCfg.kitlDevLoc, g_kitlDevices}, {L'4', L"Network Settings", OALBLMenuShow,L"Network Settings", &g_menuNetwork, NULL}, //{L'5', L"Flash Management", OALBLMenuShow,L"Flash Management", &g_menuFlash, NULL}, {L'6', L"Set Device ID", SetDeviceID,NULL, NULL, NULL}, {L'7', L"Save Settings", SaveSettings,NULL, NULL, NULL}, {L'8', L"Flash Management", OALBLMenuShow,L"Flash Management", &g_menuFlash, NULL}, {L'9', L"Enable/Disable OAL Retail Messages", SetRetailMsgMode,NULL, NULL, NULL}, #ifdef DYNAMIC_OS_BOOT {L'a', L"Set NK Boot Partition", SetBootPart, NULL, NULL, NULL}, #endif // DYNAMIC_OS_BOOT // {L'a', L"Select Display Resolution", SetDisplayResolution,NULL, NULL, NULL}, {L'b', L"Select OPP Mode", SetOPPmode,NULL, NULL, NULL}, {L'h', L"HIVE -- Keep Hive (Default)", UnSetClearHive,NULL, NULL, NULL}, {L'H', L" -- Clear Hive", SetClearHive,NULL, NULL, NULL}, {L'0', L"Exit and Continue", NULL,NULL, NULL, NULL}, {0, NULL, NULL,NULL, NULL, NULL} }; #endif
Still in menu.c 5. Implement the functions I placed them just before: #ifdef DYNAMIC_OS_BOOT VOID SetBootPart(OAL_BLMENU_ITEM *pMenu)
VOID UnSetClearHive(OAL_BLMENU_ITEM *pMenu) { g_bootCfg.bClearHive=FALSE; }
[1] Show Current Settings [2] Select Boot Device [3] Select KITL (Debug) Device [4] Network Settings [6] Set Device ID [7] Save Settings [8] Flash Management [9] Enable/Disable OAL Retail Messages [a] Set NK Boot Partition [b] Select OPP Mode [h] HIVE -- Keep Hive (Default) [H] -- Clear Hive [0] Exit and Continue
In main.c in OEMPreDownload() 6. Add a default setting for this when no boot config is found by eBoot:
//Added DJ 29/05/15 g_bootCfg.bClearHive=0;
g_bootCfg.ECCtype = (UCHAR)dwEbootECCtype
Also in main.c in OEMPreDownload()
pArgs is what gets passed form eBoot to the OS.
7. Insert the following as highlighted:
pArgs->oalFlags = g_bootCfg.oalFlags; pArgs->dispRes = g_bootCfg.displayRes; pArgs->ECCtype = g_bootCfg.ECCtype; pArgs->opp_mode = g_bootCfg.opp_mode; //DJ 29/05/15 pArgs->bClearHive = g_bootCfg.bClearHive; memcpy(pArgs->DevicePrefix, gDevice_prefix, sizeof(pArgs->DevicePrefix)); // should we check the size /* unset the cfg save flag in bootCfg; pArgs now contains the correct value for this flag*/ g_bootCfg.oalFlags &= ~BOOT_CFG_OAL_FLAGS_CFG_SAVE; memcpy(pArgs->ebootCfg,&g_bootCfg,sizeof(BOOT_CFG)); pArgs->cfgSize = sizeof(BOOT_CFG);
Now change the OAL_ARGS_QUERY_CLEAR_HIVE:case to:
8. Build and test he functionality. You will need to install the new eBoot (build as Release no KITL etc) on the target. Run the OS as Debug download so as to observe the messages. test by having an an that write to registry a value that it has just read and incremented.
I deduced that this is with a new system. Although its not the first boot, the previous boot was shutdown before any registry was flushed and hence tring to load one leads to an error. A proper shutdown (eg Soft reboot, programmatic reboot etc) or allowing time for an auto-flush should resolve this.
Also, when an new OS is booted you get:
Thanks DV What I did was an autorun app to always clear the flag if set at start up after services are started. Have thought that after actioning the clearing, could clear the flag then. In the manner I used, you can set the hive to be cleared from eboot menu.
I implemented this slightly different in my BSP at https://beaglebonebsp.codeplex.com/ As you probably do not want to persist the clean registry flag setting in the saved boot config file. This would cause a registry clean on every subsequent reboot ...probably something you do not want. A slight change in the code would insure the clear flag is never persisted being set but still allows the state of the newly set flag to be passed to the arg structure as set.