How to correctly add partition in buildroot tool? - embedded-linux

I want to add to my current "genimage.cfg" new partition "logs". So I added lines like bellow to my config file:
File "genimage.cfg":
image boot.vfat {
vfat {
files = {
"MLO",
"u-boot.img",
"uEnv.txt"
}
}
size = 2M
}
image sdcard.img {
hdimage {
}
partition boot {
partition-type = 0xC
bootable = "true"
image = "boot.vfat"
}
partition rootfs {
partition-type = 0x83
image = "rootfs.ext4"
}
partition home {
partition-type = 0x83
image = "home.ext3"
}
partition logs {
partition-type = 0x83
image = "logs.ext4"
}
}
image home.ext3 {
name = "home"
ext3 {}
size = 240M
}
image logs.ext4 {
name = "logs"
ext4 {}
size = 64M
}
But I got error during build image:
genext2fs: couldn't allocate a block (no free space)
hdimage(sdcard.img): could not generate logs.ext4
hdimage(sdcard.img): failed to generate sdcard.img
Makefile:625: recipe for target 'target-post-image' failed
What could I do to fix this error? The error is only related to the "logs" partition and its image because without them the image is built

Related

Using dynamic preloaded image in Flutter/Dart

I currently have images which the image name is returned by a function and is dynamically called based on a variable like this:
String _setImage() {
if (currentQuestion > 1 && currentQuestion < 11) {
return "assets/images/image_$intensityIndex.png";
} else {
return "assets/images/image.png";
}
}
I want to switch to preloading the images and I am using the technique described at Preload images in a stateful widget on Flutter, but I am not sure how to have the function return an image which the name is dynamically determined based on another variable. Here is what I have so far:
void initState() {
super.initState();
image0 = Image.asset('assets/images/image_0.png');
image1 = Image.asset('assets/images/image_1.png');
image2 = Image.asset('assets/images/image_2.png');
image3 = Image.asset('assets/images/image_3.png');
}
void didChangeDependencies() {
super.didChangeDependencies();
precacheImage(image0.image, context);
precacheImage(image1.image, context);
precacheImage(image2.image, context);
precacheImage(image3.image, context);
}
Image _setImage() {
if (currentQuestion > 1 && currentQuestion < 11) {
return ______________;
} else {
return image0;
}
}
All help is appreciated!
Am not sure how to return an image which the name is dynamically
determined based on another variable
You don't need to return with precach because if you use exact image that you cache.
Ex:
precacheImage('assets/images/image_1.png'); // if this is the image name
Image.asset('assets/images/image_1.png'); // when you use this it is getting from the cache but the path should be same.
If I explain it another way:
precacheImage("assets/images/image_$intensityIndex.png"); // image_1.png
Image.asset('assets/images/image_1.png'); // when you do this, asset taking from the cache by looking at the path.

Terraform AWS: override root device size using aws_launch_template and block_device_mappings

I dont find a way to override root size device using block_device_mappings in aws_launch_template with terraform aws.
I know I can specify an extra volume size doing for example:
block_device_mappings {
device_name = "/dev/xvda"
ebs {
volume_size = "${var.frontend_kong_volume_size}"
volume_type = "${var.frontend_kong_volume_type}"
delete_on_termination = "true"
}
}
but I get a new disk in the VM with those specifications.
But what I want to do is resize the root disk.
Can you help me to figure out how to do it?
Thanks.
block_device_mappings is for additional block devices.
You have to know device where root device mounted. for example for centos 7 AMI it's /dev/sda1
resource "aws_launch_template" "foobar" {
name_prefix = "foobar"
image_id = "ami-9887c6e7"
instance_type = "t2.micro"
block_device_mappings {
device_name = "/dev/sda1"
ebs {
volume_size = 40
}
}
}
resource "aws_autoscaling_group" "bar" {
availability_zones = ["us-east-1a"]
desired_capacity = 1
max_size = 1
min_size = 1
launch_template = {
id = "${aws_launch_template.foobar.id}"
version = "$$Latest"
}
}
But remember that update of volume size in terraform will not take effect to running instances. So you will have to replace instances to increase volume size.

How to calculate the size of video ?

I am working with Xamarin.iOS. I use UIImagePickerController to record video . Now I get the filePath of the video in sandBox . But I want to calculate the size of the video before I upload(over 20M will be banned) . I'm not familiar with native iOS(OC and Swift).I can only get the duration. So , how to get the size(in MB) of the video?
You can use the Class NSFileManager .Try to refer to the following code:
public double GetFileSize(NSString filepath)
{
NSFileManager fileManager = NSFileManager.DefaultManager;
double filesize = -1.0;
if (fileManager.FileExists(filepath))
{
filesize = (double)fileManager.GetAttributes(filepath).Size;
return filesize / (1024 * 1024); // return the size as MB
}
else
{
Console.Write("file can not be found");
return 0;
}
}

IE 8 wont allow me setScr (mediaelement.js)

I am playing a video with mediaelement.js. Works fine but when I want to change the source of the video I get an error:
SCRIPT438: Object doesn't support property or method 'setSrc'
Anyone an idea how to fix this?
code:
function playVideo(source) {
var fileformat:string
player.pause();
if (Modernizr.video) {
fileformat = ".mp4";
} else {
fileformat = ".flv";
}
var sources = [
{ src: 'media/'+ source + fileformat }
];
player.setSrc(sources);
player.load();
player.play();
}

size of picture windows phone

in my app i have a list of picture. I would like to determine the size of the single images but not have property.
using (MediaLibrary library = new MediaLibrary())
{
CameraRollAlbum = library.RootPictureAlbum.Albums.First((album) => album.Name == "Camera Roll");
List<Picture> pictures = CameraRollAlbum.Pictures.Tolist();
foreach (Picture pic in pictures)
{
pic.size?? pic.length??
}
}
Get the Image Stream eval the size:
foreach (Picture pic in pictures)
{
var sizeInKb = pic.GetImage().Length / 1024;
}
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.media.picture_members.aspx

Resources