GRUB2 + VESA BIOS Extensions / VBE broken? - framebuffer

Whereas I did get my earlier problem with building proper boot images fixed, I've been struggling with another GRUB2-related problem for most of the day.
The problem is that even though I do set the video info request bit in my multiboot header, GRUB2 does not return proper VESA BIOS Extensions (VBE) info.
The kernel is my own work, and it's noteworthy that it Used to Work (TM) with some earlier version of GRUB2 (I could fill the screen with white pixels, no problem).
Here's my current grub.cfg:
set timeout=10
set default=0
menuentry "zero" {
set gfxmode=1024x768x24
set gfxpayload=keep
insmod vbe
insmod gfxterm
multiboot /kern
}
And here's the script I use to build my boot images:
echo Building kernel
./build.sh
echo Creating bootable CD image...
cp zero cdimg2/kern
grub-mkimage --format=i386-pc --output=core.img \
--config="cdimg2/boot/grub/grub.cfg" loadenv biosdisk \
part_msdos part_gpt fat ntfs \
ext2 ntfscomp iso9660 loopback search linux boot \
minicmd cat cpuid chain \
halt help ls reboot echo test configfile normal sleep \
memdisk tar font \
gfxterm gettext true vbe vga video_bochs video_cirrus \
multiboot multiboot2
cat /usr/lib/grub/i386-pc/cdboot.img core.img > \
cdimg2/grub.img
genisoimage -A "ZERO" -input-charset "iso8859-1" -R -b \
grub.img -no-emul-boot \
-boot-load-size 4 -boot-info-table -o cd.iso cdimg2

Related

How to convert STL to rotating GIF using OpenSCAD?

