# uefi shell



## balanga (Mar 29, 2019)

I'm hoping to run FreeBSD on an Intel Compute stick, but first I need to get past the UEFI shell. The only command I'm familiar with is exit .

I'd try one of the many available if I could properly see what is available so the first thing I want to do is change the size of the display - there's only 25 lines. I can change this by running `mode 240 56` but I'd like to make that permanent - is that possible?

On booting it comes up with an option to skip startup.nsh but  I don't know how to access that.

`devices` does actually show the attached show the  disk I'd like to try and boot, but I'm not sure how.

Any pointers would be appreciated.


----------



## Phishfry (Mar 29, 2019)

What happened? Gave up on GoFlex, Wireless Access Point and Kodi and decided to start another project?


----------



## D-FENS (Mar 29, 2019)

Can you boot into the BIOS setup program?


----------



## balanga (Mar 29, 2019)

Phishfry said:


> What happened? Gave up on GoFlex, Wireless Access Point and Kodi and decided to start another project?



Not given up, just trying to make progress with an old project Thread 53355. Got a nice new monitor this week and thought it would be nice and discrete to use an Intel Compute stick with it, but I'd prefer to use FreeBSD rather than Windows. But can't seem to get into the BIOS and have no idea where this startup.nsh lives...

As far as Kodi goes, I found that the UPnP function appears not to work on FreeBSD 12.0, whereas it worked on 11.2.

Thread 70136


----------



## balanga (Mar 29, 2019)

roccobaroccoSC said:


> Can you boot into the BIOS setup program?


Not managed so far. I press F2  during boot but the system just carries on booting Windows. I don't know if startup.nsh controls this or how to access this file.


----------



## aragats (Mar 29, 2019)

Maybe these EFI instructions from Intel can help?


----------



## T-Daemon (Mar 29, 2019)

balanga said:


> Not managed so far. I press F2  during boot but the system just carries on booting Windows. I don't know if startup.nsh controls this or how to access this file.


Try the following: (according to the Technical Product Specifications)

"The BIOS Setup program is accessed by pressing the <F2> key after the Power-On Self-Test (POST) memory test begins and before the operating system boot begins."


----------



## balanga (Mar 29, 2019)

aragats said:


> Maybe these EFI instructions from Intel can help?



It won't load on my system. Will have to try on a Windows machine.


----------



## balanga (Mar 29, 2019)

T-Daemon said:


> Try the following: (according to the Technical Product Specifications)
> 
> "The BIOS Setup program is accessed by pressing the <F2> key after the Power-On Self-Test (POST) memory test begins and before the operating system boot begins."



Spent ages trying to get that to work but by chance found that <F7> was the magic key.

If I go 

Setup -> Boot 

I have 

```
Boot Option #1
Boot Option #2
```

and both offer the same three options

Windows Boot Manager
UEFI: Built-in EFI Shell
Disabled

I guess I'll see what I can do with the UEFI shell...


----------



## Phishfry (Mar 29, 2019)

balanga said:


> and have no idea where this startup.nsh lives...


This will reside on the media you are trying to boot from. Like a USB stick.

For instance to flash the firmware on LSI SAS cards you must send many long commands.
To make it easy I created a startup.nsh to flash the firmware after erasing it.

```
sas2flash.efi -o -e 6
sas2flash.efi -f 2008T204.ROM
sas2flash.efi -b x64sas2.rom
```

Coming from DOS you could compare startup.nsh to autoexec.bat
It auto launches a batch file. Running several EFI commands.


----------



## balanga (Mar 30, 2019)

Phishfry said:


> This will reside on the media you are trying to boot from. Like a USB stick.


In this case it is the eMMC storage of the Intel Compute stick.


> For instance to flash the firmware on LSI SAS cards you must send many long commands.
> To make it easy I created a startup.nsh to flash the firmware after erasing it.
> 
> ```
> ...



I still don't know how to access it. Maybe there is a Windows utility...

Under Administrative Tools -> Computer Management -> Storage

I see the 32GB eMMC storage has three partitions which include a 100MB EFI  and a 450MB Recovery partition, so my guess is that startup.nsh exists in the EFI partition, but I'm not sure how I can see what is on it.

I've found that if I attach a USB stick with a FreeBSD installation which includes an EFI partition it does show up in the BIOS boot selection menu but selecting it only starts Windows.


----------



## Phishfry (Mar 30, 2019)

I think you are putting too much emphasis on startup.nsh. It is optional for bootup, just like autoexec.bat.
I was trying to show you how it works.
That is simply a BIOS message.
Have you tried flashing a FreeBSD UEFI image onto the eMMC?
What size is the eMMC flash drive?


----------



## balanga (Mar 30, 2019)

I've just managed to boot from a Rescatux USB stick so it is possible to bypass Windows.

Don't know what's so special about Rescatux but it appeared on the boot menu and I was actually able to boot from it - even have Internet access.


----------



## balanga (Mar 30, 2019)

Phishfry said:


> I think you are putting too much emphasis on startup.nsh. It is optional for bootup, just like autoexec.bat.
> I was trying to show you how it works.
> That is simply a BIOS message.
> Have you tried flashing a FreeBSD UEFI image onto the eMMC?
> What size is the eMMC flash drive?



It's 32GB, but I don't know how I would flash it.


----------



## Phishfry (Mar 30, 2019)

*USE AT YOUR OWN RISK:*
Here is what I would do.
The compute stick is meant to be plugged into a HDMI device correct.
So I would plug it into a TV and attach a *externally powered* USB hub to it.
On the USB hub I would have an keyboard and FreeBSD Memstick Installer.
Now tune the TV to the correct HDMI port and plug in your compute stick.
It should show the bootup sequence on the TV.
From there you should be able to figure this out.
You might want to confirm with the Memstick installer that every device you need is supported.
Do this by dropping to LiveCD mode of the Memstick installer and look at `dmesg` output.


----------



## D-FENS (Mar 30, 2019)

I think booting from ANY UEFI enabled OS installation disk should be possible. Just plug-in the USB installation medium and goto BIOS to enable it in the boot order.
The compute stick does have a USB port, at least I see on the pictures in the web.


----------



## D-FENS (Mar 30, 2019)

balanga said:


> It's 32GB, but I don't know how I would flash it.


Well, you can just plug it in the card reader of a FreeBSD or GNU/Linux PC and then edit, format and partition it just like any other medium.
And you can use dd to burn an image on it.


----------



## Phishfry (Mar 30, 2019)

The reason I urge caution is the device is powered through the HDMI port.
If you hook up too many USB devices it could have negative consequences.
https://screen.cloud/how-to/media-players/guide-intel-compute-stick


----------



## Phishfry (Mar 30, 2019)

The real kicker here is Wifi only networking.
I have to wonder if there is Wifi driver in FreeBSD for this device. Something tells me no.


----------



## D-FENS (Mar 30, 2019)

Phishfry said:


> The reason I urge caution is the device is powered through the HDMI port.
> If you hook up too many USB devices it could have negative consequences.
> https://screen.cloud/how-to/media-players/guide-intel-compute-stick


I saw a power adapter on the pictures. Can't it be connected for power?


----------



## balanga (Mar 30, 2019)

Phishfry said:


> The real kicker here is Wifi only networking.
> I have to wonder if there is Wifi driver in FreeBSD for this device. Something tells me no.



I have one of these:-



			https://d2211byn0pk9fi.cloudfront.net/spree/products/5010/product/A7514041_ND01.jpg?1461123817
		


I did manage to boot using Rescatux and wondered if I could backup the eMMC storage using DD in case I want to restore...


----------



## balanga (Mar 30, 2019)

How would I DD the eMMC storage on the Compute Stick

`lsblk`:-


```
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda            8:0    1   7.4G  0 disk.
�..�..sda1         8:1    1   640M  0 part /lib/live/mount/medium
�..�..sda2         8:2    1   704K  0 part.
loop0          7:0    0 570.3M  1 loop /lib/live/mount/rootfs/filesystem.squashf
mmcblk0boot0 179:256  0     4M  1 disk.
mmcblk0boot1 179:512  0     4M  1 disk.
mmcblk0      179:0    0  29.1G  0 disk.
�..�..mmcblk0p1  179:1    0   100M  0 part.
�..�..mmcblk0p2  179:2    0    16M  0 part.
�..�..mmcblk0p3  179:3    0  28.6G  0 part.
�..�..mmcblk0p4  179:4    0   450M  0 part.
```


----------



## D-FENS (Mar 31, 2019)

balanga said:


> How would I DD the eMMC storage on the Compute Stick


Your memory card is mmcblk0, right?
If it is not soldered to the device and is removeable, I would just stick it in my notebook and take an image.
If it IS soldered, then it's a bit more complicated. Then just boot as you described above and then plug in a USB stick, then use dd to take an image from the memory card. Make sure to get the device names right!! Otherwise you could overwrite your memory card irreversibly!!!

I would first take an image of the standard Intel installation with Windows. Then I could play with the card and other OS-es and if I'm not happy, I could always burn the Intel original and be back to where I started.
The command should be something like:
`dd if=/dev/mmcblk0 of=....path/to/your/mounted/USB/stick..../intel_compute_memcard.img status=progress`

Then save the .img file in a safe location and play around.

Also another advice: Try not to overwrite the EFI system partition on the memory card. If you do so, you might not be able to boot into the EFI shell and load anything. In my opinion it should be bootable from a USB stick, but this is just a hypothesis, I can't validate it.


----------



## balanga (Mar 31, 2019)

roccobaroccoSC said:


> Your memory card is mmcblk0, right?



No, mmcblk0 is the 32GB (29.1G) of eMMC storage on the Compute Stick. SDA is the 8GB (7.4G)USB stick I've booted from.


> I would first take an image of the standard Intel installation with Windows. Then I could play with the card and other OS-es and if I'm not happy, I could always burn the Intel original and be back to where I started.
> The command should be something like:
> `dd if=/dev/mmcblk0 of=....path/to/your/mounted/USB/stick..../intel_compute_memcard.img status=progress`


I'm just a little concerned that I won't be able to restore using DD.

I have no idea what these two partitions are, but I guess DD would handle them correctly

mmcblk0boot0 179:256  0     4M  1 disk.
mmcblk0boot1 179:512  0     4M  1 disk.



> In my opinion it should be bootable from a USB stick, but this is just a hypothesis, I can't validate it.



Believe me, it is not an easy process. I tried booting from ArchLinux, Mint, Ubuntu, TrueOS and even Debian, and only Rescatux which is actually based on Debian managed to boot. It sounds as though the Compute Stick has a very specific  EFI requirement to be able to boot, unless there is some BIOS setting I need to make to accommodate the other OSes.


----------



## Phishfry (Mar 31, 2019)

You do see your problem right?
Writing a 32GB image file to your 8GB sda0 that you booted from?
dd writes every sector even if empty.


----------



## balanga (Mar 31, 2019)

I can also attach a hard disk which Rescatux can see. I believe it is possible to PXE boot this device but you need a specific chipset in your LAN hub. But what is so special about Rescatux. Could I use its EFI with a different OS, afterall it is based on Debian, but Debian itself won't boot


----------



## D-FENS (Mar 31, 2019)

balanga said:


> No, mmcblk0 is the 32GB (29.1G) of eMMC storage on the Compute Stick. SDA is the 8GB (7.4G)USB stick I've booted from.


That was exactly what I meant. The memory card is what it's built in the compute stick. Can it be removed? Is it like the normal SD-cards we use for phones and cameras? If so, it's quite easy to stick the card in any notebook or card reader and then you can play with it as much as you want. A total restore is possible - just take the complete image of the card on another machine.

If the card is not removable, probably don't bother playing with other OS-es, unless you're OK with bricking the device.


balanga said:


> I'm just a little concerned that I won't be able to restore using DD.
> 
> I have no idea what these two partitions are, but I guess DD would handle them correctly
> 
> ...


I would not dd the partitions themselves - it's quite error prone. Simply dd the whole device, so you're definitely on the safe side.


----------



## D-FENS (Mar 31, 2019)

Phishfry said:


> You do see your problem right?
> Writing a 32GB image file to your 8GB sda0 that you booted from?
> dd writes every sector even if empty.



You can always pipe it through gzip, so if the device is mostly empty, it'll just compress it to whatever is the real data size or close.


----------



## balanga (Mar 31, 2019)

If I manage to copy the image to another location, I'm wondering whether  DDing the ISO image of Rescatux to eMMC storage would create a bootable Compute Stick...


----------



## balanga (Apr 2, 2019)

It seems that my Intel Compute Stick is not a genuine compute stick so I won't get any help on Intel's forums... So I'm wondering if a BIOS upgrade may enable more EFI partitions to boot. Currently I've only found that that Rescatux is able to boot.

Given that I have an American Megatrends BIOS should I expect to find an upgraded BIOS here .

This actually is related to FreeBSD because I want to install FreeBSD on this stick.


----------



## tingo (Apr 3, 2019)

A BIOS upgrade is always worth it if you have trouble, IMHO. However, I only use the vendor's site to get BIOS updates. Normally each vendor modifies the BIOS for each motherboard, so a BIOS from AMI probably won't help. At best it will refuse to install, at worst it will brick your machine.

What brand and model is your compute stick?


----------



## balanga (Apr 3, 2019)

It looks like one of these  and has an American Megatrends BIOS. I looked here but didn't find an obvious file to download.


----------



## tingo (Apr 4, 2019)

Most BIOS / UEFI has one screen which shows the version of the BIOS. And often they show a "model" number for the bios as well, you can use that in google to see if you can find a place to download a bios upgrade.


----------



## balanga (Apr 4, 2019)

Under BIOS which is described as Aptio Setup Utility, Main shows BIOS Information:-


```
BIOS Vendor         American Megatrends
Core Version        5.008
Compliancy          UEFI 2.3; PI 1.2
Project Version     1ASEB 2.41
Build Date and Time 05/16/2015 09:06:04

CPU Configuration
Microcode Patch     82f
```

https://ami.com/en/products/bios-uefi-firmware/ list Aptio V and Aptio 4

It isn't obvious to me which (if either) I should use... I'll try Apto V and see what happens,

I also notice under 

Chipset  -> South Bridge -> USB Configuration 

this mentions options for :-
USB OTG SUPPORT
USB VBUS
XHCI Controller
XHCI Mode

USB2 Link Power Management

Unfortunately I have no idea what I need to set - maybe it has some impact on external devices - I don't know...


----------



## bjs (Apr 4, 2019)

You should only update your BIOS when you are absolutely sure it's the right one for your motherboard... If you're not ABSOLUTELY POSITIVE you have the right file, DON"T update!!! Do some more research until you are positive...


----------