Given an STL file, how can you convert it to an animated gif using the command line (bash)?
I've discovered a few articles that vaguely describe how to do this through the GUI. I've been able to generate the following, however the animation is very rough and the shadows jump around.
for ((angle=0; angle <=360; angle+=5)); do
openscad /dev/null -o dump$angle.png -D "cube([2,3,4]);" --imgsize=250,250 --camera=0,0,0,45,0,$angle,25
done
# https://unix.stackexchange.com/a/489210/39263
ffmpeg \
-framerate 24 \
-pattern_type glob \
-i 'dump*.png' \
-r 8 \
-vf scale=512:-1 \
out.gif \
;
OpenScad has a built in --animation X parameter, however using that likely won't work when passing in the camera angle as a parameter.
Resources
https://github.com/openscad/openscad/issues/1632#issuecomment-219203658
https://blog.prusaprinters.org/how-to-animate-models-in-openscad_29523/
https://github.com/openscad/openscad/issues/1573
https://github.com/openscad/openscad/pull/1808
https://forum.openscad.org/Product-Video-produced-with-OpenSCAD-td15783.html
Bash + Docker
Converting an STL to a GIF requires several steps
Center the STL at the origin
Convert the STL into a collection of .PNG files from different angles
Combine those PNG files into a .gif file
Assuming you have docker installed you can run the the following to convert an STL into an animated GIF
(Note: A more up to date version of this script is available at spuder/CAD-scripts/stl2gif
This depends on 3 docker containers
spuder/stl2origin
openscad/openscad:2021.01
linuxserver/ffmpeg:version-4.4-cli
# 1. Use spuder/stl2origin:latest docker container to center the file at origin
# A file with the offsets will be saved to `${MYTMPDIR}/foo.sh`
file=/tmp/foo.stl
MYTMPDIR="$(mktemp -d)"
trap 'rm -rf -- "$MYTMPDIR"' EXIT
docker run \
-e OUTPUT_BASH_FILE=/output/foo.sh \
-v $(dirname "$file"):/input \
-v $MYTMPDIR:/output \
--rm spuder/stl2origin:latest \
"/input/$(basename "$file")"
cp "${file}" "$MYTMPDIR/foo.stl"
# 2. Read ${MYTMPDIR}/foo.sh and load the offset variables ($XTRANS, $XMID,$YTRANS,$YMID,$ZTRANS,$ZMID)
# Save the new centered STL to `$MYTMPDIR/foo-centered.stl`
source $MYTMPDIR/foo.sh
docker run \
-v "$MYTMPDIR:/input" \
-v "$MYTMPDIR:/output" \
openscad/openscad:2021.01 openscad /dev/null -D "translate([$XTRANS-$XMID,$YTRANS-$YMID,$ZTRANS-$ZMID])import(\"/input/foo.stl\");" -o "/output/foo-centered.stl"
# 3. Convert the STL into 60 .PNG images with the camera rotating around the object. Note `$t` is a built in openscad variable that is automatically set based on time when --animate option is used
# OSX users will need to replace `openscad` with `/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD`
# Save all images to $MYTMPDIR/foo{0..60}.png
# This is not yet running in a docker container due to a bug: https://github.com/openscad/openscad/issues/4028
openscad /dev/null \
-D '$vpr = [60, 0, 360 * $t];' \
-o "${MYTMPDIR}/foo.png" \
-D "import(\"${MYTMPDIR}/foo-centered.stl\");" \
--imgsize=600,600 \
--animate 60 \
--colorscheme "Tomorrow Night" \
--viewall --autocenter
# 4. Use ffmpeg to combine all images into a .GIF file
# Tune framerate (15) and -r (60) to produce a faster/slower/smoother image
yes | ffmpeg \
-framerate 15 \
-pattern_type glob \
-i "$MYTMPDIR/*.png" \
-r 60 \
-vf scale=512:-1 \
"${file}.gif" \
;
rm -rf -- "$MYTMPDIR"
STL File
Gif without centering
Gif with centering

pg_upgrade with brew mac os 9.6.2 - 10.5

I've followed the excellent guide here to upgrade from 9.6.2 to 10.5 on mac os 10.11.6. When I get to the step 6
pg_upgrade -b /usr/local/Cellar/postgresql/9.6.2/bin/ \
-B /usr/local/Cellar/postgresql/10.5/bin/ \
-d /usr/local/Cellar/postgres.old/ \
-D /usr/local/Cellar/postgres.new/
I get this error
check for "/usr/local/Cellar/postgresql/9.6.2/bin" failed: No such file or directory
even though mv /usr/local/Cellar/postgresql/9.6.2 /usr/local/Cellar/postgres.old ran ok.
However when I go to
/usr/local/Cellar/postgresql/9.6.2/bin/: No such file or directory
Looking at
$ du -sh /usr/local/var/*/
148K /usr/local/var/homebrew/
917M /usr/local/var/log/
202G /usr/local/var/postgres96/
37M /usr/local/var/postgresql#9.6/
I think my data is still there (postgres96) but don't understand how to get to it and finish pg_upgrade. Any help gratefully appreciated
EDIT;
I think i need to run something like the below to undo the error i made;
undo the move
mv /usr/local/Cellar/postgres.old /usr/local/Cellar/postgresql/9.6.2
Check that worked running
ls /usr/local/Cellar/post*
I should see a bin in the 9.6.2 direcotry and then i can initialize a new cluster data dir:
initdb /usr/local/var/postgres.new
then
pg_upgrade -b /usr/local/Cellar/postgresql/9.6.2/bin/ \
-B /usr/local/Cellar/postgresql/10.5/bin/ \
-d /usr/local/var/postgres96/ \
-D /usr/local/var/postgres.new/
Is that correct?
Given I've backed up with pg_dump

Image dump fails during operation

I use the openocd script below to dump the flash memory of a STM32 microcontroller.
mkdir -p dump
openocd -f board/stm3241g_eval_stlink.cfg \
\
-c "init" \
-c "reset halt" \
-c "dump_image dump/image.bin 0x08000000 0x100000" \
-c "shutdown" \
FILENAME=dump/image.bin
FILESIZE=$(stat -c%s "$FILENAME")
echo "Size of $FILENAME = $FILESIZE bytes."
The script is supposed to read the whole memory which is 1MB in my case but it does it very rarely. Generally it stops reading the memory before the end.
Why can't I obtain 1MB each time I execute this script? What is the problem here to cause openocd stop dumping the rest of the memory?
You can use dfu-utils to reflash your STM32 micros.
In Ubuntu/Debian distros you can install dfu-utils with apt:
$ sudo apt-get install dfu-util
$ sudo apt-get install fwupd
Boot your board in DFU mode (check datasheet). Once in DFU mode, you should see something similar to this:
$ lsusb | grep DFU
Bus 003 Device 076: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
Once booted in DFU mode, reflash your binary:
$ sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D build/$(PROJECT).bin
With -d option you choose product:vendorid such as listed by lsusb in DFU mode.
With the -a 0 option you select alternate mode 0, check the options available as in the following example:
$ sudo dfu-util -l
Found DFU: [0483:df11] ver=2200, devnum=101, cfg=1, intf=0, alt=1, name="#Option Bytes /0x1FFFF800/01*016 e", serial="FFFFFFFEFFFF"
Found DFU: [0483:df11] ver=2200, devnum=101, cfg=1, intf=0, alt=0, name="#Internal Flash /0x08000000/064*0002Kg", serial="FFFFFFFEFFFF"
As you can see, alt=0 is for internal flash memory.
With the -s option you specify the flash memory address where you save your binary. Check your memory map in datasheet.
Hope this helps! :-)

|Ubuntu 18.04, opencv-3.4.0, MATLAB/R2018a| make fails on undefined reference to cv::dnn::eperimental

I have followed the wiki steps to install mexopencv, but I get the following error:
$ make MATLABDIR=/usr/local/MATLAB/R2018a WITH_CONTRIB=true all contrib
/tmp/mex_17713079591682_20541/Net_.o: In function `mexFunction':
Net_.cpp:(.text+0x10dd): undefined reference to `cv::dnn::experimental_dnn_v3::Net::Net()'
Net_.cpp:(.text+0x11ac): undefined reference to `cv::dnn::experimental_dnn_v3::readNetFromCaffe(cv::String const&, cv::String const&)'
Net_.cpp:(.text+0x122a): undefined reference to `cv::dnn::experimental_dnn_v3::Net::~Net()'
.. and so on
If I see what is to be built in opencv, the module dnn is present, which makes me wonder.
-- General configuration for OpenCV 3.4.0 =====================================
-- OpenCV modules:
-- To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dnn dpm face features2d flann freetype fuzzy hdf highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: js python2 python3 world
-- Disabled by dependency: -
-- Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv dnn_modern java matlab ovis sfm ts viz
Built modules:
$ pkg-config --cflags --libs opencv
-I/usr/local/include/opencv ..etc.. -lopencv_dnn .. etc
Current opencv version is:
$ pkg-config --modversion opencv
3.4.0
Question is; Is there a way to workaround/fix this, by i.e. disabling/unlinking dnn?
Or how do I actually compile the dnn file needed to get this reference to work?
{edit 1} file is actually compiled in:
$ ls /usr/local/include/opencv2/
...
bioinspired dnn fuzzy imgproc optflow saliency superres videoio xphoto.hpp
bioinspired.hpp dnn.hpp fuzzy.hpp imgproc.hpp
...
{edit 2} Unlinking -lopencv_dnn in the mexopencv Makefile by adding:
CV_LDFLAGS := $(filter-out -lopencv_dnn,$(CV_LDFLAGS))
is not an option, as still compilation fails on undefined reference to cv::dnn::experimental_dnn_v3. So I guess i'll need a fix for that.
Found the solution to my problem. Cause was blindly following mexopencv for the Opencv installation part. I had to use the following in the cmake step:
# build and compile opencv-3.4.0:
$ cmake -G "Unix Makefiles" \
-DBUILD_DOCS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_JAVA=OFF \
-DWITH_CUDA=OFF \
-DWITH_CUBLAS:BOOL=OFF \
-DWITH_CUFFT:BOOL=OFF \
-DWITH_NVCUVID:BOOL=OFF \
-DBUILD_opencv_cudaarithm:BOOL=OFF \
-DBUILD_opencv_cudabgsegm:BOOL=OFF \
-DBUILD_opencv_cudacodec:BOOL=OFF \
-DBUILD_opencv_cudafeatures2d:BOOL=OFF \
-DBUILD_opencv_cudafilters:BOOL=OFF \
-DBUILD_opencv_cudaimgproc:BOOL=OFF \
-DBUILD_opencv_cudalegacy:BOOL=OFF \
-DBUILD_opencv_cudaobjdetect:BOOL=OFF \
-DBUILD_opencv_cudaoptflow:BOOL=OFF \
-DBUILD_opencv_cudastereo:BOOL=OFF \
-DBUILD_opencv_cudawarping:BOOL=OFF \
-DBUILD_opencv_cudev:BOOL=OFF \
-DBUILD_opencv_java=OFF \
-DBUILD_opencv_js=OFF \
-DBUILD_opencv_python2=OFF \
-DBUILD_opencv_python3=OFF \
-DBUILD_opencv_ts=OFF \
-DBUILD_opencv_world=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DOPENCV_ENABLE_NONFREE=ON \
-DOPENCV_EXTRA_MODULES_PATH=~/cv/opencv_contrib-3.4.0/modules ~/cv/opencv-3.4.0
$ make -j8 # -j$(nproc)
$ sudo make install
# compile mexopencv = OK
$ make MATLABDIR=/usr/local/MATLAB/R2018a WITH_CONTRIB=true all contrib
main difference to wiki is to remove the following two lines from the cmake step:
-DWITH_MATLAB=OFF \
-DBUILD_opencv_matlab=OFF \

Where to get the eligible library tag file in Android O

In https://source.android.com/devices/architecture/vndk/deftool, it mentions that Google provides a tag file to classify the framework shared libraries, including LL-NDK, SP-NDK, VNDK, VNDK-SP and etc. However, after searching on this website and googling it, I'm not able to find the tag file. Where does Google provide it?
Thanks
Jincan
I found how to get such files.
You must get the file of vendor.img and system.img, for that is a file for deploying at "vendor partition" and "system partition" at a device.
Step 1
Please visit to Driver Binaries for Nexus and Pixel Devices.
There are images for two devices.
taimen (Pixel 2 XL)
walleye (Pixel 2)
Step 2: Method for file expand
Please read README.md.
There is undermentioned code
$ simg2img system.img system.raw.img
$ simg2img vendor.img vendor.raw.img
$ mkdir system
$ mkdir vendor
$ sudo mount -o loop,ro system.raw.img system
$ sudo mount -o loop,ro vendor.raw.img vendor
$ sudo python3 vndk_definition_tool.py vndk \
--system system \
--vendor vendor \
--aosp-system /path/to/aosp/generic/system \
--tag-file eligible-list-v3.0.csv
For detail, Please see that "README.md".
Thank you
git clone https://android.googlesource.com/platform/development
~/tools/development/vndk/tools/definition-tool/datasets[master]$ ls
eligible-list-o-mr1-release.csv eligible-list-o-release.csv minimum_dlopen_deps.txt minimum_tag_file.csv